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

Last change on this file since 14780 was 14747, checked in by Jens Buss, 12 years ago
add member markerstyle, defind markers of templates
File size: 39.2 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 int mrkStyle =1;
240 int mrkSize = 2;
241 if (mVerbosityLevel > 2) cout << "...drawing Template histograms" << endl ;
242 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
243 {
244 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
245 hMaxOverlay[pulse_order]->Draw("COLZ");
246
247 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
248 hPixelMax[pulse_order]->Draw("E1");
249 hPixelMax[pulse_order]->SetMarkerColor(kBlue);
250 hPixelMax[pulse_order]->SetLineColor(kBlack);
251 hPixelMax[pulse_order]->SetMarkerStyle(mrkStyle);
252 hPixelMax[pulse_order]->SetMarkerSize(mrkSize);
253
254 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
255 hPixelMedian[pulse_order]->Draw("E1");
256 hPixelMedian[pulse_order]->SetMarkerColor(kBlue);
257 hPixelMedian[pulse_order]->SetLineColor(kBlack);
258 hPixelMedian[pulse_order]->SetMarkerStyle(mrkStyle);
259 hPixelMedian[pulse_order]->SetMarkerSize(mrkSize);
260
261 pixelCanvas[pulse_order]->cd( histoFrameNr[3] );
262 hPixelMean[pulse_order]->Draw("E1");
263 hPixelMean[pulse_order]->SetMarkerColor(kBlue);
264 hPixelMean[pulse_order]->SetLineColor(kBlack);
265 hPixelMean[pulse_order]->SetMarkerStyle(mrkStyle);
266 hPixelMean[pulse_order]->SetMarkerSize(mrkSize);
267// hPixelMax[pulse_order]->Draw("SAME");
268// hPixelMedian[pulse_order]->Draw("SAME");
269
270 }
271}
272// end of DrawTemplateHistograms
273//----------------------------------------------------------------------------
274
275void
276Pixel::DrawEdgeTemplateHistograms(
277 TCanvas** pixelCanvas,
278 int* histoFrameNr
279 )
280{
281 int mrkStyle = 1;
282 int mrkSize = 3;
283
284 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ;
285 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
286 {
287 pixelCanvas[pulse_order]->cd( histoFrameNr[4] );
288 hEdgeOverlay[pulse_order]->Draw("COLZ");
289
290 pixelCanvas[pulse_order]->cd( histoFrameNr[5] );
291 hPixelEdgeMax[pulse_order]->Draw("E1");
292 hPixelEdgeMax[pulse_order]->SetLineColor(kBlack);
293 hPixelEdgeMax[pulse_order]->SetMarkerColor(kBlue);
294 hPixelEdgeMax[pulse_order]->SetMarkerStyle(mrkStyle);
295 hPixelEdgeMax[pulse_order]->SetMarkerSize(mrkSize);
296
297 pixelCanvas[pulse_order]->cd( histoFrameNr[6] );
298 hPixelEdgeMedian[pulse_order]->Draw("E1");
299 hPixelEdgeMedian[pulse_order]->SetLineColor(kBlack);
300 hPixelEdgeMedian[pulse_order]->SetMarkerColor(kBlue);
301 hPixelEdgeMedian[pulse_order]->SetMarkerStyle(mrkStyle);
302 hPixelEdgeMedian[pulse_order]->SetMarkerSize(mrkSize);
303
304 pixelCanvas[pulse_order]->cd( histoFrameNr[7] );
305 hPixelEdgeMean[pulse_order]->Draw("E1");
306 hPixelEdgeMean[pulse_order]->SetLineColor(kBlack);
307 hPixelEdgeMean[pulse_order]->SetMarkerColor(kBlue);
308 hPixelEdgeMean[pulse_order]->SetMarkerStyle(mrkStyle);
309 hPixelEdgeMean[pulse_order]->SetMarkerSize(mrkSize);
310// hPixelEdgeMax[pulse_order]->Draw("SAME");
311// hPixelEdgeMedian[pulse_order]->Draw("SAME");
312
313 }
314}
315// end of DrawTemplateHistograms
316//----------------------------------------------------------------------------
317
318
319
320
321void
322Pixel::SavePixelHistograms(
323 TString outRootFileName,
324 bool saveResults
325 )
326{
327 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid;
328 if (!saveResults) return;
329 SaveHistograms(
330 outRootFileName,
331 CreateSubDirName( mChid ),
332 hList,
333 saveResults,
334 mVerbosityLevel
335 );
336}
337// end of SavePixelHistograms
338//----------------------------------------------------------------------------
339
340TString
341Pixel::HistoName(
342 TString histoname,
343 int order
344 )
345{
346 histoname += mChid;
347 histoname += "_";
348 histoname += order;
349 return histoname;
350}
351
352TString
353Pixel::ChooseCycleNumber(
354 TString histoname,
355 int cycleNumber
356 )
357{
358 histoname += ";";
359 histoname += cycleNumber;
360 return histoname;
361}
362
363TString
364Pixel::HistoTitle(
365 TString histo_title,
366 int order
367 )
368{
369 histo_title += " [Pixel_Order] ";
370 histo_title += mChid;
371 histo_title += "_";
372 histo_title += order;
373 return histo_title;
374}
375
376TString
377Pixel::CsvFileName(
378 TString path,
379 TString overlayMethod,
380 int order
381 )
382{
383 path += "CSV/";
384 path += overlayMethod;
385 path += "OverlayTemplate";
386 path += "_";
387 path += mChid;
388 path += "_";
389 path += order;
390 path += ".csv";
391 return path;
392}
393
394
395//============================= ACESS ===================================
396//============================= INQUIRY ===================================
397/////////////////////////////// PROTECTED ///////////////////////////////////
398
399/////////////////////////////// PRIVATE ///////////////////////////////////
400
401void
402Pixel::BookPixelHistos()
403{
404 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
405 for (int order = 0; order < mMaxPulseOrder; order++)
406 {
407 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl;
408 hMaxOverlay[order]=new TH2F(
409 HistoName("hMaxOverlay", order),
410 HistoTitle("Overlay at peak maximum of detected pulses of", order),
411 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
412 (-1*mPixelOverlayXaxisLeft)-0.5,
413 mPixelOverlayXaxisRight-0.5 ,
414 512,
415 -55.5,
416 200.5
417 );
418
419 hMaxOverlay[order]->SetAxisRange(
420 mBSLMean - 5,
421 (mGainMean*(order+1)) + 10,
422 "Y");
423 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
424 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
425 //hMaxProfile->SetBit(TH2F::kCanRebin);
426 hMaxOverlay[order]->SetStats(mStats);
427 hList->Add( hMaxOverlay[order] );
428
429//------------------------------------------------------------------------
430
431 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl;
432 hEdgeOverlay[order] = new TH2F(
433 HistoName("hEdgeOverlay", order),
434 HistoTitle("Overlay at rising edge of detected pulses of", order),
435 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
436 (-1*mPixelOverlayXaxisLeft)-0.5,
437 mPixelOverlayXaxisRight-0.5 ,
438 512,
439 -55.5,
440 200.5
441 );
442
443 hEdgeOverlay[order]->SetAxisRange(
444 mBSLMean - 5,
445 (mGainMean*(order+1)) + 10,
446 "Y");
447 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
448 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
449 hEdgeOverlay[order]->SetStats(mStats);
450 hList->Add( hEdgeOverlay[order] );
451
452 //------------------------------------------------------------------------
453
454 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl;
455 hMaxProfile[order] = new TProfile(
456 HistoName("hMaxProfile", order),
457 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
458 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
459 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
460 mPixelOverlayXaxisRight-0.5 , //xup
461 // 512, //nbinsy
462 -55.5, //ylow
463 300.5, //yup
464 "s"); //option
465 hMaxProfile[order]->SetAxisRange(
466 mBSLMean - 5,
467 (mGainMean*(order+1)) + 10,
468 "Y");
469 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
470 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
471 //hMaxProfile->SetBit(TH2F::kCanRebin);
472 hMaxProfile[order]->SetStats(mStats);
473 hList->Add( hMaxProfile[order] );
474
475
476 //------------------------------------------------------------------------
477
478 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl;
479 hEdgeProfile[order] = new TProfile(
480 HistoName("hEdgeProfile", order),
481 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
482 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
483 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
484 mPixelOverlayXaxisRight-0.5 , //xup
485 // 512, //nbinsy
486 -55.5, //ylow
487 300.5, //yup
488 "s"); //option
489 hEdgeProfile[order]->SetLineColor(kRed);
490 hEdgeProfile[order]->SetAxisRange(
491 mBSLMean - 5,
492 (mGainMean*(order+1)) + 10,
493 "Y");
494 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
495 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
496 //hMaxProfile->SetBit(TH2F::kCanRebin);
497 hEdgeProfile[order]->SetStats(mStats);
498 hList->Add( hEdgeProfile[order] );
499
500 }
501 if (mVerbosityLevel > 2) cout << "...done" << endl;
502}
503//end of BookPixelHistos
504//----------------------------------------------------------------------------
505
506void
507Pixel::BookDistributionHistos( )
508{
509 if (!mOptions.IsNull() )
510 {
511 int x_min = 0;
512 int x_max = 0;
513
514 for (int order =0; order < mMaxPulseOrder; order++)
515 {
516 if (mVerbosityLevel > 2) cout << endl
517 << "...book distribution histograms"
518 << endl;
519
520 if (mOptions.Contains("S"))
521 {
522 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
523 hSlopeRisingEdge[order] = new TH1F (
524 HistoName("hSlopeRisingEdge", order),
525 HistoTitle("Distribution of rising edge's slope", order),
526 600,
527 -10.1,
528 10.1
529 );
530 hSlopeRisingEdge[order]->SetAxisRange(
531 -1,
532 7,
533 "X");
534 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" );
535 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
536 hSlopeRisingEdge[order]->SetStats(mStats);
537 hList->Add( hSlopeRisingEdge[order] );
538 }
539
540 if (mOptions.Contains("R"))
541 {
542 x_min = -15;
543 x_max = 35;
544
545 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl;
546 hRisingEdgeToMax[order] = new TH1I (
547 HistoName("hRisingEdgeToMax", order),
548 HistoTitle("Distribution of distance between rising edge and pulse's maximum", order),
549 x_max -x_min,
550 x_min,
551 x_max
552 );
553 hSlopeRisingEdge[order]->SetAxisRange(
554 -5,
555 25,
556 "X");
557 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
558 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
559 hRisingEdgeToMax[order]->SetStats(mStats);
560 hList->Add( hRisingEdgeToMax[order] );
561 }
562
563 if (mOptions.Contains("M"))
564 {
565 x_min = 10;
566 x_max = 290;
567 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl;
568 hPosOfMax[order] = new TH1I (
569 HistoName("hPosOfMax", order),
570 HistoTitle("Distribution of pulse's maximum's positon", order),
571 x_max - x_min,
572 x_min,
573 x_max
574 );
575 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
576 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
577 hRisingEdgeToMax[order]->SetStats(mStats);
578 hList->Add( hPosOfMax[order] );
579 }
580
581 if (mOptions.Contains("C"))
582 {
583 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
584 hChi2EdgetoMax[order] = new TH1F (
585 HistoName("hChi2EdgetoMax", order),
586 HistoTitle("Distribution of CHI2 comparison of Edge and Max", order),
587 600,
588 -299,
589 300
590 );
591 hChi2EdgetoMax[order]->SetAxisRange(
592 -1,
593 7,
594 "X");
595 hChi2EdgetoMax[order]->GetXaxis()->SetTitle( "p-Value" );
596 hChi2EdgetoMax[order]->GetYaxis()->SetTitle( "counts" );
597 hChi2EdgetoMax[order]->SetStats(mStats);
598// hList->Add( hChi2EdgetoMax[order] );
599 }
600
601 if (mVerbosityLevel > 2) cout << "...done" << endl;
602 }
603 }
604}
605//end of BookDistributionHistos
606//----------------------------------------------------------------------------
607
608void
609Pixel::BookTemplateHistos()
610{
611 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
612 for (int order = 0; order < mMaxPulseOrder; order++)
613 {
614 if (mVerbosityLevel > 3)
615 {
616 cout << "\t...booking " << HistoName("hPixelMax", order) << endl;
617 }
618
619 hPixelMax[order]=new TH1F(
620 HistoName("hPixelMax", order),
621 HistoTitle("Maximum value of each slice in overlay plot of", order),
622 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
623 (-1*mPixelOverlayXaxisLeft)-0.5,
624 mPixelOverlayXaxisRight-0.5
625 );
626
627 hPixelMax[order]->SetAxisRange(
628 mBSLMean - 5,
629 (mGainMean*(order+1)) + 10,
630 "Y");
631 hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
632 hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
633 //hMaxProfile->SetBit(TH2F::kCanRebin);
634 hPixelMax[order]->SetStats(mStats);
635 hList->Add( hPixelMax[order] );
636
637//------------------------------------------------------------------------
638
639 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMean", order) << endl;
640 hPixelMean[order] = new TH1F(
641 HistoName("hPixelMean", order),
642 HistoTitle("Mean value of each slice in overlay plot of", order),
643 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
644 (-1*mPixelOverlayXaxisLeft)-0.5,
645 mPixelOverlayXaxisRight-0.5
646 );
647 hPixelMean[order]->SetLineColor(kBlue);
648 hPixelMean[order]->SetAxisRange(
649 mBSLMean - 5,
650 (mGainMean*(order+1)) + 10,
651 "Y");
652 hPixelMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
653 hPixelMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
654 hPixelMean[order]->SetStats(mStats);
655 hList->Add( hPixelMean[order] );
656
657 //------------------------------------------------------------------------
658
659 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMedian", order) << endl;
660 hPixelMedian[order] = new TH1F(
661 HistoName("hPixelMedian", order),
662 HistoTitle("Median value of each slice in overlay plot of", order),
663 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
664 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
665 mPixelOverlayXaxisRight-0.5 //xup
666 );
667 hPixelMedian[order]->SetLineColor(kRed);
668 hPixelMedian[order]->SetAxisRange(
669 mBSLMean - 5,
670 (mGainMean*(order+1)) + 10,
671 "Y");
672 hPixelMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
673 hPixelMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
674 //hMaxProfile->SetBit(TH2F::kCanRebin);
675 hPixelMedian[order]->SetStats(mStats);
676 hList->Add( hPixelMedian[order] );
677
678 }
679 if (mVerbosityLevel > 2) cout << "...done" << endl;
680}
681//end of BookTemplateHistos
682//----------------------------------------------------------------------------
683
684void
685Pixel::BookEdgeTemplateHistos()
686{
687 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
688 for (int order = 0; order < mMaxPulseOrder; order++)
689 {
690 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl;
691 hPixelEdgeMax[order]=new TH1F(
692 HistoName("hPixelEdgeMax", order),
693 HistoTitle("Maximum value of each slice in overlay plot of", order),
694 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
695 (-1*mPixelOverlayXaxisLeft)-0.5,
696 mPixelOverlayXaxisRight-0.5
697 );
698
699 hPixelEdgeMax[order]->SetAxisRange(
700 mBSLMean - 5,
701 (mGainMean*(order+1)) + 10,
702 "Y");
703 hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
704 hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
705 //hMaxProfile->SetBit(TH2F::kCanRebin);
706 hPixelEdgeMax[order]->SetStats(mStats);
707 hList->Add( hPixelEdgeMax[order] );
708
709//------------------------------------------------------------------------
710
711 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl;
712 hPixelEdgeMean[order] = new TH1F(
713 HistoName("hPixelEdgeMean", order),
714 HistoTitle("Mean value of each slice in overlay plot of", order),
715 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
716 (-1*mPixelOverlayXaxisLeft)-0.5,
717 mPixelOverlayXaxisRight-0.5
718 );
719 hPixelEdgeMean[order]->SetLineColor(kBlue);
720 hPixelEdgeMean[order]->SetAxisRange(
721 mBSLMean - 5,
722 (mGainMean*(order+1)) + 10,
723 "Y");
724 hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
725 hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
726 hPixelEdgeMean[order]->SetStats(mStats);
727 hList->Add( hPixelEdgeMean[order] );
728
729 //------------------------------------------------------------------------
730
731 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl;
732 hPixelEdgeMedian[order] = new TH1F(
733 HistoName("hPixelEdgeMedian", order),
734 HistoTitle("Median value of each slice in overlay plot of", order),
735 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
736 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
737 mPixelOverlayXaxisRight-0.5 //xup
738 );
739 hPixelEdgeMedian[order]->SetLineColor(kRed);
740 hPixelEdgeMedian[order]->SetAxisRange(
741 mBSLMean - 5,
742 (mGainMean*(order+1)) + 10,
743 "Y");
744 hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
745 hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
746 //hMaxProfile->SetBit(TH2F::kCanRebin);
747 hPixelEdgeMedian[order]->SetStats(mStats);
748 hList->Add( hPixelEdgeMedian[order] );
749
750 }
751 if (mVerbosityLevel > 2) cout << "...done" << endl;
752}
753//end of BookEdgeTemplateHistos
754//----------------------------------------------------------------------------
755
756void
757Pixel::LoadPulseHistos()
758{
759 mRootFile->cd();
760
761 if (mVerbosityLevel > 2)
762 {
763 if (mVerbosityLevel > 3)
764 {
765 mRootFile->ls();
766 }
767 cout << "loading current File: " ;
768 gFile->pwd();
769 }
770
771 mRootFile->cd( CreateSubDirName( mChid ) ); //Go to pixel's subdirectory
772 mDirectory = gDirectory;
773
774 if (mVerbosityLevel > 2)
775 {
776 if (mVerbosityLevel > 3)
777 {
778 gDirectory->ls();
779 }
780 cout << "Current Directory: " ;
781 gDirectory->pwd();
782 }
783
784// mPixelOverlayXaxisRight =70; ///TODO: get it from the root file
785// mPixelOverlayXaxisLeft =230; ///TODO: get it from the root file
786// mBSLMean =-1; ///TODO: get it from the root file
787// mGainMean =9; ///TODO: get it from the root file
788// mOptions ="SRM"; ///TODO: get it from the root file
789
790 if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl;
791 for (int order = 0; order < mMaxPulseOrder; order++)
792 {
793
794 if (mVerbosityLevel > 3) cout << "\t...loading " << ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) << endl;
795 hMaxOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) );
796
797 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeOverlay", order) << endl;
798 hEdgeOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeOverlay", order), 1) );
799
800 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hMaxProfile", order) << endl;
801 hMaxProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxProfile", order), 1) );
802
803 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeProfile", order) << endl;
804 hEdgeProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeProfile", order), 1) );
805 }
806
807}
808// end of LoadPulseHistos
809//----------------------------------------------------------------------------
810
811void
812Pixel::DeletePixelHistos()
813{
814 if (mVerbosityLevel > 2)
815 {
816 cout << endl
817 << endl
818 << "\t...delete current overlay histograms of Pixel# " << mChid;
819 }
820 for (int order = 0;
821 order < mMaxPulseOrder;
822 order ++)
823 {
824 if (mVerbosityLevel > 3)
825 cout << endl << "\t\t...deleting hMaxOverlay"
826 << mChid << "_" << order;
827
828 delete hMaxOverlay[order];
829 hMaxOverlay[order] = NULL;
830
831 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
832 << mChid << "_" << order ;
833 delete hEdgeOverlay[order];
834 hEdgeOverlay[order] = NULL;
835
836 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
837 << mChid << "_" << order ;
838 delete hMaxProfile[order];
839 hMaxProfile[order] = NULL;
840
841 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
842 << mChid << "_" << order ;
843 delete hEdgeProfile[order];
844 hEdgeProfile[order] = NULL;
845 }
846 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
847
848 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
849 delete[] hMaxOverlay;
850 hMaxOverlay = NULL;
851
852 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
853 delete[] hEdgeOverlay;
854 hEdgeOverlay = NULL;
855
856 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
857 delete[] hMaxProfile;
858 hMaxProfile = NULL;
859
860 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
861 delete[] hEdgeProfile;
862 hEdgeProfile = NULL;
863}
864// end of DeletePixelHistos
865//----------------------------------------------------------------------------
866
867void
868Pixel::DeleteDistributionHistos()
869{
870 if (mVerbosityLevel > 2)
871 {
872 cout << endl
873 << "\t...delete current distribution histograms" ;
874 }
875
876 for (int order = 0;
877 order < mMaxPulseOrder;
878 order ++)
879 {
880 if (mOptions.Contains("S"))
881 {
882 if (mVerbosityLevel > 3) cout << endl
883 << "\t\t...deleting hSlopeRisingEdge"
884 << mChid << "_" << order ;
885 delete hSlopeRisingEdge[order];
886 }
887
888 if (mOptions.Contains("R"))
889 {
890 if (mVerbosityLevel > 3) cout << endl
891 << "\t\t...deleting hRisingEdgeToMax"
892 << mChid << "_" << order ;
893 delete hRisingEdgeToMax[order];
894 }
895
896 if (mOptions.Contains("M"))
897 {
898 if (mVerbosityLevel > 3) cout << endl
899 << "\t\t...deleting hPosOfMax"
900 << mChid << "_" << order ;
901
902 delete hPosOfMax[order];
903 }
904
905 }
906 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
907
908 if (mOptions.Contains("S"))
909 {
910 if (mVerbosityLevel > 3)
911 cout << endl << "\t\t...deleting hSlopeRisingEdge";
912 delete[] hSlopeRisingEdge;
913 hSlopeRisingEdge = NULL;
914 }
915
916 if (mOptions.Contains("R"))
917 {
918 if (mVerbosityLevel > 3)
919 cout << endl << "\t\t...deleting hRisingEdgeToMax";
920 delete[] hRisingEdgeToMax;
921 hRisingEdgeToMax = NULL;
922 }
923
924 if (mOptions.Contains("M"))
925 {
926 if (mVerbosityLevel > 3)
927 cout << endl << "\t\t...deleting hPosOfMax";
928 delete[] hPosOfMax;
929 hPosOfMax = NULL;
930 }
931}
932// end of DeletePixelHistos
933//----------------------------------------------------------------------------
934
935void
936Pixel::DeleteTemplateHistos()
937{
938 if (mVerbosityLevel > 2)
939 {
940 cout << endl
941 << "\t...delete current template histograms of Pixel# " << mChid;
942 }
943 for (int order = 0;
944 order < mMaxPulseOrder;
945 order ++)
946 {
947 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean"
948 << mChid << "_" << order ;
949 delete hPixelMean[order];
950 hPixelMean[order] = NULL;
951
952 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian"
953 << mChid << "_" << order ;
954 delete hPixelMedian[order];
955 hPixelMedian[order] = NULL;
956
957 if (mVerbosityLevel > 3)
958 cout << endl << "\t\t...deleting hPixelMax"
959 << mChid << "_" << order;
960 delete hPixelMax[order];
961 hPixelMax[order] = NULL;
962
963 }
964 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
965
966 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax";
967 delete[] hPixelMax;
968 hPixelMax = NULL;
969
970 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian";
971 delete[] hPixelMedian;
972 hPixelMedian = NULL;
973
974 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean";
975 delete[] hPixelMean;
976 hPixelMean = NULL;
977}
978// end of DeleteTemplateHistos
979//----------------------------------------------------------------------------
980
981void
982Pixel::DeleteEdgeTemplateHistos()
983{
984 if (mVerbosityLevel > 2)
985 {
986 cout << endl
987 << "\t...delete current Edge template histograms of Pixel# " << mChid;
988 }
989 for (int order = 0;
990 order < mMaxPulseOrder;
991 order ++)
992 {
993 if (mVerbosityLevel > 3)
994 cout << endl << "\t\t...deleting hPixelEdgeMax"
995 << mChid << "_" << order;
996
997 delete hPixelEdgeMax[order];
998 hPixelEdgeMax[order] = NULL;
999
1000 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"
1001 << mChid << "_" << order ;
1002 delete hPixelEdgeMedian[order];
1003 hPixelEdgeMedian[order] = NULL;
1004
1005 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"
1006 << mChid << "_" << order ;
1007 delete hPixelEdgeMean[order];
1008 hPixelEdgeMean[order] = NULL;
1009
1010 }
1011 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1012
1013 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax";
1014 delete[] hPixelEdgeMax;
1015 hPixelEdgeMax = NULL;
1016
1017 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian";
1018 delete[] hPixelEdgeMedian;
1019 hPixelEdgeMedian = NULL;
1020
1021 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean";
1022 delete[] hPixelEdgeMean;
1023 hPixelEdgeMean = NULL;
1024}
1025// end of DeleteTemplateHistos
1026//----------------------------------------------------------------------------
1027
1028void
1029Pixel::MakeTH1Pretty(
1030 TH1* histo,
1031 TString histName,
1032 TString histTitle,
1033 int order
1034 )
1035{
1036 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1037
1038 histo->SetNameTitle(
1039 HistoName(histName, order),
1040 HistoTitle(histTitle, order)
1041 );
1042
1043 histo->SetBins(
1044 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1045 (-1*mPixelOverlayXaxisLeft)-0.5,
1046 mPixelOverlayXaxisRight-0.5
1047 );
1048
1049 histo->SetAxisRange(
1050 mBSLMean - 5,
1051 (mGainMean*(order+1)) + 10,
1052 "Y");
1053 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1054 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1055 //histo->SetBit(TH2F::kCanRebin);
1056 histo->SetStats(mStats);
1057}
1058// end of MakeTH2Pretty
1059//----------------------------------------------------------------------------
1060
1061
1062void
1063Pixel::MakeTH2Pretty(
1064 TH2* histo,
1065 TString histName,
1066 TString histTitle,
1067 int order
1068 )
1069{
1070 if (mVerbosityLevel > 3) cout << "\t...designing " << HistoName(histName, order) << endl;
1071
1072 histo->SetNameTitle(
1073 HistoName(histName, order),
1074 HistoTitle(histTitle, order)
1075 );
1076
1077 histo->SetBins(
1078 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1079 (-1*mPixelOverlayXaxisLeft)-0.5,
1080 mPixelOverlayXaxisRight-0.5 ,
1081 512,
1082 -55.5,
1083 200.5
1084 );
1085
1086 histo->SetAxisRange(
1087 mBSLMean - 5,
1088 (mGainMean*(order+1)) + 10,
1089 "Y");
1090
1091 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1092 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1093 //histo->SetBit(TH2F::kCanRebin);
1094 histo->SetStats(mStats);
1095}
1096// end of MakeTH2Pretty
1097//----------------------------------------------------------------------------
1098
1099void
1100Pixel::MakeTProfilePretty(
1101 TProfile* histo,
1102 TString histName,
1103 TString histTitle,
1104 int order
1105 )
1106{
1107 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1108
1109 histo->SetNameTitle(
1110 HistoName(histName, order),
1111 HistoTitle(histTitle, order)
1112 );
1113
1114 histo->SetBins(
1115 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1116 (-1*mPixelOverlayXaxisLeft)-0.5,
1117 mPixelOverlayXaxisRight-0.5
1118 );
1119 histo->SetOption( "s" );
1120
1121 histo->SetAxisRange(
1122 mBSLMean - 5,
1123 (mGainMean*(order+1)) + 10,
1124 "Y");
1125
1126 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1127 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1128 //histo->SetBit(TH2F::kCanRebin);
1129 histo->SetStats(mStats);
1130}
1131// end of MakeTProfilePretty
1132//----------------------------------------------------------------------------
1133
1134
1135void
1136Pixel::ShiftHistoInY(
1137 TH1* histo,
1138 float shift
1139 )
1140{
1141 int min_bin = histo->GetXaxis()->GetFirst();
1142 int max_bin = histo->GetXaxis()->GetLast();
1143
1144 for (int bin = min_bin; bin <= max_bin; bin++)
1145 {
1146 histo->AddBinContent( bin, shift);
1147 }
1148
1149}
1150
1151
Note: See TracBrowser for help on using the repository browser.