UserModule.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "UserModule.h"
4 
5 #include <det/Detector.h>
6 
7 #include <fdet/FDetector.h>
8 #include <fdet/Telescope.h>
9 #include <fdet/Eye.h>
10 
11 #include <utl/ErrorLogger.h>
12 #include <utl/TimeStamp.h>
13 #include <utl/TimeInterval.h>
14 #include <utl/TabulatedFunction.h>
15 #include <utl/MultiTabulatedFunction.h>
16 #include <utl/Photon.h>
17 #include <utl/AugerUnits.h>
18 #include <utl/MathConstants.h>
19 #include <utl/PhysicalConstants.h>
20 #include <utl/RandomEngine.h>
21 #include <utl/Trace.h>
22 #include <utl/TraceAlgorithm.h>
23 #include <utl/Reader.h>
24 
25 #include <evt/Event.h>
26 #include <evt/ShowerSimData.h>
27 
28 #include <fevt/FEvent.h>
29 #include <fevt/Eye.h>
30 #include <fevt/TelescopeSimData.h>
31 #include <fevt/Telescope.h>
32 #include <fevt/PixelSimData.h>
33 #include <fevt/Pixel.h>
34 #include <fevt/ChannelSimData.h>
35 #include <fevt/Channel.h>
36 
37 #include <fwk/CentralConfig.h>
38 
39 #include <TFile.h>
40 #include <TObjArray.h>
41 #include <TGraph.h>
42 #include <TGraphErrors.h>
43 #include <TMultiGraph.h>
44 #include <TF1.h>
45 #include <TH2D.h>
46 #include <TVector3.h>
47 #include <TMarker.h>
48 #include <TStyle.h>
49 #include <TCanvas.h>
50 #include <TTree.h>
51 #include <TFolder.h>
52 #include <TString.h>
53 #include <TPaveText.h>
54 #include <TColor.h>
55 #include <TROOT.h>
56 #include <TPolyLine.h>
57 
58 #include <CLHEP/Random/Randomize.h>
59 
60 using namespace std;
61 using namespace utl;
62 using namespace evt;
63 using namespace fevt;
64 using namespace fwk;
65 using namespace det;
66 
67 
69  fOutputFile(0),
70  fTree(0),
71  fLongitudinalProfileCanvas(0),
72  fEnergyDepositCanvas(0),
73  fFluorLightCanvas(0),
74  fCherBeamCanvas(0),
75  fLightFluxCanvas(0),
76  fFluorFluxCanvas(0),
77  fCherMieFluxCanvas(0),
78  fCherRaylFluxCanvas(0),
79  fCherDirFluxCanvas(0),
80  fLightOnCameraCanvas(0),
81  fLightAtDiaCanvas(0),
82  fCameraCanvas(0),
83  fPhotonGraphs(0),
84  fFADCGraphs(0),
85  fEventId(0)
86 { }
87 
88 
90 {
91  // delete fOutputFile;
92  // delete fTree;
93  // delete fLongitudinalProfileCanvas;
94  // delete fEnergyDepositCanvas;
95  // delete fFluorLightCanvas;
96  // delete fCherBeamCanvas;
97  // delete fLightFluxCanvas;
98  // delete fFluorFluxCanvas;
99  // delete fCherMieFluxCanvas;
100  // delete fCherRaylFluxCanvas;
101  // delete fCameraCanvas;
102  // delete fLightOnCameraCanvas;
103  // delete fLightAtDiaCanvas;
104  // delete fEventId;
105  // delete fPhotonGraphs;
106  // delete fFADCGraphs;
107 }
108 
109 
112 {
113  //
114  // Initialize your module here. This method
115  // is called once at the beginning of the run.
116  // The eSuccess flag indicates the method ended
117  // successfully. For other possible return types,
118  // see the VModule documentation.
119  //
120  INFO("UserModule::Init()");
121 
122  CentralConfig* const cc = CentralConfig::GetInstance();
123 
124  Branch topB = cc->GetTopBranch("UserModule");
125 
126  Branch eyeB = topB.GetChild("eye");
127  if (!eyeB) {
128  ERROR("Could not find branch eye");
130  }
131  eyeB.GetData(fEye);
132 
133  Branch telB = topB.GetChild("telescope");
134  if (!telB) {
135  ERROR("Could not find branch telescope");
137  }
138  telB.GetData(fTelescope);
139 
140  fOutputFile = new TFile("OfflineOutput.root","recreate");
141  fLongitudinalProfileCanvas = new TCanvas("LongitudinalProfileC",
142  "LongitudinalProfileC");
143  fEnergyDepositCanvas = new TCanvas("EnergyDepositC",
144  "EnergyDepositC");
145  fFluorLightCanvas = new TCanvas("FluorLightC", "FluorLightC");
146  fCherBeamCanvas = new TCanvas("CherBeamC", "CherBeamC");
147 
148  fLightFluxCanvas = new TCanvas("LightFlux", "LightFlux");
149 
150  fFluorFluxCanvas = new TCanvas("FluorFlux", "FluorFlux");
151 
152  fCherMieFluxCanvas = new TCanvas("CherMieFlux", "CherMieFlux");
153 
154  fCherRaylFluxCanvas = new TCanvas("CherRaylFlux", "CherRaylFlux");
155 
156  fCherDirFluxCanvas = new TCanvas("CherDirFlux", "CherDirFlux");
157 
158  fLightOnCameraCanvas = new TCanvas("LightCamera", "LightCamera");
159 
160  fLightAtDiaCanvas = new TCanvas("LightAtDiaphragm", "LightAtDiaphragm");
161 
162  fCameraCanvas = new TCanvas("Camera", "Camera",60,60,600,600);
163 
164  fPhotonGraphs = new TObjArray;
165 
166  fFADCGraphs = new TObjArray;
167 
168  fEventId = new TString;
169 
170  return eSuccess;
171 }
172 
173 
176 {
177  INFO("UserModule::Run()");
178 
179  if (event.HasSimShower()) {
180  // AnalyzeShower(event.GetSimShower());
182  AnalyzeCamera(event.GetFEvent());
183  return eSuccess;
184  }
185 
186  ERROR("Event does not contain a simulated shower.\n"
187  "Going to the next event.");
188  return eContinueLoop;
189 }
190 
191 
194 {
195  INFO("UserModule::Finish()");
196 
197  fOutputFile->cd();
198 
199  fOutputFile->Close();
200 
201  return eSuccess;
202 }
203 
204 
205 void
207 {
209  fEnergyDepositCanvas->Clear();
210  fCherBeamCanvas->Clear();
211  fFluorLightCanvas->Clear();
212  fLightFluxCanvas->Clear();
213  fFluorFluxCanvas->Clear();
214  fCherMieFluxCanvas->Clear();
215  fCherRaylFluxCanvas->Clear();
216  fCherDirFluxCanvas->Clear();
217  fCameraCanvas->Clear();
218  fLightOnCameraCanvas->Clear();
219  fLightAtDiaCanvas->Clear();
220 }
221 
222 
223 void
225 {
226  //utl::TabulatedFunction fluor = shower.GetFluorescencePhotons(0);
227  //utl::TabulatedFunction cher = shower.GetCherenkovPhotons(0);
228 
229  // GH data of the shower
230  /*
231  cout << "---------------------------" << endl;
232  cout << "GH Parameters of the Shower" << endl;
233  cout << "---------------------------" << endl;
234  cout << "Nmax = " << shower.GetGHParameters().GetNMax() << endl;
235  cout << "Xmax = " << shower.GetGHParameters().GetXMax()/(g/(cm*cm))
236  << " g/cm²" << endl;
237  //cout << "X0 = " << gh.GetXZero()/(g/(cm*cm)) << " g/cm²" << endl;
238  cout << "chi² = " << shower.GetGHParameters().GetChiSquare() << endl
239  << endl;
240  */
241 
242  PlotLongitudinalProfile(shower);
243  PlotEnergyDeposit(shower);
244  PlotTotalFluorLight(shower);
245  PlotTotalCherBeam(shower);
246 }
247 
248 
250 void
252 {
254  unsigned int size = profile.GetNPoints();
255  double x[size];
256  double y[size];
257  for (unsigned int i = 0; i < size; ++i) {
258  x[i] = profile[i].X()/(g/cm2);
259  y[i] = profile[i].Y();
260  }
261 
263 
264  TGraph* const graph = new TGraph(size, x, y);
265  graph->SetMarkerStyle(8);
266  graph->Draw("APL");
267  graph->SetTitle("Longitudinal Charge Profile");
268  //BRD 18/2/05
269  // graph->GetXaxis()->SetTitle("Vertical depth (g/cm²)");
270  graph->GetXaxis()->SetTitle("slant depth (g/cm²)");
271  graph->GetYaxis()->SetTitle("#Particles");
272 
273  TString s;
274  fOutputFile->cd();
275  s = "LongitudinalProfileC_";
276  s += *fEventId;
277  fLongitudinalProfileCanvas->SetName(s.Data());
279 }
280 
281 
283 void
285 {
286  if (!shower.HasdEdX())
287  return;
288  utl::TabulatedFunction edep = shower.GetdEdX();
289  unsigned int size = edep.GetNPoints();
290  double x[size];
291  double y[size];
292  //double delta = abs(edep[0].X() - edep[1].X());
293  for (unsigned int i = 0; i < size; ++i) {
294  x[i] = edep[i].X()/(g/(cm*cm));
295  //BRD 18/2/05
296  // y[i] = edep[i].Y()/(eV/(g/cm/cm))/(delta/(g/(cm*cm)));
297  y[i] = edep[i].Y()/(eV/(g/cm2));
298  }
299 
300  fEnergyDepositCanvas->cd();
301 
302  TGraph* const graph = new TGraph(size, x, y);
303  graph->SetMarkerStyle(8);
304  graph->Draw("APL");
305  graph->SetTitle("EnergyDeposit");
306  //BRD 18/2/05
307  // graph->GetXaxis()->SetTitle("Vertical depth (g/cm²)");
308  graph->GetXaxis()->SetTitle("slant depth (g/cm^{2})");
309  graph->GetYaxis()->SetTitle("dE/dX (eV/(g/cm^{2}))");
310 
311  TString s;
312  fOutputFile->cd();
313  s = "EnergyDepositC_";
314  s += *fEventId;
315  fEnergyDepositCanvas->SetName(s.Data());
316  fEnergyDepositCanvas->Write();
317 }
318 
319 
321 void
323 {
324  Detector& theDetector = Detector::GetInstance();
325 
326  const std::vector<double>& waves =
327  theDetector.GetAtmosphere().GetWavelengths();
328 
329  const unsigned int nWaves = waves.size();
331  unsigned int size = part1.GetNPoints();
332  double x[size];
333  double y[size];
334  for (unsigned int i = 0; i < size; ++i) {
335  x[i] = 0;
336  y[i] = 0;
337  }
338  for (unsigned int iwl = 0; iwl < nWaves; ++iwl) {
340  for (unsigned int i = 0; i < size; ++i) {
341  if (!iwl)
342  x[i] = part[i].X()/(g/cm2);
343  y[i] += part[i].Y();
344  }
345  }
346 
347  fFluorLightCanvas->cd();
348 
349  TGraph* const graph = new TGraph(size, x, y);
350  graph->SetMarkerStyle(8);
351  graph->Draw("APL");
352  graph->SetTitle("Fluorescence light");
353  //BRD 18/2/05
354  // graph->GetXaxis()->SetTitle("Vertical depth (g/cm²)");
355  graph->GetXaxis()->SetTitle("slant depth (g/cm^{2})");
356  graph->GetYaxis()->SetTitle("#Photons");
357 
358  TString s;
359  fOutputFile->cd();
360  s = "FluorLightC_";
361  s += *fEventId;
362  fFluorLightCanvas->SetName(s.Data());
363  fFluorLightCanvas->Write();
364 }
365 
366 
368 void
370 {
371  Detector& theDetector = Detector::GetInstance();
372 
373  const std::vector<double>& waves =
374  theDetector.GetAtmosphere().GetWavelengths();
375 
376  const unsigned int nWaves = waves.size();
377 
379  unsigned int size = ph.GetNPoints();
380  double x[size];
381  double y[size];
382  for (unsigned int i = 0; i < size; ++i) {
383  //x[i] = theDetector.GetAtmosphere().EvaluateHeight(ph[i].X());
384  x[i] = ph[i].X()/(g/cm2);
385  y[i] = 0;
386  }
387 
388  for (unsigned int iwl = 0; iwl < nWaves; ++iwl) {
389 
391 
392  for (unsigned int i = 0; i < size; ++i) {
393  y[i] += ph[i].Y();
394  }
395  }
396 
397  fCherBeamCanvas->cd();
398 
399  TGraph* const graph = new TGraph(size, x, y);
400  graph->SetMarkerStyle(8);
401  graph->Draw("APL");
402  graph->SetTitle("Cherenkov beam");
403  //BRD 18/2/05
404  // graph->GetXaxis()->SetTitle("Vertical depth (g/cm²)");
405  graph->GetXaxis()->SetTitle("slant depth (g/cm^{2})");
406  graph->GetYaxis()->SetTitle("#Photons");
407 
408  TString s;
409  fOutputFile->cd();
410  s = "CherenkovBeamC_";
411  s += *fEventId;
412  fCherBeamCanvas->SetName(s.Data());
413  fCherBeamCanvas->Write();
414 }
415 
416 
417 void
419 {
420  // Get the simulated longitudinal shower profile
421  if (fevent.HasEye(fEye))
422  if (fevent.GetEye(fEye).HasTelescope(fTelescope))
423  if (fevent.GetEye(fEye).GetTelescope(fTelescope).HasSimData()) {
424  const fevt::TelescopeSimData& sim =
426  PlotLightFlux(sim);
427  PlotFluorFlux(sim);
428  PlotCherMieFlux(sim);
429  PlotCherRaylFlux(sim);
430  PlotCherDirFlux(sim);
431  ClearAllPlots();
432  }
433 }
434 
435 
437 void
439 {
440  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
441  // them up taking into account the wavelength dependence of the overall
442  // telescope efficiency
443 
445  return;
446 
447  const utl::TraceD& fluorTrace = sim.GetPhotonTrace(fevt::FdConstants::eFluorDirect, iwl);
448  const utl::TraceD& cherDirTrace = sim.GetPhotonTrace(fevt::FdConstants::eCherDirect, iwl);
449  const utl::TraceD& cherRaylTrace =
451  const utl::TraceD& cherMieTrace =
453  double bin = fluorTrace.GetBinning();
454  const int size = int(bin*fluorTrace.GetSize()/100.0);
455  double x[size];
456  double yt[size];
457  double yf[size];
458  double ycd[size];
459  double ycr[size];
460  double ycm[size];
461 
462  for (int i = 0; i < size; ++i) {
463  x[i] = i;
464  yt[i] = 0;
465  yf[i] = 0;
466  ycd[i] = 0;
467  ycr[i] = 0;
468  ycm[i] = 0;
469  }
470 
471  int j = 0;
472  for (unsigned int i = fluorTrace.GetStart(); i < fluorTrace.GetStop(); ++i) {
473 
474  yf[j] += fluorTrace[i];
475  ycd[j] += cherDirTrace[i];
476  ycr[j] += cherRaylTrace[i];
477  ycm[j] += cherMieTrace[i];
478 
479  if (!(i % int(100/bin)))
480  ++j;
481 
482  if (j > size-1)
483  break;
484 
485  }
486 
487  // Total flux
488 
489  for (int i = 0; i < size; ++i) {
490  yt[i] = yf[i] + ycm[i] + ycr[i] + ycd[i];
491  }
492 
493  fLightFluxCanvas->cd();
494 
495  TGraph* const gt = new TGraph(size, x, yt);
496  gt->SetLineColor(1);
497  gt->Draw("AL");
498  gt->SetTitle("Light flux");
499  gt->GetXaxis()->SetTitle("bin [100 ns]");
500  gt->GetXaxis()->SetRange(0,size);
501  gt->GetYaxis()->SetTitle("#Photons");
502 
503  TGraph* const gf = new TGraph(size, x, yf);
504  gf->SetLineColor(3);
505  gf->Draw("L");
506 
507  TGraph* const gcm = new TGraph(size, x, ycm);
508  gcm->SetLineColor(6);
509  gcm->Draw("L");
510 
511  TGraph* const gcr = new TGraph(size, x, ycr);
512  gcr->SetLineColor(4);
513  gcr->Draw("L");
514 
515  TGraph* const gcd = new TGraph(size, x, ycd);
516  gcd->SetLineColor(2);
517  gcd->Draw("L");
518 
519  TString s;
520  fOutputFile->cd();
521  s = "LightFluxC_";
522  s += *fEventId;
523  fLightFluxCanvas->SetName(s.Data());
524  fLightFluxCanvas->Write();
525 }
526 
527 
529 void
531 {
532  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
533  // them up taking into account the wavelength dependence of the overall
534  // telescope efficiency
535 
537  return;
538 
539  const utl::TraceD& fluorTrace = sim.GetPhotonTrace(fevt::FdConstants::eFluorDirect, iwl);
540  const double bin = fluorTrace.GetBinning();
541  const int size = int(bin*fluorTrace.GetSize()/100.0);
542  double x[size];
543  double y[size];
544 
545  for (int i = 0; i < size; ++i) {
546  x[i] = i;
547  y[i] = 0;
548  }
549 
550  int j = 0;
551  for (unsigned int i = fluorTrace.GetStart(); i < fluorTrace.GetStop(); ++i) {
552 
553  y[j] += fluorTrace[i];
554  if (i%(int(100/bin)) == 0)
555  ++j;
556 
557  if (j > size-1)
558  break;
559  }
560 
561  fFluorFluxCanvas->cd();
562 
563  TGraph* const gt = new TGraph(size, x, y);
564  gt->SetLineColor(1);
565  gt->Draw("AL");
566  gt->SetTitle("Fluorescence light flux");
567  gt->GetXaxis()->SetTitle("bin [100 ns]");
568  gt->GetXaxis()->SetRange(0,size);
569  gt->GetYaxis()->SetTitle("#Photons");
570 
571  TString s;
572  fOutputFile->cd();
573  s = "FluorFluxC_";
574  s += *fEventId;
575  fFluorFluxCanvas->SetName(s.Data());
576  fFluorFluxCanvas->Write();
577 }
578 
579 
581 void
583 {
584  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
585  // them up taking into account the wavelength dependence of the overall
586  // telescope efficiency
587 
589  return;
590 
592  const double bin = trace.GetBinning();
593  const int size = int(bin*trace.GetSize()/100.0);
594  double x[size];
595  double y[size];
596 
597  for (int i = 0; i < size; ++i) {
598  x[i] = i;
599  y[i] = 0;
600  }
601 
602  int j = 0;
603  for (unsigned int i = trace.GetStart(); i < trace.GetStop(); ++i) {
604 
605  y[j] += trace[i];
606  if (i%(int(100/bin)) == 0)
607  ++j;
608 
609  if (j > size-1)
610  break;
611  }
612 
613  fCherMieFluxCanvas->cd();
614 
615  TGraph* const gt = new TGraph(size, x, y);
616  gt->SetLineColor(1);
617  gt->Draw("AL");
618  gt->SetTitle("Cherenkov Mie-scattered light flux");
619  gt->GetXaxis()->SetTitle("bin [100 ns]");
620  gt->GetXaxis()->SetRange(0,size);
621  gt->GetYaxis()->SetTitle("#Photons");
622 
623  TString s;
624  fOutputFile->cd();
625  s = "CherMieFluxC_";
626  s += *fEventId;
627  fCherMieFluxCanvas->SetName(s.Data());
628  fCherMieFluxCanvas->Write();
629 }
630 
631 
633 void
635 {
636  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
637  // them up taking into account the wavelength dependence of the overall
638  // telescope efficiency
639 
641  return;
642 
644  const double bin = trace.GetBinning();
645  const int size = int(bin*trace.GetSize()/100.0);
646  double x[size];
647  double y[size];
648 
649  for (int i = 0; i < size; ++i) {
650  x[i] = i;
651  y[i] = 0;
652  }
653 
654  int j = 0;
655  for (unsigned int i = trace.GetStart(); i < trace.GetStop(); ++i) {
656 
657  y[j] += trace[i];
658  if (i%(int(100/bin)) == 0)
659  ++j;
660 
661  if (j > size-1)
662  break;
663  }
664 
665  fCherRaylFluxCanvas->cd();
666 
667  TGraph* const gt = new TGraph(size, x, y);
668  gt->SetLineColor(1);
669  gt->Draw("AL");
670  gt->SetTitle("Cherenkov Rayleigh-scattered light flux");
671  gt->GetXaxis()->SetTitle("bin [100 ns]");
672  gt->GetXaxis()->SetRange(0,size);
673  gt->GetYaxis()->SetTitle("#Photons");
674 
675  TString s;
676  fOutputFile->cd();
677  s = "CherRayleighFluxC_";
678  s += *fEventId;
679  fCherRaylFluxCanvas->SetName(s.Data());
680  fCherRaylFluxCanvas->Write();
681 }
682 
683 
685 void
687 {
688  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
689  // them up taking into account the wavelength dependence of the overall
690  // telescope efficiency
691 
693  return;
694 
696  const double bin = trace.GetBinning();
697  const int size = int(bin*trace.GetSize()/100.0);
698  double x[size];
699  double y[size];
700  for (int i = 0; i < size; ++i) {
701  x[i] = i;
702  y[i] = 0;
703  }
704  int j = 0;
705  for (unsigned int i = trace.GetStart(); i < trace.GetStop(); ++i) {
706 
707  y[j] += trace[i];
708  if (i%(int(100/bin)) == 0)
709  ++j;
710 
711  if (j > size-1)
712  break;
713  }
714 
715  fCherDirFluxCanvas->cd();
716 
717  TGraph* const gt = new TGraph(size, x, y);
718  gt->SetLineColor(1);
719  gt->Draw("AL");
720  gt->SetTitle("Cherenkov direct light flux");
721  gt->GetXaxis()->SetTitle("bin [100 ns]");
722  gt->GetXaxis()->SetRange(0,size);
723  gt->GetYaxis()->SetTitle("#Photons");
724 
725  TString s;
726  fOutputFile->cd();
727  s = "CherDirectFluxC_";
728  s += *fEventId;
729  fCherDirFluxCanvas->SetName(s.Data());
730  fCherDirFluxCanvas->Write();
731 }
732 
733 
734 void
736 {
737  // Get the simulated longitudinal shower profile
738  if (fevent.HasEye(fEye))
739  if (fevent.GetEye(fEye).HasTelescope(fTelescope)) {
740  const fevt::Telescope& tel = fevent.GetEye(fEye).GetTelescope(fTelescope);
741  PlotLightOnCamera(tel);
742  PlotCamera(tel);
743  PlotPhotonTraces(tel);
744  PlotFADCTraces(tel);
745  //AnalyzeLightAtDiaphragm(fevent);
746  // PlotLightAtDia(tel);
747  ClearAllPlots();
748  }
749 }
750 
751 
753 void
755 {
756  const int iwl = 0; // for realistic answer you have to loop over all wavelength and sum
757  // them up taking into account the wavelength dependence of the overall
758  // telescope efficiency
759 
760  cout << " graph plot at dia 0 " << endl;
761  const fevt::TelescopeSimData& telSimData = tel.GetSimData();
762  cout << " graph plot at dia 1 " << endl;
763  if (!telSimData.HasPhotonTrace(fevt::FdConstants::eTotal, iwl))
764  cout << " problem!" << endl;
765  // telSimData.MakePhotonTrace(fevt::FdConstants::eTotal);
766  const TraceD& totalTrace = telSimData.GetPhotonTrace(fevt::FdConstants::eTotal, iwl);
767  cout << " graph plot at dia 2 " << endl;
768 
769  fLightAtDiaCanvas->cd();
770  cout << " graph plot at dia 3 " << endl;
771 
772  const int size2 = int(totalTrace.GetSize());
773 
774  double x[size2];
775  double y[size2];
776 
777  for (int i = 0; i < size2; ++i) {
778  x[i] = i;
779  y[i] = totalTrace[i];
780  }
781 
782  // unsigned int size = totalTrace.GetSize();
783  /* double tracebin = totalTrace.GetBinning();
784 
785  TraceD* auxTrace = new TraceD(2000,100);
786  for (unsigned int i=0; i<size2; i++) {
787  unsigned int bin = int(i*tracebin/100.0);
788  (*auxTrace)[bin] =
789  photonTrace[i];
790  }
791  for (int i=0; i<2000; ++i) {
792  x[i] = i;
793  y[i] = auxTrace[i];
794  }
795  */
796 
797  /*
798  int k=0;
799  int j=0;
800  while (j<1000) {
801  j = int(k*tracebin/100.0);
802  x[j] = j;
803  y[j] += totalTrace[k];
804  k++;
805  }
806  */
807  cout << " graph plot at dia 4 " << endl;
808 
809  //Detector& theDetector = Detector::GetInstance();
810  const double diaphragmArea =
811  Detector::GetInstance().GetFDetector().GetEye(tel.GetEyeId()).GetTelescope(tel.GetId()).GetDiaphragmArea();
812 
813  cout << " graph plot at dia 5 " << endl;
814  TGraph* const graph = new TGraph(size2, x, y);
815 
816  graph->SetMarkerStyle(8);
817  graph->Draw("APL");
818  TString s1;
819  s1 = "Light At Diaphragm - area";
820  s1 += diaphragmArea;
821  s1 += "Eye ";
822  s1 += tel.GetEyeId();
823  s1 += "Tel ";
824  s1 += tel.GetId();
825 
826  // graph->SetTitle("Light At Diaphragm");
827  graph->SetTitle(s1.Data());
828  //BRD 18/2/05
829  // graph->GetXaxis()->SetTitle("Vertical depth (g/cm²)");
830  graph->GetXaxis()->SetTitle("trace bin");
831  graph->GetYaxis()->SetTitle("photons/m2");
832 
833  TString s;
834  fOutputFile->cd();
835  s = "LightAtDia_";
836  s += *fEventId;
837  fLightAtDiaCanvas->SetName(s.Data());
838  fLightAtDiaCanvas->Write();
839 }
840 
841 
843 void
845 {
846  fLightOnCameraCanvas->cd();
847  const int size = 440;
848 
849  bool first = true;
850  TraceD trace;
851  for (int i = 0; i < size; ++i) {
852  if (tel.HasPixel(i+1)) {
853  const fevt::Pixel& pix = tel.GetPixel(i+1);
854  if (pix.HasSimData()) {
855  const fevt::PixelSimData& pxsimdata = pix.GetSimData();
857  if (first) {
858  trace = pxsimdata.GetPhotonTrace(fevt::FdConstants::eTotal);
859  first = false;
860  } else {
861  trace += pxsimdata.GetPhotonTrace(fevt::FdConstants::eTotal);
862  }
863  }
864 
865  }
866  }
867  }
868  const int size2 = int(trace.GetSize());
869  double x[size2];
870  double y[size2];
871  for (int i = 0; i < size2; ++i) {
872  x[i] = i;
873  y[i] = 0;
874  }
875 
876  for (unsigned int i = trace.GetStart(); i < trace.GetStop(); ++i) {
877  y[i] = trace[i];
878  }
879 
880  unsigned int j = 0;
881  for (unsigned int i = trace.GetStop()-1; i >= trace.GetStart(); i--) {
882  if (y[i]) {
883  j = i;
884  break;
885  }
886  }
887 
888  TGraph* const gt = new TGraph(j, x, y);
889  gt->SetLineColor(1);
890  gt->Draw("AL");
891  gt->SetTitle("Photons(370nm) on camera");
892  gt->GetXaxis()->SetTitle("bin [100 ns]");
893  gt->GetXaxis()->SetRange(0,j);
894  gt->GetYaxis()->SetTitle("#Photons");
895 
896  TString s;
897  fOutputFile->cd();
898  s = "LightOnCameraC_";
899  s += *fEventId;
900  s += "Eye ";
901  s += tel.GetEyeId();
902  s += "Tel ";
903  s += tel.GetId();
904  fLightOnCameraCanvas->SetName(s.Data());
905  fLightOnCameraCanvas->Write();
906 }
907 
908 
910 void
912 {
913  fCameraCanvas->cd();
914  const int size = 440;
915  double xs[size];
916  double ys[size];
917  // double xfluor[size];
918  // double yfluor[size];
919 
920  double integral[size];
921  bool signal[size];
922 
923  for (int i = 0; i < size; ++i){
924  integral[i] = 0;
925  signal[i] = false;
926  }
927 
928  double maxint = 0;
929  double minint = 0;
930  bool first = true;
931  //int sizeSignal = 0;
932  //int j = 0;
933 
934  for (int i=0; i<size; ++i) {
935 
936  if (tel.HasPixel(i+1)) {
937 
938  const fevt::Pixel& pix = tel.GetPixel(i+1);
939 
940  if (pix.HasSimData()) {
941  const fevt::PixelSimData& pxsimdata = pix.GetSimData();
942 
943 
944  bool firstTrace=true;
945  TraceD trace;
946 
947  if (pxsimdata.HasPhotonTrace(fevt::FdConstants::eTotal)) {
948  if (firstTrace) {
949  firstTrace=false;
950  trace = pxsimdata.GetPhotonTrace(fevt::FdConstants::eTotal);
951  }
952  signal[i] = true;
953 
954  } else {
955 
957  if (firstTrace) {
958  firstTrace=false;
960  }
961  signal[i] = true;
962  }
963 
965  if (firstTrace) {
966  firstTrace=false;
968  } else
970  signal[i] = true;
971  }
972 
974  if (firstTrace) {
975  firstTrace=false;
977  } else
979  signal[i] = true;
980  }
981 
983  if (firstTrace) {
984  firstTrace=false;
986  } else
988  signal[i] = true;
989  }
990  }
991 
992  /*
993  if (pxsimdata.HasPhotonTrace(fevt::FdConstants::eBackground)) {
994  if (firstTrace) {
995  firstTrace=false;
996  trace = pxsimdata.GetPhotonTrace(fevt::FdConstants::eBackground);
997  } else
998  trace += pxsimdata.GetPhotonTrace(fevt::FdConstants::eBackground);
999  }
1000  */
1001 
1002  if (!firstTrace) {
1003 
1004  const TraceD::SizeType size = trace.GetSize();
1005  integral[i] = TraceAlgorithm::Sum(trace, 0, size-1);
1006 
1007  if (first){
1008  minint = integral[i];
1009  first = false;
1010  }
1011  //cout << i << "->" << integral[i] << endl;
1012  if (integral[i] > maxint)
1013  maxint = integral[i];
1014 
1015  if (integral[i] < minint)
1016  minint = integral[i];
1017  }
1018 
1019  //cout << "pixel with signal: " << i << endl;
1020  int nx = int(i/22.0);
1021  int ny = i%22;
1022 
1023  if (ny%2)
1024  xs[i] = nx;
1025  else
1026  xs[i] = nx + 0.5;
1027 
1028  ys[i] = 22 - ny;
1029  }
1030  }
1031  }
1032 
1033  double deltacolor = (maxint - minint)/50;
1034  double x[size];
1035  double y[size];
1036 
1037  for (int i = 0; i < size; ++i) {
1038 
1039  int nx = int(i/22.0);
1040  int ny = i%22;
1041 
1042  if(ny%2)
1043  x[i] = 1 + nx;
1044  else
1045  x[i] = 1 + nx + 0.5;
1046 
1047  y[i] = 1 + 22 - ny;
1048 
1049  }
1050 
1051  TGraph* const graph = new TGraph(size, x, y);
1052  graph->SetMarkerStyle(4);
1053  graph->Draw("AP");
1054  graph->SetTitle("Pixels with photons");
1055  graph->GetXaxis()->SetNdivisions(0);
1056  graph->GetYaxis()->SetNdivisions(0);
1057  //double x2[1];
1058  //double y2[1];
1059  //x2[0] = x[0];
1060  //y2[0] = y[0];
1061 
1062  //Rainbow colors
1063  gStyle->SetPalette(1);
1064  // Create the hexagon points
1065  float yy[] = { 0.5, 0.25, -0.25 , -0.5, -0.25, 0.25, 0.5 };
1066  float xx[] = { 0, 0.433, 0.433, 0, -0.433, -0.433, 0 };
1067 
1068  for (int i = 0; i < size; ++i) {
1069  float yyaux[7];
1070  float xxaux[7];
1071  for (int l = 0; l < 7; ++l) {
1072  yyaux[l] = 1 + yy[l] + ys[i];
1073  xxaux[l] = 1 + xx[l] + xs[i];
1074  }
1075 
1076  TPolyLine* const pline = new TPolyLine(7, xxaux, yyaux);
1077  int cl = 51 + int(ceil((integral[i]-minint)/deltacolor));
1078  if (cl > 100)
1079  cl = 100;
1080  pline->SetFillColor(cl);
1081  pline->SetLineColor(1);
1082  pline->SetLineWidth(1);
1083  if (signal[i]){
1084  pline->SetLineColor(2);
1085  pline->SetLineWidth(2);
1086  }
1087  pline->Draw("f");
1088  pline->Draw();
1089  }
1090 
1091  TString s;
1092  fOutputFile->cd();
1093  s = "CameraC_";
1094  s += *fEventId;
1095  fCameraCanvas->SetName(s.Data());
1096  fCameraCanvas->Write();
1097 }
1098 
1099 
1101 void
1103 {
1104  for (fevt::Telescope::ConstPixelIterator pixiter = tel.PixelsBegin(ComponentSelector::eHasData);
1105  pixiter!= tel.PixelsEnd(ComponentSelector::eHasData); ++pixiter) {
1106 
1107  const fevt::Pixel& pixel = *pixiter;
1108  if (pixel.HasSimData()) {
1109  const fevt::PixelSimData& pixelsimdata = pixel.GetSimData();
1110  if (pixelsimdata.HasPhotonTrace(fevt::FdConstants::eTotal)) {
1111  const TraceD& trace = pixelsimdata.GetPhotonTrace(fevt::FdConstants::eTotal);
1112 
1113  // Copy the trace
1114  const int size = trace.GetSize();
1115  double x[size];
1116  for (int i = 0; i < size; ++i)
1117  x[i] = i;
1118  double y[size];
1119 
1120  std::copy(trace.Begin(), trace.End(),y);
1121 
1122  // Graph for the photon trace
1123  TGraph* const graph = new TGraph(500,x,y);
1124  ostringstream title;
1125  title << "Tel " << pixel.GetTelescopeId()
1126  << " Pix "<< pixel.GetId();
1127 
1128  graph->SetName(title.str().c_str());
1129  graph->SetTitle(title.str().c_str());
1130 
1131  fPhotonGraphs->Add(graph);
1132  }
1133  }
1134  }
1135 
1136  fOutputFile->cd();
1137 
1138  TFolder folder;
1139 
1140  string s = "Pixels_";
1141  s += *fEventId;
1142  folder.SetName(s.c_str());
1143  folder.Add(fPhotonGraphs);
1144  folder.AddFolder("Total","Total",fPhotonGraphs);
1145 
1146  folder.Write();
1147 }
1148 
1149 
1151 void
1153 {
1154  /*double x[3000];
1155  for (int i=0; i<3000; ++i)
1156  x[i]=i;*/
1157 
1159  chiter != tel.ChannelsEnd(); ++chiter){
1160 
1161  const fevt::Channel& channel = *chiter;
1162  if (channel.HasSimData()) {
1163  //cout << "Channel " << channel.GetId() << " has sim data" << endl;
1164  const fevt::ChannelSimData& channelsimdata = channel.GetSimData();
1165  if (channelsimdata.HasFADCTrace(fevt::FdConstants::eTotal)) {
1166  //cout << "Channel " << channel.GetId() << " has FADC trace" << endl;
1167  const TraceI& trace = channelsimdata.GetFADCTrace(fevt::FdConstants::eTotal);
1168  //cout << "Channel " << channel.GetId() << " has data" << endl;
1169  // Copy the trace
1170  const int size = trace.GetSize();
1171  double x[size];
1172  for (int i=0; i<size; ++i)
1173  x[i]=i;
1174  double y[size];
1175 
1176  std::copy(trace.Begin(), trace.End(),y);
1177 
1178  // Graph for the photon trace
1179  TGraph* graph = new TGraph(500,x,y);
1180  ostringstream title;
1181  title << "Tel "<< channel.GetTelescopeId()
1182  << " Channel "<< channel.GetId();
1183 
1184  graph->SetName(title.str().c_str());
1185  graph->SetTitle(title.str().c_str());
1186 
1187  fFADCGraphs->Add(graph);
1188  }
1189  }
1190  }
1191 
1192  fOutputFile->cd();
1193 
1194  TFolder folder;
1195 
1196  string s = "Channels_";
1197  s += *fEventId;
1198  folder.SetName(s.c_str());
1199  folder.Add(fFADCGraphs);
1200  folder.AddFolder("FADC", "FADC", fFADCGraphs);
1201  folder.Write();
1202 }
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
Definition: FEvent/Eye.cc:57
TString * fEventId
Definition: UserModule.h:73
ChannelIterator ChannelsBegin()
void PlotEnergyDeposit(const evt::ShowerSimData &shower)
Plot the shower energy deposit.
Definition: UserModule.cc:284
const double eV
Definition: GalacticUnits.h:35
unsigned int GetNPoints() const
const utl::TabulatedFunction & GetdEdX() const
Get the energy deposit of the shower.
TCanvas * fCherRaylFluxCanvas
Definition: UserModule.h:66
void PlotLightOnCamera(const fevt::Telescope &tel)
Plot light on the camera.
Definition: UserModule.cc:844
TFile * fOutputFile
Definition: UserModule.h:57
unsigned int fTelescope
Definition: UserModule.h:75
bool HasPhotonTrace(const fevt::FdConstants::LightSource source, const int wl) const
Check that light trace for source /par source is present for the given wavelength bin...
const std::vector< double > & GetWavelengths(const EmissionMode mode=eFluorescence) const
void PlotCamera(const fevt::Telescope &tel)
Plot the camera.
Definition: UserModule.cc:911
SizeType GetStop() const
Get valid data stop bin.
Definition: Trace.h:148
void PlotLightAtDia(const fevt::Telescope &tel)
Plot light at diaphragm.
Definition: UserModule.cc:754
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
Class to hold collection (x,y) points and provide interpolation between them.
TObjArray * fPhotonGraphs
Definition: UserModule.h:71
unsigned int GetId() const
bool HasSimShower() const
const utl::TabulatedFunction & GetFluorescencePhotons(const int wavelength) const
Get the fluorescence photons generated along the shower axis.
double GetBinning() const
size of one slot
Definition: Trace.h:138
unsigned int GetEyeId() const
ChannelIterator ChannelsEnd()
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
PixelSimData & GetSimData()
Definition: FEvent/Pixel.h:35
bool HasFADCTrace(const FdConstants::LightSource source) const
Check that source /par source is present.
void PlotTotalCherBeam(const evt::ShowerSimData &shower)
Plot total Cerenkov light generated along the shower axis.
Definition: UserModule.cc:369
void PlotLightFlux(const fevt::TelescopeSimData &sim)
Plot the light flux at the diaphragm.
Definition: UserModule.cc:438
void Init()
Initialise the registry.
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
bool HasPhotonTrace(const FdConstants::LightSource source) const
Check that trace for source /par source is present.
Definition: PixelSimData.h:51
Fluorescence Detector Channel Simulated Data Event.
void AnalyzeCamera(const fevt::FEvent &fevent)
Definition: UserModule.cc:735
ChannelSimData & GetSimData()
PixelIterator PixelsEnd()
iterator pointing to end of available pixels of status eHasData (DEPRECATED)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Definition: UserModule.cc:175
bool HasSimData() const
Iterator Begin()
Definition: Trace.h:75
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
const atm::Atmosphere & GetAtmosphere() const
Definition: Detector.h:113
const utl::TabulatedFunction & GetCherenkovPhotons(const int wavelength) const
Get the Cherenkov photon production along the shower axis.
unsigned int GetId() const
Definition: FEvent/Pixel.h:31
bool HasPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the pixel is in the event.
fevt::TelescopeSimData & GetSimData()
Description of simulated data for one Telescope.
Class representing a document branch.
Definition: Branch.h:107
TCanvas * fLightFluxCanvas
Definition: UserModule.h:63
constexpr double s
Definition: AugerUnits.h:163
virtual ~UserModule()
Definition: UserModule.cc:89
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
void PlotFADCTraces(const fevt::Telescope &tel)
create graphs with the traces
Definition: UserModule.cc:1152
std::vector< double >::size_type SizeType
Definition: Trace.h:58
TCanvas * fCherDirFluxCanvas
Definition: UserModule.h:67
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
void PlotTotalFluorLight(const evt::ShowerSimData &shower)
Plot the total fluorecence light generated along the shower axis.
Definition: UserModule.cc:322
utl::TraceD & GetPhotonTrace(const fevt::FdConstants::LightSource source, const int wl)
Photon trace at diaphragm.
unsigned int GetTelescopeId() const
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
void PlotCherRaylFlux(const fevt::TelescopeSimData &sim)
Plot the Rayleigh-scattered Cherenkov light flux at the diaphragm.
Definition: UserModule.cc:634
constexpr double g
Definition: AugerUnits.h:200
utl::TraceI & GetFADCTrace(const FdConstants::LightSource source=FdConstants::eTotal)
bool HasSimData() const
Definition: FEvent/Pixel.h:38
SizeType GetSize() const
Definition: Trace.h:156
void ClearAllPlots()
Definition: UserModule.cc:206
Fluorescence Detector Channel Event.
void PlotCherMieFlux(const fevt::TelescopeSimData &sim)
Plot the Mie-scattered Cherenkov light flux at the diaphragm.
Definition: UserModule.cc:582
TCanvas * fCameraCanvas
Definition: UserModule.h:70
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
unsigned int fEye
Definition: UserModule.h:74
void AnalyzeShower(const evt::ShowerSimData &shower)
Definition: UserModule.cc:224
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
TObjArray * fFADCGraphs
Definition: UserModule.h:72
Eye & GetEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
return Eye by id
Definition: FEvent.cc:70
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Definition: UserModule.cc:193
bool HasdEdX() const
Check initialization of the energy deposit.
unsigned int GetTelescopeId() const
Definition: FEvent/Pixel.h:32
fevt::FEvent & GetFEvent()
Pixel & GetPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Pixel by Id, throw exception if not existent.
void PlotLongitudinalProfile(const evt::ShowerSimData &shower)
Plot the shower longitudinal charge profile.
Definition: UserModule.cc:251
bool HasEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Definition: FEvent.cc:57
TCanvas * fLightAtDiaCanvas
Definition: UserModule.h:69
TCanvas * fEnergyDepositCanvas
Definition: UserModule.h:60
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
TCanvas * fCherMieFluxCanvas
Definition: UserModule.h:65
unsigned int GetId() const
void PlotPhotonTraces(const fevt::Telescope &tel)
create graphs with the traces
Definition: UserModule.cc:1102
SizeType GetStart() const
Get valid data start bin.
Definition: Trace.h:142
bool HasTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the telescope is in the event.
Definition: FEvent/Eye.cc:117
boost::indirect_iterator< InternalConstChannelIterator, const Channel & > ConstChannelIterator
An iterator over available channles for read.
utl::TraceD & GetPhotonTrace(const FdConstants::LightSource source=FdConstants::eTotal)
Simulated Photon Trace.
Definition: PixelSimData.h:37
constexpr double cm
Definition: AugerUnits.h:117
TCanvas * fFluorLightCanvas
Definition: UserModule.h:61
Main configuration utility.
Definition: CentralConfig.h:51
void AnalyzeLightAtDiaphragm(const fevt::FEvent &fevent)
Definition: UserModule.cc:418
Fluorescence Detector Telescope Event.
TCanvas * fLongitudinalProfileCanvas
Definition: UserModule.h:59
PixelIterator PixelsBegin()
iterator pointing to first available pixel of status eHasData (DEPRECATED)
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
void PlotCherDirFlux(const fevt::TelescopeSimData &sim)
Plot the Direct Cherenkov light flux at the diaphragm.
Definition: UserModule.cc:686
Iterator End()
Definition: Trace.h:76
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSimData() const
TCanvas * fCherBeamCanvas
Definition: UserModule.h:62
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Fluorescence Detector Pixel Simulated Data.
Definition: PixelSimData.h:28
const utl::TabulatedFunction & GetLongitudinalProfile(const ProfileType type=eCharged) const
Get the longitudinal charge profile of the shower.
TCanvas * fFluorFluxCanvas
Definition: UserModule.h:64
constexpr double cm2
Definition: AugerUnits.h:118
void PlotFluorFlux(const fevt::TelescopeSimData &sim)
Plot the fluorescence light flux at the diaphragm.
Definition: UserModule.cc:530
TCanvas * fLightOnCameraCanvas
Definition: UserModule.h:68

, generated on Tue Sep 26 2023.