PrettyAnitaEvent.cxx
1 
8 #include "PrettyAnitaEvent.h"
9 
10 ClassImp(PrettyAnitaEvent);
11 
12 
13 //My incredibly dodgy approach to fitting with MINUIT that I'm going to call from within itself
14 // this is horrible and dangerous and should never bve done, but hey ho there we go.
15 void CorSumFCN(Int_t& npar, Double_t*gin,
16  Double_t&f, Double_t* par, Int_t flag)
17 {
18  //par[0] is phiWave
19  //par[1] is thetaWave
20  //par[2] is numAnts (11 or 19)
21 
22  CorrelationSummary* myDodgyCorSumPtr = dynamic_cast<CorrelationSummary*>(gMinuit->GetObjectFit());
23  f=myDodgyCorSumPtr->getChiSquared(par[0],par[1],11);
24  // std::cout << par[0] << "\t" << par[1] << "\t" << f << std::endl;
25 }
26 
27 //My incredibly dodgy approach to fitting with MINUIT that I'm going to call from within itself
28 // this is horrible and dangerous and should never bve done, but hey ho there we go.
29 void CorSumFCNanita3(Int_t& npar, Double_t*gin,
30  Double_t&f, Double_t* par, Int_t flag)
31 {
32  //par[0] is phiWave
33  //par[1] is thetaWave
34  //par[2] is numAnts (11 or 19)
35 
36  CorrelationSummaryAnita3* myDodgyCorSumPtr = dynamic_cast<CorrelationSummaryAnita3*>(gMinuit->GetObjectFit());
37  f=myDodgyCorSumPtr->getChiSquared(par[0],par[1],11);
38  // std::cout << par[0] << "\t" << par[1] << "\t" << f << std::endl;
39 }
40 
42 fPassBandFilter=0;
43 fNotchFilter=0;
44 }
45 
47 fPassBandFilter=0;
48 fNotchFilter=0;
49 }
50 
52  fPassBandFilter=0;
53  fNotchFilter=0;
54 }
55 
56 
57 TCanvas *PrettyAnitaEvent::getSixWaveformCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *incan) {
58  char graphTitle[180];
59 
60  TCanvas *can=incan;
61  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
62  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) << std::endl;
63  return NULL;
64  }
65  setStyleSixCanvas();
66 
67  //Make Canvas
68  if(!can) {
69  can = (TCanvas*) gROOT->FindObject("canSixWave");
70  if(!can) {
71  can = new TCanvas("canSixWave","canSixWave",800,600);
72  }
73  }
74 
75  can->Clear();
76  can->Divide(3,2);
77 
78  int topAnts[3];
79  int bottomAnts[3];
80  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
81  fillSixAntArrays(ant,topAnts,bottomAnts);
82 
83  for(int i=0;i<3;i++) {
84  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
85  sprintf(graphTitle,"Ant: %d",topAnts[i]);
86  can->cd(i+1);
87  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
88  TGraph *grTop = getGraph(ciTop);
89  grTop->SetLineColor(getPrettyColour(i));
90  grTop->SetTitle(graphTitle);
91  grTop->Draw("al");
92 
93 
94  can->cd(i+4);
95  sprintf(graphTitle,"Ant: %d",bottomAnts[i]);
96  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
97  TGraph *grBottom = getGraph(ciBottom);
98  grBottom->SetLineColor(getPrettyColour(i));
99  grBottom->SetTitle(graphTitle);
100  grBottom->Draw("al");
101 
102  }
103  return can;
104 }
105 
106 
107 TCanvas *PrettyAnitaEvent::getTenWaveformCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *incan) {
108  char graphTitle[180];
109 
110  TCanvas *can=incan;
111  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
112  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) << std::endl;
113  return NULL;
114  }
115  setStyleSixCanvas();
116 
117  //Make Canvas
118  if(!can) {
119  can = (TCanvas*) gROOT->FindObject("canTenWave");
120  if(!can) {
121  can = new TCanvas("canTenWave","canTenWave",1000,600);
122  }
123  }
124 
125  can->Clear();
126  can->Divide(5,2);
127 
128  int topAnts[3];
129  int bottomAnts[3];
130  int nextFourAnts[4];
131  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
132  fillSixAntArrays(ant,topAnts,bottomAnts);
133  fillNextFourAntArrays(ant,nextFourAnts);
134 
135  int newTopAnts[5]={nextFourAnts[0],topAnts[0],topAnts[1],topAnts[2],nextFourAnts[1]};
136  int newBottomAnts[5]={nextFourAnts[2],bottomAnts[0],bottomAnts[1],bottomAnts[2],nextFourAnts[3]};
137 
138 
139  for(int i=0;i<5;i++) {
140  // std::cout << i << "\t" << newTopAnts[i] << "\t" << bottomAnts[i] << std::endl;
141  sprintf(graphTitle,"Ant: %d",newTopAnts[i]);
142  can->cd(i+1);
143  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(newTopAnts[i],pol);
144  TGraph *grTop = getGraph(ciTop);
145  grTop->SetLineColor(getPrettyColour(i));
146  grTop->SetTitle(graphTitle);
147  grTop->Draw("al");
148 
149 
150  can->cd(i+6);
151  sprintf(graphTitle,"Ant: %d",newBottomAnts[i]);
152  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(newBottomAnts[i],pol);
153  TGraph *grBottom = getGraph(ciBottom);
154  grBottom->SetLineColor(getPrettyColour(i));
155  grBottom->SetTitle(graphTitle);
156  grBottom->Draw("al");
157 
158  }
159  return can;
160 }
161 
162 
163 
164 
165 TCanvas *PrettyAnitaEvent::getSixFFTPowerCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *incan) {
166  char graphTitle[180];
167 
168  TCanvas *can=incan;
169  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
170  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) << std::endl;
171  return NULL;
172  }
173  setStyleSixCanvas();
174 
175  //Make Canvas
176  if(!can) {
177  can = (TCanvas*) gROOT->FindObject("canSixFFTPower");
178  if(!can) {
179  can = new TCanvas("canSixFFTPower","canSixFFTPower",800,600);
180  }
181  }
182 
183  can->Clear();
184  can->Divide(3,2);
185 
186  int topAnts[3];
187  int bottomAnts[3];
188  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
189  fillSixAntArrays(ant,topAnts,bottomAnts);
190 
191  for(int i=0;i<3;i++) {
192  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
193  sprintf(graphTitle,"Ant: %d",topAnts[i]);
194  can->cd(i+1);
195  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
196  TGraph *grTop = getFFTMagnitude(ciTop);
197  grTop->SetLineColor(getPrettyColour(i));
198  grTop->SetTitle(graphTitle);
199  grTop->Draw("al");
200 
201 
202  can->cd(i+4);
203  sprintf(graphTitle,"Ant: %d",bottomAnts[i]);
204  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
205  TGraph *grBottom = getFFTMagnitude(ciBottom);
206  grBottom->SetLineColor(getPrettyColour(i));
207  grBottom->SetTitle(graphTitle);
208  grBottom->Draw("al");
209 
210  }
211  return can;
212 }
213 
214 
216  char graphTitle[180];
217 
218  TCanvas *can=incan;
219  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
220  std::cerr << "Antenna " << ant << " is not in range 0-" <<(NUM_SEAVEYS-1)<< std::endl;
221  return NULL;
222  }
223  setStyleSixCanvas();
224 
225  //Make Canvas
226  if(!can) {
227  can = (TCanvas*) gROOT->FindObject("canSixPower");
228  if(!can) {
229  can = new TCanvas("canSixPower","canSixPower",800,600);
230  }
231  }
232 
233  can->Clear();
234  can->Divide(3,2);
235 
236  int topAnts[3];
237  int bottomAnts[3];
238  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
239  fillSixAntArrays(ant,topAnts,bottomAnts);
240 
241  for(int i=0;i<3;i++) {
242  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
243  sprintf(graphTitle,"Ant: %d",topAnts[i]);
244  can->cd(i+1);
245  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
246  TGraph *grTop = getSimplePowerEnvelopeGraph(ciTop);
247  grTop->SetLineColor(getPrettyColour(i));
248  grTop->SetTitle(graphTitle);
249  grTop->Draw("al");
250 
251 
252  can->cd(i+4);
253  sprintf(graphTitle,"Ant: %d",bottomAnts[i]);
254  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
255  TGraph *grBottom = getSimplePowerEnvelopeGraph(ciBottom);
256  grBottom->SetLineColor(getPrettyColour(i));
257  grBottom->SetTitle(graphTitle);
258  grBottom->Draw("al");
259 
260  }
261  return can;
262 }
263 
264 
265 TCanvas *PrettyAnitaEvent::getSixCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *incan) {
266  char graphTitle[180];
267 
268  TCanvas *can=incan;
269  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
270  std::cerr << "Antenna " << ant << " is not in range 0-" <<(NUM_SEAVEYS-1) << std::endl;
271  return NULL;
272  }
273  setStyleSixCanvas();
274 
275  //Make Canvas
276  if(!can) {
277  can = (TCanvas*) gROOT->FindObject("canSixCorr");
278  if(!can) {
279  can = new TCanvas("canSixCorr","canSixCorr",800,600);
280  }
281  }
282 
283  can->Clear();
284  can->Divide(3,2);
285 
286  int topAnts[3];
287  int bottomAnts[3];
288  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
289  fillSixAntArrays(ant,topAnts,bottomAnts);
290 
291  for(int i=0;i<3;i++) {
292  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
293  sprintf(graphTitle,"Ants: %d - %d",topAnts[i],bottomAnts[i]);
294  can->cd(i+1);
295  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
296  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
297 
298  TGraph *grTop = getCorrelation(ciTop,ciBottom);
299  grTop->SetLineColor(getPrettyColour(i));
300  grTop->SetTitle(graphTitle);
301  grTop->Draw("al");
302 
303 
304  can->cd(i+4);
305  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[i],topAnts[i]);
306  TGraph *grBottom = getCorrelation(ciBottom,ciTop);
307  grBottom->SetLineColor(getPrettyColour(i));
308  grBottom->SetTitle(graphTitle);
309  grBottom->Draw("al");
310 
311  }
312  return can;
313 }
314 
315 
316 
317 TCanvas *PrettyAnitaEvent::getTenCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *incan) {
318  char graphTitle[180];
319 
320  TCanvas *can=incan;
321  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
322  std::cerr << "Antenna " << ant << " is not in range 0-" <<(NUM_SEAVEYS-1) << std::endl;
323  return NULL;
324  }
325  setStyleSixCanvas();
326 
327  //Make Canvas
328  if(!can) {
329  can = (TCanvas*) gROOT->FindObject("canTenCorr");
330  if(!can) {
331  can = new TCanvas("canTenCorr","canTenCorr",1000,600);
332  }
333  }
334 
335  can->Clear();
336  can->Divide(5,2);
337 
338  int topAnts1[3];
339  int bottomAnts1[3];
340  int nextFourAnts[4];
341  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
342  fillSixAntArrays(ant,topAnts1,bottomAnts1);
343  fillNextFourAntArrays(ant,nextFourAnts);
344 
345  int topAnts[5]={nextFourAnts[0],topAnts1[0],topAnts1[1],topAnts1[2],nextFourAnts[1]};
346  int bottomAnts[5]={nextFourAnts[2],bottomAnts1[0],bottomAnts1[1],bottomAnts1[2],nextFourAnts[3]};
347 
348 
349  for(int i=0;i<5;i++) {
350  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
351  sprintf(graphTitle,"Ants: %d - %d",topAnts[i],bottomAnts[i]);
352  can->cd(i+1);
353  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
354  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
355 
356  TGraph *grTop = getCorrelation(ciTop,ciBottom);
357  grTop->SetLineColor(getPrettyColour(i));
358  grTop->SetTitle(graphTitle);
359  grTop->Draw("al");
360 
361 
362  can->cd(i+4);
363  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[i],topAnts[i]);
364  TGraph *grBottom = getCorrelation(ciBottom,ciTop);
365  grBottom->SetLineColor(getPrettyColour(i));
366  grBottom->SetTitle(graphTitle);
367  grBottom->Draw("al");
368 
369  }
370  return can;
371 }
372 
373 
375  char graphTitle[180];
376 
377  TCanvas *can=incan;
378  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
379  std::cerr << "Antenna " << ant << " is not in range 0-" <<(NUM_SEAVEYS-1) << std::endl;
380  return NULL;
381  }
382  setStyleSixCanvas();
383 
384  //Make Canvas
385  if(!can) {
386  can = (TCanvas*) gROOT->FindObject("canElevenCorr");
387  if(!can) {
388  can = new TCanvas("canElevenCorr","canElevenCorr",1000,400);
389  }
390  }
391 
392  can->Clear();
393  can->Divide(4,3);
394 
395  int topAnts[3];
396  int bottomAnts[3];
397  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
398  fillSixAntArrays(ant,topAnts,bottomAnts);
399 
400 
401  int ciLeftTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[0],pol);
402  int ciMidTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[1],pol);
403  int ciRightTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[2],pol);
404 
405  int ciLeftBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[0],pol);
406  int ciMidBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[1],pol);
407  int ciRightBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[2],pol);
408  //First row
409  // TPad *paddy = (TPad*)can->cd(1);
410  // paddy->Divide(4,1);
411  {
412  can->cd(1);
413  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],bottomAnts[0]);
414  TGraph *grL=getCorrelation(ciMidTop,ciLeftBottom);
415  grL->SetLineColor(getPrettyColour(1));
416  grL->SetTitle(graphTitle);
417  grL->Draw("al");
418 
419 
420  can->cd(2);
421  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],topAnts[0]);
422  TGraph *grML=getCorrelation(ciMidTop,ciLeftTop);
423  grML->SetLineColor(getPrettyColour(2));
424  grML->SetTitle(graphTitle);
425  grML->Draw("al");
426 
427  can->cd(3);
428  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],topAnts[2]);
429  TGraph *grMR=getCorrelation(ciMidTop,ciRightTop);
430  grMR->SetLineColor(getPrettyColour(3));
431  grMR->SetTitle(graphTitle);
432  grMR->Draw("al");
433 
434  can->cd(4);
435  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],bottomAnts[2]);
436  TGraph *grR=getCorrelation(ciMidTop,ciRightBottom);
437  grR->SetLineColor(getPrettyColour(4));
438  grR->SetTitle(graphTitle);
439  grR->Draw("al");
440 
441  }
442 
443 
444  //Second row
445  // TPad *paddy2 = (TPad*)can->cd(1);
446  // paddy2->Divide(3,1);
447 
448  for(int i=0;i<3;i++) {
449  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
450 
451  can->cd(i+5);
452  sprintf(graphTitle,"Ants: %d - %d",topAnts[i],bottomAnts[i]);
453  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
454  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
455 
456  TGraph *grTop = getCorrelation(ciTop,ciBottom);
457  grTop->SetLineColor(getPrettyColour(i));
458  grTop->SetTitle(graphTitle);
459  grTop->Draw("al");
460 
461  }
462 
463  //Third row
464  // TPad *paddy3 = (TPad*) can->cd(1);
465  // paddy3->Divide(4,1);
466  {
467  can->cd(9);
468  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],topAnts[0]);
469  TGraph *grL=getCorrelation(ciMidBottom,ciLeftTop);
470  grL->SetLineColor(getPrettyColour(1));
471  grL->SetTitle(graphTitle);
472  grL->Draw("al");
473 
474 
475  can->cd(10);
476  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],bottomAnts[0]);
477  TGraph *grML=getCorrelation(ciMidBottom,ciLeftBottom);
478  grML->SetLineColor(getPrettyColour(2));
479  grML->SetTitle(graphTitle);
480  grML->Draw("al");
481 
482  can->cd(11);
483  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],bottomAnts[2]);
484  TGraph *grMR=getCorrelation(ciMidBottom,ciRightBottom);
485  grMR->SetLineColor(getPrettyColour(3));
486  grMR->SetTitle(graphTitle);
487  grMR->Draw("al");
488 
489  can->cd(12);
490  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],topAnts[2]);
491  TGraph *grR=getCorrelation(ciMidBottom,ciRightTop);
492  grR->SetLineColor(getPrettyColour(4));
493  grR->SetTitle(graphTitle);
494  grR->Draw("al");
495 
496  }
497 
498  return can;
499 }
500 
501 
502 
503 TCanvas *PrettyAnitaEvent::getElevenInterpolationCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT, TCanvas *incan) {
504  char graphTitle[180];
505 
506  TCanvas *can=incan;
507  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
508  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) <<std::endl;
509  return NULL;
510  }
511  setStyleSixCanvas();
512 
513  //Make Canvas
514  if(!can) {
515  can = (TCanvas*) gROOT->FindObject("canElevenIntCorr");
516  if(!can) {
517  can = new TCanvas("canElevenIntCorr","canElevenIntCorr",1000,400);
518  }
519  }
520 
521  can->Clear();
522  can->Divide(4,3);
523 
524  int topAnts[3];
525  int bottomAnts[3];
526  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
527  fillSixAntArrays(ant,topAnts,bottomAnts);
528 
529 
530  int ciLeftTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[0],pol);
531  int ciMidTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[1],pol);
532  int ciRightTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[2],pol);
533 
534  int ciLeftBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[0],pol);
535  int ciMidBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[1],pol);
536  int ciRightBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[2],pol);
537  //First row
538  // TPad *paddy = (TPad*)can->cd(1);
539  // paddy->Divide(4,1);
540  {
541  can->cd(1);
542  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],bottomAnts[0]);
543  TGraph *grL=getCorrelationInterpolated(ciMidTop,ciLeftBottom,deltaT);
544  grL->SetLineColor(getPrettyColour(1));
545  grL->SetTitle(graphTitle);
546  grL->Draw("al");
547 
548 
549  can->cd(2);
550  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],topAnts[0]);
551  TGraph *grML=getCorrelationInterpolated(ciMidTop,ciLeftTop,deltaT);
552  grML->SetLineColor(getPrettyColour(2));
553  grML->SetTitle(graphTitle);
554  grML->Draw("al");
555 
556  can->cd(3);
557  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],topAnts[2]);
558  TGraph *grMR=getCorrelationInterpolated(ciMidTop,ciRightTop,deltaT);
559  grMR->SetLineColor(getPrettyColour(3));
560  grMR->SetTitle(graphTitle);
561  grMR->Draw("al");
562 
563  can->cd(4);
564  sprintf(graphTitle,"Ants: %d - %d",topAnts[1],bottomAnts[2]);
565  TGraph *grR=getCorrelationInterpolated(ciMidTop,ciRightBottom,deltaT);
566  grR->SetLineColor(getPrettyColour(4));
567  grR->SetTitle(graphTitle);
568  grR->Draw("al");
569 
570  }
571 
572 
573  //Second row
574  // TPad *paddy2 = (TPad*)can->cd(1);
575  // paddy2->Divide(3,1);
576 
577  for(int i=0;i<3;i++) {
578  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
579 
580  can->cd(i+5);
581  sprintf(graphTitle,"Ants: %d - %d",topAnts[i],bottomAnts[i]);
582  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
583  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
584 
585  TGraph *grTop = getCorrelationInterpolated(ciTop,ciBottom,deltaT);
586  grTop->SetLineColor(getPrettyColour(i));
587  grTop->SetTitle(graphTitle);
588  grTop->Draw("al");
589 
590  }
591 
592  //Third row
593  // TPad *paddy3 = (TPad*) can->cd(1);
594  // paddy3->Divide(4,1);
595  {
596  can->cd(9);
597  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],topAnts[0]);
598  TGraph *grL=getCorrelationInterpolated(ciMidBottom,ciLeftTop,deltaT);
599  grL->SetLineColor(getPrettyColour(1));
600  grL->SetTitle(graphTitle);
601  grL->Draw("al");
602 
603 
604  can->cd(10);
605  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],bottomAnts[0]);
606  TGraph *grML=getCorrelationInterpolated(ciMidBottom,ciLeftBottom,deltaT);
607  grML->SetLineColor(getPrettyColour(2));
608  grML->SetTitle(graphTitle);
609  grML->Draw("al");
610 
611  can->cd(11);
612  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],bottomAnts[2]);
613  TGraph *grMR=getCorrelationInterpolated(ciMidBottom,ciRightBottom,deltaT);
614  grMR->SetLineColor(getPrettyColour(3));
615  grMR->SetTitle(graphTitle);
616  grMR->Draw("al");
617 
618  can->cd(12);
619  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[1],topAnts[2]);
620  TGraph *grR=getCorrelationInterpolated(ciMidBottom,ciRightTop,deltaT);
621  grR->SetLineColor(getPrettyColour(4));
622  grR->SetTitle(graphTitle);
623  grR->Draw("al");
624 
625  }
626 
627  return can;
628 }
629 
630 
631 TCanvas *PrettyAnitaEvent::getSixInterpolatedCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT, TCanvas *incan) {
632  char graphTitle[180];
633 
634  TCanvas *can=incan;
635  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
636  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) << std::endl;
637  return NULL;
638  }
639  setStyleSixCanvas();
640 
641  //Make Canvas
642  if(!can) {
643  can = (TCanvas*) gROOT->FindObject("canSixIntCorr");
644  if(!can) {
645  can = new TCanvas("canSixIntCorr","canSixIntCorr",800,600);
646  }
647  }
648 
649  can->Clear();
650  can->Divide(3,2);
651 
652  int topAnts[3];
653  int bottomAnts[3];
654  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
655  fillSixAntArrays(ant,topAnts,bottomAnts);
656 
657  for(int i=0;i<3;i++) {
658  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
659  sprintf(graphTitle,"Ants: %d - %d",topAnts[i],bottomAnts[i]);
660  can->cd(i+1);
661  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
662  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
663 
664  TGraph *grTop = getCorrelationInterpolated(ciTop,ciBottom,deltaT);
665  grTop->SetLineColor(getPrettyColour(i));
666  grTop->SetTitle(graphTitle);
667  grTop->Draw("al");
668 
669 
670  can->cd(i+4);
671  sprintf(graphTitle,"Ants: %d - %d",bottomAnts[i],topAnts[i]);
672  TGraph *grBottom = getCorrelationInterpolated(ciBottom,ciTop,deltaT);
673  grBottom->SetLineColor(getPrettyColour(i));
674  grBottom->SetTitle(graphTitle);
675  grBottom->Draw("al");
676 
677  }
678  return can;
679 }
680 
681 
682 TCanvas *PrettyAnitaEvent::getSixInterpolatedCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT, TCanvas *incan) {
683  char graphTitle[180];
684 
685  TCanvas *can=incan;
686  if(ant<0 || ant>(NUM_SEAVEYS-1)) {
687  std::cerr << "Antenna " << ant << " is not in range 0-" << (NUM_SEAVEYS-1) << std::endl;
688  return NULL;
689  }
690  setStyleSixCanvas();
691 
692  //Make Canvas
693  if(!can) {
694  can = (TCanvas*) gROOT->FindObject("canSixInter");
695  if(!can) {
696  can = new TCanvas("canSixInter","canSixInter",800,600);
697  }
698  }
699 
700  can->Clear();
701  can->Divide(3,2);
702 
703  int topAnts[3];
704  int bottomAnts[3];
705  // std::cout << ant << "\t" << AnitaGeomTool::getAzimuthPartner(ant) << std::endl;
706  fillSixAntArrays(ant,topAnts,bottomAnts);
707 
708  for(int i=0;i<3;i++) {
709  // std::cout << i << "\t" << topAnts[i] << "\t" << bottomAnts[i] << std::endl;
710  sprintf(graphTitle,"Ant: %d",topAnts[i]);
711  can->cd(i+1);
712  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(topAnts[i],pol);
713  TGraph *grTop = getInterpolatedGraph(ciTop,deltaT);
714  grTop->SetLineColor(getPrettyColour(i));
715  grTop->SetTitle(graphTitle);
716  grTop->Draw("al");
717 
718 
719  can->cd(i+4);
720  sprintf(graphTitle,"Ant: %d",bottomAnts[i]);
721  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(bottomAnts[i],pol);
722  TGraph *grBottom = getInterpolatedGraph(ciBottom,deltaT);
723  grBottom->SetLineColor(getPrettyColour(i));
724  grBottom->SetTitle(graphTitle);
725  grBottom->Draw("al");
726 
727  }
728  return can;
729 }
730 
731 
733  TGraph *grWave = getGraph(chanIndex);
734  TGraph *grPowerEnv = FFTtools::getSimplePowerEnvelopeGraph(grWave);
735  delete grWave;
736  return grPowerEnv;
737 }
738 
739 
740 TGraph *PrettyAnitaEvent::getInterpolatedGraph(int chanIndex, double deltaT) {
741 
742  TGraph *grWave = getGraph(chanIndex);
743 
744  double x = 0; double x1 = 0;
745  double y = 0; double y1 = 0;
746 
747  int numP = grWave->GetN();
748 
749  for(int i = 1; i < numP; i++){
750  grWave->GetPoint(i,x,y);
751  grWave->GetPoint(i-1,x1,y1);
752 
753  if((x<x1)){
754  std::cout << x << " " << x1 << " "<< chanIndex << " " << i << " " << numP << " "<< eventNumber << std::endl;
755  }
756 
757  }
758 
759  if(fPassBandFilter || fNotchFilter) {
760  TGraph *grInt = FFTtools::getInterpolatedGraph(grWave,1./2.6);
761  delete grWave;
762  //Now for the filtering
763  if(fPassBandFilter) {
764  TGraph *grFilt = FFTtools::simplePassBandFilter(grInt,fLowPassEdge,fHighPassEdge);
765  delete grInt;
766  grInt=grFilt;
767  }
768  if(fNotchFilter>0) {
769  TGraph *grFilt = FFTtools::multipleSimpleNotchFilters(grInt,fNotchFilter,fLowNotchEdge,fHighNotchEdge);
770  delete grInt;
771  grInt=grFilt;
772  }
773  TGraph *grFinal = FFTtools::getInterpolatedGraph(grInt,deltaT);
774  delete grInt;
775  return grFinal;
776  }
777 
778 
779  TGraph *grInt = FFTtools::getInterpolatedGraph(grWave,deltaT);
780  delete grWave;
781  return grInt;
782 }
783 
784 TGraph *PrettyAnitaEvent::getFFTMagnitude(int chanIndex)
785 {
786  TGraph *grWave=getGraph(chanIndex);
787  TGraph *grFFT=getFFTMagnitude(grWave);
788  delete grWave;
789  return grFFT;
790 }
791 
792 
794 {
795  TGraph *grFFT=FFTtools::makePowerSpectrum(grIn);
796  return grFFT;
797 }
798 
799 TGraph *PrettyAnitaEvent::getCorrelation(TGraph *gr1, TGraph *gr2)
800 {
801  return FFTtools::getCorrelationGraph(gr1,gr2);
802 }
803 
804 TGraph *PrettyAnitaEvent::getCorrelation(int chanIndex1, int chanIndex2)
805 {
806  TGraph *gr1 =getGraph(chanIndex1);
807  TGraph *gr2 = getGraph(chanIndex2);
808 
809  TGraph *grCor = getCorrelation(gr1,gr2);
810  Double_t x1,y1,x2,y2;
811  gr1->GetPoint(0,x1,y1);
812  // std::cout << 1 << "\t" << chanIndex1 << "\t" << x << "\t" << y << "\n";
813  gr2->GetPoint(0,x2,y2);
814  fWaveOffset=x1-x2;
815 
816  // std::cout << 2 << "\t" << chanIndex2 << "\t" << x << "\t" << y << "\n";
817  // grCor->GetPoint(0,x1,y1);
818  gr1->GetPoint(1,x2,y2);
819  fDeltaT=x2-x1;
820 
821  // Double_t x,y;
822  // gr1->GetPoint(0,x,y);
823  // std::cout << 1 << "\t" << chanIndex1 << "\t" << x << "\t" << y << "\n";
824  // gr2->GetPoint(0,x,y);
825  // std::cout << 2 << "\t" << chanIndex2 << "\t" << x << "\t" << y << "\n";
826  // grCor->GetPoint(0,x,y);
827  // std::cout << "Cor\t" << chanIndex2 << "\t" << x << "\t" << y << "\n";
828 
829 
830  delete gr1;
831  delete gr2;
832  return grCor;
833 }
834 
835 TGraph *PrettyAnitaEvent::getCorrelationInterpolated(int chanIndex1, int chanIndex2, Double_t deltaT)
836 {
837  if(chanIndex1 <0 || chanIndex1>(NUM_DIGITZED_CHANNELS-1))
838  std::cerr << "Invalid channel index:\t" << chanIndex1 << "\n";
839 
840  if(chanIndex2 <0 || chanIndex2>(NUM_DIGITZED_CHANNELS-1))
841  std::cerr << "Invalid channel index:\t" << chanIndex2 << "\n";
842 
843  TGraph *gr1 =getInterpolatedGraph(chanIndex1,deltaT);
844  TGraph *gr2 = getInterpolatedGraph(chanIndex2,deltaT);
845 
846  TGraph *grCor = getCorrelation(gr1,gr2);
847  Double_t x1,y1,x2,y2;
848  gr1->GetPoint(0,x1,y1);
849  // std::cout << 1 << "\t" << chanIndex1 << "\t" << x << "\t" << y << "\n";
850  gr2->GetPoint(0,x2,y2);
851  fWaveOffset=x1-x2;
852 
853  // std::cout << 2 << "\t" << chanIndex2 << "\t" << x << "\t" << y << "\n";
854  // grCor->GetPoint(0,x1,y1);
855  gr1->GetPoint(1,x2,y2);
856  fDeltaT=x2-x1;
857 
858  // std::cout << "CorInt\t" << chanIndex2 << "\t" << x << "\t" << y << "\n";
859 
860 
861  // TFile *fp = new TFile("tempCorFile.root","RECREATE");
862 // grCor->SetName("grCor");
863 // grCor->Write();
864 // gr1->SetName("gr1");
865 // gr1->Write();
866 // gr2->SetName("gr2");
867 // gr2->Write();
868 // TGraph *fft1 = FFTtools::makePowerSpectrumMilliVoltsNanoSecondsdB(gr1);
869 // fft1->SetName("fft1");
870 // fft1->Write();
871 // TGraph *fft2 = FFTtools::makePowerSpectrumMilliVoltsNanoSecondsdB(gr2);
872 // fft2->SetName("fft2");
873 // fft2->Write();
874 
875 // exit(0);
876 
877  delete gr1;
878  delete gr2;
879 
880 
881  return grCor;
882 }
883 
884 
885 
886 
887 void PrettyAnitaEvent::setStyleSixCanvas()
888 {
889  gStyle->SetPadTopMargin(0.05);
890  gStyle->SetPadBottomMargin(0.05);
891  gStyle->SetPadLeftMargin(0.05);
892  gStyle->SetPadRightMargin(0.05);
893 }
894 
895 void PrettyAnitaEvent::fillSixAntArrays(int ant, int topAnts[3], int bottomAnts[3])
896 {
897  // std::cerr << "fillSixAntArrays( " << ant << ")\n";
898  int top=-1,bottom=-1;
899  int leftTop=-1, rightTop=-1;
900  int leftBottom=-1, rightBottom=-1;
901 
902  if(ant<16) {
903  top=ant;
905  }
906  else {
907  bottom=ant;
909  }
910 
911  // std::cout << top << "\t" << bottom << std::endl;
912  AnitaGeomTool::getThetaPartners(top,leftTop,rightTop);
913  AnitaGeomTool::getThetaPartners(bottom,leftBottom,rightBottom);
914  topAnts[0]=leftTop;
915  topAnts[1]=top;
916  topAnts[2]=rightTop;
917  bottomAnts[0]=leftBottom;
918  bottomAnts[1]=bottom;
919  bottomAnts[2]=rightBottom;
920 
921 }
922 
923 
924 void PrettyAnitaEvent::fillNineAntArrays(int ant, int nineAnts[9])
925 {
926  // Top 0-2
927  // Middle 3-5
928  // Bottom 6-8
929 
930  // std::cerr << "fillSixAntArrays( " << ant << ")\n";
931  int top=-1,middle=-1,bottom=-1;
932  int leftTop=-1, rightTop=-1;
933  int leftMiddle=-1, rightMiddle=-1;
934  int leftBottom=-1, rightBottom=-1;
935 
936  if(ant<16) {
937  top=ant;
939  bottom=middle+16;
940  } else if (ant<32){
941  middle = ant;
942  top = AnitaGeomTool::getAzimuthPartner(middle);
943  bottom=middle+16;
944  } else {
945  bottom=ant;
946  middle=AnitaGeomTool::getAzimuthPartner(bottom);
948  }
949 
950 // std::cout << top << "\t" << bottom << std::endl;
951  AnitaGeomTool::getThetaPartners(top,leftTop,rightTop);
952  AnitaGeomTool::getThetaPartners(middle,leftMiddle,rightMiddle);
953  AnitaGeomTool::getThetaPartners(bottom,leftBottom,rightBottom);
954 
955  nineAnts[0] = leftTop;
956  nineAnts[1] = top;
957  nineAnts[2] = rightTop;
958  nineAnts[3] = leftMiddle;
959  nineAnts[4] = middle;
960  nineAnts[5] = rightMiddle;
961  nineAnts[6] = leftBottom;
962  nineAnts[7] = bottom;
963  nineAnts[8] = rightBottom;
964 
965 }
966 
967 
968 void PrettyAnitaEvent::fillNextFourAntArrays(int ant, int nextFourAnts[4])
969 {
970 
971  int top=-1,bottom=-1;
972  int leftTop=-1, rightTop=-1;
973  int leftLeftTop=-1, rightRightTop=-1;
974  int leftBottom=-1, rightBottom=-1;
975  int leftLeftBottom=-1, rightRightBottom=-1;
976 
977  if(ant<16) {
978  top=ant;
980  }
981  else {
982  bottom=ant;
984  }
985  int crap;
986  // std::cout << top << "\t" << bottom << std::endl;
987  AnitaGeomTool::getThetaPartners(top,leftTop,rightTop);
988  AnitaGeomTool::getThetaPartners(bottom,leftBottom,rightBottom);
989  AnitaGeomTool::getThetaPartners(leftTop,leftLeftTop,crap);
990  AnitaGeomTool::getThetaPartners(rightTop,crap,rightRightTop);
991  AnitaGeomTool::getThetaPartners(leftBottom,leftLeftBottom,crap);
992  AnitaGeomTool::getThetaPartners(rightBottom,crap,rightRightBottom);
993  nextFourAnts[0]=leftLeftTop;
994  nextFourAnts[1]=rightRightTop;
995  nextFourAnts[2]=leftLeftBottom;
996  nextFourAnts[3]=rightRightBottom;
997 
998 }
999 
1000 void PrettyAnitaEvent::fillNextSixAntArrays(int ant, int nextSixAnts[6])
1001 {
1002 
1003  int top=-1,middle=-1,bottom=-1;
1004  int leftTop=-1, rightTop=-1;
1005  int leftLeftTop=-1, rightRightTop=-1;
1006  int leftMiddle=-1, rightMiddle=-1;
1007  int leftLeftMiddle=-1, rightRightMiddle=-1;
1008  int leftBottom=-1, rightBottom=-1;
1009  int leftLeftBottom=-1, rightRightBottom=-1;
1010 
1011  if(ant<16) {
1012  top=ant;
1014  bottom=middle+16;
1015  } else if (ant<32){
1016  middle = ant;
1017  top = AnitaGeomTool::getAzimuthPartner(middle);
1018  bottom=middle+16;
1019  } else {
1020  bottom=ant;
1021  middle=AnitaGeomTool::getAzimuthPartner(bottom);
1023  }
1024 
1025 
1026  int crap;
1027  // std::cout << top << "\t" << bottom << std::endl;
1028  AnitaGeomTool::getThetaPartners(top,leftTop,rightTop);
1029  AnitaGeomTool::getThetaPartners(middle,leftMiddle,rightMiddle);
1030  AnitaGeomTool::getThetaPartners(bottom,leftBottom,rightBottom);
1031  AnitaGeomTool::getThetaPartners(leftTop,leftLeftTop,crap);
1032  AnitaGeomTool::getThetaPartners(rightTop,crap,rightRightTop);
1033  AnitaGeomTool::getThetaPartners(leftMiddle,leftLeftMiddle,crap);
1034  AnitaGeomTool::getThetaPartners(rightMiddle,crap,rightRightMiddle);
1035  AnitaGeomTool::getThetaPartners(leftBottom,leftLeftBottom,crap);
1036  AnitaGeomTool::getThetaPartners(rightBottom,crap,rightRightBottom);
1037  nextSixAnts[0]=leftLeftTop;
1038  nextSixAnts[1]=rightRightTop;
1039  nextSixAnts[2]=leftLeftMiddle;
1040  nextSixAnts[3]=rightRightMiddle;
1041  nextSixAnts[4]=leftLeftBottom;
1042  nextSixAnts[5]=rightRightBottom;
1043 
1044 }
1045 
1046 
1047 void PrettyAnitaEvent::fillNadirArrays(int ant, int nadirAnts[5])
1048 {
1049  // std::cerr << "fillSixAntArrays( " << ant << ")\n";
1050 
1051  //some logic to convert from top to nadir (on or between antennas)
1052 
1053 
1054 
1055  int nadirAntNums[NUM_PHI]={32,-1,33,-1,34,-1,35,-1,36,-1,37,-1,38,-1,39,-1};
1056 
1057  int left = -1; int right = -1;
1058  int leftLeft = -1; int rightRight = -1;
1059  int antBottom = ant;
1060 
1061  if(ant<16) {
1062  antBottom=AnitaGeomTool::getAzimuthPartner(ant);
1063  }
1064 
1065  int nadir = nadirAntNums[antBottom-16];
1066 
1067  if(nadir == -1){
1068 
1069  leftLeft = -1;
1070  rightRight = -1;
1071  left = nadirAntNums[antBottom-17];
1072 
1073  if((antBottom-15)==16){
1074  right = 32;
1075  }else{
1076  right = nadirAntNums[antBottom-15];
1077  }
1078 
1079  }else{
1080  left = -1;
1081  right = -1;
1082  if(nadir==32){
1083  leftLeft = 39;
1084  }else{
1085  leftLeft = nadir - 1;
1086  }
1087 
1088  if(nadir==39){
1089  rightRight = 32;
1090  }else{
1091  rightRight = nadir + 1;
1092  }
1093  }
1094 
1095  //only need nadir antennas
1096 
1097  // AnitaGeomTool::getThetaPartners(top,leftTop,rightTop);
1098 // AnitaGeomTool::getThetaPartners(ant,leftBottom,rightBottom);
1099 // AnitaGeomTool::getThetaPartners(leftTop,leftLeftTop,crap);
1100 // AnitaGeomTool::getThetaPartners(rightTop,crap,rightRightTop);
1101 // AnitaGeomTool::getThetaPartners(leftBottom,leftLeftBottom,crap);
1102 // AnitaGeomTool::getThetaPartners(rightBottom,crap,rightRightBottom);
1103 
1104 // // std::cout << top << "\t" << bottom << std::endl;
1105 // AnitaGeomTool::getThetaPartners(nadir,leftTop,rightTop);
1106  nadirAnts[0]=leftLeft;
1107  nadirAnts[1]=rightRight;
1108  nadirAnts[2]=left;
1109  nadirAnts[3]=right;
1110  nadirAnts[4]=nadir;
1111 // nadirAnts[5]=rightRightTop;
1112 // nadirAnts[6]=ant;
1113 // nadirAnts[7]=top;
1114 
1115 
1116 }
1117 
1118 int PrettyAnitaEvent::getPrettyColour(int index)
1119 {
1120  if(index>10) return index;
1121  Int_t niceColours[11]={50,38,30,9,8,44,24,12,40,20,41};
1122  return niceColours[index];
1123 }
1124 
1125 
1126 //Putative Analysis methods
1128 {
1129  return getMaxAntennaCorrelationRollingAvg(pol, peakPtr);
1130  // return getMaxAntennaCorrelation(pol, peakPtr);
1131  // getMaxAntennaVSquared(pol,peakPtr);
1132 }
1133 
1134 
1136 {
1137  //Returns the antenna with the maximum power
1138  //Could consider changng this to make things better
1139  double maxVal=0;
1140  int maxAnt=0;
1141  for(int ant=0;ant<32;ant++) {
1142  int chanIndex=AnitaGeomTool::getChanIndexFromAntPol(ant,pol);
1143  Double_t rmsChan=TMath::RMS(fNumPoints[chanIndex],fVolts[chanIndex]);
1144  for(int samp=0;samp<fNumPoints[chanIndex];samp++) {
1145  double vSquared=fVolts[chanIndex][samp]*fVolts[chanIndex][samp];
1146  vSquared/=rmsChan;
1147  if(vSquared>maxVal) {
1148  maxVal=vSquared;
1149  maxAnt=ant;
1150  }
1151  }
1152  }
1153  if(peakPtr) *peakPtr=maxVal;
1154  return maxAnt;
1155 }
1156 
1158 {
1159  //Returns the antenna with the lagest peak/rms in the correlation with its azimuth partner antenna
1160  double maxVal=0;
1161  int maxAnt=0;
1162  for(int ant=0;ant<16;ant++) {
1163  //Loop over the top antennas
1164  int otherAnt=AnitaGeomTool::getAzimuthPartner(ant);
1165  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(ant,pol);
1166  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(otherAnt,pol);
1167 
1168  TGraph *grCor = getCorrelation(ciTop,ciBottom);
1169  Double_t *y = grCor->GetY();
1170  Double_t peak=TMath::MaxElement(grCor->GetN(),y);
1171  Double_t rms=TMath::RMS(grCor->GetN(),y);
1172  // FFTtools::getPeakRmsSqVal(grCor,peak,rms);
1173  if((peak/rms)>maxVal) {
1174  maxVal=peak/rms;
1175  maxAnt=ant;
1176  Double_t maxTop=TMath::MaxElement(fNumPoints[ciTop],fVolts[ciTop]);
1177  Double_t maxBottom=TMath::MaxElement(fNumPoints[ciBottom],fVolts[ciBottom]);
1178  if(maxBottom>maxTop)
1179  maxAnt=otherAnt;
1180  }
1181  delete grCor;
1182 
1183  }
1184  if(peakPtr) *peakPtr=maxVal;
1185  return maxAnt;
1186 }
1187 
1189 {
1190  //Returns the antenna at the centre of three phi-secotrs with the largest peak/rms in the correlation with its azimuth partner antenna
1191  double maxVal=0;
1192  int maxAnt=0;
1193  double maxVals[16]={0};
1194  for(int ant=0;ant<16;ant++) {
1195  //Loop over the top antennas
1196  int otherAnt=AnitaGeomTool::getAzimuthPartner(ant);
1197  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(ant,pol);
1198  int ciMiddle=AnitaGeomTool::getChanIndexFromAntPol(otherAnt,pol);
1199  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(otherAnt+16,pol);
1200 
1201  TGraph *grCor1 = getCorrelation(ciTop,ciMiddle);
1202  TGraph *grCor2 = getCorrelation(ciTop,ciBottom);
1203  TGraph *grCor3 = getCorrelation(ciMiddle,ciBottom);
1204  Double_t *y1 = grCor1->GetY();
1205  Double_t PeakRMS[3];
1206  PeakRMS[0]=TMath::MaxElement(grCor1->GetN(),y1)/TMath::RMS(grCor1->GetN(),y1);
1207  Double_t *y2 = grCor2->GetY();
1208  PeakRMS[1]=TMath::MaxElement(grCor2->GetN(),y2)/TMath::RMS(grCor2->GetN(),y2);
1209 
1210  Double_t *y3 = grCor3->GetY();
1211  PeakRMS[2]=TMath::MaxElement(grCor3->GetN(),y3)/TMath::RMS(grCor3->GetN(),y3);
1212  Double_t maxPeakRMS = TMath::MaxElement(3, PeakRMS);
1213 
1214  // FFTtools::getPeakRmsSqVal(grCor,peak,rms);
1215  if(maxPeakRMS>maxVals[ant])
1216  maxVals[ant]=maxPeakRMS;
1217 
1218  delete grCor1;
1219  delete grCor2;
1220  delete grCor3;
1221  }
1222 
1223  for(int ant=0;ant<16;ant++) {
1224  int leftAnt=ant-1;
1225  if(leftAnt<0) leftAnt=15;
1226  int rightAnt=ant+1;
1227  if(rightAnt>15) rightAnt=0;
1228 
1229 
1230  int otherAnt=AnitaGeomTool::getAzimuthPartner(ant);
1231  int ciTop=AnitaGeomTool::getChanIndexFromAntPol(ant,pol);
1232  int ciMiddle=AnitaGeomTool::getChanIndexFromAntPol(otherAnt,pol);
1233  int ciBottom=AnitaGeomTool::getChanIndexFromAntPol(otherAnt+16,pol);
1234 
1235  Double_t newVal=maxVals[leftAnt]+maxVals[ant]+maxVals[rightAnt];
1236 
1237  if(newVal>maxVal) {
1238  maxVal=newVal;
1239  maxAnt=ant;
1240  Double_t maxTop=TMath::MaxElement(fNumPoints[ciTop],fVolts[ciTop]);
1241  Double_t maxMiddle=TMath::MaxElement(fNumPoints[ciMiddle],fVolts[ciMiddle]);
1242  Double_t maxBottom=TMath::MaxElement(fNumPoints[ciBottom],fVolts[ciBottom]);
1243  if(maxTop>maxBottom && maxTop>maxMiddle) maxAnt = ant;
1244  else if (maxMiddle>maxBottom) maxAnt = otherAnt;
1245  else maxAnt=otherAnt+16;
1246  }
1247 
1248  }
1249  if(peakPtr) *peakPtr=maxVal;
1250  return maxAnt;
1251 }
1252 
1253 
1255 {
1256  //Gets the 11 correlations and then takes the max, rms and neighbouring maxima
1257  if(centreAnt<0)
1258  centreAnt=getMaxAntenna(pol);
1259  int sixAnts[6];
1260  fillSixAntArrays(centreAnt,sixAnts,&(sixAnts[3]));
1261  int nextFourAnts[4];
1262  fillNextFourAntArrays(centreAnt,nextFourAnts);
1263  int nadirAnts[5]={0};
1264  fillNadirArrays(centreAnt,nadirAnts);
1265 
1266 
1267  CorrelationSummary *theSum = new CorrelationSummary(eventNumber, centreAnt, sixAnts,deltaT);
1268  for(int i=0;i<4;i++)
1269  theSum->nextFourAnts[i]=nextFourAnts[i];
1270 
1271 
1272  //Now need to make correlation index pairs
1273  //Top-Bottom first
1274  theSum->firstAnt[0]=sixAnts[0];
1275  theSum->secondAnt[0]=sixAnts[3];
1276  theSum->firstAnt[1]=sixAnts[1];
1277  theSum->secondAnt[1]=sixAnts[4];
1278  theSum->firstAnt[2]=sixAnts[2];
1279  theSum->secondAnt[2]=sixAnts[5];
1280  //Now Left-Right
1281  theSum->firstAnt[3]=sixAnts[0];
1282  theSum->secondAnt[3]=sixAnts[1];
1283  theSum->firstAnt[4]=sixAnts[1];
1284  theSum->secondAnt[4]=sixAnts[2];
1285  theSum->firstAnt[5]=sixAnts[3];
1286  theSum->secondAnt[5]=sixAnts[4];
1287  theSum->firstAnt[6]=sixAnts[4];
1288  theSum->secondAnt[6]=sixAnts[5];
1289  //Now Diagonal
1290  theSum->firstAnt[7]=sixAnts[0];
1291  theSum->secondAnt[7]=sixAnts[4];
1292  theSum->firstAnt[8]=sixAnts[2];
1293  theSum->secondAnt[8]=sixAnts[4];
1294  theSum->firstAnt[9]=sixAnts[1];
1295  theSum->secondAnt[9]=sixAnts[3];
1296  theSum->firstAnt[10]=sixAnts[1];
1297  theSum->secondAnt[10]=sixAnts[5];
1298 
1299 
1300  //Now Leftmost - centre top
1301  theSum->firstAnt[11]=nextFourAnts[0];
1302  theSum->secondAnt[11]=sixAnts[1];
1303  //Now centre - right most top
1304  theSum->firstAnt[12]=sixAnts[1];
1305  theSum->secondAnt[12]=nextFourAnts[1];
1306  //Now Leftmost - centre bottom
1307  theSum->firstAnt[13]=nextFourAnts[2];
1308  theSum->secondAnt[13]=sixAnts[4];
1309  //Now centre - right most bottom
1310  theSum->firstAnt[14]=sixAnts[4];
1311  theSum->secondAnt[14]=nextFourAnts[3];
1312 
1313  //Now Leftmost - left top
1314  theSum->firstAnt[15]=nextFourAnts[0];
1315  theSum->secondAnt[15]=sixAnts[0];
1316  //Now right - right most top
1317  theSum->firstAnt[16]=sixAnts[2];
1318  theSum->secondAnt[16]=nextFourAnts[1];
1319  //Now Leftmost - left bottom
1320  theSum->firstAnt[17]=nextFourAnts[2];
1321  theSum->secondAnt[17]=sixAnts[3];
1322  //Now right - right most bottom
1323  theSum->firstAnt[18]=sixAnts[5];
1324  theSum->secondAnt[18]=nextFourAnts[3];
1325 
1326 
1327  //Now Nadir
1328 
1329  if(nadirAnts[4]>-1){
1330  // std::cout << "Here1\t" << nadirAnts[4] << "\t" << nadirAnts[0] << "\n";
1331  // - "[19]" CN - LLN
1332  theSum->firstAnt[19]=nadirAnts[4];
1333  theSum->secondAnt[19]=nadirAnts[0];
1334  // std::cout << "Here1\t" << theSum->firstAnt[19] << "\t" << theSum->secondAnt[19] << "\n";
1335 
1336  // - "[20]" CN - RRN
1337  theSum->firstAnt[20]=nadirAnts[4];
1338  theSum->secondAnt[20]=nadirAnts[1];
1339 
1340  // - "[21]" LLN - LLB
1341  theSum->firstAnt[21]=nadirAnts[4];
1342  theSum->secondAnt[21]=nextFourAnts[2];
1343 
1344  // - "[22]" LLN - LB
1345  theSum->firstAnt[22]=nadirAnts[0];
1346  theSum->secondAnt[22]=sixAnts[3];
1347 
1348 // - "[23]" CN - CB
1349  theSum->firstAnt[23]=nadirAnts[4];
1350  theSum->secondAnt[23]=sixAnts[4];
1351 
1352  // - "[24]" CN - LB
1353  theSum->firstAnt[24]=nadirAnts[4];
1354  theSum->secondAnt[24]=sixAnts[3];
1355 
1356 // - "[25]" CN - RB
1357  theSum->firstAnt[25]=nadirAnts[4];
1358  theSum->secondAnt[25]=sixAnts[5];
1359 
1360  // - "[26]" RRN - RB
1361  theSum->firstAnt[26]=nadirAnts[1];
1362  theSum->secondAnt[26]=sixAnts[5];
1363 
1364  // - "[27]" RRN - RRB
1365  theSum->firstAnt[27]=nadirAnts[1];
1366  theSum->secondAnt[27]=nextFourAnts[3];
1367 
1368  // - "[28]" LLN - LLT
1369  theSum->firstAnt[28]=nadirAnts[0];
1370  theSum->secondAnt[28]=nextFourAnts[0];
1371 
1372 // - "[29]" LLN - LT
1373  theSum->firstAnt[29]=nadirAnts[0];
1374  theSum->secondAnt[29]=sixAnts[0];
1375 // - "[30]" CN - CT
1376  theSum->firstAnt[30]=nadirAnts[4];
1377  theSum->secondAnt[30]=sixAnts[1];
1378 // - "[31]" CN - LT
1379  theSum->firstAnt[31]=nadirAnts[4];
1380  theSum->secondAnt[31]=sixAnts[0];
1381 // - "[32]" CN - RT
1382  theSum->firstAnt[32]=nadirAnts[4];
1383  theSum->secondAnt[32]=sixAnts[2];
1384 // - "[33]" RRN - RT
1385  theSum->firstAnt[33]=nadirAnts[1];
1386  theSum->secondAnt[33]=sixAnts[2];
1387 // - "[34]" RRN - RRT
1388  theSum->firstAnt[34]=nadirAnts[1];
1389  theSum->secondAnt[34]=nextFourAnts[1];
1390 
1391 
1392  }else{
1393 
1394  // std::cout << "Here2\t" << nadirAnts[2] << "\t" << nadirAnts[3] << "\n";
1395 // - "[19]" LN - RN
1396  theSum->firstAnt[19]=nadirAnts[2];
1397  theSum->secondAnt[19]=nadirAnts[3];
1398 
1399  // - "[20]" LN - LLB
1400  theSum->firstAnt[20]=nadirAnts[2];
1401  theSum->secondAnt[20]=nextFourAnts[2];
1402 
1403  // - "[21]" LN - LB
1404  theSum->firstAnt[21]=nadirAnts[2];
1405  theSum->secondAnt[21]=sixAnts[3];
1406 
1407  // - "[22]" LN - CB
1408  theSum->firstAnt[22]=nadirAnts[2];
1409  theSum->secondAnt[22]=sixAnts[4];
1410 
1411 // - "[23]" LN - RB
1412  theSum->firstAnt[23]=nadirAnts[2];
1413  theSum->secondAnt[23]=sixAnts[5];
1414 
1415  // - "[24]" RN - RRB
1416  theSum->firstAnt[24]=nadirAnts[3];
1417  theSum->secondAnt[24]=nextFourAnts[3];
1418 
1419 // - "[25]" RN - RB
1420  theSum->firstAnt[25]=nadirAnts[3];
1421  theSum->secondAnt[25]=sixAnts[5];
1422 
1423  // - "[26]" RN - CB
1424  theSum->firstAnt[26]=nadirAnts[3];
1425  theSum->secondAnt[26]=sixAnts[4];
1426 
1427  // - "[27]" RN - LB
1428  theSum->firstAnt[27]=nadirAnts[3];
1429  theSum->secondAnt[27]=sixAnts[3];
1430 
1431 
1432 // - "[28]" LN - LLT
1433  theSum->firstAnt[28]=nadirAnts[2];
1434  theSum->secondAnt[28]=nextFourAnts[0];
1435 
1436 // - "[29]" LN - LT
1437  theSum->firstAnt[29]=nadirAnts[2];
1438  theSum->secondAnt[29]=sixAnts[0];
1439 
1440 // - "[30]" LN - CT
1441  theSum->firstAnt[30]=nadirAnts[2];
1442  theSum->secondAnt[30]=sixAnts[1];
1443 
1444 // - "[31]" LN - RT
1445  theSum->firstAnt[31]=nadirAnts[2];
1446  theSum->secondAnt[31]=sixAnts[2];
1447 
1448 // - "[32]" RN - RRT
1449  theSum->firstAnt[32]=nadirAnts[3];
1450  theSum->secondAnt[32]=nextFourAnts[1];
1451 // - "[33]" RN - RT
1452  theSum->firstAnt[33]=nadirAnts[3];
1453  theSum->secondAnt[33]=sixAnts[2];
1454 // - "[34]" RN - CT
1455  theSum->firstAnt[34]=nadirAnts[3];
1456  theSum->secondAnt[34]=sixAnts[1];
1457 
1458 
1459  }
1460 
1461 
1462 
1463  //Now can make correlations and find max, rms, etc.
1464  for(int corInd=0;corInd<35;corInd++) {
1465  TGraph *grCor;
1466  // std::cout << corInd << "\t" << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd] << "\n";
1467  Int_t ci1=AnitaGeomTool::getChanIndexFromAntPol(theSum->firstAnt[corInd],pol);
1468  Int_t ci2=AnitaGeomTool::getChanIndexFromAntPol(theSum->secondAnt[corInd],pol);
1469 
1470  // std::cout << nadirAnts[0] << "\t" << corInd << "\t"<< ci1 << " " << ci2 << " " << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd] <<std::endl;
1471 
1472  // if (ci1*ci2<0) continue; // Linda added this condition
1473 
1474  if(deltaT==0) {
1475  grCor=getCorrelation(ci1,ci2);
1476  }
1477  else {
1478  grCor=getCorrelationInterpolated(ci1,ci2,deltaT);
1479  }
1480 
1481  // theSum->rmsCorVals[corInd]=grCor->GetRMS(2);
1482 
1483  double *theTimes = grCor->GetX();
1484  double *theValues = grCor->GetY();
1485 
1486  int numPoints=grCor->GetN();
1487  double rmsVal=TMath::RMS(numPoints,theValues);
1488  int maxIndex=TMath::LocMax(numPoints,theValues);
1489 // double maxVal=theValues[maxIndex];;
1490  // Double_t maxVal,rmsVal;
1491  // Int_t maxIndex;
1492  // FFTtools::getPeakRmsRectified(grCor,maxVal,rmsVal,&maxIndex);
1493 
1494  // FFTtools::getPeakRmsSqVal(grCor,maxVal,rmsVal,&maxIndex);
1495  // for(int i=0;i<grCor->GetN();i++) {
1496  // std::cout << i << "\t" << theTimes[i] << "\t" << theValues[i] << "\n";
1497  // if(theValues[i]>maxVal) {
1498  // maxVal=theValues[i];
1499  // maxIndex=i;
1500  // }
1501  // }
1502  theSum->rmsCorVals[corInd]=rmsVal;
1503  theSum->maxCorVals[corInd]=theValues[maxIndex];
1504  theSum->maxCorTimes[corInd]=theTimes[maxIndex];
1505 
1506  // std::cout << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd]
1507 // << "\t" << theSum->maxCorTimes[corInd]
1508 // << "\t" << theSum->maxCorVals[corInd] << "\t"
1509 // << "\t" << (theSum->maxCorTimes[corInd]-fWaveOffset)/fDeltaT << "\t"
1510 // << fWaveOffset << "\t" << fDeltaT << std::endl;
1511 
1512  theSum->secondCorVals[corInd][0]=theSum->maxCorVals[corInd];
1513  theSum->secondCorTimes[corInd][0]=theSum->maxCorTimes[corInd];
1514  theSum->secondCorVals[corInd][1]=theSum->maxCorVals[corInd];
1515  theSum->secondCorTimes[corInd][1]=theSum->maxCorTimes[corInd];
1516  for(int i=maxIndex-1;i>=1;i--) {
1517  if(i<1) break;
1518  if(theValues[i]>=theValues[i-1] && theValues[i]>=theValues[i+1]) {
1519  theSum->secondCorVals[corInd][0]=theValues[i];
1520  theSum->secondCorTimes[corInd][0]=theTimes[i];
1521  break;
1522  }
1523  }
1524  for(int i=maxIndex+1;i<grCor->GetN();i++) {
1525  if(i>=grCor->GetN()-1) break;
1526  if(theValues[i]>=theValues[i-1] && theValues[i]>=theValues[i+1]) {
1527  theSum->secondCorVals[corInd][1]=theValues[i];
1528  theSum->secondCorTimes[corInd][1]=theTimes[i];
1529  break;
1530  }
1531  }
1532  delete grCor;
1533  }
1534 
1535  //Will add a call to
1536  theSum->fillErrorsAndFit();
1537 
1538  //Set up MINUIT for the fit
1539  static int firstTime=1;
1540  if(firstTime) {
1541  gMinuit = new TMinuit(2);
1542  firstTime=0;
1543  }
1544  gMinuit->SetObjectFit(theSum);
1545  gMinuit->SetFCN(CorSumFCN);
1546  double par[2]={theSum->fAntPhi[1][0],0}; // the start values
1547  double stepSize[2]={0.01,0.01}; // step sizes
1548  double minVal[2]={0,-1*TMath::PiOver2()}; // minimum bound on parameter
1549  double maxVal[2]={TMath::TwoPi(),TMath::PiOver2()}; // maximum bound on parameter
1550  char parName[2][20];
1551  sprintf(parName[0],"phiWave");
1552  sprintf(parName[1],"thetaWave");
1553  for (int i=0; i<2; i++){
1554  gMinuit->DefineParameter(i, parName[i], par[i], stepSize[i], minVal[i], maxVal[i]);
1555  }
1556 
1557  Double_t phiWave,thetaWave;
1558  Double_t phiWaveErr,thetaWaveErr;
1559  //do the fit and get the answers
1560  gMinuit->SetPrintLevel(-1);
1561  gMinuit->Migrad(); // Minuit's best minimization algorithm
1562  gMinuit->GetParameter(0,phiWave,phiWaveErr);
1563  gMinuit->GetParameter(1,thetaWave,thetaWaveErr);
1564 
1565  Int_t npari,nparx,istat;
1566  Double_t fmin,fedm,errdef;
1567  gMinuit->mnstat(fmin,fedm,errdef,npari,nparx,istat);
1568  // std::cout << fmin << "\t" << fedm << "\t" << npari << "\t" << nparx
1569  // << "\t" << istat << std::endl;
1570  theSum->setFitResults(phiWave,thetaWave,phiWaveErr,thetaWaveErr,fmin);
1571 
1572 
1573 
1574  return theSum;
1575 }
1576 
1577 
1578 
1579 
1581 {
1582  //Gets the 11 correlations and then takes the max, rms and neighbouring maxima
1583  if(centreAnt<0)
1584  centreAnt=getMaxAntenna(pol);
1585 
1586  // Anita 3 has 15 antennas in 5 phi sectors
1587  // LLT LT CT RT RRT
1588  // LLM LM CM RM RRM
1589  // LLB LB CB RB RRB
1590  // Resulting in 48 correlations
1591 
1592  int nineAnts[9];
1593  fillNineAntArrays(centreAnt,nineAnts);
1594  int nextSixAnts[6];
1595  fillNextSixAntArrays(centreAnt,nextSixAnts);
1596 
1597  CorrelationSummaryAnita3 *theSum = new CorrelationSummaryAnita3(eventNumber, centreAnt, nineAnts,deltaT);
1598  for(int i=0;i<6;i++)
1599  theSum->nextSixAnts[i]=nextSixAnts[i];
1600 
1601 
1602  //Now need to make correlation index pairs
1603  //Top-Bottom first
1604  theSum->firstAnt[0]=nineAnts[0];
1605  theSum->secondAnt[0]=nineAnts[3];
1606  theSum->firstAnt[1]=nineAnts[1];
1607  theSum->secondAnt[1]=nineAnts[4];
1608  theSum->firstAnt[2]=nineAnts[2];
1609  theSum->secondAnt[2]=nineAnts[5];
1610  theSum->firstAnt[3]=nineAnts[3];
1611  theSum->secondAnt[3]=nineAnts[6];
1612  theSum->firstAnt[4]=nineAnts[4];
1613  theSum->secondAnt[4]=nineAnts[7];
1614  theSum->firstAnt[5]=nineAnts[5];
1615  theSum->secondAnt[5]=nineAnts[8];
1616  //Now Left-Right
1617  theSum->firstAnt[6]=nineAnts[0];
1618  theSum->secondAnt[6]=nineAnts[1];
1619  theSum->firstAnt[7]=nineAnts[1];
1620  theSum->secondAnt[7]=nineAnts[2];
1621  theSum->firstAnt[8]=nineAnts[3];
1622  theSum->secondAnt[8]=nineAnts[4];
1623  theSum->firstAnt[9]=nineAnts[4];
1624  theSum->secondAnt[9]=nineAnts[5];
1625  theSum->firstAnt[10]=nineAnts[6];
1626  theSum->secondAnt[10]=nineAnts[7];
1627  theSum->firstAnt[11]=nineAnts[7];
1628  theSum->secondAnt[11]=nineAnts[8];
1629  //Now Diagonal
1630  theSum->firstAnt[12]=nineAnts[0];
1631  theSum->secondAnt[12]=nineAnts[4];
1632  theSum->firstAnt[13]=nineAnts[2];
1633  theSum->secondAnt[13]=nineAnts[4];
1634  theSum->firstAnt[14]=nineAnts[6];
1635  theSum->secondAnt[14]=nineAnts[4];
1636  theSum->firstAnt[15]=nineAnts[8];
1637  theSum->secondAnt[15]=nineAnts[4];
1638  theSum->firstAnt[16]=nineAnts[1];
1639  theSum->secondAnt[16]=nineAnts[3];
1640  theSum->firstAnt[17]=nineAnts[1];
1641  theSum->secondAnt[17]=nineAnts[5];
1642  theSum->firstAnt[18]=nineAnts[3];
1643  theSum->secondAnt[18]=nineAnts[7];
1644  theSum->firstAnt[19]=nineAnts[7];
1645  theSum->secondAnt[19]=nineAnts[5];
1646  //Now Leftmost - centre or centre - rightmost
1647  theSum->firstAnt[20]=nextSixAnts[0];
1648  theSum->secondAnt[20]=nineAnts[1];
1649  theSum->firstAnt[21]=nineAnts[1];
1650  theSum->secondAnt[21]=nextSixAnts[1];
1651  theSum->firstAnt[22]=nextSixAnts[2];
1652  theSum->secondAnt[22]=nineAnts[4];
1653  theSum->firstAnt[23]=nineAnts[4];
1654  theSum->secondAnt[23]=nextSixAnts[3];
1655  theSum->firstAnt[24]=nextSixAnts[4];
1656  theSum->secondAnt[24]=nineAnts[7];
1657  theSum->firstAnt[25]=nineAnts[7];
1658  theSum->secondAnt[25]=nextSixAnts[5];
1659  //Now Leftmost - left or right-rightmost
1660  theSum->firstAnt[26]=nextSixAnts[0];
1661  theSum->secondAnt[26]=nineAnts[0];
1662  theSum->firstAnt[27]=nineAnts[2];
1663  theSum->secondAnt[27]=nextSixAnts[1];
1664  theSum->firstAnt[28]=nextSixAnts[2];
1665  theSum->secondAnt[28]=nineAnts[3];
1666  theSum->firstAnt[29]=nineAnts[5];
1667  theSum->secondAnt[29]=nextSixAnts[3];
1668  theSum->firstAnt[30]=nextSixAnts[4];
1669  theSum->secondAnt[30]=nineAnts[6];
1670  theSum->firstAnt[31]=nineAnts[8];
1671  theSum->secondAnt[31]=nextSixAnts[5];
1672  // Now diagonals to LM and RM
1673  theSum->firstAnt[32]=nextSixAnts[0];
1674  theSum->secondAnt[32]=nineAnts[3];
1675  theSum->firstAnt[33]=nextSixAnts[4];
1676  theSum->secondAnt[33]=nineAnts[3];
1677  theSum->firstAnt[34]=nextSixAnts[1];
1678  theSum->secondAnt[34]=nineAnts[5];
1679  theSum->firstAnt[35]=nextSixAnts[5];
1680  theSum->secondAnt[35]=nineAnts[5];
1681  // Now bottom to top
1682  theSum->firstAnt[36]=nextSixAnts[0];
1683  theSum->secondAnt[36]=nextSixAnts[4];
1684  theSum->firstAnt[37]=nineAnts[0];
1685  theSum->secondAnt[37]=nineAnts[6];
1686  theSum->firstAnt[38]=nineAnts[1];
1687  theSum->secondAnt[38]=nineAnts[7];
1688  theSum->firstAnt[39]=nineAnts[2];
1689  theSum->secondAnt[39]=nineAnts[8];
1690  theSum->firstAnt[40]=nextSixAnts[1];
1691  theSum->secondAnt[40]=nextSixAnts[5];
1692  // Now top to bottom displaced right
1693  theSum->firstAnt[41]=nextSixAnts[0];
1694  theSum->secondAnt[41]=nineAnts[6];
1695  theSum->firstAnt[42]=nineAnts[0];
1696  theSum->secondAnt[42]=nineAnts[7];
1697  theSum->firstAnt[43]=nineAnts[1];
1698  theSum->secondAnt[43]=nineAnts[8];
1699  theSum->firstAnt[44]=nineAnts[2];
1700  theSum->secondAnt[44]=nextSixAnts[5];
1701  // Now top to bottom displaced left
1702  theSum->firstAnt[45]=nineAnts[0];
1703  theSum->secondAnt[45]=nextSixAnts[4];
1704  theSum->firstAnt[46]=nineAnts[1];
1705  theSum->secondAnt[46]=nineAnts[6];
1706  theSum->firstAnt[47]=nineAnts[2];
1707  theSum->secondAnt[47]=nineAnts[7];
1708  theSum->firstAnt[48]=nextSixAnts[1];
1709  theSum->secondAnt[48]=nineAnts[8];
1710  // horizontal across center
1711  theSum->firstAnt[49] = nineAnts[0];
1712  theSum->secondAnt[49] = nineAnts[2];
1713  theSum->firstAnt[50] = nineAnts[3];
1714  theSum->secondAnt[50] = nineAnts[5];
1715  theSum->firstAnt[51] = nineAnts[6];
1716  theSum->secondAnt[51] = nineAnts[8];
1717 
1718  return theSum;
1719 }
1720 
1721 
1723 
1724  CorrelationSummaryAnita3 *theSum = createCorrelationSummaryAnita3(centreAnt, pol, deltaT);
1725 
1726  //Now can make correlations and find max, rms, etc.
1727  for(int corInd=0;corInd<NUM_CORRELATIONS_ANITA3;corInd++) {
1728  TGraph *grCor;
1729  // std::cout << corInd << "\t" << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd] << "\n";
1730  Int_t ci1=AnitaGeomTool::getChanIndexFromAntPol(theSum->firstAnt[corInd],pol);
1731  Int_t ci2=AnitaGeomTool::getChanIndexFromAntPol(theSum->secondAnt[corInd],pol);
1732 
1733  // std::cout << corInd << "\t"<< ci1 << " " << ci2 << " " << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd] <<std::endl;
1734 
1735 // if (ci1*ci2<0) continue; // Linda added this condition
1736 
1737  if(deltaT==0) {
1738  grCor=getCorrelation(ci1,ci2);
1739  }
1740  else {
1741  grCor=getCorrelationInterpolated(ci1,ci2,deltaT);
1742  }
1743 
1744  // theSum->rmsCorVals[corInd]=grCor->GetRMS(2);
1745 
1746  double *theTimes = grCor->GetX();
1747  double *theValues = grCor->GetY();
1748 
1749  int numPoints=grCor->GetN();
1750  double rmsVal=TMath::RMS(numPoints,theValues);
1751  int maxIndex=TMath::LocMax(numPoints,theValues);
1752 // double maxVal=theValues[maxIndex];
1753 
1754 // Double_t maxVal,rmsVal;
1755 // Int_t maxIndex;
1756 // FFTtools::getPeakRmsRectified(grCor,maxVal,rmsVal,&maxIndex);
1757 
1758 // FFTtools::getPeakRmsSqVal(grCor,maxVal,rmsVal,&maxIndex);
1759 // for(int i=0;i<grCor->GetN();i++) {
1760 // // std::cout << i << "\t" << theTimes[i] << "\t" << theValues[i] << "\n";
1761 // if(theValues[i]>maxVal) {
1762 // maxVal=theValues[i];
1763 // maxIndex=i;
1764 // }
1765 // }
1766  theSum->rmsCorVals[corInd]=rmsVal;
1767  theSum->maxCorVals[corInd]=theValues[maxIndex];
1768  theSum->maxCorTimes[corInd]=theTimes[maxIndex];
1769 
1770  // std::cout << theSum->firstAnt[corInd] << "\t" << theSum->secondAnt[corInd]
1771 // << "\t" << theSum->maxCorTimes[corInd]
1772 // << "\t" << theSum->maxCorVals[corInd] << "\t"
1773 // << "\t" << (theSum->maxCorTimes[corInd]-fWaveOffset)/fDeltaT << "\t"
1774 // << fWaveOffset << "\t" << fDeltaT << std::endl;
1775 
1776  theSum->secondCorVals[corInd][0]=theSum->maxCorVals[corInd];
1777  theSum->secondCorTimes[corInd][0]=theSum->maxCorTimes[corInd];
1778  theSum->secondCorVals[corInd][1]=theSum->maxCorVals[corInd];
1779  theSum->secondCorTimes[corInd][1]=theSum->maxCorTimes[corInd];
1780  for(int i=maxIndex-1;i>=1;i--) {
1781  if(i<1) break;
1782  if(theValues[i]>=theValues[i-1] && theValues[i]>=theValues[i+1]) {
1783  theSum->secondCorVals[corInd][0]=theValues[i];
1784  theSum->secondCorTimes[corInd][0]=theTimes[i];
1785  break;
1786  }
1787  }
1788  for(int i=maxIndex+1;i<grCor->GetN();i++) {
1789  if(i>=grCor->GetN()-1) break;
1790  if(theValues[i]>=theValues[i-1] && theValues[i]>=theValues[i+1]) {
1791  theSum->secondCorVals[corInd][1]=theValues[i];
1792  theSum->secondCorTimes[corInd][1]=theTimes[i];
1793  break;
1794  }
1795  }
1796  delete grCor;
1797  }
1798 
1799  //Will add a call to
1800  theSum->fillErrorsAndFit();
1801 
1802  //Set up MINUIT for the fit
1803  static int firstTime=1;
1804  if(firstTime) {
1805  gMinuit = new TMinuit(2);
1806  firstTime=0;
1807  }
1808  gMinuit->SetObjectFit(theSum);
1809  gMinuit->SetFCN(CorSumFCNanita3);
1810  double par[2]={theSum->fAntPhi[1][0],0}; // the start values
1811  double stepSize[2]={0.01,0.01}; // step sizes
1812  double minVal[2]={0,-1*TMath::PiOver2()}; // minimum bound on parameter
1813  double maxVal[2]={TMath::TwoPi(),TMath::PiOver2()}; // maximum bound on parameter
1814  char parName[2][20];
1815  sprintf(parName[0],"phiWave");
1816  sprintf(parName[1],"thetaWave");
1817  for (int i=0; i<2; i++){
1818  gMinuit->DefineParameter(i, parName[i], par[i], stepSize[i], minVal[i], maxVal[i]);
1819  }
1820 
1821  Double_t phiWave,thetaWave;
1822  Double_t phiWaveErr,thetaWaveErr;
1823  //do the fit and get the answers
1824  gMinuit->SetPrintLevel(-1);
1825 
1826  gMinuit->Migrad(); // Minuit's best minimization algorithm
1827 
1828  gMinuit->GetParameter(0,phiWave,phiWaveErr);
1829  gMinuit->GetParameter(1,thetaWave,thetaWaveErr);
1830 
1831 
1832  Int_t npari,nparx,istat;
1833  Double_t fmin,fedm,errdef;
1834  gMinuit->mnstat(fmin,fedm,errdef,npari,nparx,istat);
1835 // std::cout << fmin << "\t" << fedm << "\t" << npari << "\t" << nparx
1836 // << "\t" << istat << std::endl;
1837  theSum->setFitResults(phiWave,thetaWave,phiWaveErr,thetaWaveErr,fmin);
1838 
1839 
1840 
1841  return theSum;
1842 }
1843 
1844 
1845 /*
1846 
1847 #define NUM_BINS_PHI 10
1848 #define NUM_BINS_THETA 10
1849 #define NUM_ANTS 2
1850 
1851 TCanvas *PrettyAnitaEvent::getTwoAntMap(int ant1,int ant2){
1852 
1853  gStyle->SetPalette(1);
1854 
1855  //Double_t inch=0.0254;//inch in m
1856  //antenna centre locations from anita note 345. The coordinates noted are radius to centre of antenna (centre of base) - NEED TO ADJUST FOR PHASE CENTRE ACTUALLY BEING 17.5 CM INTO ANTENNA - and azimuth (az) angle. uses inches and degrees... only upper ring at the moment
1857  //Double_t antennaCentres[16][2]={{56.831,-45.100},{56.77,-0.363},{56.464,44.59},{56.164,89.801},{56.012,135.095},{56.387,-179.576},{56.59,-134.46},{56.884,-89.728},{50.249,-67.471},{50.218,-22.571},{50.126,22.239},{49.823,67.286},{49.61,112.537},{49.667,157.928},{49.973,-157.101},{50.219,-112.091}};
1858  //for(int i=0;i<16;i++){
1859  // antennaCentres[i][1]+=0.363;//so that everything is calibrated wrt antenna 2
1860  // antennaCentres[i][0]/=inch;
1861  // antennaCentres[i][0]-=17.5;//converts to phase centre from antenna centre
1862  // antennaCentres[i][1]=antennaCentres[i][1]*PI/180;
1863  //}
1864 
1865  Double_t PI=3.14159;
1866 
1867  //setup the phi and theta arrays, phi from -pi to pi, theta from -pi/2 to pi/2
1868  Double_t phiArray[NUM_BINS_PHI];
1869  Double_t thetaArray[NUM_BINS_THETA];
1870  for(UInt_t i=0;i<NUM_BINS_PHI;i++){
1871  phiArray[i] = (i+1/2) * 2*PI/NUM_BINS_PHI - PI;
1872  }
1873  for(UInt_t i=0;i<NUM_BINS_PHI;i++){
1874  thetaArray[i] =(i+1/2) * PI/NUM_BINS_PHI - PI/2;
1875  }
1876 
1877  //time relative to phi sector 1 (ant 2 and 20)
1878  Double_t timeRel[NUM_BINS_PHI][NUM_BINS_THETA][NUM_ANTS];
1879  Double_t gainRel[NUM_BINS_PHI][NUM_BINS_THETA][NUM_ANTS];
1880 
1881  for(int phi=0;phi<NUM_BINS_PHI;phi++){
1882  for(int theta=0;theta<NUM_BINS_THETA;theta++){
1883 
1884  timeRel[phi][theta] = UsefulAdu5Pat::getDeltaTExpected(ant1,ant2,phiArray[phi],thetaArray[theta],10.);
1885 
1886  }
1887  }
1888 
1889  Double_t deltaT=1/(2.6*8);
1890 
1891  TGraph *gr[NUM_ANTS]={0};
1892 
1893  gr[0] = getInterpolatedGraph(AnitaGeomTool::getChanFromAntPol(ant1,AnitaPol::kVertical),deltaT);
1894  gr[1] = getInterpolatedGraph(AnitaGeomTool::getChanFromAntPol(ant2,AnitaPol::kVertical),deltaT);
1895 
1896  Int_t numBins=gr[0]->GetN();
1897 
1898  Double_t maxPeak[NUM_BINS_PHI][NUM_BINS_THETA];
1899  Double_t testPeak;
1900  Double_t testX[NUM_ANTS]={0};
1901  Double_t testY[NUM_ANTS]={0};
1902 
1903  for(int phi=0;phi<NUM_BINS_PHI;phi++){
1904  for(int theta=0;theta<NUM_BINS_THETA;theta++){
1905 
1906  maxPeak[phi][theta]=0.;
1907  testPeak=0.;
1908 
1909  Int_t binShift=static_cast<Int_t>((timeRel[phi][theta][ant2]-timeRel[phi][theta][ant1])/deltaT);
1910 
1911  for(int bin=0;bin<numBins;bin++){
1912 
1913  if((bin+binShift)<0) continue;
1914  if((bin+binShift)>numBins) continue;
1915 
1916  gr[0]->GetPoint(bin,testX[0],testY[0]);
1917  gr[1]->GetPoint(bin+binShift,testX[1],testY[1]);
1918 
1919  testPeak=testY[0]+testY[1];
1920  if(testPeak>maxPeak[phi][theta]) maxPeak[phi][theta]=testPeak;
1921 
1922 
1923  }
1924 
1925  }
1926  }
1927 
1928  TCanvas *canvas = (TCanvas*) gROOT->FindObject("twoAntCorr");
1929  if(!canvas) {
1930  canvas = new TCanvas("twoAntCorr","twoAntCorr",600,500);
1931  }
1932 
1933  TH2F *corrPlot = new TH2F("Two Ant Correlation","Two Ant Correlation",NUM_BINS_PHI,0,2*PI,NUM_BINS_THETA,-PI/2,PI/2);
1934 
1935  for(int phi=0;phi<NUM_BINS_PHI;phi++){
1936  for(int theta=0;theta<NUM_BINS_THETA;theta++){
1937  corrPlot->Fill(phiArray[phi],thetaArray[theta],maxPeak[phi][theta]);
1938  }
1939  }
1940 
1941  corrPlot->Draw("colz");
1942 
1943  return canvas;
1944 
1945 }
1946 */
UInt_t eventNumber
Event number from software.
Definition: RawAnitaEvent.h:33
double secondCorTimes[35][2]
The time of the next highest correlation values (tore both left and right vals).
double maxCorVals[35]
The maximumn correlation value for each of the 35 possible correlations (3 up-down, 4 left-right, 4 diagonal, 4 outside-neighbour).
void fillErrorsAndFit()
The worker function that actually does the fitting.
void fillErrorsAndFit()
The worker function that actually does the fitting.
TCanvas * getTenWaveformCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with ten waveforms plotted in it.
void fillSixAntArrays(int ant, int topAnts[3], int bottomAnts[3])
Utility to get neighbouring antenna numbers.
void setFitResults(Double_t tPhi, Double_t tTheta, Double_t tPhiErr, Double_t tThetaErr, Double_t tChiSq)
Sets the result of an external fit.
static void getThetaPartners(Int_t rx, int &rxleft, int &rxright)
output the antennas that are in neighbouring phi sectors (not the neighbouring antennas) ...
void setFitResults(Double_t tPhi, Double_t tTheta, Double_t tPhiErr, Double_t tThetaErr, Double_t tChiSq)
Sets the result of an external fit.
int nextSixAnts[6]
The numbers of the six outside antennas.
TGraph * multipleSimpleNotchFilters(const TGraph *grWave, Int_t numNotches, const Double_t minFreq[], const Double_t maxFreq[])
This returns a TGraph which has had N simple notch band filters applied.
Definition: FFTtools.cxx:2038
double secondCorVals[35][2]
The peak of the next highest correlation values (tore both left and right vals).
TCanvas * getSixCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with six correlations plotted in it.
double rmsCorVals[52]
The rms correlation value for each of the 49 possible correlations (3 top-middle, 3 middle-bottom...
double maxCorTimes[35]
The time of the maximum correlation value for each of the 35 possible correlations (3 up-down...
double maxCorVals[52]
The maximum correlation value for each of the 49 possible correlations (3 top-middle, 3 middle-bottom, 6 left-right, 6 diagonal, 6 outside-centre, 6 outside-neighbour, 4 diagonal with neighbour, 13 top-bottom combinations).
This is the event class, inherited from UsefulAnitaEvent, that has a number of correlation related me...
TGraph * getInterpolatedGraph(int chanIndex, double deltaT)
Wrapper around FFTtools::getInterpolatedGraph.
enum WaveCalType::EWaveCalType WaveCalType_t
The calibration enumeration type.
Double_t getChiSquared(Double_t tPhiWave, Double_t tThetaWave, Int_t numAnts)
Tests a given plane wave hypothesis using a either six or ten antennas.
int getMaxAntennaCorrelationRollingAvg(AnitaPol::AnitaPol_t pol, Double_t *peakPtr=0)
Select the upper antenna with the maximum correlation (defined as peak/rms of the correlation) with i...
PrettyAnitaHk – The prettified ANITA Hk.
Definition: PrettyAnitaHk.h:22
double fVolts[12 *9][260]
Array of unwrapped (unless kNoCalib) voltages for each channel.
static Int_t getChanIndexFromAntPol(Int_t ant, AnitaPol::AnitaPol_t pol)
Convert ant-pol to logical index.
This is a poorly thought out class that was meant to be a summary of peaks of the correlations of som...
int fNumPoints[12 *9]
Number of poins per channel.
TCanvas * getSixWaveformCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with six waveforms plotted in it.
TCanvas * getSixInterpolatedCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT=(1./(2.6 *8)), TCanvas *can=0)
Generates a TCanvas with six correlations of interpolated waveforms plotted in it.
TCanvas * getElevenCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with eleven correlations (the combinations of six antennas) plotted in it...
int secondAnt[52]
The index of the second antenna in the 49 possible pairs (3 top-middle, 3 middle-bottom, 6 left-right, 6 diagonal, 6 outside-centre, 6 outside-neighbour, 4 diagonal with neighbour, 13 top-bottom combinations).
TGraph * getInterpolatedGraph(const TGraph *grIn, Double_t deltaT)
Interpolation Routines that use ROOT::Math::Interpolator.
Definition: FFTtools.cxx:32
RawAnitaHeader – The Raw ANITA Event Header.
TGraph * getCorrelationInterpolated(int chanIndex1, int chanIndex2, Double_t deltaT=(1./(2.6 *8)))
Wrapper around FFTtools::getInterpolatedCorrelationGraph.
TCanvas * getElevenInterpolationCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT=(1./(2.6 *8)), TCanvas *can=0)
Generates a TCanvas with eleven correlations of interpolated waveforms (the 11 correlations are combi...
static Int_t getAzimuthPartner(Int_t rx)
output the antenna that points to the same place in phi as the input antenna
CorrelationSummaryAnita3 * createCorrelationSummaryAnita3(Int_t centreAnt, AnitaPol::AnitaPol_t pol, Double_t deltaT=0)
Generates a CorrelationSummaryAnita3 object for a set of 15 antennas.
int firstAnt[52]
There are 49 correlations formed from a set of 15 antennas (5-phi sectors).
void fillNextFourAntArrays(int ant, int nextFourAnts[4])
Utility to get next to neighbouring antenna numbers.
Double_t getChiSquared(Double_t tPhiWave, Double_t tThetaWave, Int_t numAnts)
Tests a given plane wave hypothesis using a either six or ten antennas.
TGraph * getSimplePowerEnvelopeGraph(const TGraph *gr)
Returns the simple power envelope of a waveform. The waveform is first squared and then only local pe...
Definition: FFTtools.cxx:1817
TGraph * getSimplePowerEnvelopeGraph(int chanIndex)
Wrapper around FFTtools::getSimplePowerEnvelopeGraph.
TGraph * getGraph(int chanIndex) const
Returns a voltage-time waveform for given channel index.
UsefulAnitaEvent – The Calibrated Useful Anita Event object.
Float_t rms[12 *9]
RMS of the waveform.
Definition: RawAnitaEvent.h:64
int getMaxAntenna(AnitaPol::AnitaPol_t pol, Double_t *peakPtr=0)
Calls getMaxAntennaCorrelation.
TGraph * getFFTMagnitude(TGraph *grIn)
Wrapper around FFTtools::makePowerSpectrum.
double secondCorTimes[52][2]
The time of the next highest correlation values (tore both left and right vals).
TCanvas * getSixPowerEnvelopeCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with six power envelope plots using FFTtools::getSimplePowerEnvelopeGraph.
TGraph * getCorrelation(int chanIndex1, int chanIndex2)
Wrapper around FFTtools::getCorrelationGraph.
CalibratedAnitaEvent – The Calibrated Calibrated Anita Event object.
double maxCorTimes[52]
The time of the maximum correlation value for each of the 49 possible correlations (3 top-middle...
TGraph * getCorrelationGraph(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0)
Returns the correlation of two TGraphs.
Definition: FFTtools.cxx:754
TGraph * makePowerSpectrum(const TGraph *grWave)
Returns the power spectral density. Note the PSD is unormalised (or if you prefer is normalised to th...
Definition: FFTtools.cxx:1031
void fillNineAntArrays(int ant, int nineAnts[9])
Utility to get neighbouring antenna numbers ( Top 0-2, Middle 3-5, Bottom 6-8)
int firstAnt[35]
There are 35 correlations formed from a set of 13 antennas (5-phi sectors).
TCanvas * getSixInterpolatedCanvas(int ant, AnitaPol::AnitaPol_t pol, Double_t deltaT=(1./(2.6 *8)), TCanvas *can=0)
Generates a TCanvas with six interpolated waveforms plotted in it.
This is a poorly thought out class that was meant to be a summary of peaks of the correlations of som...
CorrelationSummaryAnita3 * getCorrelationSummaryAnita3(Int_t centreAnt, AnitaPol::AnitaPol_t pol, Double_t deltaT=0)
Generates a CorrelationSummaryAnita3 object for a set of 15 antennas.
int getMaxAntennaVSquared(AnitaPol::AnitaPol_t pol, Double_t *peakPtr=0)
Select the antenna with the maximum voltage squared.
double rmsCorVals[35]
The rms correlation value for each of the 35 possible correlations (3 up-down, 4 left-right, 4 diagonal, 4 outside-neighbour).
TCanvas * getSixFFTPowerCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with six FFT power spectral densitity plots.
int getMaxAntennaCorrelation(AnitaPol::AnitaPol_t pol, Double_t *peakPtr=0)
Select the upper antenna with the maximum correlation (defined as peak/rms of the correlation) with i...
int nextFourAnts[4]
The numbers of the four outside antennas.
void fillNextSixAntArrays(int ant, int nextFourAnts[4])
Utility to get next to neighbouring antenna numbers.
double secondCorVals[52][2]
The peak of the next highest correlation values (tore both left and right vals).
CorrelationSummary * getCorrelationSummary(Int_t centreAnt, AnitaPol::AnitaPol_t pol, Double_t deltaT=0)
Generates a CorrelationSummary object for a set of 10 antennas.
TGraph * simplePassBandFilter(const TGraph *grWave, Double_t minFreq, Double_t maxFreq)
This returns a TGraph which has had a simple pass band filter applied.
Definition: FFTtools.cxx:1938
int secondAnt[35]
The index of the second antenna in the 35 possible pairs (3 up-down, 4 left-right, 4 diagonal, 4 outside-neighbour).
Double_t fAntPhi[35][2]
A lookup table for antenna postions.
Double_t fAntPhi[52][2]
A lookup table for antenna postions.
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
TCanvas * getTenCorrelationCanvas(int ant, AnitaPol::AnitaPol_t pol, TCanvas *can=0)
Generates a TCanvas with ten correlations plotted in it.
RawAnitaEvent – The Raw ANITA Event Data.
Definition: RawAnitaEvent.h:22
PrettyAnitaEvent(CalibratedAnitaEvent *calPtr, WaveCalType::WaveCalType_t calType=WaveCalType::kDefault)
The assignment constructor.