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

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