source: fact/tools/rootmacros/PulseTemplates/pixel.C@ 13520

Last change on this file since 13520 was 13520, checked in by Jens Buss, 12 years ago
update some bugfixes in the destructor
File size: 17.3 KB
Line 
1#include "pixel.h" // class implemented
2using namespace std;
3
4/////////////////////////////// PUBLIC ///////////////////////////////////////
5
6//============================= LIFECYCLE ====================================
7
8//Pixel::Pixel(int pixelID)
9//{
10// Chid = pixelID;
11// max_puslse_order = 1;
12// hMaxOverlay = NULL;
13// hEdgeOverlay = NULL;
14// hMaxProfile = NULL;
15// hEdgeProfile = NULL;
16// hList = NULL;
17
18//}
19
20Pixel::Pixel(
21 int pixelID,
22 int maxPulsorder,
23 int verbosityLevel,
24 int pixelOverlayXaxisLeft,
25 int pixelOverlayXaxisRight,
26 int bSLMean,
27 int gainMean,
28 TString options
29 )
30{
31 mChid = pixelID;
32 mMaxPulseOrder = maxPulsorder;
33 mVerbosityLevel = verbosityLevel;
34 mOptions = options;
35 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
36 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
37 mBSLMean = bSLMean;
38 mGainMean = gainMean;
39
40 hMaxOverlay = new TH2F*[mMaxPulseOrder];
41 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
42 hMaxProfile = new TProfile*[mMaxPulseOrder];
43 hEdgeProfile = new TProfile*[mMaxPulseOrder];
44
45 if (mOptions.Contains("S") )
46 {
47 hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
48 }
49
50 if (mOptions.Contains("R") )
51 {
52 hRisingEdgeToMax = new TH1F*[mMaxPulseOrder];
53 }
54
55 if (mOptions.Contains("P") )
56 {
57 hPosOfMax = new TH1F*[mMaxPulseOrder];
58 }
59
60 hList = new TObjArray;
61
62 BookPixelHistos();
63 BookDistributionHistos();
64}
65
66Pixel::~Pixel()
67{
68 if (mVerbosityLevel > 1) cout << endl << "...delete histograms of pixel " << mChid ;
69
70 DeletePixelHistos();
71 DeleteDistributionHistos();
72
73 delete hList;
74 hList = NULL;
75
76}// ~Pixel
77
78
79//============================= OPERATORS ====================================
80
81//XX&
82//XX::operator=(const XX&);
83//{
84// return *this;
85
86//}// =
87
88//============================= OPERATIONS ===================================
89void
90Pixel::BookPixelHistos()
91{
92 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
93 TString histo_name;
94
95 for (int order = 0; order < mMaxPulseOrder; order++)
96 {
97 histo_name = "hMaxOverlay";
98 histo_name += mChid;
99 histo_name += "_";
100 histo_name += order;
101 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
102 hMaxOverlay[order]=new TH2F(
103 histo_name,
104 "Overlay of detected pulses of one pulse order for one Pixel",
105 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
106 (-1*mPixelOverlayXaxisLeft)-0.5,
107 mPixelOverlayXaxisRight-0.5 ,
108 512,
109 -55.5,
110 200.5
111 );
112/*
113 SetHistogramAttributes(
114 "PeakMaxGaus",
115 order,
116 gMaxGausAttrib,
117 MaxAmplOfFirstPulse
118 );
119 */
120 hMaxOverlay[order]->SetAxisRange(
121 mBSLMean - 5,
122 (mGainMean*(order+1)) + 10,
123 "Y");
124 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
125 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
126 //hMaxProfile->SetBit(TH2F::kCanRebin);
127 hList->Add( hMaxOverlay[order] );
128
129//------------------------------------------------------------------------
130/*
131 SetHistogramAttributes(
132 "PeakMaxGaus",
133 order,
134 gMaxGausAttrib,
135 MaxAmplOfFirstPulse
136 );
137 */
138 histo_name = "hEdgeOverlay";
139 histo_name += mChid;
140 histo_name += "_";
141 histo_name += order;
142 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
143 hEdgeOverlay[order] = new TH2F(
144 histo_name,
145 "Overlay at rising edge of detected pulses of one pulse order for one Pixel ",
146 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
147 (-1*mPixelOverlayXaxisLeft)-0.5,
148 mPixelOverlayXaxisRight-0.5 ,
149 512,
150 -55.5,
151 200.5
152 );
153
154 hEdgeOverlay[order]->SetAxisRange(
155 mBSLMean - 5,
156 (mGainMean*(order+1)) + 10,
157 "Y");
158 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
159 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
160 hList->Add( hEdgeOverlay[order] );
161
162 //------------------------------------------------------------------------
163/*
164 SetHistogramAttributes(
165 "PeakMaxGaus",
166 order,
167 gMaxGausAttrib,
168 MaxAmplOfFirstPulse
169 );
170 */
171 histo_name = "hMaxProfile";
172 histo_name += mChid;
173 histo_name += "_";
174 histo_name += order;
175 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
176 hMaxProfile[order] = new TProfile(
177 histo_name,
178 "Mean value of each slice in overlay plot (Tprofile)",
179 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
180 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
181 mPixelOverlayXaxisRight-0.5 , //xup
182 // 512, //nbinsy
183 -55.5, //ylow
184 300.5, //yup
185 "s"); //option
186 hMaxProfile[order]->SetAxisRange(
187 mBSLMean - 5,
188 (mGainMean*(order+1)) + 10,
189 "Y");
190 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
191 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
192 //hMaxProfile->SetBit(TH2F::kCanRebin);
193 hList->Add( hMaxProfile[order] );
194
195
196 //------------------------------------------------------------------------
197/*
198 SetHistogramAttributes(
199 "PeakMaxGaus",
200 order,
201 gMaxGausAttrib,
202 MaxAmplOfFirstPulse
203 );
204 */
205 histo_name = "hEdgeProfile";
206 histo_name += mChid;
207 histo_name += "_";
208 histo_name += order;
209 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
210 hEdgeProfile[order] = new TProfile(
211 histo_name,
212 "Mean value of each slice in overlay plot (Tprofile)",
213 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
214 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
215 mPixelOverlayXaxisRight-0.5 , //xup
216 // 512, //nbinsy
217 -55.5, //ylow
218 300.5, //yup
219 "s"); //option
220 hEdgeProfile[order]->SetLineColor(kRed);
221 hEdgeProfile[order]->SetAxisRange(
222 mBSLMean - 5,
223 (mGainMean*(order+1)) + 10,
224 "Y");
225 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
226 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
227 //hMaxProfile->SetBit(TH2F::kCanRebin);
228 hList->Add( hEdgeProfile[order] );
229
230 }
231 if (mVerbosityLevel > 2) cout << "...done" << endl;
232}
233//end of BookPixelHistos
234//----------------------------------------------------------------------------
235
236
237void
238Pixel::DrawHistograms(
239 TCanvas* pixelCanvas,
240 int* histoFrameNr
241 )
242{
243 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
244 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
245 {
246 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
247 hMaxOverlay[pulse_order]->Draw("COLZ");
248 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
249 hMaxProfile[pulse_order]->Draw("COLZ");
250 hEdgeProfile[pulse_order]->Draw("SAME");
251
252 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
253 hEdgeOverlay[pulse_order]->Draw("COLZ");
254 }
255}
256// end of DrawPulseHistograms
257//----------------------------------------------------------------------------
258
259
260void
261Pixel::BookDistributionHistos( )
262{
263 if (!mOptions.IsNull() )
264 {
265 TString histo_name;
266 for (int order =0; order < mMaxPulseOrder; order++)
267 {
268 if (mVerbosityLevel > 2) cout << endl
269 << "...book distribution histograms"
270 << endl;
271
272 if (mOptions.Contains("S"))
273 {
274 histo_name = "hSlopeRisingEdge";
275 histo_name += mChid;
276 histo_name += "_";
277 histo_name += order;
278 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
279 hSlopeRisingEdge[order] = new TH1F (
280 histo_name,
281 "Distribution of rising edge",
282 600,
283 -10.1,
284 10.1
285 );
286 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
287 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
288 hList->Add( hSlopeRisingEdge[order] );
289 }
290
291 if (mOptions.Contains("R"))
292 {
293 histo_name = "hRisingEdgeToMax";
294 histo_name += mChid;
295 histo_name += "_";
296 histo_name += order;
297 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
298 hRisingEdgeToMax[order] = new TH1F (
299 histo_name,
300 "Deviation of rising edge and maximum",
301 600,
302 -10.1,
303 10.1
304 );
305 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
306 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
307 hList->Add( hRisingEdgeToMax[order] );
308 }
309
310 if (mOptions.Contains("P"))
311 {
312 histo_name = "hPosOfMax";
313 histo_name += mChid;
314 histo_name += "_";
315 histo_name += order;
316 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
317 hPosOfMax[order] = new TH1F (
318 histo_name,
319 "Deviation of rising edge and maximum",
320 600,
321 -10.1,
322 10.1
323 );
324 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
325 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
326 hList->Add( hPosOfMax[order] );
327 }
328
329 if (mVerbosityLevel > 2) cout << "...done" << endl;
330 }
331 }
332}
333
334void
335Pixel::DrawDistributionHistograms(
336 TCanvas* pixelCanvas,
337 int* histoFrameNr
338 )
339{
340 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
341 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
342 {
343 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
344 hSlopeRisingEdge[pulse_order]->Draw();
345 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
346 hRisingEdgeToMax[pulse_order]->Draw();
347
348 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
349 hPosOfMax[pulse_order]->Draw();
350 }
351}
352// end of DrawDistributionHistograms
353//----------------------------------------------------------------------------
354
355void
356Pixel::SavePixelHistograms(
357 const char* outRootFileName,
358 bool saveResults
359 )
360{
361 cout << endl << "Saving histograms of Pixel# " << mChid
362 << " Adress " << &mChid;
363 if (!saveResults) return;
364 cout << endl << "#### ";
365 SaveHistograms(
366 outRootFileName,
367 CreateSubDirName( mChid ),
368 hList,
369 saveResults,
370 mVerbosityLevel
371 );
372}
373// end of SavePixelHistograms
374//----------------------------------------------------------------------------
375
376void
377Pixel::DeletePixelHistos()
378{
379 if (mVerbosityLevel > 2) cout << endl << "\t...delete current overlay histograms" ;
380 cout << endl << "Deleting histograms of Pixel# " << mChid
381 << " Adress " << &mChid;
382// for (int order = 0;
383// order < mMaxPulseOrder;
384// order ++)
385// {
386//// if (mVerbosityLevel > 3)
387// cout << endl << "\t\t...deleting hMaxOverlay"
388// << mChid << "_" << order
389// << " hMaxOverlay[order] adr " << hMaxOverlay[order]
390// << " hMaxOverlay adr " << hMaxOverlay
391// ;
392
393// delete hMaxOverlay[order];
394// hMaxOverlay[order] = NULL;
395
396// if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
397// << mChid << "_" << order ;
398// delete hEdgeOverlay[order];
399// hEdgeOverlay[order] = NULL;
400
401// if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
402// << mChid << "_" << order ;
403// delete hMaxProfile[order];
404// hMaxProfile[order] = NULL;
405
406// if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
407// << mChid << "_" << order ;
408// delete hEdgeProfile[order];
409// hEdgeProfile[order] = NULL;
410// }
411 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
412
413 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
414 delete[] hMaxOverlay;
415 hMaxOverlay = NULL;
416
417 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
418 delete[] hEdgeOverlay;
419 hEdgeOverlay = NULL;
420
421 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
422 delete[] hMaxProfile;
423 hMaxProfile = NULL;
424
425 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
426 delete[] hEdgeProfile;
427 hEdgeProfile = NULL;
428}
429// end of DeletePixelHistos
430//----------------------------------------------------------------------------
431
432void
433Pixel::DeleteDistributionHistos()
434{
435 if (mVerbosityLevel > 2) cout << endl
436 << "\t...delete current distribution histograms" ;
437
438// for (int order = 0;
439// order < mMaxPulseOrder;
440// order ++)
441// {
442// if (mOptions.Contains("S"))
443// {
444// if (mVerbosityLevel > 3) cout << endl
445// << "\t\t...deleting hSlopeRisingEdge"
446// << mChid << "_" << order ;
447// delete hSlopeRisingEdge[order];
448// }
449
450// if (mOptions.Contains("R"))
451// {
452// if (mVerbosityLevel > 3) cout << endl
453// << "\t\t...deleting hRisingEdgeToMax"
454// << mChid << "_" << order ;
455//// delete hRisingEdgeToMax[order];
456// }
457
458// if (mOptions.Contains("P"))
459// {
460// if (mVerbosityLevel > 3) cout << endl
461// << "\t\t...deleting hPosOfMax"
462// << mChid << "_" << order ;
463
464//// delete hPosOfMax[order];
465// }
466
467// }
468 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
469
470 if (mOptions.Contains("S"))
471 {
472 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge";
473 delete[] hSlopeRisingEdge;
474 hSlopeRisingEdge = NULL;
475 }
476
477 if (mOptions.Contains("R"))
478 {
479 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax";
480 delete[] hRisingEdgeToMax;
481 hRisingEdgeToMax = NULL;
482 }
483
484 if (mOptions.Contains("P"))
485 {
486 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax";
487 delete[] hPosOfMax;
488 hPosOfMax = NULL;
489 }
490}
491// end of DeletePixelHistos
492//----------------------------------------------------------------------------
493
494//============================= ACESS ===================================
495//============================= INQUIRY ===================================
496/////////////////////////////// PROTECTED ///////////////////////////////////
497
498/////////////////////////////// PRIVATE ///////////////////////////////////
499
500
501
502
503
504
505
506
Note: See TracBrowser for help on using the repository browser.