1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: GlobalHisto.C 1367 2005-01-06 00:24:57Z thea $ |
---|
3 | // A.Thea created May, 8 2003 |
---|
4 | |
---|
5 | #include "GlobalHisto.h" |
---|
6 | #if !defined (__CINT__) || defined (__MAKECINT__) |
---|
7 | #include "TMath.h" |
---|
8 | #include "TArrayF.h" |
---|
9 | #include "TTree.h" |
---|
10 | #include "TBranch.h" |
---|
11 | #include "TVector3.h" |
---|
12 | #include "TH1.h" |
---|
13 | #include "TH2.h" |
---|
14 | #include "TPad.h" |
---|
15 | #include "TLatex.h" |
---|
16 | |
---|
17 | #include "iostream.h" |
---|
18 | #include "EEvent.hh" |
---|
19 | |
---|
20 | |
---|
21 | #endif |
---|
22 | |
---|
23 | // constructor |
---|
24 | GlobalHisto::GlobalHisto( TTree *tree ): |
---|
25 | fEvent(0), fCutMinEnergy(0), fCutMaxEnergy(0), fCutMinThetaOne(0), |
---|
26 | fCutMaxThetaOne(0), fCutMinTheta(0), fCutMaxTheta(0) { |
---|
27 | |
---|
28 | Init(tree); |
---|
29 | SetXVariable("Energy"); |
---|
30 | } |
---|
31 | |
---|
32 | void GlobalHisto::Init( TTree *tree ){ |
---|
33 | |
---|
34 | fTree = tree; |
---|
35 | fTree->SetMakeClass(1); |
---|
36 | Int_t fNumPhotons; |
---|
37 | Float_t fTruth_fTrueEnergy; |
---|
38 | Float_t fTruth_fTrueShowerMaxPos[3]; |
---|
39 | Float_t fTruth_fTrueTheta; |
---|
40 | |
---|
41 | // Getting branches |
---|
42 | TBranch *b_events = fTree->GetBranch("events"); |
---|
43 | TBranch *b_fNumPhotons = fTree->GetBranch("fNumPhotons"); |
---|
44 | |
---|
45 | TBranch *b_fTruth_fTrueEnergy = fTree->GetBranch("fTruth.fTrueEnergy"); |
---|
46 | TBranch *b_fTruth_fTrueShowerMaxPos = fTree->GetBranch("fTruth.fTrueShowerMaxPos[3]"); |
---|
47 | TBranch *b_fTruth_fTrueTheta = fTree->GetBranch("fTruth.fTrueTheta"); |
---|
48 | |
---|
49 | fNumEvents = (Int_t) fTree->GetEntries(); |
---|
50 | |
---|
51 | cout << "Read " << fNumEvents << " Events" << endl; |
---|
52 | |
---|
53 | fGlobalNumPhotons = new Int_t[fNumEvents]; |
---|
54 | fGlobalTrueEnergy = new Float_t[fNumEvents]; |
---|
55 | fGlobalTrueThetaOne = new Float_t[fNumEvents]; |
---|
56 | fGlobalTrueTheta = new Float_t[fNumEvents]; |
---|
57 | |
---|
58 | // Setting Addresses |
---|
59 | b_events->SetAddress(&fEvent); |
---|
60 | |
---|
61 | b_fNumPhotons->SetAddress(&fNumPhotons); |
---|
62 | b_fTruth_fTrueEnergy->SetAddress(&fTruth_fTrueEnergy); |
---|
63 | b_fTruth_fTrueShowerMaxPos->SetAddress(fTruth_fTrueShowerMaxPos); |
---|
64 | b_fTruth_fTrueTheta->SetAddress(&fTruth_fTrueTheta); |
---|
65 | |
---|
66 | |
---|
67 | fGlobalMaxNumPhotons = 0; |
---|
68 | |
---|
69 | fNoPhotons = 0; |
---|
70 | |
---|
71 | TVector3 TrueShowerMaxPos; |
---|
72 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
73 | |
---|
74 | b_fNumPhotons->GetEntry(i); |
---|
75 | |
---|
76 | if ( fNumPhotons == 0 ) { |
---|
77 | fNoPhotons++; |
---|
78 | // continue; |
---|
79 | } |
---|
80 | b_fTruth_fTrueEnergy->GetEntry(i); |
---|
81 | b_fTruth_fTrueTheta->GetEntry(i); |
---|
82 | b_fTruth_fTrueShowerMaxPos->GetEntry(i); |
---|
83 | |
---|
84 | fGlobalNumPhotons[i] = fNumPhotons; |
---|
85 | fGlobalTrueEnergy[i] = fTruth_fTrueEnergy/1e18; |
---|
86 | // FIXME: |
---|
87 | TrueShowerMaxPos.SetXYZ( fTruth_fTrueShowerMaxPos[0], |
---|
88 | fTruth_fTrueShowerMaxPos[1], 6371+430-fTruth_fTrueShowerMaxPos[2] ); |
---|
89 | fGlobalTrueThetaOne[i] = TrueShowerMaxPos.Theta(); // *360/TMath::TwoPi(); |
---|
90 | fGlobalTrueTheta[i] = fTruth_fTrueTheta; // *360/TMath::TwoPi(); |
---|
91 | |
---|
92 | } |
---|
93 | |
---|
94 | fGlobalMaxNumPhotons = |
---|
95 | fGlobalNumPhotons[TMath::LocMax(fNumEvents,fGlobalNumPhotons)]; |
---|
96 | } |
---|
97 | |
---|
98 | // destructor |
---|
99 | GlobalHisto::~GlobalHisto() { |
---|
100 | delete fGlobalNumPhotons; |
---|
101 | delete fGlobalTrueEnergy; |
---|
102 | delete fGlobalTrueThetaOne; |
---|
103 | delete fGlobalTrueTheta; |
---|
104 | } |
---|
105 | |
---|
106 | Bool_t GlobalHisto::IsInsideCuts(Int_t i) { |
---|
107 | if ( i < 0 || i > fNumEvents ) return kFALSE; |
---|
108 | Bool_t isInside(kTRUE); |
---|
109 | isInside = fGlobalNumPhotons[i] > 0; |
---|
110 | if ( fCutMinEnergy || fCutMaxEnergy ) |
---|
111 | isInside &= ( fGlobalTrueEnergy[i] > fCutMinEnergy && |
---|
112 | fGlobalTrueEnergy[i] < fCutMaxEnergy); |
---|
113 | if ( fCutMinThetaOne || fCutMaxThetaOne ) |
---|
114 | isInside &= ( fGlobalTrueThetaOne[i] > fCutMinThetaOne && |
---|
115 | fGlobalTrueThetaOne[i] < fCutMaxThetaOne); |
---|
116 | if ( fCutMinTheta || fCutMaxTheta ) |
---|
117 | isInside &= ( fGlobalTrueThetaOne[i] > fCutMinTheta && |
---|
118 | fGlobalTrueThetaOne[i] < fCutMaxTheta); |
---|
119 | return isInside; |
---|
120 | |
---|
121 | } |
---|
122 | |
---|
123 | Bool_t GlobalHisto::SetEnergyCut(Float_t EMin, Float_t EMax) { |
---|
124 | if ( EMin > EMax ) return kFALSE; |
---|
125 | fCutMinEnergy = EMin; |
---|
126 | fCutMaxEnergy = EMax; |
---|
127 | return kTRUE; |
---|
128 | } |
---|
129 | |
---|
130 | Bool_t GlobalHisto::SetThetaOneCut(Float_t T1Min, Float_t T1Max) { |
---|
131 | if ( T1Min > T1Max ) return kFALSE; |
---|
132 | fCutMinThetaOne = T1Min; |
---|
133 | fCutMaxThetaOne = T1Max; |
---|
134 | return kTRUE; |
---|
135 | } |
---|
136 | |
---|
137 | Bool_t GlobalHisto::SetThetaCut(Float_t TMin, Float_t TMax) { |
---|
138 | if ( TMin > TMax ) return kFALSE; |
---|
139 | fCutMinTheta = TMin; |
---|
140 | fCutMaxTheta = TMax; |
---|
141 | return kTRUE; |
---|
142 | } |
---|
143 | |
---|
144 | Bool_t GlobalHisto::SetXVariable(Option_t *opt){ |
---|
145 | TString option(opt); |
---|
146 | Bool_t set(kFALSE); |
---|
147 | if ( set = !(option.CompareTo("Energy")) ){ |
---|
148 | fXVariable = fGlobalTrueEnergy; |
---|
149 | fXLabel = "Energy [EeV]"; |
---|
150 | fXTitle = "Energy"; |
---|
151 | } |
---|
152 | else if ( set = !(option.CompareTo("ThetaOne")) ) { |
---|
153 | fXVariable = fGlobalTrueThetaOne; |
---|
154 | fXLabel = "#theta_{1} [rad]"; |
---|
155 | fXTitle = "#theta_{1}"; |
---|
156 | } |
---|
157 | else if ( set = !(option.CompareTo("Theta")) ) { |
---|
158 | fXVariable = fGlobalTrueTheta; |
---|
159 | fXLabel = "#theta [rad]"; |
---|
160 | fXTitle = "#theta"; |
---|
161 | } |
---|
162 | |
---|
163 | if (set) { |
---|
164 | fCurrentX = opt; |
---|
165 | fXMin = fXVariable[TMath::LocMin(fNumEvents, fXVariable)]; |
---|
166 | fXMax = fXVariable[TMath::LocMax(fNumEvents, fXVariable)]; |
---|
167 | |
---|
168 | } |
---|
169 | return set; |
---|
170 | |
---|
171 | } |
---|
172 | |
---|
173 | TH1 * GlobalHisto::Do1DX() { |
---|
174 | |
---|
175 | TString hName = "EusoHF_G1D_True"; |
---|
176 | hName += fCurrentX; |
---|
177 | // Cleaning old histogram |
---|
178 | gDirectory->Delete(hName); |
---|
179 | |
---|
180 | Int_t binX(100); |
---|
181 | TH1F *th0=new TH1F( hName, fXTitle + " of the Showers", |
---|
182 | binX, fXMin, fXMax); |
---|
183 | for ( Int_t i=0; i < fNumEvents; i++) { |
---|
184 | if (IsInsideCuts(i)) |
---|
185 | th0->Fill(fXVariable[i]); |
---|
186 | } |
---|
187 | th0->SetLineColor(37); |
---|
188 | th0->SetFillColor(2); |
---|
189 | //th0->SetStats(kFALSE); |
---|
190 | //th0->SetXTitle("Energy [EeV]"); |
---|
191 | th0->SetXTitle(fXLabel); |
---|
192 | th0->SetYTitle("Events"); |
---|
193 | th0->Draw(); |
---|
194 | |
---|
195 | return th0; |
---|
196 | } |
---|
197 | |
---|
198 | TH1 * GlobalHisto::Do1DNumPhotons() { |
---|
199 | |
---|
200 | TString hName = "EusoHF_G1D_NumPhotons"; |
---|
201 | // Cleaning old histogram |
---|
202 | gDirectory->Delete(hName); |
---|
203 | |
---|
204 | |
---|
205 | Int_t binNP(100); |
---|
206 | Int_t minNP=fGlobalNumPhotons[TMath::LocMin(fNumEvents,fGlobalNumPhotons)]; |
---|
207 | Int_t maxNP=fGlobalNumPhotons[TMath::LocMax(fNumEvents,fGlobalNumPhotons)]; |
---|
208 | |
---|
209 | Int_t deltaNP = (Int_t)TMath::Ceil((Float_t)(maxNP-minNP)/ |
---|
210 | (Float_t)(binNP-2)); |
---|
211 | maxNP += deltaNP; |
---|
212 | |
---|
213 | TH1F *th0=new TH1F( hName, "Number of #gamma of the Showers", binNP, minNP, maxNP); |
---|
214 | for ( Int_t i=0; i < fNumEvents; i++) { |
---|
215 | if (IsInsideCuts(i)) |
---|
216 | th0->Fill(fGlobalNumPhotons[i]); |
---|
217 | } |
---|
218 | th0->SetLineColor(37); |
---|
219 | th0->SetFillColor(2); |
---|
220 | //th0->SetStats(kFALSE); |
---|
221 | //th0->SetXTitle("Energy [EeV]"); |
---|
222 | th0->SetXTitle(fXLabel); |
---|
223 | th0->SetYTitle("Events"); |
---|
224 | th0->Draw(); |
---|
225 | |
---|
226 | return th0; |
---|
227 | } |
---|
228 | |
---|
229 | |
---|
230 | // |
---|
231 | // Detected Photons by Electronics Threshold |
---|
232 | // |
---|
233 | |
---|
234 | TH1 * GlobalHisto::Do1DDetectedPhotonsFromChip(){ |
---|
235 | |
---|
236 | // some histo variables |
---|
237 | Int_t binMC(100); |
---|
238 | TString hname = "EusoHF_G1D_MadeCount"; |
---|
239 | // Cleaning old histogram |
---|
240 | gDirectory->Delete(hname); |
---|
241 | |
---|
242 | UChar_t *fPhotons_fMadeCount = new UChar_t[fGlobalMaxNumPhotons]; |
---|
243 | |
---|
244 | // getting branches |
---|
245 | TBranch *b_fPhotons_fMadeCount = fTree->GetBranch("fPhotons.fMadeCount"); |
---|
246 | |
---|
247 | //setting addresses |
---|
248 | b_fPhotons_fMadeCount->SetAddress(fPhotons_fMadeCount); |
---|
249 | |
---|
250 | Int_t *NumMadeCount = new Int_t[fNumEvents]; |
---|
251 | Int_t minMC, maxMC; |
---|
252 | |
---|
253 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
254 | |
---|
255 | NumMadeCount[i] = 0; |
---|
256 | b_fPhotons_fMadeCount->GetEntry(i); |
---|
257 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
258 | if (fPhotons_fMadeCount[k]) NumMadeCount[i]++; |
---|
259 | } |
---|
260 | } |
---|
261 | minMC = NumMadeCount[TMath::LocMin(fNumEvents, NumMadeCount)]; |
---|
262 | maxMC = NumMadeCount[TMath::LocMax(fNumEvents, NumMadeCount)]; |
---|
263 | |
---|
264 | Int_t deltaMC = (Int_t)TMath::Ceil((Float_t)(maxMC-minMC)/ |
---|
265 | (Float_t)(binMC-2)); |
---|
266 | maxMC+=deltaMC; |
---|
267 | minMC-=deltaMC; |
---|
268 | TH1 *th0=new TH1F( hname, "Detected #gamma from Chips", |
---|
269 | binMC, minMC, maxMC); |
---|
270 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
271 | if (IsInsideCuts(i)) |
---|
272 | th0->Fill(NumMadeCount[i]); |
---|
273 | } |
---|
274 | |
---|
275 | th0->SetLineColor(37); |
---|
276 | th0->SetFillColor(2); |
---|
277 | //th0->SetStats(kFALSE); |
---|
278 | th0->SetXTitle("Detected #gamma"); |
---|
279 | th0->SetYTitle("Events"); |
---|
280 | th0->Draw(); |
---|
281 | |
---|
282 | delete NumMadeCount; |
---|
283 | delete fPhotons_fMadeCount; |
---|
284 | |
---|
285 | return th0; |
---|
286 | } |
---|
287 | |
---|
288 | // |
---|
289 | // Detected Photons by Macrocell Trigger |
---|
290 | // |
---|
291 | |
---|
292 | TH1 * GlobalHisto::Do1DDetectedPhotonsFromMacrocells(){ |
---|
293 | |
---|
294 | // some histo variables |
---|
295 | Int_t binFO(100); |
---|
296 | TString hname = "EusoHF_G1D_MadeFastOR"; |
---|
297 | |
---|
298 | // Cleaning old histogram |
---|
299 | gDirectory->Delete(hname); |
---|
300 | |
---|
301 | UChar_t *fPhotons_fMadeFastOR = new UChar_t[fGlobalMaxNumPhotons]; |
---|
302 | |
---|
303 | // getting branches |
---|
304 | TBranch *b_fPhotons_fMadeFastOR = fTree->GetBranch("fPhotons.fMadeFastOR"); |
---|
305 | |
---|
306 | //setting addresses |
---|
307 | b_fPhotons_fMadeFastOR->SetAddress(fPhotons_fMadeFastOR); |
---|
308 | |
---|
309 | Int_t *NumMadeFastOR = new Int_t[fNumEvents]; |
---|
310 | Int_t minFO, maxFO; |
---|
311 | |
---|
312 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
313 | |
---|
314 | NumMadeFastOR[i] = 0; |
---|
315 | b_fPhotons_fMadeFastOR->GetEntry(i); |
---|
316 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
317 | if (fPhotons_fMadeFastOR[k]) NumMadeFastOR[i]++; |
---|
318 | } |
---|
319 | } |
---|
320 | minFO = NumMadeFastOR[TMath::LocMin(fNumEvents, NumMadeFastOR)]; |
---|
321 | maxFO = NumMadeFastOR[TMath::LocMax(fNumEvents, NumMadeFastOR)]; |
---|
322 | |
---|
323 | Int_t deltaFO = (Int_t)TMath::Ceil((Float_t)(maxFO-minFO)/ |
---|
324 | (Float_t)(binFO-2)); |
---|
325 | maxFO+=deltaFO; |
---|
326 | minFO-=deltaFO; |
---|
327 | TH1 *th0=new TH1F( hname, "Detected #gamma from Macrocells", |
---|
328 | binFO, minFO, maxFO); |
---|
329 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
330 | if (IsInsideCuts(i)) |
---|
331 | th0->Fill(NumMadeFastOR[i]); |
---|
332 | } |
---|
333 | |
---|
334 | th0->SetLineColor(37); |
---|
335 | th0->SetFillColor(2); |
---|
336 | //th0->SetStats(kFALSE); |
---|
337 | th0->SetXTitle("Detected #gamma"); |
---|
338 | th0->SetYTitle("Events"); |
---|
339 | th0->Draw(); |
---|
340 | |
---|
341 | delete NumMadeFastOR; |
---|
342 | delete fPhotons_fMadeFastOR; |
---|
343 | |
---|
344 | return th0; |
---|
345 | } |
---|
346 | |
---|
347 | |
---|
348 | // |
---|
349 | // Photons lost in the optics |
---|
350 | // |
---|
351 | |
---|
352 | TH1 * GlobalHisto::Do1DPhotonsLostInOptics(){ |
---|
353 | |
---|
354 | // some histo variables |
---|
355 | Int_t binNotHit(100); |
---|
356 | |
---|
357 | // Cleaning old histogram |
---|
358 | gDirectory->Delete("EusoHF_G1D_NoHitOnIFS"); |
---|
359 | |
---|
360 | UChar_t *fPhotons_fHitOnIFS = new UChar_t[fGlobalMaxNumPhotons]; |
---|
361 | |
---|
362 | // getting branches |
---|
363 | TBranch *b_fPhotons_fHitOnIFS = fTree->GetBranch("fPhotons.fHitOnIFS"); |
---|
364 | |
---|
365 | //setting addresses |
---|
366 | b_fPhotons_fHitOnIFS->SetAddress(fPhotons_fHitOnIFS); |
---|
367 | |
---|
368 | Int_t *NumNotHitOnIFS = new Int_t[fNumEvents]; |
---|
369 | Int_t minNotHit, maxNotHit; |
---|
370 | |
---|
371 | Int_t NumHitOnIFS; |
---|
372 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
373 | NumHitOnIFS = 0; |
---|
374 | b_fPhotons_fHitOnIFS->GetEntry(i); |
---|
375 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
376 | if (fPhotons_fHitOnIFS[k]) NumHitOnIFS++; |
---|
377 | } |
---|
378 | NumNotHitOnIFS[i] = fGlobalNumPhotons[i]-NumHitOnIFS; |
---|
379 | } |
---|
380 | minNotHit = NumNotHitOnIFS[TMath::LocMin(fNumEvents, NumNotHitOnIFS)]; |
---|
381 | maxNotHit = NumNotHitOnIFS[TMath::LocMax(fNumEvents, NumNotHitOnIFS)]; |
---|
382 | |
---|
383 | Int_t deltaNotHit = (Int_t)TMath::Ceil((Float_t)(maxNotHit-minNotHit)/ |
---|
384 | (Float_t)(binNotHit-2)); |
---|
385 | maxNotHit+=deltaNotHit; |
---|
386 | minNotHit-=deltaNotHit; |
---|
387 | TH1 *th0=new TH1F( "EusoHF_G1D_NoHitOnIFS", "Lost #gamma in the optics", |
---|
388 | binNotHit, minNotHit, maxNotHit); |
---|
389 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
390 | if (IsInsideCuts(i)) |
---|
391 | th0->Fill(NumNotHitOnIFS[i]); |
---|
392 | } |
---|
393 | |
---|
394 | th0->SetLineColor(37); |
---|
395 | th0->SetFillColor(2); |
---|
396 | //th0->SetStats(kFALSE); |
---|
397 | th0->SetXTitle("Lost #gamma"); |
---|
398 | th0->SetYTitle("Events"); |
---|
399 | th0->Draw(); |
---|
400 | |
---|
401 | delete NumNotHitOnIFS; |
---|
402 | delete fPhotons_fHitOnIFS; |
---|
403 | |
---|
404 | return th0; |
---|
405 | } |
---|
406 | |
---|
407 | // |
---|
408 | // Photons lost on the focal surface |
---|
409 | // |
---|
410 | |
---|
411 | TH1 * GlobalHisto::Do1DPhotonsLostOnFocalPlane(){ |
---|
412 | |
---|
413 | // some histo variables |
---|
414 | Int_t binNotSig(100); |
---|
415 | |
---|
416 | // Cleaning old histogram |
---|
417 | gDirectory->Delete("EusoHF_G1D_NoMadeSignal"); |
---|
418 | |
---|
419 | UChar_t *fPhotons_fHitOnIFS = new UChar_t[fGlobalMaxNumPhotons]; |
---|
420 | UChar_t *fPhotons_fMadeSignal = new UChar_t[fGlobalMaxNumPhotons]; |
---|
421 | |
---|
422 | // getting branches |
---|
423 | TBranch *b_fPhotons_fHitOnIFS = fTree->GetBranch("fPhotons.fHitOnIFS"); |
---|
424 | TBranch *b_fPhotons_fMadeSignal = fTree->GetBranch("fPhotons.fMadeSignal"); |
---|
425 | |
---|
426 | //setting addresses |
---|
427 | b_fPhotons_fHitOnIFS->SetAddress(fPhotons_fHitOnIFS); |
---|
428 | b_fPhotons_fMadeSignal->SetAddress(fPhotons_fMadeSignal); |
---|
429 | |
---|
430 | Int_t *NumNotMadeSignal = new Int_t[fNumEvents]; |
---|
431 | Int_t minNotSig, maxNotSig; |
---|
432 | |
---|
433 | Int_t NumHitOnIFS; |
---|
434 | Int_t NumMadeSignal; |
---|
435 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
436 | NumHitOnIFS = 0; |
---|
437 | NumMadeSignal = 0; |
---|
438 | b_fPhotons_fHitOnIFS->GetEntry(i); |
---|
439 | b_fPhotons_fMadeSignal->GetEntry(i); |
---|
440 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
441 | if (fPhotons_fHitOnIFS[k]) NumHitOnIFS++; |
---|
442 | if (fPhotons_fMadeSignal[k]) NumMadeSignal++; |
---|
443 | } |
---|
444 | NumNotMadeSignal[i] = NumHitOnIFS-NumMadeSignal; |
---|
445 | } |
---|
446 | minNotSig = NumNotMadeSignal[TMath::LocMin(fNumEvents, NumNotMadeSignal)]; |
---|
447 | maxNotSig = NumNotMadeSignal[TMath::LocMax(fNumEvents, NumNotMadeSignal)]; |
---|
448 | |
---|
449 | Int_t deltaNotHit = (Int_t)TMath::Ceil((Float_t)(maxNotSig-minNotSig)/ |
---|
450 | (Float_t)(binNotSig-2)); |
---|
451 | maxNotSig+=deltaNotHit; |
---|
452 | minNotSig-=deltaNotHit; |
---|
453 | TH1 *th0=new TH1F( "EusoHF_G1D_NoMadeSignal", "Lost #gamma on the focal plane", |
---|
454 | binNotSig, minNotSig, maxNotSig); |
---|
455 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
456 | if (IsInsideCuts(i)) |
---|
457 | th0->Fill(NumNotMadeSignal[i]); |
---|
458 | } |
---|
459 | |
---|
460 | th0->SetLineColor(37); |
---|
461 | th0->SetFillColor(2); |
---|
462 | //th0->SetStats(kFALSE); |
---|
463 | th0->SetXTitle("Lost #gamma"); |
---|
464 | th0->SetYTitle("Events"); |
---|
465 | th0->Draw(); |
---|
466 | |
---|
467 | delete NumNotMadeSignal; |
---|
468 | delete fPhotons_fHitOnIFS; |
---|
469 | |
---|
470 | return th0; |
---|
471 | } |
---|
472 | |
---|
473 | // |
---|
474 | // Correlation Detected Photons Vs X |
---|
475 | // |
---|
476 | |
---|
477 | TH1 * GlobalHisto::Do2DDetectedPhotonsVsX(){ |
---|
478 | TString hName = "EusoHF_G2D_DetectedPhotonsVs"; |
---|
479 | hName += fCurrentX; |
---|
480 | |
---|
481 | // some histo variables |
---|
482 | Int_t binMC(100), binX(100); |
---|
483 | |
---|
484 | // Cleaning old histograms |
---|
485 | gDirectory->Delete(hName); |
---|
486 | |
---|
487 | UChar_t *fPhotons_fMadeCount = new UChar_t[fGlobalMaxNumPhotons]; |
---|
488 | |
---|
489 | // getting branches |
---|
490 | TBranch *b_fPhotons_fMadeCount = fTree->GetBranch("fPhotons.fMadeCount"); |
---|
491 | |
---|
492 | // setting addresses |
---|
493 | b_fPhotons_fMadeCount->SetAddress(fPhotons_fMadeCount); |
---|
494 | |
---|
495 | //Float_t *TrueEnergy = new Float_t[fNumEvents]; |
---|
496 | Int_t *NumMadeCount = new Int_t[fNumEvents]; |
---|
497 | Int_t minMC(1000000), maxMC(0); |
---|
498 | // cout << "before main loop" << endl; |
---|
499 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
500 | // cout << "in the loop " << i << endl; |
---|
501 | NumMadeCount[i] = 0; |
---|
502 | b_fPhotons_fMadeCount->GetEntry(i); |
---|
503 | for ( Int_t k=0; k < fGlobalNumPhotons[i] ; k++){ |
---|
504 | if (fPhotons_fMadeCount[k]) NumMadeCount[i]++; |
---|
505 | } |
---|
506 | } |
---|
507 | minMC = NumMadeCount[TMath::LocMin(fNumEvents, NumMadeCount)]; |
---|
508 | maxMC = NumMadeCount[TMath::LocMax(fNumEvents, NumMadeCount)]; |
---|
509 | |
---|
510 | Int_t deltaMC = (Int_t)TMath::Ceil((maxMC-minMC)/(Float_t)(binMC-2)); |
---|
511 | maxMC+=deltaMC; |
---|
512 | //minMC-=deltaMC; |
---|
513 | //Float_t deltaEn = (maxEn-minEn)/(Float_t)(binEn-2); |
---|
514 | //maxEn+=deltaEn; |
---|
515 | //minEn-=deltaEn; |
---|
516 | |
---|
517 | TH2F *th0=new TH2F( hName, |
---|
518 | TString("Detected photons vs ") + fXTitle, binX, |
---|
519 | fXMin, fXMax, binMC, minMC, maxMC); |
---|
520 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
521 | if (IsInsideCuts(i)) |
---|
522 | th0->Fill(fXVariable[i],NumMadeCount[i]); |
---|
523 | } |
---|
524 | th0->SetMarkerStyle( 8 ); |
---|
525 | th0->SetMarkerColor( kRed ); |
---|
526 | //th0->SetStats(kFALSE); |
---|
527 | // th0->SetXTitle("Energy [EeV]"); |
---|
528 | th0->SetXTitle(fXLabel); |
---|
529 | th0->SetYTitle("Detected #gamma"); |
---|
530 | |
---|
531 | th0->Draw("scat"); |
---|
532 | delete NumMadeCount; |
---|
533 | delete fPhotons_fMadeCount; |
---|
534 | |
---|
535 | return th0; |
---|
536 | } |
---|
537 | |
---|
538 | // |
---|
539 | // Correlation A vs X |
---|
540 | // A = (Detected Photons)/Energy |
---|
541 | // |
---|
542 | |
---|
543 | TH1 * GlobalHisto::Do2DXCorrelation(){ |
---|
544 | TString hName = "EusoHF_G2D_DetPhOverEVs"; |
---|
545 | hName += fCurrentX; |
---|
546 | |
---|
547 | // some histo variables |
---|
548 | Int_t binA(100), binX(100); |
---|
549 | |
---|
550 | // Cleaning old histograms |
---|
551 | gDirectory->Delete(hName); |
---|
552 | |
---|
553 | UChar_t *fPhotons_fMadeCount = new UChar_t[fGlobalMaxNumPhotons]; |
---|
554 | |
---|
555 | // getting branches |
---|
556 | TBranch *b_fPhotons_fMadeCount = fTree->GetBranch("fPhotons.fMadeCount"); |
---|
557 | |
---|
558 | // setting addresses |
---|
559 | b_fPhotons_fMadeCount->SetAddress(fPhotons_fMadeCount); |
---|
560 | |
---|
561 | Int_t *NumMadeCount = new Int_t[fNumEvents]; |
---|
562 | Float_t minA(0.), maxA(1.); |
---|
563 | |
---|
564 | |
---|
565 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
566 | |
---|
567 | NumMadeCount[i] = 0; |
---|
568 | b_fPhotons_fMadeCount->GetEntry(i); |
---|
569 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
570 | if (fPhotons_fMadeCount[k]) NumMadeCount[i]++; |
---|
571 | } |
---|
572 | if ( minA > (Float_t)NumMadeCount[i]/fGlobalTrueEnergy[i] ) |
---|
573 | minA = (Float_t)NumMadeCount[i]/fGlobalTrueEnergy[i]; |
---|
574 | if ( maxA < (Float_t)NumMadeCount[i]/fGlobalTrueEnergy[i] ) |
---|
575 | maxA = (Float_t)NumMadeCount[i]/fGlobalTrueEnergy[i]; |
---|
576 | } |
---|
577 | |
---|
578 | Float_t deltaA = (maxA-minA)/(Float_t)(binA-2); |
---|
579 | maxA+=deltaA; |
---|
580 | minA-=deltaA; |
---|
581 | //Float_t deltaTh = (maxTh-minTh)/(Float_t)(binTh-2); |
---|
582 | //maxTh+=deltaTh; |
---|
583 | //minTh-=deltaTh; |
---|
584 | |
---|
585 | TH2F *th0=new TH2F( hName, TString("(Detected #gamma)/E vs ")+fXTitle, binX, fXMin, fXMax, binA, minA, maxA); |
---|
586 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
587 | if ( IsInsideCuts(i) ) |
---|
588 | th0->Fill(fXVariable[i],(Float_t)NumMadeCount[i]/fGlobalTrueEnergy[i]); |
---|
589 | } |
---|
590 | th0->SetMarkerStyle( 8 ); |
---|
591 | th0->SetMarkerColor( kRed ); |
---|
592 | //th0->SetStats(kFALSE); |
---|
593 | th0->SetXTitle(fXLabel); |
---|
594 | th0->SetYTitle("(Det. #gamma)/Energy [EeV]^{-1}"); |
---|
595 | |
---|
596 | th0->Draw("scat"); |
---|
597 | delete NumMadeCount; |
---|
598 | delete fPhotons_fMadeCount; |
---|
599 | |
---|
600 | return th0; |
---|
601 | } |
---|
602 | |
---|
603 | |
---|
604 | // |
---|
605 | // Histogram of the number of hit pixels |
---|
606 | // |
---|
607 | |
---|
608 | TH1 * GlobalHisto::Do1DHitPixels(){ |
---|
609 | |
---|
610 | // some histo variables |
---|
611 | Int_t binHP(100); |
---|
612 | |
---|
613 | // Cleaning old histograms |
---|
614 | gDirectory->Delete("EusoHF_G1D_HitPixels"); |
---|
615 | |
---|
616 | Int_t *fMacrocell_fNumPixels; |
---|
617 | Int_t fNumCells; |
---|
618 | |
---|
619 | // getting branches |
---|
620 | TBranch *b_fNumCells = fTree->GetBranch("fNumCells"); |
---|
621 | TBranch *b_fMacrocell_fNumPixels = fTree->GetBranch("fMacrocell.fNumPixels"); |
---|
622 | |
---|
623 | // setting addresses |
---|
624 | b_fNumCells->SetAddress(&fNumCells); |
---|
625 | |
---|
626 | Int_t *HitPixels = new Int_t[fNumEvents]; |
---|
627 | Int_t minHP, maxHP, maxNumCells(0); |
---|
628 | |
---|
629 | // retrieving maximum number of macrocells |
---|
630 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
631 | b_fNumCells->GetEntry(i); |
---|
632 | if (fNumCells > maxNumCells) maxNumCells = fNumCells; |
---|
633 | } |
---|
634 | // setting up the fNumPixel branch |
---|
635 | fMacrocell_fNumPixels = new Int_t[maxNumCells]; |
---|
636 | b_fMacrocell_fNumPixels->SetAddress(fMacrocell_fNumPixels); |
---|
637 | |
---|
638 | |
---|
639 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
640 | HitPixels[i]=0; |
---|
641 | b_fNumCells->GetEntry(i); |
---|
642 | b_fMacrocell_fNumPixels->GetEntry(i); |
---|
643 | for ( Int_t k=0; k < fNumCells; k++){ |
---|
644 | HitPixels[i]+=fMacrocell_fNumPixels[k]; |
---|
645 | } |
---|
646 | } |
---|
647 | |
---|
648 | minHP = HitPixels[TMath::LocMin(fNumEvents, HitPixels)]; |
---|
649 | maxHP = HitPixels[TMath::LocMax(fNumEvents, HitPixels)]; |
---|
650 | |
---|
651 | Int_t deltaHP = (Int_t)TMath::Ceil((maxHP-minHP)/(Float_t)(binHP-2)); |
---|
652 | maxHP+=deltaHP; |
---|
653 | minHP-=deltaHP; |
---|
654 | |
---|
655 | TH1 *th0=new TH1F( "EusoHF_G1D_HitPixels", "Hit Pixels", binHP, minHP, maxHP); |
---|
656 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
657 | if ( IsInsideCuts(i) ) |
---|
658 | th0->Fill(HitPixels[i]); |
---|
659 | } |
---|
660 | |
---|
661 | th0->SetLineColor(37); |
---|
662 | th0->SetFillColor(2); |
---|
663 | // th0->SetStats(kFALSE); |
---|
664 | th0->SetXTitle("Hit Pixels"); |
---|
665 | th0->SetYTitle("Events"); |
---|
666 | th0->Draw(); |
---|
667 | delete HitPixels; |
---|
668 | delete fMacrocell_fNumPixels; |
---|
669 | |
---|
670 | return th0; |
---|
671 | } |
---|
672 | |
---|
673 | // |
---|
674 | // Histogram of the number of hit Macrocells |
---|
675 | // |
---|
676 | |
---|
677 | TH1 * GlobalHisto::Do1DHitMacroCells(){ |
---|
678 | |
---|
679 | // some histo variables |
---|
680 | Int_t binMC(20); |
---|
681 | |
---|
682 | // Cleaning old histograms |
---|
683 | gDirectory->Delete("EusoHF_G1D_HitMacrocells"); |
---|
684 | |
---|
685 | Int_t fNumCells; |
---|
686 | |
---|
687 | // getting branches |
---|
688 | TBranch *b_fNumCells = fTree->GetBranch("fNumCells"); |
---|
689 | |
---|
690 | // setting addresses |
---|
691 | b_fNumCells->SetAddress(&fNumCells); |
---|
692 | |
---|
693 | Int_t *HitMacrocells = new Int_t[fNumEvents]; |
---|
694 | Int_t minMC, maxMC; |
---|
695 | |
---|
696 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
697 | b_fNumCells->GetEntry(i); |
---|
698 | HitMacrocells[i]=fNumCells; |
---|
699 | } |
---|
700 | |
---|
701 | minMC = HitMacrocells[TMath::LocMin(fNumEvents, HitMacrocells)]; |
---|
702 | maxMC = HitMacrocells[TMath::LocMax(fNumEvents, HitMacrocells)]; |
---|
703 | |
---|
704 | Int_t deltaMC=maxMC-minMC; |
---|
705 | if (binMC > deltaMC) { |
---|
706 | binMC=deltaMC+1; |
---|
707 | maxMC+=1; |
---|
708 | } |
---|
709 | // else { |
---|
710 | // maxMC+=deltaMC*0.1; |
---|
711 | // minMC-=deltaMC*0.1; |
---|
712 | // } |
---|
713 | TH1 *th0=new TH1F( "EusoHF_G1D_HitMacrocells", "Hit Macrocells", binMC, minMC, maxMC); |
---|
714 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
715 | if ( IsInsideCuts(i) ) |
---|
716 | th0->Fill(HitMacrocells[i]); |
---|
717 | } |
---|
718 | |
---|
719 | th0->SetLineColor(37); |
---|
720 | th0->SetFillColor(2); |
---|
721 | // th0->SetStats(kFALSE); |
---|
722 | th0->SetXTitle("Hit Macrocells"); |
---|
723 | th0->SetYTitle("Events"); |
---|
724 | th0->Draw(); |
---|
725 | delete HitMacrocells; |
---|
726 | |
---|
727 | return th0; |
---|
728 | } |
---|
729 | |
---|
730 | // |
---|
731 | // Histogram of the number of Fee |
---|
732 | // |
---|
733 | |
---|
734 | TH1 * GlobalHisto::Do1DNumOfFee(){ |
---|
735 | |
---|
736 | // some histo variables |
---|
737 | Int_t binNFee(100); |
---|
738 | |
---|
739 | // Cleaning old histograms |
---|
740 | gDirectory->Delete("EusoHF_G1D_NumOfFee"); |
---|
741 | |
---|
742 | Int_t fNumFee; |
---|
743 | |
---|
744 | // getting branches |
---|
745 | TBranch *b_fNumFee = fTree->GetBranch("fNumFee"); |
---|
746 | |
---|
747 | // setting addresses |
---|
748 | b_fNumFee->SetAddress(&fNumFee); |
---|
749 | |
---|
750 | Int_t *NumOfFee = new Int_t[fNumEvents]; |
---|
751 | Int_t minNFee, maxNFee; |
---|
752 | |
---|
753 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
754 | b_fNumFee->GetEntry(i); |
---|
755 | NumOfFee[i]=fNumFee; |
---|
756 | } |
---|
757 | |
---|
758 | minNFee = NumOfFee[TMath::LocMin(fNumEvents, NumOfFee)]; |
---|
759 | maxNFee = NumOfFee[TMath::LocMax(fNumEvents, NumOfFee)]; |
---|
760 | |
---|
761 | Int_t deltaNFee = (Int_t)TMath::Ceil((maxNFee-minNFee)/ |
---|
762 | (Float_t)(binNFee-2)); |
---|
763 | maxNFee+=deltaNFee; |
---|
764 | minNFee-=deltaNFee; |
---|
765 | |
---|
766 | TH1 *th0=new TH1F( "EusoHF_G1D_NumOfFee", "Number of Fee", binNFee, minNFee, maxNFee); |
---|
767 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
768 | if ( IsInsideCuts(i) ) |
---|
769 | th0->Fill(NumOfFee[i]); |
---|
770 | } |
---|
771 | |
---|
772 | th0->SetLineColor(37); |
---|
773 | th0->SetFillColor(2); |
---|
774 | // th0->SetStats(kFALSE); |
---|
775 | th0->SetXTitle("Number of Fee"); |
---|
776 | th0->SetYTitle("Events"); |
---|
777 | th0->Draw(); |
---|
778 | delete NumOfFee; |
---|
779 | |
---|
780 | return th0; |
---|
781 | } |
---|
782 | |
---|
783 | // |
---|
784 | // Histogram of the number of AFee |
---|
785 | // |
---|
786 | |
---|
787 | TH1 * GlobalHisto::Do1DNumOfAFee(){ |
---|
788 | |
---|
789 | // some histo variables |
---|
790 | Int_t binNAFee(100); |
---|
791 | |
---|
792 | // Cleaning old histograms |
---|
793 | gDirectory->Delete("EusoHF_G1D_NumOfAFee"); |
---|
794 | |
---|
795 | Int_t fNumAFee; |
---|
796 | |
---|
797 | // getting branches |
---|
798 | TBranch *b_fNumAFee = fTree->GetBranch("fNumAFee"); |
---|
799 | |
---|
800 | // setting addresses |
---|
801 | b_fNumAFee->SetAddress(&fNumAFee); |
---|
802 | |
---|
803 | Int_t *NumOfAFee = new Int_t[fNumEvents]; |
---|
804 | Int_t minNAFee, maxNAFee; |
---|
805 | |
---|
806 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
807 | b_fNumAFee->GetEntry(i); |
---|
808 | NumOfAFee[i]=fNumAFee; |
---|
809 | } |
---|
810 | |
---|
811 | minNAFee = NumOfAFee[TMath::LocMin(fNumEvents, NumOfAFee)]; |
---|
812 | maxNAFee = NumOfAFee[TMath::LocMax(fNumEvents, NumOfAFee)]; |
---|
813 | |
---|
814 | Int_t deltaNAFee = (Int_t)TMath::Ceil((maxNAFee-minNAFee)/ |
---|
815 | (Float_t)(binNAFee-2)); |
---|
816 | maxNAFee+=deltaNAFee; |
---|
817 | minNAFee-=deltaNAFee; |
---|
818 | |
---|
819 | TH1 *th0=new TH1F( "EusoHF_G1D_NumOfAFee", "Number of AFee", binNAFee, minNAFee, maxNAFee); |
---|
820 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
821 | if ( IsInsideCuts(i) ) |
---|
822 | th0->Fill(NumOfAFee[i]); |
---|
823 | } |
---|
824 | |
---|
825 | th0->SetLineColor(37); |
---|
826 | th0->SetFillColor(2); |
---|
827 | // th0->SetStats(kFALSE); |
---|
828 | th0->SetXTitle("Number of Fee"); |
---|
829 | th0->SetYTitle("Events"); |
---|
830 | th0->Draw(); |
---|
831 | delete NumOfAFee; |
---|
832 | |
---|
833 | return th0; |
---|
834 | } |
---|
835 | |
---|
836 | |
---|
837 | |
---|
838 | // |
---|
839 | // Histogram of the number of triggers versus X |
---|
840 | // |
---|
841 | |
---|
842 | TH1 * GlobalHisto::Do1DTriggerVsX() { |
---|
843 | TString hName = "EusoHF_G1D_TriggerVs"; |
---|
844 | hName += fCurrentX; |
---|
845 | |
---|
846 | // some histo variables |
---|
847 | Int_t binX(100); |
---|
848 | |
---|
849 | // Cleaning old histograms |
---|
850 | gDirectory->Delete(hName); |
---|
851 | |
---|
852 | Int_t *fMacrocell_fHasTriggered; |
---|
853 | Int_t fNumCells; |
---|
854 | |
---|
855 | // getting branches |
---|
856 | TBranch *b_fNumCells = fTree->GetBranch("fNumCells"); |
---|
857 | TBranch *b_fMacrocell_fHasTriggered = fTree->GetBranch("fMacrocell.fHasTriggered"); |
---|
858 | |
---|
859 | // setting addresses |
---|
860 | b_fNumCells->SetAddress(&fNumCells); |
---|
861 | |
---|
862 | Int_t *HasTriggered = new Int_t[fNumEvents]; |
---|
863 | Int_t maxNumCells(0); |
---|
864 | |
---|
865 | // retrieving maximum number of macrocells |
---|
866 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
867 | b_fNumCells->GetEntry(i); |
---|
868 | if (fNumCells > maxNumCells) maxNumCells = fNumCells; |
---|
869 | } |
---|
870 | // setting up the fHasTriggered branch |
---|
871 | fMacrocell_fHasTriggered = new Int_t[maxNumCells]; |
---|
872 | b_fMacrocell_fHasTriggered->SetAddress(fMacrocell_fHasTriggered); |
---|
873 | |
---|
874 | |
---|
875 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
876 | HasTriggered[i]=0; |
---|
877 | b_fNumCells->GetEntry(i); |
---|
878 | b_fMacrocell_fHasTriggered->GetEntry(i); |
---|
879 | for ( Int_t k=0; k < fNumCells; k++){ |
---|
880 | HasTriggered[i]+=fMacrocell_fHasTriggered[k]; |
---|
881 | } |
---|
882 | } |
---|
883 | //Float_t deltaEn = (maxEn-minEn)/(Float_t)(binEn-2); |
---|
884 | //maxEn+=deltaEn; |
---|
885 | //minEn-=deltaEn; |
---|
886 | |
---|
887 | TH1 *th0=new TH1F( hName, TString("Trigger vs ")+fXTitle, binX, fXMin, fXMax); |
---|
888 | TH1 *th1=new TH1F( hName+"_Temp", fXTitle, binX, fXMin, fXMax); |
---|
889 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
890 | if (IsInsideCuts(i)){ |
---|
891 | if ( HasTriggered[i] ) |
---|
892 | th0->Fill(fXVariable[i]); |
---|
893 | th1->Fill(fXVariable[i]); |
---|
894 | } |
---|
895 | } |
---|
896 | |
---|
897 | th0->Divide(th1); |
---|
898 | th0->SetLineColor(37); |
---|
899 | th0->SetFillColor(2); |
---|
900 | //th0->SetStats(kFALSE); |
---|
901 | th0->SetXTitle(fXLabel); |
---|
902 | th0->SetYTitle("% trigger"); |
---|
903 | th0->Draw(); |
---|
904 | |
---|
905 | delete th1; |
---|
906 | delete HasTriggered; |
---|
907 | delete fMacrocell_fHasTriggered; |
---|
908 | |
---|
909 | return th0; |
---|
910 | } |
---|
911 | |
---|
912 | |
---|
913 | // |
---|
914 | // Correlation Average (Num of Photons per Pixel)/X |
---|
915 | // |
---|
916 | |
---|
917 | TH1 * GlobalHisto::Do2DAveragePhotonVsX() { |
---|
918 | TString hName = "EusoHF_G1D_AveragePhotonVs"; |
---|
919 | hName += fCurrentX; |
---|
920 | |
---|
921 | |
---|
922 | // some histo variables |
---|
923 | Int_t binAv(100), binX(100); |
---|
924 | |
---|
925 | // Cleaning old histograms |
---|
926 | gDirectory->Delete(hName); |
---|
927 | |
---|
928 | UChar_t *fPhotons_fMadeCount = new UChar_t[fGlobalMaxNumPhotons]; |
---|
929 | Int_t *fMacrocell_fNumPixels; |
---|
930 | Int_t fNumCells; |
---|
931 | |
---|
932 | // getting branches |
---|
933 | TBranch *b_fPhotons_fMadeCount = fTree->GetBranch("fPhotons.fMadeCount"); |
---|
934 | TBranch *b_fNumCells = fTree->GetBranch("fNumCells"); |
---|
935 | TBranch *b_fMacrocell_fNumPixels = fTree->GetBranch("fMacrocell.fNumPixels"); |
---|
936 | |
---|
937 | // setting addresses |
---|
938 | b_fNumCells->SetAddress(&fNumCells); |
---|
939 | b_fPhotons_fMadeCount->SetAddress(fPhotons_fMadeCount); |
---|
940 | |
---|
941 | Int_t *NumMadeCount = new Int_t[fNumEvents]; |
---|
942 | Int_t *HitPixels = new Int_t[fNumEvents]; |
---|
943 | Float_t minAv(10000.), maxAv(0.); |
---|
944 | Int_t maxNumCells(0); |
---|
945 | |
---|
946 | // retrieving maximum number of macrocells |
---|
947 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
948 | b_fNumCells->GetEntry(i); |
---|
949 | if (fNumCells > maxNumCells) maxNumCells = fNumCells; |
---|
950 | } |
---|
951 | // setting up the fNumPixel branch |
---|
952 | fMacrocell_fNumPixels = new Int_t[maxNumCells]; |
---|
953 | b_fMacrocell_fNumPixels->SetAddress(fMacrocell_fNumPixels); |
---|
954 | |
---|
955 | |
---|
956 | for ( Int_t i=0; i < fNumEvents ; i++) { |
---|
957 | |
---|
958 | NumMadeCount[i] = 0; |
---|
959 | HitPixels[i]=0; |
---|
960 | |
---|
961 | b_fNumCells->GetEntry(i); |
---|
962 | b_fPhotons_fMadeCount->GetEntry(i); |
---|
963 | b_fMacrocell_fNumPixels->GetEntry(i); |
---|
964 | for ( Int_t k=0; k < fGlobalNumPhotons[i]; k++){ |
---|
965 | if (fPhotons_fMadeCount[k]) NumMadeCount[i]++; |
---|
966 | } |
---|
967 | for ( Int_t k=0; k < fNumCells; k++){ |
---|
968 | HitPixels[i]+=fMacrocell_fNumPixels[k]; |
---|
969 | } |
---|
970 | if (HitPixels[i] != 0){ |
---|
971 | if ( minAv > (Float_t)NumMadeCount[i]/(Float_t)HitPixels[i] ) |
---|
972 | minAv = (Float_t)NumMadeCount[i]/(Float_t)HitPixels[i]; |
---|
973 | if ( maxAv < (Float_t)NumMadeCount[i]/(Float_t)HitPixels[i] ) |
---|
974 | maxAv = (Float_t)NumMadeCount[i]/(Float_t)HitPixels[i]; |
---|
975 | } |
---|
976 | } |
---|
977 | Float_t deltaAv = (maxAv-minAv)/(Float_t)(binAv-2); |
---|
978 | maxAv+=deltaAv; |
---|
979 | minAv-=deltaAv; |
---|
980 | //Float_t deltaAl = (maxAl-minAl)/(Float_t)(binAl-2); |
---|
981 | //maxAl+=deltaAl; |
---|
982 | //minAl-=deltaAl; |
---|
983 | |
---|
984 | TH2F *th0=new TH2F( hName, TString("Average #gamma per Pixel Vs " |
---|
985 | + fXTitle), binX, fXMin, fXMax, binAv, minAv, maxAv); |
---|
986 | for (Int_t i=0; i < fNumEvents; i++) { |
---|
987 | if (HitPixels[i] != 0 && IsInsideCuts(i) ) |
---|
988 | th0->Fill(fXVariable[i],(Float_t)NumMadeCount[i]/(Float_t)HitPixels[i]); |
---|
989 | } |
---|
990 | th0->SetMarkerStyle( 8 ); |
---|
991 | th0->SetMarkerColor( kRed ); |
---|
992 | //th0->SetStats(kFALSE); |
---|
993 | th0->SetXTitle(fXLabel); |
---|
994 | th0->SetYTitle("(Det. #gamma)/N_{pixel}"); |
---|
995 | |
---|
996 | th0->Draw("scat"); |
---|
997 | |
---|
998 | // Adding TLatex |
---|
999 | // some operations to calculate text position |
---|
1000 | |
---|
1001 | Float_t frameHeight = th0->GetYaxis()->GetXmax()- |
---|
1002 | th0->GetYaxis()->GetXmin(); |
---|
1003 | Float_t frameWidth = th0->GetXaxis()->GetXmax()- |
---|
1004 | th0->GetXaxis()->GetXmin(); |
---|
1005 | Float_t textSize = 0.04; |
---|
1006 | Float_t textSizeFactor = frameHeight/ |
---|
1007 | (1-gPad->GetTopMargin()-gPad->GetBottomMargin()); |
---|
1008 | Float_t textTopBorder = th0->GetYaxis()->GetXmax() |
---|
1009 | -1.5*textSize*textSizeFactor; |
---|
1010 | Float_t textLeftBorder = th0->GetXaxis()->GetXmin()+0.01*frameWidth; |
---|
1011 | |
---|
1012 | TLatex t; |
---|
1013 | Char_t txt[200]; |
---|
1014 | t.SetTextFont( 72 ); |
---|
1015 | t.SetTextColor( 50 ); |
---|
1016 | t.SetTextSize( textSize ); |
---|
1017 | sprintf(txt,"N^{o} of ev. (HitPixel>0) : %d", (Int_t) th0->GetEntries()); |
---|
1018 | |
---|
1019 | t.DrawLatex( textLeftBorder, textTopBorder, txt); |
---|
1020 | |
---|
1021 | //if (minEnergy != 0 || maxEnergy != 0) { |
---|
1022 | // sprintf( txt, "Energy cut: Min = %.2e, Max = %.2e", |
---|
1023 | // minEnergy, maxEnergy); |
---|
1024 | // |
---|
1025 | // t.DrawLatex( textLeftBorder, |
---|
1026 | // textTopBorder-textSize*textSizeFactor*1.1, txt); |
---|
1027 | // } |
---|
1028 | |
---|
1029 | delete NumMadeCount; |
---|
1030 | delete HitPixels; |
---|
1031 | delete fPhotons_fMadeCount; |
---|
1032 | delete fMacrocell_fNumPixels; |
---|
1033 | |
---|
1034 | return th0; |
---|
1035 | |
---|
1036 | } |
---|
1037 | |
---|