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

Last change on this file since 13961 was 13855, checked in by Jens Buss, 12 years ago
modification of verbosity output
File size: 35.9 KB
Line 
1#include <iostream>
2
3#include "rootfilehandler.h"
4#include "pixel.h" // class implemented
5using namespace std;
6
7/////////////////////////////// PUBLIC ///////////////////////////////////////
8
9//============================= LIFECYCLE ====================================
10
11
12Pixel::Pixel(
13 int pixelID,
14 int maxPulsorder,
15 int verbosityLevel,
16 bool stats,
17 TString options,
18 int pixelOverlayXaxisLeft,
19 int pixelOverlayXaxisRight,
20 float bSLMean,
21 float gainMean,
22 TFile* filename,
23 TFile* outfilename
24 )
25{
26 mConstructorType = 1; //important for deletion 0 delete distribution 1 delete TemplateHistos
27
28 mChid = pixelID;
29 mMaxPulseOrder = maxPulsorder;
30 mVerbosityLevel = verbosityLevel;
31 mStats = stats;
32 mOptions = options;
33 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
34 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
35 mBSLMean = bSLMean;
36 mGainMean = gainMean;
37 mRootFile = filename;
38 mOutRootFile = outfilename;
39
40 hMaxOverlay = new TH2F*[mMaxPulseOrder];
41 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
42 hMaxProfile = new TProfile*[mMaxPulseOrder];
43 hEdgeProfile = new TProfile*[mMaxPulseOrder];
44
45 hPixelMax = new TH1F*[mMaxPulseOrder];
46 hPixelMedian = new TH1F*[mMaxPulseOrder];
47 hPixelMean = new TH1F*[mMaxPulseOrder];
48
49 hPixelEdgeMax = new TH1F*[mMaxPulseOrder];
50 hPixelEdgeMedian = new TH1F*[mMaxPulseOrder];
51 hPixelEdgeMean = new TH1F*[mMaxPulseOrder];
52
53 hList = new TList();
54 if (options.Contains("L"))
55 {
56 LoadPulseHistos( );
57 }
58 else
59 {
60 BookPixelHistos();
61 }
62 BookTemplateHistos();
63 BookEdgeTemplateHistos();
64}
65
66Pixel::Pixel(
67 int pixelID,
68 int maxPulsorder,
69 int verbosityLevel,
70 bool stats,
71 TString options,
72 int pixelOverlayXaxisLeft,
73 int pixelOverlayXaxisRight,
74 float bSLMean,
75 float gainMean
76 )
77{
78 mConstructorType = 0;
79
80 mChid = pixelID;
81 mMaxPulseOrder = maxPulsorder;
82 mVerbosityLevel = verbosityLevel;
83 mStats = stats; ///TODO: HANDOVER THE VALUE
84 mOptions = options;
85 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
86 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
87 mBSLMean = bSLMean;
88 mGainMean = gainMean;
89
90 hMaxOverlay = new TH2F*[mMaxPulseOrder];
91 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
92 hMaxProfile = new TProfile*[mMaxPulseOrder];
93 hEdgeProfile = new TProfile*[mMaxPulseOrder];
94
95 if (mOptions.Contains("S") )
96 {
97 hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
98 }
99
100 if (mOptions.Contains("R") )
101 {
102 hRisingEdgeToMax = new TH1I*[mMaxPulseOrder];
103 }
104
105 if (mOptions.Contains("M") )
106 {
107 hPosOfMax = new TH1I*[mMaxPulseOrder];
108 }
109
110 hList = new TList();
111
112 BookPixelHistos();
113 BookDistributionHistos();
114}
115
116Pixel::~Pixel()
117{
118 if (mVerbosityLevel > 1)
119 {
120 cout << endl << "...delete histograms of pixel " << mChid ;
121 cout << endl << "...mConstructorType = " << mConstructorType ;
122 }
123
124 if (mConstructorType == 0)
125 {
126 DeleteDistributionHistos();
127 }
128
129 if (mConstructorType == 1)
130 {
131 DeleteTemplateHistos();
132 DeleteEdgeTemplateHistos();
133 }
134
135 DeletePixelHistos();
136 delete hList;
137 hList = NULL;
138 if (mVerbosityLevel > 1)
139 {
140 cout << endl << "...histograms of pixel " << mChid ;
141 cout << "...deleted " << endl ;
142 }
143}// ~Pixel
144
145
146//============================= OPERATORS ====================================
147
148//XX&
149//XX::operator=(const XX&);
150//{
151// return *this;
152
153//}// =
154
155//============================= OPERATIONS ===================================
156void
157Pixel::DrawOverlayHistograms(
158 TCanvas** pixelCanvas,
159 int* histoFrameNr
160 )
161{
162 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
163 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
164 {
165 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
166 hMaxOverlay[pulse_order]->Draw("COLZ");
167 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
168 hMaxProfile[pulse_order]->Draw();
169
170 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
171 hEdgeOverlay[pulse_order]->Draw("COLZ");
172 pixelCanvas[pulse_order]->cd( histoFrameNr[3] );
173 hEdgeProfile[pulse_order]->Draw();
174 }
175}
176// end of DrawOverlayHistograms
177//----------------------------------------------------------------------------
178
179void
180Pixel::DrawDistributionHistograms(
181 TCanvas** pixelCanvas,
182 int* histoFrameNr
183 )
184{
185 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
186 bool nothing_to_fill = true;
187 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
188 {
189 if (mOptions.Contains("S") )
190 {
191 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
192 hSlopeRisingEdge[pulse_order]->Draw();
193 nothing_to_fill = false;
194 }
195
196 if (mOptions.Contains("R") )
197 {
198 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
199 hRisingEdgeToMax[pulse_order]->Draw();
200 nothing_to_fill = false;
201 }
202
203 if (mOptions.Contains("M") )
204 {
205 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
206 hPosOfMax[pulse_order]->Draw();
207 nothing_to_fill = false;
208 }
209
210 }
211 if (nothing_to_fill)
212 {
213 cout << endl << "there were NO DISTRIBUTION HISTOGRAMS to fill" << endl;
214 }
215}
216// end of DrawDistributionHistograms
217//----------------------------------------------------------------------------
218
219void
220Pixel::DrawTemplateHistograms(
221 TCanvas** pixelCanvas,
222 int* histoFrameNr
223 )
224{
225 if (mVerbosityLevel > 2) cout << "...drawing Template histograms" << endl ;
226 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
227 {
228 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
229 hPixelMax[pulse_order]->Draw();
230
231 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
232 hPixelMedian[pulse_order]->Draw();
233
234 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
235 hPixelMean[pulse_order]->Draw();
236
237 }
238}
239// end of DrawTemplateHistograms
240//----------------------------------------------------------------------------
241
242void
243Pixel::DrawEdgeTemplateHistograms(
244 TCanvas** pixelCanvas,
245 int* histoFrameNr
246 )
247{
248 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ;
249 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
250 {
251 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
252 hPixelEdgeMax[pulse_order]->Draw();
253
254 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
255 hPixelEdgeMedian[pulse_order]->Draw();
256
257 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
258 hPixelEdgeMean[pulse_order]->Draw();
259
260 }
261}
262// end of DrawTemplateHistograms
263//----------------------------------------------------------------------------
264
265
266
267
268void
269Pixel::SavePixelHistograms(
270 TString outRootFileName,
271 bool saveResults
272 )
273{
274 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid;
275 if (!saveResults) return;
276 SaveHistograms(
277 outRootFileName,
278 CreateSubDirName( mChid ),
279 hList,
280 saveResults,
281 mVerbosityLevel
282 );
283}
284// end of SavePixelHistograms
285//----------------------------------------------------------------------------
286
287TString
288Pixel::HistoName(
289 TString histoname,
290 int order
291 )
292{
293 histoname += mChid;
294 histoname += "_";
295 histoname += order;
296 return histoname;
297}
298
299TString
300Pixel::ChooseCycleNumber(
301 TString histoname,
302 int cycleNumber
303 )
304{
305 histoname += ";";
306 histoname += cycleNumber;
307 return histoname;
308}
309
310TString
311Pixel::HistoTitle(
312 TString histo_title,
313 int order
314 )
315{
316 histo_title += " [Pixel_Order] ";
317 histo_title += mChid;
318 histo_title += "_";
319 histo_title += order;
320 return histo_title;
321}
322
323TString
324Pixel::CsvFileName(
325 TString path,
326 TString overlayMethod,
327 int order
328 )
329{
330 path += "CSV/";
331 path += overlayMethod;
332 path += "OverlayTemplate";
333 path += "_";
334 path += mChid;
335 path += "_";
336 path += order;
337 path += ".csv";
338 return path;
339}
340
341
342//============================= ACESS ===================================
343//============================= INQUIRY ===================================
344/////////////////////////////// PROTECTED ///////////////////////////////////
345
346/////////////////////////////// PRIVATE ///////////////////////////////////
347
348void
349Pixel::BookPixelHistos()
350{
351 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
352 for (int order = 0; order < mMaxPulseOrder; order++)
353 {
354 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl;
355 hMaxOverlay[order]=new TH2F(
356 HistoName("hMaxOverlay", order),
357 HistoTitle("Overlay at peak maximum of detected pulses of", order),
358 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
359 (-1*mPixelOverlayXaxisLeft)-0.5,
360 mPixelOverlayXaxisRight-0.5 ,
361 512,
362 -55.5,
363 200.5
364 );
365
366 hMaxOverlay[order]->SetAxisRange(
367 mBSLMean - 5,
368 (mGainMean*(order+1)) + 10,
369 "Y");
370 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
371 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
372 //hMaxProfile->SetBit(TH2F::kCanRebin);
373 hMaxOverlay[order]->SetStats(mStats);
374 hList->Add( hMaxOverlay[order] );
375
376//------------------------------------------------------------------------
377
378 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl;
379 hEdgeOverlay[order] = new TH2F(
380 HistoName("hEdgeOverlay", order),
381 HistoTitle("Overlay at rising edge of detected pulses of", order),
382 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
383 (-1*mPixelOverlayXaxisLeft)-0.5,
384 mPixelOverlayXaxisRight-0.5 ,
385 512,
386 -55.5,
387 200.5
388 );
389
390 hEdgeOverlay[order]->SetAxisRange(
391 mBSLMean - 5,
392 (mGainMean*(order+1)) + 10,
393 "Y");
394 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
395 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
396 hEdgeOverlay[order]->SetStats(mStats);
397 hList->Add( hEdgeOverlay[order] );
398
399 //------------------------------------------------------------------------
400
401 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl;
402 hMaxProfile[order] = new TProfile(
403 HistoName("hMaxProfile", order),
404 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
405 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
406 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
407 mPixelOverlayXaxisRight-0.5 , //xup
408 // 512, //nbinsy
409 -55.5, //ylow
410 300.5, //yup
411 "s"); //option
412 hMaxProfile[order]->SetAxisRange(
413 mBSLMean - 5,
414 (mGainMean*(order+1)) + 10,
415 "Y");
416 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
417 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
418 //hMaxProfile->SetBit(TH2F::kCanRebin);
419 hMaxProfile[order]->SetStats(mStats);
420 hList->Add( hMaxProfile[order] );
421
422
423 //------------------------------------------------------------------------
424
425 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl;
426 hEdgeProfile[order] = new TProfile(
427 HistoName("hEdgeProfile", order),
428 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
429 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
430 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
431 mPixelOverlayXaxisRight-0.5 , //xup
432 // 512, //nbinsy
433 -55.5, //ylow
434 300.5, //yup
435 "s"); //option
436 hEdgeProfile[order]->SetLineColor(kRed);
437 hEdgeProfile[order]->SetAxisRange(
438 mBSLMean - 5,
439 (mGainMean*(order+1)) + 10,
440 "Y");
441 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
442 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
443 //hMaxProfile->SetBit(TH2F::kCanRebin);
444 hEdgeProfile[order]->SetStats(mStats);
445 hList->Add( hEdgeProfile[order] );
446
447 }
448 if (mVerbosityLevel > 2) cout << "...done" << endl;
449}
450//end of BookPixelHistos
451//----------------------------------------------------------------------------
452
453void
454Pixel::BookDistributionHistos( )
455{
456 if (!mOptions.IsNull() )
457 {
458 int x_min = 0;
459 int x_max = 0;
460
461 for (int order =0; order < mMaxPulseOrder; order++)
462 {
463 if (mVerbosityLevel > 2) cout << endl
464 << "...book distribution histograms"
465 << endl;
466
467 if (mOptions.Contains("S"))
468 {
469 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
470 hSlopeRisingEdge[order] = new TH1F (
471 HistoName("hSlopeRisingEdge", order),
472 HistoTitle("Distribution of rising edge's slope", order),
473 600,
474 -10.1,
475 10.1
476 );
477 hSlopeRisingEdge[order]->SetAxisRange(
478 -1,
479 7,
480 "X");
481 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" );
482 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
483 hSlopeRisingEdge[order]->SetStats(mStats);
484 hList->Add( hSlopeRisingEdge[order] );
485 }
486
487 if (mOptions.Contains("R"))
488 {
489 x_min = -15;
490 x_max = 35;
491
492 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl;
493 hRisingEdgeToMax[order] = new TH1I (
494 HistoName("hRisingEdgeToMax", order),
495 HistoTitle("Distribution of distance between rising edge and pulse's maximum", order),
496 x_max -x_min,
497 x_min,
498 x_max
499 );
500 hSlopeRisingEdge[order]->SetAxisRange(
501 -5,
502 25,
503 "X");
504 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
505 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
506 hRisingEdgeToMax[order]->SetStats(mStats);
507 hList->Add( hRisingEdgeToMax[order] );
508 }
509
510 if (mOptions.Contains("M"))
511 {
512 x_min = 10;
513 x_max = 290;
514 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl;
515 hPosOfMax[order] = new TH1I (
516 HistoName("hPosOfMax", order),
517 HistoTitle("Distribution of pulse's maximum's positon", order),
518 x_max - x_min,
519 x_min,
520 x_max
521 );
522 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
523 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
524 hRisingEdgeToMax[order]->SetStats(mStats);
525 hList->Add( hPosOfMax[order] );
526 }
527
528 if (mVerbosityLevel > 2) cout << "...done" << endl;
529 }
530 }
531}
532//end of BookDistributionHistos
533//----------------------------------------------------------------------------
534
535void
536Pixel::BookTemplateHistos()
537{
538 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
539 for (int order = 0; order < mMaxPulseOrder; order++)
540 {
541 if (mVerbosityLevel > 3)
542 {
543 cout << "\t...booking " << HistoName("hPixelMax", order) << endl;
544 }
545
546 hPixelMax[order]=new TH1F(
547 HistoName("hPixelMax", order),
548 HistoTitle("Maximum value of each slice in overlay plot of", order),
549 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
550 (-1*mPixelOverlayXaxisLeft)-0.5,
551 mPixelOverlayXaxisRight-0.5
552 );
553
554 hPixelMax[order]->SetAxisRange(
555 mBSLMean - 5,
556 (mGainMean*(order+1)) + 10,
557 "Y");
558 hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
559 hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
560 //hMaxProfile->SetBit(TH2F::kCanRebin);
561 hPixelMax[order]->SetStats(mStats);
562 hList->Add( hPixelMax[order] );
563
564//------------------------------------------------------------------------
565
566 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMean", order) << endl;
567 hPixelMean[order] = new TH1F(
568 HistoName("hPixelMean", order),
569 HistoTitle("Mean value of each slice in overlay plot of", order),
570 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
571 (-1*mPixelOverlayXaxisLeft)-0.5,
572 mPixelOverlayXaxisRight-0.5
573 );
574 hPixelMean[order]->SetLineColor(kBlue);
575 hPixelMean[order]->SetAxisRange(
576 mBSLMean - 5,
577 (mGainMean*(order+1)) + 10,
578 "Y");
579 hPixelMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
580 hPixelMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
581 hPixelMean[order]->SetStats(mStats);
582 hList->Add( hPixelMean[order] );
583
584 //------------------------------------------------------------------------
585
586 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMedian", order) << endl;
587 hPixelMedian[order] = new TH1F(
588 HistoName("hPixelMedian", order),
589 HistoTitle("Median value of each slice in overlay plot of", order),
590 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
591 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
592 mPixelOverlayXaxisRight-0.5 //xup
593 );
594 hPixelMedian[order]->SetLineColor(kRed);
595 hPixelMedian[order]->SetAxisRange(
596 mBSLMean - 5,
597 (mGainMean*(order+1)) + 10,
598 "Y");
599 hPixelMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
600 hPixelMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
601 //hMaxProfile->SetBit(TH2F::kCanRebin);
602 hPixelMedian[order]->SetStats(mStats);
603 hList->Add( hPixelMedian[order] );
604
605 }
606 if (mVerbosityLevel > 2) cout << "...done" << endl;
607}
608//end of BookTemplateHistos
609//----------------------------------------------------------------------------
610
611void
612Pixel::BookEdgeTemplateHistos()
613{
614 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
615 for (int order = 0; order < mMaxPulseOrder; order++)
616 {
617 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl;
618 hPixelEdgeMax[order]=new TH1F(
619 HistoName("hPixelEdgeMax", order),
620 HistoTitle("Maximum value of each slice in overlay plot of", order),
621 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
622 (-1*mPixelOverlayXaxisLeft)-0.5,
623 mPixelOverlayXaxisRight-0.5
624 );
625
626 hPixelEdgeMax[order]->SetAxisRange(
627 mBSLMean - 5,
628 (mGainMean*(order+1)) + 10,
629 "Y");
630 hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
631 hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
632 //hMaxProfile->SetBit(TH2F::kCanRebin);
633 hPixelEdgeMax[order]->SetStats(mStats);
634 hList->Add( hPixelEdgeMax[order] );
635
636//------------------------------------------------------------------------
637
638 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl;
639 hPixelEdgeMean[order] = new TH1F(
640 HistoName("hPixelEdgeMean", order),
641 HistoTitle("Mean value of each slice in overlay plot of", order),
642 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
643 (-1*mPixelOverlayXaxisLeft)-0.5,
644 mPixelOverlayXaxisRight-0.5
645 );
646 hPixelEdgeMean[order]->SetLineColor(kBlue);
647 hPixelEdgeMean[order]->SetAxisRange(
648 mBSLMean - 5,
649 (mGainMean*(order+1)) + 10,
650 "Y");
651 hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
652 hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
653 hPixelEdgeMean[order]->SetStats(mStats);
654 hList->Add( hPixelEdgeMean[order] );
655
656 //------------------------------------------------------------------------
657
658 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl;
659 hPixelEdgeMedian[order] = new TH1F(
660 HistoName("hPixelEdgeMedian", order),
661 HistoTitle("Median value of each slice in overlay plot of", order),
662 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
663 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
664 mPixelOverlayXaxisRight-0.5 //xup
665 );
666 hPixelEdgeMedian[order]->SetLineColor(kRed);
667 hPixelEdgeMedian[order]->SetAxisRange(
668 mBSLMean - 5,
669 (mGainMean*(order+1)) + 10,
670 "Y");
671 hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
672 hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
673 //hMaxProfile->SetBit(TH2F::kCanRebin);
674 hPixelEdgeMedian[order]->SetStats(mStats);
675 hList->Add( hPixelEdgeMedian[order] );
676
677 }
678 if (mVerbosityLevel > 2) cout << "...done" << endl;
679}
680//end of BookEdgeTemplateHistos
681//----------------------------------------------------------------------------
682
683void
684Pixel::LoadPulseHistos()
685{
686 mRootFile->cd();
687
688 if (mVerbosityLevel > 2)
689 {
690 if (mVerbosityLevel > 3)
691 {
692 mRootFile->ls();
693 }
694 cout << "loading current File: " ;
695 gFile->pwd();
696 }
697
698 mRootFile->cd( CreateSubDirName( mChid ) ); //Go to pixel's subdirectory
699 mDirectory = gDirectory;
700
701 if (mVerbosityLevel > 2)
702 {
703 if (mVerbosityLevel > 3)
704 {
705 gDirectory->ls();
706 }
707 cout << "Current Directory: " ;
708 gDirectory->pwd();
709 }
710
711// mPixelOverlayXaxisRight =70; ///TODO: get it from the root file
712// mPixelOverlayXaxisLeft =230; ///TODO: get it from the root file
713// mBSLMean =-1; ///TODO: get it from the root file
714// mGainMean =9; ///TODO: get it from the root file
715// mOptions ="SRM"; ///TODO: get it from the root file
716
717 if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl;
718 for (int order = 0; order < mMaxPulseOrder; order++)
719 {
720
721 if (mVerbosityLevel > 3) cout << "\t...loading " << ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) << endl;
722 hMaxOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) );
723
724 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeOverlay", order) << endl;
725 hEdgeOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeOverlay", order), 1) );
726
727 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hMaxProfile", order) << endl;
728 hMaxProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxProfile", order), 1) );
729
730 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeProfile", order) << endl;
731 hEdgeProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeProfile", order), 1) );
732 }
733
734}
735// end of LoadPulseHistos
736//----------------------------------------------------------------------------
737
738void
739Pixel::DeletePixelHistos()
740{
741 if (mVerbosityLevel > 2)
742 {
743 cout << endl
744 << endl
745 << "\t...delete current overlay histograms of Pixel# " << mChid;
746 }
747 for (int order = 0;
748 order < mMaxPulseOrder;
749 order ++)
750 {
751 if (mVerbosityLevel > 3)
752 cout << endl << "\t\t...deleting hMaxOverlay"
753 << mChid << "_" << order;
754
755 delete hMaxOverlay[order];
756 hMaxOverlay[order] = NULL;
757
758 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
759 << mChid << "_" << order ;
760 delete hEdgeOverlay[order];
761 hEdgeOverlay[order] = NULL;
762
763 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
764 << mChid << "_" << order ;
765 delete hMaxProfile[order];
766 hMaxProfile[order] = NULL;
767
768 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
769 << mChid << "_" << order ;
770 delete hEdgeProfile[order];
771 hEdgeProfile[order] = NULL;
772 }
773 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
774
775 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
776 delete[] hMaxOverlay;
777 hMaxOverlay = NULL;
778
779 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
780 delete[] hEdgeOverlay;
781 hEdgeOverlay = NULL;
782
783 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
784 delete[] hMaxProfile;
785 hMaxProfile = NULL;
786
787 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
788 delete[] hEdgeProfile;
789 hEdgeProfile = NULL;
790}
791// end of DeletePixelHistos
792//----------------------------------------------------------------------------
793
794void
795Pixel::DeleteDistributionHistos()
796{
797 if (mVerbosityLevel > 2)
798 {
799 cout << endl
800 << "\t...delete current distribution histograms" ;
801 }
802
803 for (int order = 0;
804 order < mMaxPulseOrder;
805 order ++)
806 {
807 if (mOptions.Contains("S"))
808 {
809 if (mVerbosityLevel > 3) cout << endl
810 << "\t\t...deleting hSlopeRisingEdge"
811 << mChid << "_" << order ;
812 delete hSlopeRisingEdge[order];
813 }
814
815 if (mOptions.Contains("R"))
816 {
817 if (mVerbosityLevel > 3) cout << endl
818 << "\t\t...deleting hRisingEdgeToMax"
819 << mChid << "_" << order ;
820 delete hRisingEdgeToMax[order];
821 }
822
823 if (mOptions.Contains("M"))
824 {
825 if (mVerbosityLevel > 3) cout << endl
826 << "\t\t...deleting hPosOfMax"
827 << mChid << "_" << order ;
828
829 delete hPosOfMax[order];
830 }
831
832 }
833 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
834
835 if (mOptions.Contains("S"))
836 {
837 if (mVerbosityLevel > 3)
838 cout << endl << "\t\t...deleting hSlopeRisingEdge";
839 delete[] hSlopeRisingEdge;
840 hSlopeRisingEdge = NULL;
841 }
842
843 if (mOptions.Contains("R"))
844 {
845 if (mVerbosityLevel > 3)
846 cout << endl << "\t\t...deleting hRisingEdgeToMax";
847 delete[] hRisingEdgeToMax;
848 hRisingEdgeToMax = NULL;
849 }
850
851 if (mOptions.Contains("M"))
852 {
853 if (mVerbosityLevel > 3)
854 cout << endl << "\t\t...deleting hPosOfMax";
855 delete[] hPosOfMax;
856 hPosOfMax = NULL;
857 }
858}
859// end of DeletePixelHistos
860//----------------------------------------------------------------------------
861
862void
863Pixel::DeleteTemplateHistos()
864{
865 if (mVerbosityLevel > 2)
866 {
867 cout << endl
868 << "\t...delete current template histograms of Pixel# " << mChid;
869 }
870 for (int order = 0;
871 order < mMaxPulseOrder;
872 order ++)
873 {
874 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean"
875 << mChid << "_" << order ;
876 delete hPixelMean[order];
877 hPixelMean[order] = NULL;
878
879 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian"
880 << mChid << "_" << order ;
881 delete hPixelMedian[order];
882 hPixelMedian[order] = NULL;
883
884 if (mVerbosityLevel > 3)
885 cout << endl << "\t\t...deleting hPixelMax"
886 << mChid << "_" << order;
887 delete hPixelMax[order];
888 hPixelMax[order] = NULL;
889
890 }
891 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
892
893 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax";
894 delete[] hPixelMax;
895 hPixelMax = NULL;
896
897 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian";
898 delete[] hPixelMedian;
899 hPixelMedian = NULL;
900
901 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean";
902 delete[] hPixelMean;
903 hPixelMean = NULL;
904}
905// end of DeleteTemplateHistos
906//----------------------------------------------------------------------------
907
908void
909Pixel::DeleteEdgeTemplateHistos()
910{
911 if (mVerbosityLevel > 2)
912 {
913 cout << endl
914 << "\t...delete current Edge template histograms of Pixel# " << mChid;
915 }
916 for (int order = 0;
917 order < mMaxPulseOrder;
918 order ++)
919 {
920 if (mVerbosityLevel > 3)
921 cout << endl << "\t\t...deleting hPixelEdgeMax"
922 << mChid << "_" << order;
923
924 delete hPixelEdgeMax[order];
925 hPixelEdgeMax[order] = NULL;
926
927 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"
928 << mChid << "_" << order ;
929 delete hPixelEdgeMedian[order];
930 hPixelEdgeMedian[order] = NULL;
931
932 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"
933 << mChid << "_" << order ;
934 delete hPixelEdgeMean[order];
935 hPixelEdgeMean[order] = NULL;
936
937 }
938 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
939
940 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax";
941 delete[] hPixelEdgeMax;
942 hPixelEdgeMax = NULL;
943
944 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian";
945 delete[] hPixelEdgeMedian;
946 hPixelEdgeMedian = NULL;
947
948 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean";
949 delete[] hPixelEdgeMean;
950 hPixelEdgeMean = NULL;
951}
952// end of DeleteTemplateHistos
953//----------------------------------------------------------------------------
954
955void
956Pixel::MakeTH1Pretty(
957 TH1* histo,
958 TString histName,
959 TString histTitle,
960 int order
961 )
962{
963 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
964
965 histo->SetNameTitle(
966 HistoName(histName, order),
967 HistoTitle(histTitle, order)
968 );
969
970 histo->SetBins(
971 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
972 (-1*mPixelOverlayXaxisLeft)-0.5,
973 mPixelOverlayXaxisRight-0.5
974 );
975
976 histo->SetAxisRange(
977 mBSLMean - 5,
978 (mGainMean*(order+1)) + 10,
979 "Y");
980
981 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
982 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
983 //histo->SetBit(TH2F::kCanRebin);
984 histo->SetStats(mStats);
985}
986// end of MakeTH2Pretty
987//----------------------------------------------------------------------------
988
989
990void
991Pixel::MakeTH2Pretty(
992 TH2* histo,
993 TString histName,
994 TString histTitle,
995 int order
996 )
997{
998 if (mVerbosityLevel > 3) cout << "\t...designing " << HistoName(histName, order) << endl;
999
1000 histo->SetNameTitle(
1001 HistoName(histName, order),
1002 HistoTitle(histTitle, order)
1003 );
1004
1005 histo->SetBins(
1006 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1007 (-1*mPixelOverlayXaxisLeft)-0.5,
1008 mPixelOverlayXaxisRight-0.5 ,
1009 512,
1010 -55.5,
1011 200.5
1012 );
1013
1014 histo->SetAxisRange(
1015 mBSLMean - 5,
1016 (mGainMean*(order+1)) + 10,
1017 "Y");
1018
1019 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1020 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1021 //histo->SetBit(TH2F::kCanRebin);
1022 histo->SetStats(mStats);
1023}
1024// end of MakeTH2Pretty
1025//----------------------------------------------------------------------------
1026
1027void
1028Pixel::MakeTProfilePretty(
1029 TProfile* histo,
1030 TString histName,
1031 TString histTitle,
1032 int order
1033 )
1034{
1035 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1036
1037 histo->SetNameTitle(
1038 HistoName(histName, order),
1039 HistoTitle(histTitle, order)
1040 );
1041
1042 histo->SetBins(
1043 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1044 (-1*mPixelOverlayXaxisLeft)-0.5,
1045 mPixelOverlayXaxisRight-0.5
1046 );
1047 histo->SetOption( "s" );
1048
1049 histo->SetAxisRange(
1050 mBSLMean - 5,
1051 (mGainMean*(order+1)) + 10,
1052 "Y");
1053
1054 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1055 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1056 //histo->SetBit(TH2F::kCanRebin);
1057 histo->SetStats(mStats);
1058}
1059// end of MakeTProfilePretty
1060//----------------------------------------------------------------------------
1061
1062
1063
Note: See TracBrowser for help on using the repository browser.