19 #define PI 3.141592654 32 void format_histogram(TH1D* h, std::string title ,std::string xtitle, std::string ytitle){
33 h->SetTitle( title.c_str() );
34 h->GetXaxis()->SetTitle( xtitle.c_str() );
35 h->GetYaxis()->SetTitle( ytitle.c_str() );
36 h->SetLineColor(kRed);
40 void format_histogram(TH2D* h, std::string title ,std::string xtitle, std::string ytitle){
41 h->SetTitle( title.c_str() );
42 h->GetXaxis()->SetTitle( xtitle.c_str() );
43 h->GetYaxis()->SetTitle( ytitle.c_str() );
50 std::cout << std::scientific;
51 std::cout << std::setprecision(2);
52 std::cout << std::left;
58 TFile *inFile =
new TFile(inFileName.c_str(),
"READ");
59 if ( !inFile->IsOpen() ){
60 std::cout <<
"Error: could not open input file \"" << inFileName <<
"\"." <<std::endl;
62 }
else if (verbosity) {
63 std::cout <<
"Input file: " << inFileName << std::endl;
69 TTree *wcsimTree = (TTree*) inFile->Get(
"wcsimT");
72 long int nEvent = wcsimTree->GetEntries();
73 if (verbosity) { std::cout <<
"Number of events: "<< nEvent << std::endl;}
81 TBranch *branch = wcsimTree->GetBranch(
"wcsimrootevent");
82 TBranch *branchOD = wcsimTree->GetBranch(
"wcsimrootevent_OD");
83 TBranch *branchMPMT = wcsimTree->GetBranch(
"wcsimrootevent2");
84 branch->SetAddress(&wcsimRootID);
85 branchOD->SetAddress(&wcsimRootOD);
86 branchMPMT->SetAddress(&wcsimRootMPMT);
89 wcsimTree->GetBranch(
"wcsimrootevent")->SetAutoDelete(kTRUE);
90 wcsimTree->GetBranch(
"wcsimrootevent_OD")->SetAutoDelete(kTRUE);
91 wcsimTree->GetBranch(
"wcsimrootevent2")->SetAutoDelete(kTRUE);
94 TTree *geoTree = (TTree*) inFile->Get(
"wcsimGeoT");
96 geoTree->SetBranchAddress(
"wcsimrootgeom",&
geo);
97 if (verbosity) {std::cout <<
"Geotree has " << geoTree->GetEntries() <<
" entries." << std::endl;}
106 TFile *outFile =
new TFile(outFileName.c_str(),
"RECREATE");
107 TTree *outBranch =
new TTree(
"simulation",
"simulation");
114 float injectorVtxX, injectorVtxY, injectorVtxZ;
115 float injectorDirX, injectorDirY, injectorDirZ;
119 int numPMTsDigiHitID;
123 int numPMTsDigiHitOD;
127 int numPMTsDigiHitMPMT;
142 outBranch->Branch(
"event", &event,
"event/I");
143 outBranch->Branch(
"trigger", &trigger,
"trigger/I");
144 outBranch->Branch(
"injectorVtxX", &injectorVtxX,
"injectorVtxX/F");
145 outBranch->Branch(
"injectorVtxY", &injectorVtxY,
"injectorVtxY/F");
146 outBranch->Branch(
"injectorVtxZ", &injectorVtxZ,
"injectorVtxZ/F");
147 outBranch->Branch(
"injectorDirX", &injectorDirX,
"injectorDirX/F");
148 outBranch->Branch(
"injectorDirY", &injectorDirY,
"injectorDirY/F");
149 outBranch->Branch(
"injectorDirZ", &injectorDirZ,
"injectorDirZ/F");
150 outBranch->Branch(
"rawHitsID", &rawHitsID,
"rawHitsID/F");
151 outBranch->Branch(
"digiHitsID", &digiHitsID,
"digiHitsID/F");
152 outBranch->Branch(
"numPMTsHitID", &numPMTsHitID,
"numPMTsHitID/I");
153 outBranch->Branch(
"numPMTsDigiHitID", &numPMTsDigiHitID,
"numPMTsDigiHitID/I");
154 outBranch->Branch(
"rawHitsMPMT", &rawHitsMPMT,
"rawHitsMPMT/F");
155 outBranch->Branch(
"digiHitsMPMT", &digiHitsMPMT,
"digiHitsMPMT/F");
156 outBranch->Branch(
"numPMTsHitMPMT", &numPMTsHitMPMT,
"numPMTsHitMPMT/I");
157 outBranch->Branch(
"numPMTsDigiHitMPMT", &numPMTsDigiHitMPMT,
"numPMTsDigiHitMPMT/I");
158 outBranch->Branch(
"rawHitsOD", &rawHitsOD,
"rawHitsOD/F");
159 outBranch->Branch(
"digiHitsOD", &digiHitsOD,
"digiHitsOD/F");
160 outBranch->Branch(
"numPMTsHitOD", &numPMTsHitOD,
"numPMTsHitOD/I");
161 outBranch->Branch(
"numPMTsDigiHitOD", &numPMTsDigiHitOD,
"numPMTsDigiHitOD/I");
162 outBranch->Branch(
"cylLoc",&cylLoc,
"cylLoc/I");
163 outBranch->Branch(
"tubeNumber",&tubeNumber,
"tubeNumber/I");
164 outBranch->Branch(
"pmtX",&pmtX,
"pmtX/F");
165 outBranch->Branch(
"pmtY",&pmtY,
"pmtY/F");
166 outBranch->Branch(
"pmtZ",&pmtZ,
"pmtZ/F");
167 outBranch->Branch(
"digiTime",&digiTime,
"digiTime/F");
168 outBranch->Branch(
"digiCharge",&digiCharge,
"digiCharge/F");
172 TH1D *numRawHitPMTsIDHist =
new TH1D(
"numRawHitPMTsIDHist",
"numRawHitPMTsIDHist",200, 0, 1000);
173 TH1D *numDigiHitPMTsIDHist =
new TH1D(
"numDigiHitPMTsIDHist",
"numDigiHitPMTsIDHist",200, 0, 1000);
174 TH1D *numRawHitPMTsMPMTHist =
new TH1D(
"numRawHitPMTsMPMTHist",
"numRawHitPMTsMPMTHist",200, 0, 1000);
175 TH1D *numDigiHitPMTsMPMTHist =
new TH1D(
"numDigiHitPMTsMPMTHist",
"numDigiHitPMTsMPMTHist",200, 0, 1000);
176 TH1D *numRawHitPMTsODHist =
new TH1D(
"numRawHitPMTsODHist",
"numRawHitPMTsODHist",200, 0, 1000);
177 TH1D *numDigiHitPMTsODHist =
new TH1D(
"numDigiHitPMTsODHist",
"numDigiHitPMTsODHist",200, 0, 1000);
179 TH1D *numRawHitsIDHist =
new TH1D(
"numRawHitsIDHist",
"numRawHitsIDHist",200, 0, 1000);
180 TH1D *numDigiHitsIDHist =
new TH1D(
"numDigiHitsIDHist",
"numDigiHitsIDHist",200, 0, 1000);
181 TH1D *numRawHitsMPMTHist =
new TH1D(
"numRawHitsMPMTHist",
"numRawHitsMPMTHist",200, 0, 1000);
182 TH1D *numDigiHitsMPMTHist =
new TH1D(
"numDigiHitsMPMTHist",
"numDigiHitsMPMTHist",200, 0, 1000);
183 TH1D *numRawHitsODHist =
new TH1D(
"numRawHitsODHist",
"numRawHitsODHist",200, 0, 1000);
184 TH1D *numDigiHitsODHist =
new TH1D(
"numDigiHitsODHist",
"numDigiHitsODHist",200, 0, 1000);
187 format_histogram(numRawHitPMTsIDHist,
"" ,
"Number of hit ID PMTs [raw]",
"");
188 format_histogram(numDigiHitPMTsIDHist,
"" ,
"Number of hit ID PMTs [digi]",
"");
189 format_histogram(numRawHitPMTsMPMTHist,
"" ,
"Number of hit MPMT PMTs [raw]",
"");
190 format_histogram(numDigiHitPMTsMPMTHist,
"" ,
"Number of hit MPMT PMTs [digi]",
"");
191 format_histogram(numRawHitPMTsODHist,
"" ,
"Number of hit OD PMTs [raw]",
"");
192 format_histogram(numDigiHitPMTsODHist,
"" ,
"Number of hit OD PMTs [digi]",
"");
202 for (
int ev = 0; ev < nEvent; ev++){
205 wcsimTree->GetEntry(ev);
214 wcsimTriggerMPMT = wcsimRootMPMT->
GetTrigger(0);
219 for (
int nTrig = 0; nTrig < numTriggersID; nTrig++){
224 wcsimTriggerID = wcsimRootID->
GetTrigger(nTrig);
225 int numTracksID = wcsimTriggerID->
GetNtrack();
230 injectorVtxX = wcsimTriggerID->
GetVtx(0);
231 injectorVtxY = wcsimTriggerID->
GetVtx(1);
232 injectorVtxZ = wcsimTriggerID->
GetVtx(2);
233 injectorDirX = trackID->
GetDir(0);
234 injectorDirY = trackID->
GetDir(1);
235 injectorDirZ = trackID->
GetDir(2);
244 for (
int i = 0;
i < numPMTsHitID;
i++){
246 float tmpRawHitsID = cherenkovHitID->
GetTotalPe(1);
247 rawHitsID += tmpRawHitsID;
251 for (
int i = 0;
i < numPMTsDigiHitID;
i++){
253 float tmpDigiHitsID = cherenkovDigiHitID->
GetQ();
255 digiHitsID += tmpDigiHitsID;
259 for (
int nTrig = 0; nTrig < numTriggersMPMT; nTrig++){
263 wcsimTriggerMPMT = wcsimRootMPMT->
GetTrigger(nTrig);
264 int numTracksMPMT = wcsimTriggerMPMT->
GetNtrack();
274 for (
int i = 0;
i < numPMTsHitMPMT;
i++){
276 float tmpRawHitsMPMT = cherenkovHitMPMT->
GetTotalPe(1);
277 rawHitsMPMT += tmpRawHitsMPMT;
281 for (
int i = 0;
i < numPMTsDigiHitMPMT;
i++){
283 float tmpDigiHitsMPMT = cherenkovDigiHitMPMT->
GetQ();
285 digiHitsMPMT += tmpDigiHitsMPMT;
290 for (
int nTrigOD = 0; nTrigOD < numTriggersOD; nTrigOD++){
292 wcsimTriggerOD = wcsimRootOD->
GetTrigger(nTrigOD);
293 int numTracksOD = wcsimTriggerOD->
GetNtrack();
304 for (
int i = 0;
i < numPMTsHitOD;
i++){
306 float tmpRawHitsOD = cherenkovHitOD->
GetTotalPe(1);
307 rawHitsOD += tmpRawHitsOD;
311 for (
int i = 0;
i < numPMTsDigiHitOD;
i++){
313 float tmpDigiHitsOD = cherenkovDigiHitOD->
GetQ();
315 digiHitsOD += tmpDigiHitsOD;
321 for (
int i=0;
i< ncherenkovdigihits_slots;
i++){
327 tubeNumber = wcsimrootcherenkovdigihit->
GetTubeId();
328 digiCharge = wcsimrootcherenkovdigihit->
GetQ();
329 digiTime = wcsimrootcherenkovdigihit->
GetT();
341 std::cout <<
"====================================================" << std::endl;
342 std::cout <<
"Event\t" << ev << std::endl;
343 std::cout <<
"Trigger\t" << nTrigOD << std::endl;
344 std::cout <<
"injectorVtx\t" << injectorVtxX <<
" " << injectorVtxY <<
" " << injectorVtxZ << std::endl;
345 std::cout <<
"injectorDir\t" << injectorDirX <<
" " << injectorDirY <<
" " << injectorDirZ << std::endl;
346 std::cout <<
"rawhitsOD\t" << rawHitsOD << std::endl;
347 std::cout <<
"digihitsOD\t" << digiHitsOD << std::endl;
348 std::cout <<
"rawhitsID\t" << rawHitsID << std::endl;
349 std::cout <<
"digihitsID\t" << digiHitsID << std::endl;
350 std::cout <<
"numPMTsHitOD\t" << numPMTsHitOD << std::endl;
351 std::cout <<
"numPMTsDigiHitOD\t" << numPMTsDigiHitOD << std::endl;
352 std::cout <<
"numPMTsHitID\t" << numPMTsHitID << std::endl;
353 std::cout <<
"numPMTsDigiHitID\t" << numPMTsDigiHitID << std::endl;
356 numRawHitsIDHist->Fill(rawHitsID);
357 numDigiHitsIDHist->Fill(digiHitsID);
358 numRawHitsMPMTHist->Fill(rawHitsMPMT);
359 numDigiHitsMPMTHist->Fill(digiHitsMPMT);
360 numRawHitsODHist->Fill(rawHitsOD);
361 numDigiHitsODHist->Fill(digiHitsOD);
363 numRawHitPMTsIDHist->Fill(numPMTsHitID);
364 numDigiHitPMTsIDHist->Fill(numPMTsDigiHitID);
365 numRawHitPMTsMPMTHist->Fill(numPMTsHitMPMT);
366 numDigiHitPMTsMPMTHist->Fill(numPMTsDigiHitMPMT);
367 numRawHitPMTsODHist->Fill(numPMTsHitOD);
368 numDigiHitPMTsODHist->Fill(numPMTsDigiHitOD);
Int_t GetODWCNumPMT() const
Detector geometry information (also containing PMT information arrays)
Int_t GetNumberOfSubEvents() const
Class holding digitised hit (aka digit or digi) information (after PMT & electronics simulation + tri...
TClonesArray * GetTracks() const
Int_t GetNcherenkovhits() const
Float_t GetDir(Int_t i=0) const
Float_t GetVtx(Int_t i=0)
PMT geometry information.
Int_t GetWCNumPMT(bool hybridsecondtype=false) const
TClonesArray * GetCherenkovHits() const
Int_t GetNcherenkovdigihits() const
Class storing trigger information.
Int_t GetTotalPe(int i) const
WCSimRootTrigger * GetTrigger(int number)
void format_histogram(TH1D *h, std::string title, std::string xtitle, std::string ytitle)
WCSimRootPMT GetODPMT(Int_t i)
Int_t GetNumberOfEvents() const
void read_LIGen_OD_output(std::string inFileName, std::string outFileName, bool verbosity=0)
Class containing event information.
Int_t GetNcherenkovdigihits_slots() const
Class holding true (Cherenkov photon + dark noise) hit information.
TClonesArray * GetCherenkovDigiHits() const
Class holding true track information.
Float_t GetPosition(Int_t i=0) const