calhit-validation-macro.cpp
Go to the documentation of this file.
1 #include "TCanvas.h"
2 #include "TH1D.h"
3 
5 {
6 
7  TFile fold("/nova/data/mc/S13-06-05/cosmics/fd/hadd/fd_S13-06-05_v1_cosmics_200.sim.reco.validhists.root");
8  fold.cd("calhitana");
9  TTree *hitold = gDirectory->Get("fHitTree");
10  TTree *evtold = gDirectory->Get("fEvtTree");
11 
12  TFile fnew("/nova/prod/mc/S14-03-06/reco/validation/hadd/fardet_cosmics_S14-03-06.sim.daq.reco.hist.root");
13  fnew.cd("calhitana");
14  TTree *hitnew = gDirectory->Get("fHitTree");
15  TTree *evtnew = gDirectory->Get("fEvtTree");
16 
17  cout<<"Got the files and trees\n";
18 
19  int nadc, oadc, ntdc, otdc, nnoise, onoise;
20  float npe, ope, ntns, otns, npee, opee;
21  unsigned int nplane, oplane, ncell, ocell;
22 
23  hitold->SetBranchAddress("Pe", &ope);
24  hitold->SetBranchAddress("Adc", &oadc);
25  hitold->SetBranchAddress("Tdc", &otdc);
26  hitold->SetBranchAddress("Tns", &otns);
27  hitold->SetBranchAddress("Plane", &oplane);
28  hitold->SetBranchAddress("Cell", &ocell);
29 
30  evtold->SetBranchAddress("Noise", &onoise);
31  evtold->SetBranchAddress("PePerTrueE", &opee);
32 
33  hitnew->SetBranchAddress("Pe", &npe);
34  hitnew->SetBranchAddress("Adc", &nadc);
35  hitnew->SetBranchAddress("Tdc", &ntdc);
36  hitnew->SetBranchAddress("Tns", &ntns);
37  hitnew->SetBranchAddress("Plane", &nplane);
38  hitnew->SetBranchAddress("Cell", &ncell);
39 
40  evtnew->SetBranchAddress("Noise", &nnoise);
41  evtnew->SetBranchAddress("PePerTrueE", &npee);
42 
43  cout<<"Set tree branches\n";
44 
45  TH1D *hnpe = new TH1D("npe",";PE;Hits",250,0,2500);
46  TH1D *hope = new TH1D("ope",";PE;Hits",250,0,2500);
47  hnpe->Sumw2();
48  hope->Sumw2();
49 
50  TH1D *hnadc = new TH1D("nadc",";ADC[0];Hits",210,0,4200);
51  TH1D *hoadc = new TH1D("oadc",";ADC[0];Hits",210,0,4200);
52  hnadc->Sumw2();
53  hoadc->Sumw2();
54 
55  TH1D *hntdc = new TH1D("ntdc",";TDC;Hits",200,0,40000);
56  TH1D *hotdc = new TH1D("otdc",";TDC;Hits",200,0,40000);
57  hntdc->Sumw2();
58  hotdc->Sumw2();
59 
60  TH1D *hntns = new TH1D("ntns",";TNS;Hits",300,0,600000);
61  TH1D *hotns = new TH1D("otns",";TNS;Hits",300,0,600000);
62  hntns->Sumw2();
63  hotns->Sumw2();
64 
65  TH1D *hnplane = new TH1D("nplane",";Plane;Hits",900,-0.5,899.5);
66  TH1D *hoplane = new TH1D("oplane",";Plane;Hits",900,-0.5,899.5);
67  hnplane->Sumw2();
68  hoplane->Sumw2();
69 
70  TH1D *hncell = new TH1D("ncell",";Cell;Hits",384,-0.5,383.5);
71  TH1D *hocell = new TH1D("ocell",";Cell;Hits",384,-0.5,383.5);
72  hncell->Sumw2();
73  hocell->Sumw2();
74 
75  TH2D *hncp = new TH2D("ncp","Hit map;Plane;Cell",900,-0.5,899.5,384,-0.5,383.5);
76  TH2D *hocp = new TH2D("ocp","Hit map;Plane;Cell",900,-0.5,899.5,384,-0.5,383.5);
77 
78  TH1D *hnnoise = new TH1D("nnoise",";Noise Hits;Event", 300,18700,19900);
79  TH1D *honoise = new TH1D("onoise",";Noise Hits;Event", 300,18700,19900);
80  hnnoise->Sumw2();
81  honoise->Sumw2();
82 
83  TH1D *hnpee = new TH1D("npee",";PE per FLS Energy [PE/GeV];Event", 300,13000,25000);
84  TH1D *hopee = new TH1D("opee",";PE per FLS Energy [PE/GeV];Event", 300,13000,25000);
85  hnpee->Sumw2();
86  hopee->Sumw2();
87 
88  TLegend *leg = new TLegend(0.55,0.7,0.8,0.85);
89  leg->SetTextSize(0.04);
90  leg->AddEntry(hnpe, "New", "l");
91  leg->AddEntry(hope, "Old", "l");
92 
93  cout<<"Declared histograms\n";
94 
95  int nnh = hitnew->GetEntries();
96  int noh = hitold->GetEntries();
97 
98  int nne = evtnew->GetEntries();
99  int noe = evtold->GetEntries();
100 
101  cout<<nnh<<" "<<noh<<" "<<nne<<" "<<noe<<endl;
102  cout<<"scale pes by "<<((float)(nnh*100)/(float)(nne))<<" and "<<((float)(noh*100)/(float)(noe))<<endl;
103 
104  cout<<"Entries in new hit tree: "<<nnh<<endl;
105 
106  for(int e = 0; e < nnh; ++e){
107  hitnew->GetEntry(e);
108 
109  hnpe->Fill(npe);
110  hnadc->Fill(nadc);
111  hntdc->Fill(ntdc);
112  hntns->Fill(ntns);
113  hnplane->Fill(nplane);
114  hncell->Fill(ncell);
115  hncp->Fill(nplane, ncell);
116 
117  }// end loop over hitnew entries
118 
119  cout<<"Entries in old hit tree: "<<noh<<endl;
120 
121  for(int e = 0; e < noh; ++e){
122  hitold->GetEntry(e);
123 
124  hope->Fill(ope);
125  hoadc->Fill(oadc);
126  hotdc->Fill(otdc);
127  hotns->Fill(otns);
128  hoplane->Fill(oplane);
129  hocell->Fill(ocell);
130  hocp->Fill(oplane, ocell);
131 
132  }// end loop over hitnew entries
133 
134  cout<<"Entries in new evt tree: "<<nne<<endl;
135 
136  for(int e = 0; e < nne; ++e){
137  evtnew->GetEntry(e);
138 
139  hnpee->Fill(npee);
140  hnnoise->Fill(nnoise);
141 
142  }// end loop over hitnew entries
143 
144  cout<<"Entries in old evt tree: "<<noe<<endl;
145 
146  for(int e = 0; e < noe; ++e){
147  evtold->GetEntry(e);
148 
149  hopee->Fill(opee);
150  honoise->Fill(onoise);
151 
152  }// end loop over hitnew entries
153 
154 
155  // makes sense tonormalize everything to the same number of events.
156  // this will show any differences in hitrate.
157  // number of events in old file is noe, and in new is nne
158  // normalizing to 100 events
159 
160  TCanvas *c1 = new TCanvas("c1");
161  c1->SetLogy();
162  hnpe->SetMarkerSize(0);
163  hope->SetMarkerSize(0);
164  hnpe->Scale( nnh*100/(float)nne);
165  hope->Scale( noh*100/(float)noe);
166 
167  hnpe->SetLineColor(2);
168  hnpe->Draw("ehist");
169  hnpe->GetYaxis()->SetRangeUser(0.001, 1.5* hnpe->GetBinContent(hnpe->GetMaximumBin()) );
170  hope->Draw("sameehist");
171  leg->Draw("same");
172  c1->SaveAs("../results/plots/pe-log.pdf");
173 
174  TCanvas *c2 = new TCanvas("c2");
175  c2->SetLogy();
176  hnadc->SetMarkerSize(0);
177  hoadc->SetMarkerSize(0);
178  hnadc->Scale( nnh*100/(float)nne);
179  hoadc->Scale( noh*100/(float)noe);
180  hnadc->SetLineColor(2);
181  hnadc->Draw("ehist");
182  hnadc->GetYaxis()->SetRangeUser(0.001, 1.5* hnadc->GetBinContent(hnadc->GetMaximumBin()) );
183  hoadc->Draw("sameehist");
184  leg->Draw("same");
185  c2->SaveAs("../results/plots/adc-log.pdf");
186 
187  TCanvas *c3 = new TCanvas("c3");
188  c3->SetLogy();
189  hntdc->SetMarkerSize(0);
190  hotdc->SetMarkerSize(0);
191  hntdc->Scale( nnh*100/(float)nne);
192  hotdc->Scale( noh*100/(float)noe);
193  hntdc->SetLineColor(2);
194  hntdc->Draw("ehist");
195  hntdc->GetYaxis()->SetRangeUser(0.001, 1.5* hntdc->GetBinContent(hntdc->GetMaximumBin()) );
196  hotdc->Draw("sameehist");
197  leg->Draw("same");
198  c3->SaveAs("../results/plots/tdc-log.pdf");
199 
200  TCanvas *c4 = new TCanvas("c4");
201  c4->SetLogy();
202  hntns->SetMarkerSize(0);
203  hotns->SetMarkerSize(0);
204  hntns->Scale( nnh*100/(float)nne);
205  hotns->Scale( noh*100/(float)noe);
206  hntns->SetLineColor(2);
207  hntns->Draw("ehist");
208  hntns->GetYaxis()->SetRangeUser(0.001, 1.5* hntns->GetBinContent(hntns->GetMaximumBin()) );
209  hotns->Draw("sameehist");
210  leg->Draw("same");
211  c4->SaveAs("../results/plots/tns-log.pdf");
212 
213  TCanvas *c5 = new TCanvas("c5");
214  c5->SetLogy();
215  hnplane->SetMarkerSize(0);
216  hoplane->SetMarkerSize(0);
217  hnplane->Scale( nnh*100/(float)nne);
218  hoplane->Scale( noh*100/(float)noe);
219  hnplane->SetLineColor(2);
220  hnplane->Draw("ehist");
221  hnplane->GetYaxis()->SetRangeUser(0.001, 1.5* hnplane->GetBinContent(hnplane->GetMaximumBin()) );
222  hoplane->Draw("sameehist");
223  leg->Draw("same");
224  c5->SaveAs("../results/plots/plane-log.pdf");
225 
226  TCanvas *c6 = new TCanvas("c6");
227  c6->SetLogy();
228  hncell->SetMarkerSize(0);
229  hocell->SetMarkerSize(0);
230  hncell->Scale( nnh*100/(float)nne);
231  hocell->Scale( noh*100/(float)noe);
232  hncell->SetLineColor(2);
233  hncell->Draw("ehist");
234  hncell->GetYaxis()->SetRangeUser(0.001, 1.5* hncell->GetBinContent(hncell->GetMaximumBin()) );
235  hocell->Draw("sameehist");
236  leg->Draw("same");
237  c6->SaveAs("../results/plots/cell-log.pdf");
238 
239  TCanvas *c7 = new TCanvas("c7");
240  c7->SetLogy();
241  hnnoise->SetMarkerSize(0);
242  honoise->SetMarkerSize(0);
243  hnnoise->Scale( nnh*100/(float)nne);
244  honoise->Scale( noh*100/(float)noe);
245  hnnoise->SetLineColor(2);
246  hnnoise->Draw("ehist");
247  hnnoise->GetYaxis()->SetRangeUser(0.001, 1.5* hnnoise->GetBinContent(hnnoise->GetMaximumBin()) );
248  honoise->Draw("ehistsame");
249  leg->Draw("same");
250  c7->SaveAs("../results/plots/noise-log.pdf");
251 
252  TCanvas *c8 = new TCanvas("c8");
253  c8->SetLogy();
254  hnpee->SetMarkerSize(0);
255  hopee->SetMarkerSize(0);
256  hnpee->Scale( nnh*100/(float)nne);
257  hopee->Scale( noh*100/(float)noe);
258  hnpee->SetLineColor(2);
259  hnpee->Draw("ehist");
260  hnpee->GetYaxis()->SetRangeUser(0.001, 1.5* hnpee->GetBinContent(hnpee->GetMaximumBin()) );
261  hopee->Draw("ehistsame");
262  leg->Draw("same");
263  c8->SaveAs("../results/plots/pee-log.pdf");
264 
265  TCanvas *c9 = new TCanvas("c9");
266  hncp->Draw("colz");
267  c9->SaveAs("../results/plots/ncp-log.pdf");
268 
269  TCanvas *c10 = new TCanvas("c10");
270  hocp->Draw("colz");
271  c10->SaveAs("../results/plots/ocp-log.pdf");
272 
273  return;
274 }
c2
Definition: demo5.py:33
OStream cout
Definition: OStream.cxx:6
void calhit_validation_macro()
c1
Definition: demo5.py:24
Float_t e
Definition: plot.C:35