19 #define PI 3.141592654 29 void format_histogram(TH1D* h, std::string title ,std::string xtitle, std::string ytitle){
30 h->SetTitle( title.c_str() );
31 h->GetXaxis()->SetTitle( xtitle.c_str() );
32 h->GetYaxis()->SetTitle( ytitle.c_str() );
33 h->SetLineColor(kRed);
37 void format_histogram(TH2D* h, std::string title ,std::string xtitle, std::string ytitle){
38 h->SetTitle( title.c_str() );
39 h->GetXaxis()->SetTitle( xtitle.c_str() );
40 h->GetYaxis()->SetTitle( ytitle.c_str() );
43 void read_OD(std::string inFileName, std::string outFileName,
bool verbosity){
47 std::cout << std::scientific;
48 std::cout << std::setprecision(2);
49 std::cout << std::left;
55 TFile *inFile =
new TFile(inFileName.c_str(),
"READ");
56 if ( !inFile->IsOpen() ){
57 std::cout <<
"Error: could not open input file \"" << inFileName <<
"\"." <<std::endl;
59 }
else if (verbosity) {
60 std::cout <<
"Input file: " << inFileName << std::endl;
66 TTree *wcsimTree = (TTree*) inFile->Get(
"wcsimT");
69 long int nEvent = wcsimTree->GetEntries();
70 if (verbosity) { std::cout <<
"Number of events: "<< nEvent << std::endl;}
77 TBranch *branch = wcsimTree->GetBranch(
"wcsimrootevent");
78 TBranch *branchOD = wcsimTree->GetBranch(
"wcsimrootevent_OD");
79 branch->SetAddress(&wcsimRootID);
80 branchOD->SetAddress(&wcsimRootOD);
83 wcsimTree->GetBranch(
"wcsimrootevent")->SetAutoDelete(kTRUE);
84 wcsimTree->GetBranch(
"wcsimrootevent_OD")->SetAutoDelete(kTRUE);
87 TTree *geoTree = (TTree*) inFile->Get(
"wcsimGeoT");
89 TBranch *branchG = geoTree->GetBranch(
"wcsimrootgeom");
90 branchG->SetAddress(&
geo);
92 if (verbosity) {std::cout <<
"Geotree has " << geoTree->GetEntries() <<
" entries." << std::endl;}
100 TFile *outFile =
new TFile(outFileName.c_str(),
"RECREATE");
101 TTree *outBranch =
new TTree(
"simulation",
"simulation");
109 float vtxX, vtxY, vtxZ;
110 float dirX, dirY, dirZ;
115 int numPMTsDigiHitID;
117 float vtxXOD, vtxYOD, vtxZOD;
118 float dirXOD, dirYOD, dirZOD;
123 int numPMTsDigiHitOD;
130 outBranch->Branch(
"event", &event,
"event/I");
131 outBranch->Branch(
"trigger", &trigger,
"trigger/I");
132 outBranch->Branch(
"vtxX", &vtxX,
"vtxX/F");
133 outBranch->Branch(
"vtxY", &vtxY,
"vtxY/F");
134 outBranch->Branch(
"vtxZ", &vtxZ,
"vtxZ/F");
135 outBranch->Branch(
"dirX", &dirX,
"dirX/F");
136 outBranch->Branch(
"dirY", &dirY,
"dirY/F");
137 outBranch->Branch(
"dirZ", &dirZ,
"dirZ/F");
138 outBranch->Branch(
"phi", &phi,
"phi/F");
139 outBranch->Branch(
"theta", &theta,
"theta/F");
140 outBranch->Branch(
"energy", &
energy,
"energy/F");
141 outBranch->Branch(
"rawHitsID", &rawHitsID,
"rawHitsID/F");
142 outBranch->Branch(
"digiHitsID", &digiHitsID,
"digiHitsID/F");
143 outBranch->Branch(
"rawHitsOD", &rawHitsOD,
"rawHitsOD/F");
144 outBranch->Branch(
"digiHitsOD", &digiHitsOD,
"digiHitsOD/F");
145 outBranch->Branch(
"numPMTsHitID", &numPMTsHitID,
"numPMTsHitID/I");
146 outBranch->Branch(
"numPMTsDigiHitID", &numPMTsDigiHitID,
"numPMTsDigiHitID/I");
147 outBranch->Branch(
"numPMTsHitOD", &numPMTsHitOD,
"numPMTsHitOD/I");
148 outBranch->Branch(
"numPMTsDigiHitOD", &numPMTsDigiHitOD,
"numPMTsDigiHitOD/I");
153 TH1D *numRawHitPMTsIDHist =
new TH1D(
"numRawHitPMTsIDHist",
"numRawHitPMTsIDHist",200, 0, 1000);
154 TH1D *numRawHitPMTsODHist =
new TH1D(
"numRawHitPMTsODHist",
"numRawHitPMTsODHist",200, 0, 1000);
155 TH1D *numDigiHitPMTsIDHist =
new TH1D(
"numDigiHitPMTsIDHist",
"numDigiHitPMTsIDHist",200, 0, 1000);
156 TH1D *numDigiHitPMTsODHist =
new TH1D(
"numDigiHitPMTsODHist",
"numDigiHitPMTsODHist",200, 0, 1000);
158 TH1D *numRawHitsIDHist =
new TH1D(
"numRawHitsIDHist",
"numRawHitsIDHist",200, 0, 1000);
159 TH1D *numRawHitsODHist =
new TH1D(
"numRawHitsODHist",
"numRawHitsODHist",200, 0, 1000);
160 TH1D *numDigiHitsIDHist =
new TH1D(
"numDigiHitsIDHist",
"numDigiHitsIDHist",200, 0, 1000);
161 TH1D *numDigiHitsODHist =
new TH1D(
"numDigiHitsODHist",
"numDigiHitsODHist",200, 0, 1000);
163 TH2D *thetaVsPhi =
new TH2D(
"thetaVsPhi",
"thetaVsPhi", 60, -
PI,
PI, 60, -
PI,
PI );
166 format_histogram(numRawHitPMTsIDHist,
"" ,
"Number of hit ID PMTs [raw]",
"");
167 format_histogram(numRawHitPMTsODHist,
"" ,
"Number of hit OD PMTs [raw]",
"");
168 format_histogram(numDigiHitPMTsIDHist,
"" ,
"Number of hit ID PMTs [digi]",
"");
169 format_histogram(numDigiHitPMTsODHist,
"" ,
"Number of hit OD PMTs [digi]",
"");
176 format_histogram(thetaVsPhi,
"" ,
"Particle direction #theta",
"Particle direction #phi");
179 for (
int ev = 0; ev < nEvent; ev++){
182 wcsimTree->GetEntry(ev);
193 for (
int nTrig = 0; nTrig < numTriggersID; nTrig++){
198 wcsimTriggerID = wcsimRootID->
GetTrigger(nTrig);
199 int numTracksID = wcsimTriggerID->
GetNtrack();
202 vtxX = wcsimTriggerID->
GetVtx(0);
203 vtxY = wcsimTriggerID->
GetVtx(1);
204 vtxZ = wcsimTriggerID->
GetVtx(2);
205 dirX = trackID->
GetDir(0);
206 dirY = trackID->
GetDir(1);
207 dirZ = trackID->
GetDir(2);
210 theta = atan2( dirX, dirZ );
211 phi = atan2( dirY, dirX );
212 thetaVsPhi->Fill(theta, phi);
222 wcsimTriggerOD = wcsimRootOD->
GetTrigger(nTrig);
223 int numTracksOD = wcsimTriggerOD->
GetNtrack();
226 vtxXOD = wcsimTriggerOD->
GetVtx(0);
227 vtxYOD = wcsimTriggerOD->
GetVtx(1);
228 vtxZOD = wcsimTriggerOD->
GetVtx(2);
229 dirXOD = trackOD->
GetDir(0);
230 dirYOD = trackOD->
GetDir(1);
231 dirZOD = trackOD->
GetDir(2);
232 energyOD = trackOD->
GetE();
242 for (
int i = 0;
i < numPMTsHitID;
i++){
244 float tmpRawHitsID = cherenkovHitID->
GetTotalPe(1);
245 rawHitsID += tmpRawHitsID;
249 for (
int i = 0;
i < numPMTsHitOD;
i++){
251 float tmpRawHitsOD = cherenkovHitOD->
GetTotalPe(1);
252 rawHitsOD += tmpRawHitsOD;
256 for (
int i = 0;
i < numPMTsDigiHitID;
i++){
258 float tmpDigiHitsID = cherenkovDigiHitID->
GetQ();
260 digiHitsID += tmpDigiHitsID;
261 int tubeID = cherenkovDigiHitID->
GetTubeId() -1;
265 for (
int i = 0;
i < numPMTsDigiHitOD;
i++){
267 float tmpDigiHitsOD = cherenkovDigiHitOD->
GetQ();
269 digiHitsOD += tmpDigiHitsOD;
271 int tubeOD = MAXPMT + cherenkovDigiHitOD->
GetTubeId() -1;
276 std::cout <<
"====================================================" << std::endl;
277 std::cout <<
"Event\t" << ev << std::endl;
278 std::cout <<
"Trigger\t" << nTrig << std::endl;
279 std::cout <<
"vtx\t" << vtxXOD <<
" " << vtxYOD <<
" " << vtxZOD << std::endl;
280 std::cout <<
"dir\t" << dirXOD <<
" " << dirYOD <<
" " << dirZOD << std::endl;
281 std::cout <<
"ene\t" << energyOD << std::endl;
282 std::cout <<
"rawhitsOD\t" << rawHitsOD << std::endl;
283 std::cout <<
"digihitsOD\t" << digiHitsOD << std::endl;
284 std::cout <<
"rawhitsID\t" << rawHitsID << std::endl;
285 std::cout <<
"digihitsID\t" << digiHitsID << std::endl;
286 std::cout <<
"numPMTsHitOD\t" << numPMTsHitOD << std::endl;
287 std::cout <<
"numPMTsDigiHitOD\t" << numPMTsDigiHitOD << std::endl;
288 std::cout <<
"numPMTsHitID\t" << numPMTsHitID << std::endl;
289 std::cout <<
"numPMTsDigiHitID\t" << numPMTsDigiHitID << std::endl;
292 numRawHitsIDHist->Fill(rawHitsID);
293 numDigiHitsIDHist->Fill(digiHitsID);
294 numRawHitsODHist->Fill(rawHitsOD);
295 numDigiHitsODHist->Fill(digiHitsOD);
297 numRawHitPMTsIDHist->Fill(numPMTsHitID);
298 numRawHitPMTsODHist->Fill(numPMTsHitOD);
299 numDigiHitPMTsIDHist->Fill(numPMTsDigiHitID);
300 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...
void format_histogram(TH1D *h, std::string title, std::string xtitle, std::string ytitle)
TClonesArray * GetTracks() const
Int_t GetNcherenkovhits() const
Float_t GetDir(Int_t i=0) const
Float_t GetVtx(Int_t i=0)
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)
Int_t GetNumberOfEvents() const
Class containing event information.
void read_OD(std::string inFileName, std::string outFileName, bool verbosity)
Class holding true (Cherenkov photon + dark noise) hit information.
TClonesArray * GetCherenkovDigiHits() const
Class holding true track information.