1 | // $Id: MakeHistoSingleEvent.C 94 2003-06-12 22:15:31Z thea $ |
---|
2 | // M. Pallavicini / A. Thea created 16/04/03 |
---|
3 | // root Macro designed to produce standard Euso Histograms |
---|
4 | // Display information about a single event |
---|
5 | // |
---|
6 | // |
---|
7 | // Histo Name Description |
---|
8 | // GtuPhotons Photons reaching different simulation point |
---|
9 | // vs time |
---|
10 | // |
---|
11 | |
---|
12 | #include "TH1F.h" |
---|
13 | #include "TChain.h" |
---|
14 | #include "TKey.h" |
---|
15 | #include "TText.h" |
---|
16 | |
---|
17 | // this plot is the number of photons in different stage of the simulation |
---|
18 | // as a function of the GTU number; the first photon defines the first GTU |
---|
19 | // it is not exactly the GTU simulated by the macrocell because this number |
---|
20 | // is not available for the photons that did not give signal into the |
---|
21 | // front end electronics |
---|
22 | // 3 stages: photons entering the pupil, reaching the FS and giving signal in PMT |
---|
23 | // the gtu length is in micro-seconds |
---|
24 | void DoGtuPhotonsHisto(Int_t event=0, TTree *tree=0, Float_t gtu_len=2.5) { |
---|
25 | if ( !tree ) { |
---|
26 | tree = (TTree*)gDirectory->FindObject("etree"); |
---|
27 | if ( !tree) { |
---|
28 | tree = (TTree*)gDirectory->GetKey("etree")->ReadObj(); |
---|
29 | if ( !tree) { |
---|
30 | printf("Cannot find a valid Euso etree\n"); |
---|
31 | return; |
---|
32 | } |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | // create and fill histograms |
---|
37 | TH1F *th0 = (TH1F*)gROOT->FindObject("EventGtuPhotons0"); |
---|
38 | if ( !th0 ) |
---|
39 | th0 = new TH1F("EventGtuPhotons0","Photons vs GTU number",100,0.,100.); |
---|
40 | else |
---|
41 | th0->Reset(); |
---|
42 | char cut[300],var[300]; |
---|
43 | sprintf(cut,"fHeader.fNum == %d",event); |
---|
44 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons0",gtu_len); |
---|
45 | tree->Draw(var,cut,"",1,event); |
---|
46 | |
---|
47 | TH1F *th1 = (TH1F*)gROOT->FindObject("EventGtuPhotons1"); |
---|
48 | if ( !th1 ) |
---|
49 | th1 = new TH1F("EventGtuPhotons1","Photons vs GTU number",100,0.,100.); |
---|
50 | else |
---|
51 | th1->Reset(); |
---|
52 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d",event); |
---|
53 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons1",gtu_len); |
---|
54 | tree->Draw(var,cut,"",1,event); |
---|
55 | |
---|
56 | TH1F *th2 = (TH1F*)gROOT->FindObject("EventGtuPhotons2"); |
---|
57 | if ( !th2 ) |
---|
58 | th2 = new TH1F("EventGtuPhotons2","Photons vs GTU number",100,0.,100.); |
---|
59 | else |
---|
60 | th2->Reset(); |
---|
61 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeSignal>0.1",event); |
---|
62 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons2",gtu_len); |
---|
63 | tree->Draw(var,cut,"",1,event); |
---|
64 | |
---|
65 | // draw histograms with colors and filling |
---|
66 | th0->SetStats(0); |
---|
67 | th0->SetLineColor(9); |
---|
68 | th0->SetFillColor(0); |
---|
69 | th0->SetXTitle("GTU number"); |
---|
70 | th0->SetYTitle("Number of Photons"); |
---|
71 | th0->Draw(); |
---|
72 | th1->SetStats(0); |
---|
73 | th1->SetLineColor(2); |
---|
74 | th1->SetFillColor(0); |
---|
75 | th1->Draw("same"); |
---|
76 | th2->SetStats(0); |
---|
77 | th2->SetLineColor(8); |
---|
78 | th2->SetFillColor(8); |
---|
79 | th2->Draw("same"); |
---|
80 | |
---|
81 | // write meaning and statistics |
---|
82 | TText *t = new TText(); |
---|
83 | char txt[200]; |
---|
84 | t->SetTextFont(62); |
---|
85 | t->SetTextColor(9); |
---|
86 | t->SetTextSize(0.04); |
---|
87 | sprintf(txt,"Ph. on Pupil:%d",(int)th0->GetEntries()); |
---|
88 | t->DrawText(60.,th0->GetMaximum()*0.94,txt); |
---|
89 | t->SetTextColor(2); |
---|
90 | sprintf(txt,"Ph. on FS:%d",(int)th1->GetEntries()); |
---|
91 | t->DrawText(60.,th0->GetMaximum()*0.86,txt); |
---|
92 | t->SetTextColor(8); |
---|
93 | sprintf(txt,"Ph. detected:%d",(int)th2->GetEntries()); |
---|
94 | t->DrawText(60.,th0->GetMaximum()*0.78,txt); |
---|
95 | } |
---|
96 | |
---|
97 | // same as before starting from Photons reaching the ideal focal surface |
---|
98 | // (in this plot the photons that entered the pupil and were lot in the |
---|
99 | // optical system are not accounted for |
---|
100 | // the effect of single channel and digital counter threshold are highlighted |
---|
101 | void DoGtuPhotonsHisto2(Int_t event=0, TTree *tree=0, Float_t gtu_len=2.5) { |
---|
102 | if ( !tree ) { |
---|
103 | tree = (TTree*)gDirectory->FindObject("etree"); |
---|
104 | if ( !tree) { |
---|
105 | tree = (TTree*)gDirectory->GetKey("etree")->ReadObj(); |
---|
106 | if ( !tree) { |
---|
107 | printf("Cannot find a valid Euso etree\n"); |
---|
108 | return; |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | TH1F *th1 = (TH1F*)gROOT->FindObject("EventGtuPhotons1"); |
---|
114 | if ( !th1 ) |
---|
115 | th1 = new TH1F("EventGtuPhotons1","Photons vs GTU number",100,0.,100.); |
---|
116 | else |
---|
117 | th1->Reset(); |
---|
118 | |
---|
119 | char cut[300],var[300]; |
---|
120 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d",event); |
---|
121 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons1",gtu_len); |
---|
122 | tree->Draw(var,cut,"",1,event); |
---|
123 | |
---|
124 | TH1F *th2 = (TH1F*)gROOT->FindObject("EventGtuPhotons2"); |
---|
125 | if ( !th2 ) |
---|
126 | th2 = new TH1F("EventGtuPhotons2","Photons vs GTU number",100,0.,100.); |
---|
127 | else |
---|
128 | th2->Reset(); |
---|
129 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeSignal>0.1",event); |
---|
130 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons2",gtu_len); |
---|
131 | tree->Draw(var,cut,"",1,event); |
---|
132 | |
---|
133 | TH1F *th3 = (TH1F*)gROOT->FindObject("EventGtuPhotons3"); |
---|
134 | if ( !th3 ) |
---|
135 | th3 = new TH1F("EventGtuPhotons3","Photons vs GTU number",100,0.,100.); |
---|
136 | else |
---|
137 | th3->Reset(); |
---|
138 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeCount>0.1",event); |
---|
139 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons3",gtu_len); |
---|
140 | tree->Draw(var,cut,"",1,event); |
---|
141 | |
---|
142 | TH1F *th4 = (TH1F*)gROOT->FindObject("EventGtuPhotons4"); |
---|
143 | if ( !th4 ) |
---|
144 | th4 = new TH1F("EventGtuPhotons4","Photons vs GTU number",100,0.,100.); |
---|
145 | else |
---|
146 | th4->Reset(); |
---|
147 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeFastOR>0.1",event); |
---|
148 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons4",gtu_len); |
---|
149 | tree->Draw(var,cut,"",1,event); |
---|
150 | |
---|
151 | th1->SetStats(0); |
---|
152 | th1->SetLineColor(9); |
---|
153 | th1->SetFillColor(0); |
---|
154 | th1->SetXTitle("GTU number"); |
---|
155 | th1->SetYTitle("Number of Photons"); |
---|
156 | th1->Draw(); |
---|
157 | th2->SetStats(0); |
---|
158 | th2->SetLineColor(6); |
---|
159 | th2->SetFillColor(0); |
---|
160 | th2->Draw("same"); |
---|
161 | th3->SetStats(0); |
---|
162 | th3->SetLineColor(2); |
---|
163 | th3->SetFillColor(2); |
---|
164 | th3->Draw("same"); |
---|
165 | th4->SetStats(0); |
---|
166 | th4->SetLineColor(8); |
---|
167 | th4->SetFillColor(8); |
---|
168 | th4->Draw("same"); |
---|
169 | |
---|
170 | TText *t = new TText(); |
---|
171 | char txt[100]; |
---|
172 | t->SetTextFont(62); |
---|
173 | t->SetTextColor(9); |
---|
174 | t->SetTextSize(0.04); |
---|
175 | sprintf(txt,"Photons on FS:%d",(int)th1->GetEntries()); |
---|
176 | t->DrawText(65.,th1->GetMaximum()*0.94,txt); |
---|
177 | t->SetTextColor(6); |
---|
178 | sprintf(txt,"Pmt signals:%d",(int)th2->GetEntries()); |
---|
179 | t->DrawText(65.,th1->GetMaximum()*0.86,txt); |
---|
180 | t->SetTextColor(2); |
---|
181 | sprintf(txt,"Frontend hits:%d",(int)th3->GetEntries()); |
---|
182 | t->DrawText(65.,th1->GetMaximum()*0.78,txt); |
---|
183 | t->SetTextColor(8); |
---|
184 | sprintf(txt,"Fast OR counts:%d",(int)th4->GetEntries()); |
---|
185 | t->DrawText(65.,th1->GetMaximum()*0.70,txt); |
---|
186 | } |
---|
187 | /** |
---|
188 | // same as before starting from Photons detected by PMTs |
---|
189 | // (in this plot the photons that entered the pupil and were lot in the |
---|
190 | // optical system or those that were not detected because of QE are not accounted for |
---|
191 | // the effect of single channel and digital counter threshold are highlighted |
---|
192 | // Also AFEE infos are added here (FULL AFEE) |
---|
193 | void DoGtuPhotonsHisto3(Int_t event=0, TTree *tree=0, Float_t gtu_len=2.5) { |
---|
194 | if ( !tree ) { |
---|
195 | tree = (TTree*)gDirectory->FindObject("etree"); |
---|
196 | if ( !tree) { |
---|
197 | tree = (TTree*)gDirectory->GetKey("etree")->ReadObj(); |
---|
198 | if ( !tree) { |
---|
199 | printf("Cannot find a valid Euso etree\n"); |
---|
200 | return; |
---|
201 | } |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | char cut[300],var[300]; |
---|
206 | TH1F *th1 = (TH1F*)gROOT->FindObject("EventGtuPhotons1"); |
---|
207 | if ( !th1 ) |
---|
208 | th1 = new TH1F("EventGtuPhotons1","Photons vs GTU number",100,0.,100.); |
---|
209 | else |
---|
210 | th1->Reset(); |
---|
211 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeSignal>0.1",event); |
---|
212 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons1",gtu_len); |
---|
213 | tree->Draw(var,cut,"",1,event); |
---|
214 | |
---|
215 | TH1F *th2 = (TH1F*)gROOT->FindObject("EventGtuPhotons2"); |
---|
216 | if ( !th2 ) |
---|
217 | th2 = new TH1F("EventGtuPhotons2","Photons vs GTU number",100,0.,100.); |
---|
218 | else |
---|
219 | th2->Reset(); |
---|
220 | sprintf(cut,"fPhotons.fHitOnIFS>0 && fHeader.fNum == %d && fPhotons.fMadeCount>0.1",event); |
---|
221 | sprintf(var,"((fPhotons.fTime-fFirstTime)/(1000.*%f))>>EventGtuPhotons2",gtu_len); |
---|
222 | tree->Draw(var,cut,"",1,event); |
---|
223 | |
---|
224 | TH1F *th3 = (TH1F*)gROOT->FindObject("EventGtuPhotons3"); |
---|
225 | if ( !th3 ) |
---|
226 | th3 = new TH1F("EventGtuPhotons3","Photons vs GTU number",100,0.,100.); |
---|
227 | else |
---|
228 | th3->Reset(); |
---|
229 | |
---|
230 | // compute charge for each GTU and fill histogram |
---|
231 | Float_t total_afee_charge=0.; |
---|
232 | TBranch *br = tree->GetBranch("events"); |
---|
233 | EEvent *pEv = new EEvent(); |
---|
234 | br->SetAddress( &pEv ); |
---|
235 | tree->GetEntry( event ); |
---|
236 | |
---|
237 | for(Int_t i=0; i < pEv->GetNumAFee(); i++ ) { |
---|
238 | EAFee *afee = pEv->GetEAFee( i ); |
---|
239 | Int_t gtu = afee->GetGtuId(); |
---|
240 | Float_t charge = afee->GetDyCharge(); |
---|
241 | Int_t numpe = charge*2.e13; // convert into NOMINAL photoelectrons, gain 3.E5 |
---|
242 | if ( gtu > 0 && gtu < 100 ) { |
---|
243 | Int_t old = th3->GetBinContent( gtu ); |
---|
244 | th3->SetBinContent( gtu, old + numpe ); |
---|
245 | total_afee_charge += numpe; |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | th1->SetStats(0); |
---|
250 | th1->SetLineColor(9); |
---|
251 | th1->SetFillColor(0); |
---|
252 | th1->SetXTitle("GTU number"); |
---|
253 | th1->SetYTitle("Number of Photons"); |
---|
254 | th1->Draw(); |
---|
255 | th2->SetStats(0); |
---|
256 | th2->SetLineColor(6); |
---|
257 | th2->SetFillColor(0); |
---|
258 | th2->Draw("same"); |
---|
259 | th3->SetStats(0); |
---|
260 | th3->SetLineColor(8); |
---|
261 | th3->SetFillColor(8); |
---|
262 | th3->Draw("same"); |
---|
263 | |
---|
264 | TText *t = new TText(); |
---|
265 | char txt[100]; |
---|
266 | t->SetTextFont(62); |
---|
267 | t->SetTextColor(9); |
---|
268 | t->SetTextSize(0.04); |
---|
269 | sprintf(txt,"Ph. detected:%d",th1->GetEntries()); |
---|
270 | t->DrawText(65.,th1->GetMaximum()*0.94.,txt); |
---|
271 | t->SetTextColor(6); |
---|
272 | sprintf(txt,"Ph. in DFEE:%d",th2->GetEntries()); |
---|
273 | t->DrawText(65.,th1->GetMaximum()*0.86,txt); |
---|
274 | t->SetTextColor(2); |
---|
275 | sprintf(txt,"Charge (pC,dynode):%f",total_afee_charge); |
---|
276 | t->DrawText(65.,th1->GetMaximum()*0.78,txt); |
---|
277 | } |
---|
278 | **/ |
---|
279 | |
---|
280 | void MakeHistoSingleEvent(int histo_set=0, int event=0, TChain *chain=0) { |
---|
281 | } |
---|