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

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