22 TFile *f =
new TFile(
filename,
"read");
24 cout <<
"Error, could not open input file: " <<
filename << endl;
28 TFile *f2 =
new TFile(filename2,
"read");
30 cout <<
"Error, could not open input file: " << filename2 << endl;
35 TTree *wcsimT = (TTree*)f->Get(
"wcsimT");
36 int nevent = wcsimT->GetEntries();
37 TTree *wcsimT2 = (TTree*)f2->Get(
"wcsimT");
38 int nevent2 = wcsimT2->GetEntries();
42 wcsimT->SetBranchAddress(
"wcsimrootevent",&wcsimrootsuperevent);
44 wcsimT2->SetBranchAddress(
"wcsimrootevent",&wcsimrootsuperevent2);
47 wcsimT->GetBranch(
"wcsimrootevent")->SetAutoDelete(kTRUE);
48 wcsimT2->GetBranch(
"wcsimrootevent")->SetAutoDelete(kTRUE);
53 cout <<
"Stats for the first event in your version of WCSim using " <<
filename << endl;
54 cout <<
"Number of tube hits " << wcsimrootevent->
GetNumTubesHit() << endl;
55 cout <<
"Number of digitized tube hits " << wcsimrootevent->
GetNumDigiTubesHit() << endl;
56 cout <<
"Number of photoelectron hit times " << wcsimrootevent->
GetCherenkovHitTimes()->GetEntries() << endl;
61 cout <<
"***********************************************************" << endl;
62 cout <<
"Stats for the first event of WCSim version on GitHub using "<< filename2 << endl;
63 cout <<
"Number of tube hits " << wcsimrootevent2->
GetNumTubesHit() << endl;
64 cout <<
"Number of digitized tube hits " << wcsimrootevent2->
GetNumDigiTubesHit() << endl;
65 cout <<
"Number of photoelectron hit times " << wcsimrootevent2->
GetCherenkovHitTimes()->GetEntries() << endl;
68 cout <<
"***********************************************************" << endl;
69 if (abs(wcsimrootevent->
GetNumTubesHit() - wcsimrootevent2->
GetNumTubesHit())>1.0e-6){cout <<
"FIRST EVENT TEST FAILED: Number of hit tubes do not match" << endl;}
70 else {cout <<
"FIRST EVENT TEST PASSED: Number of hit tubes matches" << endl;}
71 if (abs(wcsimrootevent->
GetNumDigiTubesHit() - wcsimrootevent2->
GetNumDigiTubesHit())>1.0e-6){cout <<
"FIRST EVENT TEST FAILED: Number of digitized tubes do not match" << endl; }
72 else {cout <<
"FIRST EVENT TEST PASSED: Number of digitized tubes matches" << endl; }
73 if (abs(wcsimrootevent->
GetCherenkovHitTimes()->GetEntries() - wcsimrootevent2->
GetCherenkovHitTimes()->GetEntries())> 1.0e-6){cout <<
"FIRST EVENT TEST FAILED: Number of hit times do not match" << endl;}
74 else {cout <<
"FIRST EVENT TEST PASSED: Number of hit times matches" << endl;}
76 if (nevent != nevent2) {
77 cout <<
"***********************************************************" << endl;
78 cout <<
"The input files don’t contain the same number of events. Only the first events were compared. To see histograms of the number of hits, deposited charge and hit time, please choose two input files which contain the same number of events." << endl;
84 TH1F *hits =
new TH1F(
"PMT Hits",
"# Digitized Hits", 500, 0, 3000);
85 TH1F *
time =
new TH1F(
"Average Time",
"Average Time", 600, 900, 2000);
86 TH1F *charge =
new TH1F(
"Q/# Digitized PMT",
"Average Charge", 200, 0, 5);
88 TH1F *hits2 =
new TH1F(
"PMT Hits 2",
"Digitized Hits", 500, 0, 3000);
89 TH1F *time2 =
new TH1F(
"Average Time 2",
"Average Time", 600, 900, 2000);
90 TH1F *charge2 =
new TH1F(
"Q/# Digitized PMT 2",
"Average Charge", 200, 0, 5);
94 for (
int ev=0; ev<nevent; ev++){
97 wcsimrootevent = wcsimrootsuperevent->
GetTrigger(0);
99 printf(
"********************************************************");
102 printf(
"Mode %d\n", wcsimrootevent->
GetMode());
103 printf(
"Number of subevents %d\n",
106 printf(
"Vtxvol %d\n", wcsimrootevent->
GetVtxvol());
107 printf(
"Vtx %f %f %f\n", wcsimrootevent->
GetVtx(0),
116 double vtx_x = wcsimrootevent->
GetVtx(0);
117 double vtx_y = wcsimrootevent->
GetVtx(1);
118 double vtx_z = wcsimrootevent->
GetVtx(2);
119 double dist = sqrt(vtx_x*vtx_x + vtx_y * vtx_y);
122 wcsimrootevent = wcsimrootsuperevent->
GetTrigger(index);
125 hits->Fill(ncherenkovdigihits);
131 std::cout << ncherenkovdigihits << std::endl;
135 for (
int i=0;
i< ncherenkovdigihits_slots;
i++){
142 float q = wcsimrootcherenkovdigihit->
GetQ();
143 float t = wcsimrootcherenkovdigihit->
GetT();
147 occupancy->Fill(tubeNumber);
149 occupancy_mPMT->Fill(tubeNumber%33 == 0 ? 33 : tubeNumber%33);
150 occupancy_mPMT2->Fill(tubeNumber/33);
154 float av_time = (ncherenkovdigihits > 0) ? totalt/ncherenkovdigihits : 0;
155 float av_q = (ncherenkovdigihits > 0) ? totalq/ncherenkovdigihits : 0;
165 for (
int index = 0 ; index < wcsimrootsuperevent2->
GetNumberOfEvents(); index++){
166 wcsimrootevent2 = wcsimrootsuperevent2->
GetTrigger(index);
168 hits2->Fill(ncherenkovdigihits);
173 for (
int i=0;
i< ncherenkovdigihits;
i++){
178 float q = wcsimrootcherenkovdigihit->
GetQ();
179 float t = wcsimrootcherenkovdigihit->
GetT();
185 float av_time = (ncherenkovdigihits > 0) ? totalt/ncherenkovdigihits : 0;
186 float av_q = (ncherenkovdigihits > 0) ? totalq/ncherenkovdigihits : 0;
188 time2->Fill(av_time);
195 Double_t
ks_hits = hits->KolmogorovTest(hits2);
198 cout <<
"***********************************************************" << endl;
199 cout <<
"ks test for # of digitized hits: " <<
ks_hits << endl;
200 cout <<
"ks test for average charge: " <<
ks_charge << endl;
201 cout <<
"ks test for average time: " <<
ks_time << endl;
204 float win_scale = 0.75;
207 TCanvas* c1 =
new TCanvas(
"c1",
"Test Plots", 500*n_wide*win_scale, 500*n_high*win_scale);
211 hits2->SetLineColor(kRed);
213 c1->cd(1); hits2->Draw(
"SAME");
215 TLegend *
leg =
new TLegend(0.2,0.7,0.55,0.85,
"");
216 leg->SetFillColor(0);
217 leg->SetBorderSize(0);
219 leg->AddEntry(hits2,filename2,
"l");
223 charge->GetXaxis()->SetTitle(
"Total Charge / # digitized hits");
225 charge2->SetLineColor(kRed);
226 c1->cd(2); charge2->Draw(
"SAME");
228 time->GetXaxis()->SetTitle(
"Total Time / # digitized hits (ns)");
230 time2->SetLineColor(kRed);
231 c1->cd(3); time2->Draw(
"SAME");
235 hit_pmts2->SetLineColor(kRed);
236 hit_pmts2->Draw(
"same");
238 TCanvas*
c2 =
new TCanvas(
"c2",
"Test Plots", 500*n_wide*win_scale, 500*n_high*win_scale);
239 gStyle->SetOptStat(1);
240 gStyle->SetOptFit(111);
247 tot_charge2->SetLineColor(kRed);
248 tot_charge2->Draw(
"same");
252 TCanvas *
c3 =
new TCanvas();
255 occupancy_mPMT2->Draw();
257 occupancy_mPMT->Draw();
260 ttime2->SetLineColor(kRed);
261 ttime2->Draw(
"same");
264 charge2->SetLineColor(kRed);
265 charge2->Draw(
"same");
268 TCanvas *
c4 =
new TCanvas();
272 TCanvas *
c5 =
new TCanvas();
Int_t GetNumberOfSubEvents() const
Class holding digitised hit (aka digit or digi) information (after PMT & electronics simulation + tri...
Int_t GetNumDigiTubesHit() const
double q[MAX_N_ACTIVE_TUBES]
WCSimRootEventHeader * GetHeader()
Float_t GetVtx(Int_t i=0)
Int_t GetNcherenkovdigihits() const
int verification_HitsChargeTime(const char *filename="wcsimtest.root", const char *filename2="../../WCSim_clean/verification-test-scripts/wcsimtest.root", bool verbose=false)
Class storing trigger information.
WCSimRootTrigger * GetTrigger(int number)
TClonesArray * GetCherenkovHitTimes() const
Int_t GetNumTubesHit() const
Int_t GetNumberOfEvents() const
Class containing event information.
double t[MAX_N_ACTIVE_TUBES]
Int_t GetNcherenkovdigihits_slots() const
TClonesArray * GetCherenkovDigiHits() const