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

Last change on this file since 15241 was 15120, checked in by Jens Buss, 12 years ago
added distribution histograsms
File size: 50.5 KB
Line 
1#include <iostream>
2#include <TMath.h>
3#include <TF1.h>
4#include <TVectorF.h>
5
6#include "rootfilehandler.h"
7#include "pixel.h" // class implemented
8using namespace std;
9
10/////////////////////////////// PUBLIC ///////////////////////////////////////
11
12//============================= LIFECYCLE ====================================
13
14
15Pixel::Pixel(
16 int pixelID,
17 int maxPulsorder,
18 int verbosityLevel,
19 bool stats,
20 TString options,
21 int pixelOverlayXaxisLeft,
22 int pixelOverlayXaxisRight,
23 float bSLMean,
24 float gainMean,
25 TFile* filename,
26 TFile* outfilename
27 )
28{
29 mConstructorType = 1; //important for deletion 0 delete distribution 1 delete TemplateHistos
30
31 mChid = pixelID;
32 mMaxPulseOrder = maxPulsorder;
33 mVerbosityLevel = verbosityLevel;
34 mStats = stats;
35 mOptions = options;
36 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
37 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
38 mBSLMean = bSLMean;
39 mGainMean = gainMean;
40 mRootFile = filename;
41 mOutRootFile = outfilename;
42
43 hMaxOverlay = new TH2F*[mMaxPulseOrder];
44 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
45 hMaxProfile = new TProfile*[mMaxPulseOrder];
46 hEdgeProfile = new TProfile*[mMaxPulseOrder];
47
48 hPixelMax = new TH1F*[mMaxPulseOrder];
49 hPixelMedian = new TH1F*[mMaxPulseOrder];
50 hPixelMean = new TH1F*[mMaxPulseOrder];
51
52 hPixelEdgeMax = new TH1F*[mMaxPulseOrder];
53 hPixelEdgeMedian = new TH1F*[mMaxPulseOrder];
54 hPixelEdgeMean = new TH1F*[mMaxPulseOrder];
55
56 hList = new TList();
57 hMemberlist = new TList();
58
59 if (mOptions.Contains("C") )
60 {
61 hChi2EdgetoMax = new TH1F*[mMaxPulseOrder];
62 }
63
64 if (options.Contains("L"))
65 {
66 LoadPulseHistos( );
67 }
68 else
69 {
70 BookPixelHistos();
71 }
72
73 if (mOptions.Contains("C"))
74 {
75 BookDistributionHistos();
76 }
77
78 BookTemplateHistos();
79 BookEdgeTemplateHistos();
80}
81
82Pixel::Pixel(
83 int pixelID,
84 int maxPulsorder,
85 int verbosityLevel,
86 bool stats,
87 TString options,
88 int pixelOverlayXaxisLeft,
89 int pixelOverlayXaxisRight,
90 float bSLMean,
91 float gainMean
92 )
93{
94 mConstructorType = 0;
95
96 mChid = pixelID;
97 mMaxPulseOrder = maxPulsorder;
98 mVerbosityLevel = verbosityLevel;
99 mStats = stats; ///TODO: HANDOVER THE VALUE
100 mOptions = options;
101 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
102 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
103 mBSLMean = bSLMean;
104 mGainMean = gainMean;
105
106 hMaxOverlay = new TH2F*[mMaxPulseOrder];
107 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
108 hMaxProfile = new TProfile*[mMaxPulseOrder];
109 hEdgeProfile = new TProfile*[mMaxPulseOrder];
110
111 if (mOptions.Contains("S") )
112 {
113 hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
114 }
115
116 if (mOptions.Contains("R") )
117 {
118 hRisingEdgeToMax = new TH1I*[mMaxPulseOrder];
119 }
120
121 if (mOptions.Contains("M") )
122 {
123 hPosOfMax = new TH1I*[mMaxPulseOrder];
124 }
125
126 hList = new TList();
127 hMemberlist = new TList();
128
129 BookPixelHistos();
130 BookDistributionHistos();
131}
132
133Pixel::~Pixel()
134{
135 if (mVerbosityLevel > 1)
136 {
137 cout << endl << "...delete histograms of pixel " << mChid ;
138 cout << endl << "...mConstructorType = " << mConstructorType ;
139 }
140
141 if (mConstructorType == 0)
142 {
143 DeleteDistributionHistos();
144 }
145
146 if (mConstructorType == 1)
147 {
148 DeleteTemplateHistos();
149 DeleteEdgeTemplateHistos();
150 }
151
152 DeletePixelHistos();
153 delete hList;
154 delete hMemberlist;
155
156 hList = NULL;
157 hMemberlist = NULL;
158 if (mVerbosityLevel > 1)
159 {
160 cout << endl << "...histograms of pixel " << mChid ;
161 cout << "...deleted " << endl ;
162 }
163}// ~Pixel
164
165
166//============================= OPERATORS ====================================
167
168//XX&
169//XX::operator=(const XX&);
170//{
171// return *this;
172
173//}// =
174
175//============================= OPERATIONS ===================================
176void
177Pixel::DrawOverlayHistograms(
178 TCanvas** pixelCanvas,
179 int* histoFrameNr
180 )
181{
182 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
183 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
184 {
185 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
186 hMaxOverlay[pulse_order]->Draw("COLZ");
187 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
188 hMaxProfile[pulse_order]->Draw();
189
190 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
191 hEdgeOverlay[pulse_order]->Draw("COLZ");
192 pixelCanvas[pulse_order]->cd( histoFrameNr[3] );
193 hEdgeProfile[pulse_order]->Draw();
194 }
195}
196// end of DrawOverlayHistograms
197//----------------------------------------------------------------------------
198
199void
200Pixel::DrawDistributionHistograms(
201 TCanvas** pixelCanvas,
202 int* histoFrameNr
203 )
204{
205 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
206 bool nothing_to_fill = true;
207 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
208 {
209 if (mOptions.Contains("S") )
210 {
211 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
212 hSlopeRisingEdge[pulse_order]->Draw();
213 nothing_to_fill = false;
214 }
215
216 if (mOptions.Contains("R") )
217 {
218 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
219 hRisingEdgeToMax[pulse_order]->Draw();
220 nothing_to_fill = false;
221 }
222
223 if (mOptions.Contains("M") )
224 {
225 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
226 hPosOfMax[pulse_order]->Draw();
227 nothing_to_fill = false;
228 }
229
230 }
231 if (nothing_to_fill)
232 {
233 cout << endl << "there were NO DISTRIBUTION HISTOGRAMS to fill" << endl;
234 }
235}
236// end of DrawDistributionHistograms
237//----------------------------------------------------------------------------
238
239void
240Pixel::DrawTemplateHistograms(
241 TCanvas** pixelCanvas,
242 int* histoFrameNr
243 )
244{
245 int mrkStyle =1;
246 int mrkSize = 2;
247 if (mVerbosityLevel > 2) cout << "...drawing Template histograms" << endl ;
248 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
249 {
250 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
251 hMaxOverlay[pulse_order]->Draw("COLZ");
252
253 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
254 hPixelMax[pulse_order]->Draw("E1");
255 hPixelMax[pulse_order]->SetMarkerColor(kBlue);
256 hPixelMax[pulse_order]->SetLineColor(kBlack);
257 hPixelMax[pulse_order]->SetMarkerStyle(mrkStyle);
258 hPixelMax[pulse_order]->SetMarkerSize(mrkSize);
259
260 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
261 hPixelMedian[pulse_order]->Draw("E1");
262 hPixelMedian[pulse_order]->SetMarkerColor(kBlue);
263 hPixelMedian[pulse_order]->SetLineColor(kBlack);
264 hPixelMedian[pulse_order]->SetMarkerStyle(mrkStyle);
265 hPixelMedian[pulse_order]->SetMarkerSize(mrkSize);
266
267 pixelCanvas[pulse_order]->cd( histoFrameNr[3] );
268 hPixelMean[pulse_order]->Draw("E1");
269 hPixelMean[pulse_order]->SetMarkerColor(kBlue);
270 hPixelMean[pulse_order]->SetLineColor(kBlack);
271 hPixelMean[pulse_order]->SetMarkerStyle(mrkStyle);
272 hPixelMean[pulse_order]->SetMarkerSize(mrkSize);
273// hPixelMax[pulse_order]->Draw("SAME");
274// hPixelMedian[pulse_order]->Draw("SAME");
275
276 }
277}
278// end of DrawTemplateHistograms
279//----------------------------------------------------------------------------
280
281void
282Pixel::DrawEdgeTemplateHistograms(
283 TCanvas** pixelCanvas,
284 int* histoFrameNr
285 )
286{
287 int mrkStyle = 1;
288 int mrkSize = 3;
289
290 if (mVerbosityLevel > 2) cout << endl << "...drawing Template histograms" ;
291 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
292 {
293 pixelCanvas[pulse_order]->cd( histoFrameNr[4] );
294 hEdgeOverlay[pulse_order]->Draw("COLZ");
295
296 pixelCanvas[pulse_order]->cd( histoFrameNr[5] );
297 hPixelEdgeMax[pulse_order]->Draw("E1");
298 hPixelEdgeMax[pulse_order]->SetLineColor(kBlack);
299 hPixelEdgeMax[pulse_order]->SetMarkerColor(kBlue);
300 hPixelEdgeMax[pulse_order]->SetMarkerStyle(mrkStyle);
301 hPixelEdgeMax[pulse_order]->SetMarkerSize(mrkSize);
302
303 pixelCanvas[pulse_order]->cd( histoFrameNr[6] );
304 hPixelEdgeMedian[pulse_order]->Draw("E1");
305 hPixelEdgeMedian[pulse_order]->SetLineColor(kBlack);
306 hPixelEdgeMedian[pulse_order]->SetMarkerColor(kBlue);
307 hPixelEdgeMedian[pulse_order]->SetMarkerStyle(mrkStyle);
308 hPixelEdgeMedian[pulse_order]->SetMarkerSize(mrkSize);
309
310 pixelCanvas[pulse_order]->cd( histoFrameNr[7] );
311 hPixelEdgeMean[pulse_order]->Draw("E1");
312 hPixelEdgeMean[pulse_order]->SetLineColor(kBlack);
313 hPixelEdgeMean[pulse_order]->SetMarkerColor(kBlue);
314 hPixelEdgeMean[pulse_order]->SetMarkerStyle(mrkStyle);
315 hPixelEdgeMean[pulse_order]->SetMarkerSize(mrkSize);
316// hPixelEdgeMax[pulse_order]->Draw("SAME");
317// hPixelEdgeMedian[pulse_order]->Draw("SAME");
318
319 }
320}
321// end of DrawTemplateHistograms
322//----------------------------------------------------------------------------
323
324
325
326
327void
328Pixel::SavePixelHistograms(
329 TString outRootFileName,
330 bool saveResults
331 )
332{
333 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid;
334 if (!saveResults) return;
335 SaveList(
336 outRootFileName,
337 CreateSubDirName( mChid ),
338 hList,
339 saveResults,
340 mVerbosityLevel
341 );
342 /*
343 we also need to save same values:
344
345 EXAMPLE
346 root > TFile f("v.root","recreate")
347 root > TVectorD v(1)
348 root > v[0] = 3.14
349 root > v.Write("v")
350 and to read the file do
351 CODE: SELECT ALL
352 root > TFile f("v.root")
353 root > TVectorD *v = (TVectorD*)f.get("v");
354 root > v->Print()
355
356 */
357}
358// end of SavePixelHistograms
359//----------------------------------------------------------------------------
360
361TString
362Pixel::HistoName(
363 TString histoname,
364 int order
365 )
366{
367 histoname += mChid;
368 histoname += "_";
369 histoname += order;
370 return histoname;
371}
372
373TString
374Pixel::ChooseCycleNumber(
375 TString histoname,
376 int cycleNumber
377 )
378{
379 histoname += ";";
380 histoname += cycleNumber;
381 return histoname;
382}
383
384TString
385Pixel::HistoTitle(
386 TString histo_title,
387 int order
388 )
389{
390 histo_title += " [Pixel_Order] ";
391 histo_title += mChid;
392 histo_title += "_";
393 histo_title += order;
394 return histo_title;
395}
396
397TString
398Pixel::CsvFileName(
399 TString path,
400 TString overlayMethod,
401 int order
402 )
403{
404 path += "CSV/";
405 path += overlayMethod;
406 path += "OverlayTemplate";
407 path += "_";
408 path += mChid;
409 path += "_";
410 path += order;
411 path += ".csv";
412 return path;
413}
414
415
416//============================= ACESS ===================================
417//============================= INQUIRY ===================================
418/////////////////////////////// PROTECTED ///////////////////////////////////
419
420/////////////////////////////// PRIVATE ///////////////////////////////////
421
422void
423Pixel::BookPixelHistos()
424{
425 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
426 for (int order = 0; order < mMaxPulseOrder; order++)
427 {
428 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxOverlay", order) << endl;
429 hMaxOverlay[order]=new TH2F(
430 HistoName("hMaxOverlay", order),
431 HistoTitle("Overlay at peak maximum of detected pulses of", order),
432 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
433 (-1*mPixelOverlayXaxisLeft)-0.5,
434 mPixelOverlayXaxisRight-0.5 ,
435 512,
436 -55.5,
437 200.5
438 );
439
440 hMaxOverlay[order]->SetAxisRange(
441 mBSLMean - 5,
442 (mGainMean*(order+1)) + 10,
443 "Y");
444 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
445 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
446 //hMaxProfile->SetBit(TH2F::kCanRebin);
447 hMaxOverlay[order]->SetStats(mStats);
448 hList->Add( hMaxOverlay[order] );
449
450//------------------------------------------------------------------------
451
452 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl;
453 hEdgeOverlay[order] = new TH2F(
454 HistoName("hEdgeOverlay", order),
455 HistoTitle("Overlay at rising edge of detected pulses of", order),
456 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
457 (-1*mPixelOverlayXaxisLeft)-0.5,
458 mPixelOverlayXaxisRight-0.5 ,
459 512,
460 -55.5,
461 200.5
462 );
463
464 hEdgeOverlay[order]->SetAxisRange(
465 mBSLMean - 5,
466 (mGainMean*(order+1)) + 10,
467 "Y");
468 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
469 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
470 hEdgeOverlay[order]->SetStats(mStats);
471 hList->Add( hEdgeOverlay[order] );
472
473 //------------------------------------------------------------------------
474
475 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl;
476 hMaxProfile[order] = new TProfile(
477 HistoName("hMaxProfile", order),
478 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
479 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
480 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
481 mPixelOverlayXaxisRight-0.5 , //xup
482 // 512, //nbinsy
483 -55.5, //ylow
484 300.5, //yup
485 "s"); //option
486 hMaxProfile[order]->SetAxisRange(
487 mBSLMean - 5,
488 (mGainMean*(order+1)) + 10,
489 "Y");
490 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
491 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
492 //hMaxProfile->SetBit(TH2F::kCanRebin);
493 hMaxProfile[order]->SetStats(mStats);
494 hList->Add( hMaxProfile[order] );
495
496
497 //------------------------------------------------------------------------
498
499 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl;
500 hEdgeProfile[order] = new TProfile(
501 HistoName("hEdgeProfile", order),
502 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
503 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
504 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
505 mPixelOverlayXaxisRight-0.5 , //xup
506 // 512, //nbinsy
507 -55.5, //ylow
508 300.5, //yup
509 "s"); //option
510 hEdgeProfile[order]->SetLineColor(kRed);
511 hEdgeProfile[order]->SetAxisRange(
512 mBSLMean - 5,
513 (mGainMean*(order+1)) + 10,
514 "Y");
515 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
516 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
517 //hMaxProfile->SetBit(TH2F::kCanRebin);
518 hEdgeProfile[order]->SetStats(mStats);
519 hList->Add( hEdgeProfile[order] );
520
521 }
522 if (mVerbosityLevel > 2) cout << "...done" << endl;
523}
524//end of BookPixelHistos
525//----------------------------------------------------------------------------
526
527void
528Pixel::BookDistributionHistos( )
529{
530 if (!mOptions.IsNull() )
531 {
532 int x_min = 0;
533 int x_max = 0;
534
535 for (int order =0; order < mMaxPulseOrder; order++)
536 {
537 if (mVerbosityLevel > 2) cout << endl
538 << "...book distribution histograms"
539 << endl;
540
541 if (mOptions.Contains("S"))
542 {
543 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
544 hSlopeRisingEdge[order] = new TH1F (
545 HistoName("hSlopeRisingEdge", order),
546 HistoTitle("Distribution of rising edge's slope", order),
547 600,
548 -10.1,
549 10.1
550 );
551 hSlopeRisingEdge[order]->SetAxisRange(
552 -1,
553 7,
554 "X");
555 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" );
556 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
557 hSlopeRisingEdge[order]->SetStats(mStats);
558 hList->Add( hSlopeRisingEdge[order] );
559 }
560
561 if (mOptions.Contains("R"))
562 {
563 x_min = -15;
564 x_max = 35;
565
566 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl;
567 hRisingEdgeToMax[order] = new TH1I (
568 HistoName("hRisingEdgeToMax", order),
569 HistoTitle("Distribution of distance between rising edge and pulse's maximum", order),
570 x_max -x_min,
571 x_min,
572 x_max
573 );
574 hSlopeRisingEdge[order]->SetAxisRange(
575 -5,
576 25,
577 "X");
578 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
579 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
580 hRisingEdgeToMax[order]->SetStats(mStats);
581 hList->Add( hRisingEdgeToMax[order] );
582 }
583
584 if (mOptions.Contains("M"))
585 {
586 x_min = 10;
587 x_max = 290;
588 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl;
589 hPosOfMax[order] = new TH1I (
590 HistoName("hPosOfMax", order),
591 HistoTitle("Distribution of pulse's maximum's positon", order),
592 x_max - x_min,
593 x_min,
594 x_max
595 );
596 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
597 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
598 hRisingEdgeToMax[order]->SetStats(mStats);
599 hList->Add( hPosOfMax[order] );
600 }
601
602 if (mOptions.Contains("C"))
603 {
604 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
605 hChi2EdgetoMax[order] = new TH1F (
606 HistoName("hChi2EdgetoMax", order),
607 HistoTitle("Distribution of CHI2 comparison of Edge and Max", order),
608 600,
609 -299,
610 300
611 );
612 hChi2EdgetoMax[order]->SetAxisRange(
613 -1,
614 7,
615 "X");
616 hChi2EdgetoMax[order]->GetXaxis()->SetTitle( "p-Value" );
617 hChi2EdgetoMax[order]->GetYaxis()->SetTitle( "counts" );
618 hChi2EdgetoMax[order]->SetStats(mStats);
619// hList->Add( hChi2EdgetoMax[order] );
620 }
621
622 if (mVerbosityLevel > 2) cout << "...done" << endl;
623 }
624
625 // Arrival Time Distributions
626 //----------------------------------
627 if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxPos" << endl;
628 hMaxPos = new TH1F (
629 "hMaxPos",
630 "Distribution of arrival times according to the EdgePos",
631 1024,
632 0,
633 1024
634 );
635// hMaxPos->SetAxisRange(
636// 0,
637// 1024,
638// "X");
639 hMaxPos->GetXaxis()->SetTitle( " arrival time [timeslices]" );
640 hMaxPos->GetYaxis()->SetTitle( "counts" );
641 hMaxPos->SetStats(mStats);
642 hList->Add( hMaxPos );
643
644 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgePos" << endl;
645 hEdgePos = new TH1F (
646 "hEdgePos",
647 "Distribution of arrival times according to the EdgePos",
648 1024,
649 0,
650 1024
651 );
652// hEdgePos->SetAxisRange(
653// 0,
654// 1024,
655// "X");
656 hEdgePos->GetXaxis()->SetTitle( " arrival time [timeslices]" );
657 hEdgePos->GetYaxis()->SetTitle( "counts" );
658 hEdgePos->SetStats(mStats);
659 hList->Add( hEdgePos );
660
661 // Edge Slope Distributions
662 //----------------------------------
663 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeSlope" << endl;
664 hEdgeSlope = new TH1F (
665 "hEdgeSlope",
666 "Distribution of slope of leading edges",
667 100*10,
668 -9,
669 90
670 );
671// hEdgeSlope->SetAxisRange(
672// 0,
673// 1024,
674// "X");
675 hEdgeSlope->GetXaxis()->SetTitle( " slope [a.u.]" );
676 hEdgeSlope->GetYaxis()->SetTitle( "counts" );
677 hEdgeSlope->SetStats(mStats);
678 hList->Add( hEdgeSlope );
679
680 // Intercept Distributions
681 //----------------------------------
682 if (mVerbosityLevel > 3) cout << "\t...booking " << "hIntercept" << endl;
683 hIntercept = new TH1F (
684 "hIntercept",
685 "Distribution of Intercept of leading edges",
686 100*10,
687 -9,
688 90
689 );
690// hEdgeSlope->SetAxisRange(
691// 0,
692// 1024,
693// "X");
694 hIntercept->GetXaxis()->SetTitle( " Intercept [a.u.]" );
695 hIntercept->GetYaxis()->SetTitle( "counts" );
696 hIntercept->SetStats(mStats);
697 hList->Add( hIntercept );
698
699 // Edge lengt Distributions
700 //----------------------------------
701 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeLength" << endl;
702 hEdgeLength = new TH1F (
703 "hIntercept",
704 "Distribution of hEdgeLength of leading edges",
705 20*10,
706 0,
707 20
708 );
709// hEdgeLength->SetAxisRange(
710// 0,
711// 1024,
712// "X");
713 hEdgeLength->GetXaxis()->SetTitle( " edge length [a.u.]" );
714 hEdgeLength->GetYaxis()->SetTitle( "counts" );
715 hEdgeLength->SetStats(mStats);
716 hList->Add( hEdgeLength );
717
718 // Pulse length Distributions
719 //----------------------------------
720 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLength" << endl;
721 hPulseLength = new TH1F (
722 "hPulseLength",
723 "Distribution of pulse lengthes",
724 1024,
725 0,
726 1024
727 );
728// hPulseLength->SetAxisRange(
729// 0,
730// 1024,
731// "X");
732 hPulseLength->GetXaxis()->SetTitle( " pulse length [samples]" );
733 hPulseLength->GetYaxis()->SetTitle( "counts" );
734 hPulseLength->SetStats(mStats);
735 hList->Add( hPulseLength );
736
737 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthAPcutoff" << endl;
738 hPulseLengthAPcutoff = new TH1F (
739 "hPulseLengthAPcutoff",
740 "Distribution of pulse lengthes due to afterpulse cut off",
741 1024,
742 0,
743 1024
744 );
745// hPulseLength->SetAxisRange(
746// 0,
747// 1024,
748// "X");
749 hPulseLengthAPcutoff->GetXaxis()->SetTitle( " pulse length [samples]" );
750 hPulseLengthAPcutoff->GetYaxis()->SetTitle( "counts" );
751 hPulseLengthAPcutoff->SetStats(mStats);
752 hList->Add( hPulseLengthAPcutoff );
753
754 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthTLcutoff" << endl;
755 hPulseLengthTLcutoff = new TH1F (
756 "hPulseLengthTLcutoff",
757 "Distribution of pulse lengthes due to time line cut off",
758 1024,
759 0,
760 1024
761 );
762// hPulseLengthTLcutoff->SetAxisRange(
763// 0,
764// 1024,
765// "X");
766 hPulseLengthTLcutoff->GetXaxis()->SetTitle( " pulse length [samples]" );
767 hPulseLengthTLcutoff->GetYaxis()->SetTitle( "counts" );
768 hPulseLengthTLcutoff->SetStats(mStats);
769 hList->Add( hPulseLengthTLcutoff );
770
771 // Amplitude Distributions
772 //----------------------------------
773
774 if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxAmpl" << endl;
775 hMaxAmpl = new TH1F (
776 "hMaxAmpl",
777 "Distribution of MaxAmpl of leading edges",
778 20*10,
779 0,
780 20
781 );
782// hMaxAmpl->SetAxisRange(
783// 0,
784// 1024,
785// "X");
786 hMaxAmpl->GetXaxis()->SetTitle( " Amplitude [a.u.]" );
787 hMaxAmpl->GetYaxis()->SetTitle( "counts" );
788 hMaxAmpl->SetStats(mStats);
789 hList->Add( hEdgeLength );
790
791 // Discarted Pulses Distributions
792 //----------------------------------
793 if (mVerbosityLevel > 3) cout << "\t...booking " << "hDiscartedPulses" << endl;
794 hDiscartedPulses=new TH2F(
795 "hDiscartedPulses",
796 "DiscartedPulses vs. preperation step",
797 15 ,
798 0,
799 15 ,
800 1000000,
801 0,
802 1000000
803 );
804
805// hMaxOverlay[order]->SetAxisRange(
806// mBSLMean - 5,
807// (mGainMean*(order+1)) + 10,
808// "Y");
809 hDiscartedPulses->GetXaxis()->SetTitle( "step [a.u.]" );
810 hDiscartedPulses->GetYaxis()->SetTitle( "# discartep pulses [a.u.]" );
811 //hDiscartedPulses->SetBit(TH2F::kCanRebin);
812 hDiscartedPulses->SetStats(mStats);
813 hList->Add( hDiscartedPulses );
814
815 // Afterpulse Distributions
816 //----------------------------------
817 if (mVerbosityLevel > 3) cout << "\t...booking " << hAfterPulses << endl;
818 hAfterPulses=new TH2F(
819 "hAfterPulses",
820 "amplitude distribution of pulses after trigger pulse",
821 1024 ,
822 0,
823 1024 ,
824 10*70,
825 -9,
826 60
827 );
828
829// hMaxOverlay[order]->SetAxisRange(
830// mBSLMean - 5,
831// (mGainMean*(order+1)) + 10,
832// "Y");
833 hAfterPulses->GetXaxis()->SetTitle( "delay [sample/ 0.5 ns]" );
834 hAfterPulses->GetYaxis()->SetTitle( "amplitude [mV]" );
835 //hDiscartedPulses->SetBit(TH2F::kCanRebin);
836 hAfterPulses->SetStats(mStats);
837 hList->Add( hAfterPulses );
838
839 }
840}
841//end of BookDistributionHistos
842//----------------------------------------------------------------------------
843
844void
845Pixel::BookTemplateHistos()
846{
847 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
848 for (int order = 0; order < mMaxPulseOrder; order++)
849 {
850 if (mVerbosityLevel > 3)
851 {
852 cout << "\t...booking " << HistoName("hPixelMax", order) << endl;
853 }
854
855 hPixelMax[order]=new TH1F(
856 HistoName("hPixelMax", order),
857 HistoTitle("Maximum value of each slice in overlay plot of", order),
858 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
859 (-1*mPixelOverlayXaxisLeft)-0.5,
860 mPixelOverlayXaxisRight-0.5
861 );
862
863 hPixelMax[order]->SetAxisRange(
864 mBSLMean - 5,
865 (mGainMean*(order+1)) + 10,
866 "Y");
867 hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
868 hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
869 //hMaxProfile->SetBit(TH2F::kCanRebin);
870 hPixelMax[order]->SetStats(mStats);
871 hList->Add( hPixelMax[order] );
872
873//------------------------------------------------------------------------
874
875 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMean", order) << endl;
876 hPixelMean[order] = new TH1F(
877 HistoName("hPixelMean", order),
878 HistoTitle("Mean value of each slice in overlay plot of", order),
879 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
880 (-1*mPixelOverlayXaxisLeft)-0.5,
881 mPixelOverlayXaxisRight-0.5
882 );
883 hPixelMean[order]->SetLineColor(kBlue);
884 hPixelMean[order]->SetAxisRange(
885 mBSLMean - 5,
886 (mGainMean*(order+1)) + 10,
887 "Y");
888 hPixelMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
889 hPixelMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
890 hPixelMean[order]->SetStats(mStats);
891 hList->Add( hPixelMean[order] );
892
893 //------------------------------------------------------------------------
894
895 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMedian", order) << endl;
896 hPixelMedian[order] = new TH1F(
897 HistoName("hPixelMedian", order),
898 HistoTitle("Median value of each slice in overlay plot of", order),
899 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
900 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
901 mPixelOverlayXaxisRight-0.5 //xup
902 );
903 hPixelMedian[order]->SetLineColor(kRed);
904 hPixelMedian[order]->SetAxisRange(
905 mBSLMean - 5,
906 (mGainMean*(order+1)) + 10,
907 "Y");
908 hPixelMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
909 hPixelMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
910 //hMaxProfile->SetBit(TH2F::kCanRebin);
911 hPixelMedian[order]->SetStats(mStats);
912 hList->Add( hPixelMedian[order] );
913
914 }
915 if (mVerbosityLevel > 2) cout << "...done" << endl;
916}
917//end of BookTemplateHistos
918//----------------------------------------------------------------------------
919
920void
921Pixel::BookEdgeTemplateHistos()
922{
923 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
924 for (int order = 0; order < mMaxPulseOrder; order++)
925 {
926 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl;
927 hPixelEdgeMax[order]=new TH1F(
928 HistoName("hPixelEdgeMax", order),
929 HistoTitle("Maximum value of each slice in overlay plot of", order),
930 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
931 (-1*mPixelOverlayXaxisLeft)-0.5,
932 mPixelOverlayXaxisRight-0.5
933 );
934
935 hPixelEdgeMax[order]->SetAxisRange(
936 mBSLMean - 5,
937 (mGainMean*(order+1)) + 10,
938 "Y");
939 hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
940 hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
941 //hMaxProfile->SetBit(TH2F::kCanRebin);
942 hPixelEdgeMax[order]->SetStats(mStats);
943 hList->Add( hPixelEdgeMax[order] );
944
945//------------------------------------------------------------------------
946
947 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl;
948 hPixelEdgeMean[order] = new TH1F(
949 HistoName("hPixelEdgeMean", order),
950 HistoTitle("Mean value of each slice in overlay plot of", order),
951 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
952 (-1*mPixelOverlayXaxisLeft)-0.5,
953 mPixelOverlayXaxisRight-0.5
954 );
955 hPixelEdgeMean[order]->SetLineColor(kBlue);
956 hPixelEdgeMean[order]->SetAxisRange(
957 mBSLMean - 5,
958 (mGainMean*(order+1)) + 10,
959 "Y");
960 hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
961 hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
962 hPixelEdgeMean[order]->SetStats(mStats);
963 hList->Add( hPixelEdgeMean[order] );
964
965 //------------------------------------------------------------------------
966
967 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl;
968 hPixelEdgeMedian[order] = new TH1F(
969 HistoName("hPixelEdgeMedian", order),
970 HistoTitle("Median value of each slice in overlay plot of", order),
971 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
972 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
973 mPixelOverlayXaxisRight-0.5 //xup
974 );
975 hPixelEdgeMedian[order]->SetLineColor(kRed);
976 hPixelEdgeMedian[order]->SetAxisRange(
977 mBSLMean - 5,
978 (mGainMean*(order+1)) + 10,
979 "Y");
980 hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
981 hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
982 //hMaxProfile->SetBit(TH2F::kCanRebin);
983 hPixelEdgeMedian[order]->SetStats(mStats);
984 hList->Add( hPixelEdgeMedian[order] );
985
986 }
987 if (mVerbosityLevel > 2) cout << "...done" << endl;
988}
989//end of BookEdgeTemplateHistos
990//----------------------------------------------------------------------------
991
992void
993Pixel::LoadPulseHistos()
994{
995 mRootFile->cd();
996
997 if (mVerbosityLevel > 2)
998 {
999 if (mVerbosityLevel > 3)
1000 {
1001 mRootFile->ls();
1002 }
1003 cout << "loading current File: " ;
1004 gFile->pwd();
1005 }
1006
1007 mRootFile->cd( CreateSubDirName( mChid ) ); //Go to pixel's subdirectory
1008 mDirectory = gDirectory;
1009
1010 if (mVerbosityLevel > 2)
1011 {
1012 if (mVerbosityLevel > 3)
1013 {
1014 gDirectory->ls();
1015 }
1016 cout << "Current Directory: " ;
1017 gDirectory->pwd();
1018 }
1019
1020
1021 if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl;
1022 for (int order = 0; order < mMaxPulseOrder; order++)
1023 {
1024
1025 if (mVerbosityLevel > 3) cout << "\t...loading " << ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) << endl;
1026 hMaxOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) );
1027
1028 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeOverlay", order) << endl;
1029 hEdgeOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeOverlay", order), 1) );
1030
1031 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hMaxProfile", order) << endl;
1032 hMaxProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxProfile", order), 1) );
1033
1034 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeProfile", order) << endl;
1035 hEdgeProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeProfile", order), 1) );
1036
1037
1038 }
1039 // mPixelOverlayXaxisRight =70; ///TODO: get it from the root file
1040 // mPixelOverlayXaxisLeft =230; ///TODO: get it from the root file
1041// mBSLMean =-2; ///TODO: get it from the root file
1042// mGainMean =11; ///TODO: get it from the root file
1043 // mOptions ="SRM"; ///TODO: get it from the root file
1044
1045// mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetXaxis()->GetBinLowEdge(
1046// hEdgeOverlay[0]->GetXaxis()->GetFirst()
1047// );
1048
1049// mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetXaxis()->GetBinUpEdge(
1050// hEdgeOverlay[0]->GetXaxis()->GetLast()
1051// );
1052
1053 mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetBinCenter(
1054 hEdgeOverlay[0]->GetXaxis()->GetFirst()
1055 );
1056
1057 mPixelOverlayXaxisLeft *= -1;
1058
1059 mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetBinCenter(
1060 hEdgeOverlay[0]->GetXaxis()->GetLast()
1061 );
1062
1063}
1064// end of LoadPulseHistos
1065//----------------------------------------------------------------------------
1066
1067void
1068Pixel::DeletePixelHistos()
1069{
1070 if (mVerbosityLevel > 2)
1071 {
1072 cout << endl
1073 << endl
1074 << "\t...delete current overlay histograms of Pixel# " << mChid;
1075 }
1076 for (int order = 0;
1077 order < mMaxPulseOrder;
1078 order ++)
1079 {
1080 if (mVerbosityLevel > 3)
1081 cout << endl << "\t\t...deleting hMaxOverlay"
1082 << mChid << "_" << order;
1083
1084 delete hMaxOverlay[order];
1085 hMaxOverlay[order] = NULL;
1086
1087 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
1088 << mChid << "_" << order ;
1089 delete hEdgeOverlay[order];
1090 hEdgeOverlay[order] = NULL;
1091
1092 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
1093 << mChid << "_" << order ;
1094 delete hMaxProfile[order];
1095 hMaxProfile[order] = NULL;
1096
1097 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
1098 << mChid << "_" << order ;
1099 delete hEdgeProfile[order];
1100 hEdgeProfile[order] = NULL;
1101 }
1102 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1103
1104 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
1105 delete[] hMaxOverlay;
1106 hMaxOverlay = NULL;
1107
1108 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
1109 delete[] hEdgeOverlay;
1110 hEdgeOverlay = NULL;
1111
1112 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
1113 delete[] hMaxProfile;
1114 hMaxProfile = NULL;
1115
1116 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
1117 delete[] hEdgeProfile;
1118 hEdgeProfile = NULL;
1119}
1120// end of DeletePixelHistos
1121//----------------------------------------------------------------------------
1122
1123void
1124Pixel::DeleteDistributionHistos()
1125{
1126 if (mVerbosityLevel > 2)
1127 {
1128 cout << endl
1129 << "\t...delete current distribution histograms" ;
1130 }
1131
1132 delete hMaxPos;
1133 delete hEdgePos;
1134 delete hEdgeSlope;
1135 delete hIntercept;
1136 delete hEdgeLength;
1137 delete hPulseLength;
1138 delete hPulseLengthAPcutoff;
1139 delete hPulseLengthTLcutoff;
1140 delete hMaxAmpl;
1141 delete hDiscartedPulses;
1142 delete hAfterPulses;
1143
1144 for (int order = 0;
1145 order < mMaxPulseOrder;
1146 order ++)
1147 {
1148 if (mOptions.Contains("S"))
1149 {
1150 if (mVerbosityLevel > 3) cout << endl
1151 << "\t\t...deleting hSlopeRisingEdge"
1152 << mChid << "_" << order ;
1153 delete hSlopeRisingEdge[order];
1154 }
1155
1156 if (mOptions.Contains("R"))
1157 {
1158 if (mVerbosityLevel > 3) cout << endl
1159 << "\t\t...deleting hRisingEdgeToMax"
1160 << mChid << "_" << order ;
1161 delete hRisingEdgeToMax[order];
1162 }
1163
1164 if (mOptions.Contains("M"))
1165 {
1166 if (mVerbosityLevel > 3) cout << endl
1167 << "\t\t...deleting hPosOfMax"
1168 << mChid << "_" << order ;
1169
1170 delete hPosOfMax[order];
1171 }
1172
1173 }
1174 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1175
1176 if (mOptions.Contains("S"))
1177 {
1178 if (mVerbosityLevel > 3)
1179 cout << endl << "\t\t...deleting hSlopeRisingEdge";
1180 delete[] hSlopeRisingEdge;
1181 hSlopeRisingEdge = NULL;
1182 }
1183
1184 if (mOptions.Contains("R"))
1185 {
1186 if (mVerbosityLevel > 3)
1187 cout << endl << "\t\t...deleting hRisingEdgeToMax";
1188 delete[] hRisingEdgeToMax;
1189 hRisingEdgeToMax = NULL;
1190 }
1191
1192 if (mOptions.Contains("M"))
1193 {
1194 if (mVerbosityLevel > 3)
1195 cout << endl << "\t\t...deleting hPosOfMax";
1196 delete[] hPosOfMax;
1197 hPosOfMax = NULL;
1198 }
1199}
1200// end of DeletePixelHistos
1201//----------------------------------------------------------------------------
1202
1203void
1204Pixel::DeleteTemplateHistos()
1205{
1206 if (mVerbosityLevel > 2)
1207 {
1208 cout << endl
1209 << "\t...delete current template histograms of Pixel# " << mChid;
1210 }
1211 for (int order = 0;
1212 order < mMaxPulseOrder;
1213 order ++)
1214 {
1215 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean"
1216 << mChid << "_" << order ;
1217 delete hPixelMean[order];
1218 hPixelMean[order] = NULL;
1219
1220 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian"
1221 << mChid << "_" << order ;
1222 delete hPixelMedian[order];
1223 hPixelMedian[order] = NULL;
1224
1225 if (mVerbosityLevel > 3)
1226 cout << endl << "\t\t...deleting hPixelMax"
1227 << mChid << "_" << order;
1228 delete hPixelMax[order];
1229 hPixelMax[order] = NULL;
1230
1231 }
1232 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1233
1234 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax";
1235 delete[] hPixelMax;
1236 hPixelMax = NULL;
1237
1238 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian";
1239 delete[] hPixelMedian;
1240 hPixelMedian = NULL;
1241
1242 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean";
1243 delete[] hPixelMean;
1244 hPixelMean = NULL;
1245}
1246// end of DeleteTemplateHistos
1247//----------------------------------------------------------------------------
1248
1249void
1250Pixel::DeleteEdgeTemplateHistos()
1251{
1252 if (mVerbosityLevel > 2)
1253 {
1254 cout << endl
1255 << "\t...delete current Edge template histograms of Pixel# " << mChid;
1256 }
1257 for (int order = 0;
1258 order < mMaxPulseOrder;
1259 order ++)
1260 {
1261 if (mVerbosityLevel > 3)
1262 cout << endl << "\t\t...deleting hPixelEdgeMax"
1263 << mChid << "_" << order;
1264
1265 delete hPixelEdgeMax[order];
1266 hPixelEdgeMax[order] = NULL;
1267
1268 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"
1269 << mChid << "_" << order ;
1270 delete hPixelEdgeMedian[order];
1271 hPixelEdgeMedian[order] = NULL;
1272
1273 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"
1274 << mChid << "_" << order ;
1275 delete hPixelEdgeMean[order];
1276 hPixelEdgeMean[order] = NULL;
1277
1278 }
1279 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1280
1281 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax";
1282 delete[] hPixelEdgeMax;
1283 hPixelEdgeMax = NULL;
1284
1285 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian";
1286 delete[] hPixelEdgeMedian;
1287 hPixelEdgeMedian = NULL;
1288
1289 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean";
1290 delete[] hPixelEdgeMean;
1291 hPixelEdgeMean = NULL;
1292}
1293// end of DeleteTemplateHistos
1294//----------------------------------------------------------------------------
1295
1296void
1297Pixel::MakeTH1Pretty(
1298 TH1* histo,
1299 TString histName,
1300 TString histTitle,
1301 int order
1302 )
1303{
1304 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1305
1306 histo->SetNameTitle(
1307 HistoName(histName, order),
1308 HistoTitle(histTitle, order)
1309 );
1310
1311 histo->SetBins(
1312 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1313 (-1*mPixelOverlayXaxisLeft)-0.5,
1314 mPixelOverlayXaxisRight-0.5
1315 );
1316
1317 histo->SetAxisRange(
1318 mBSLMean - 5,
1319 (mGainMean*(order+1)) + 10,
1320 "Y");
1321 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1322 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1323 //histo->SetBit(TH2F::kCanRebin);
1324 histo->SetStats(mStats);
1325}
1326// end of MakeTH2Pretty
1327//----------------------------------------------------------------------------
1328
1329
1330void
1331Pixel::MakeTH2Pretty(
1332 TH2* histo,
1333 TString histName,
1334 TString histTitle,
1335 int order
1336 )
1337{
1338 if (mVerbosityLevel > 3) cout << "\t...designing " << HistoName(histName, order) << endl;
1339
1340 histo->SetNameTitle(
1341 HistoName(histName, order),
1342 HistoTitle(histTitle, order)
1343 );
1344
1345 histo->SetBins(
1346 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1347 (-1*mPixelOverlayXaxisLeft)-0.5,
1348 mPixelOverlayXaxisRight-0.5 ,
1349 512,
1350 -55.5,
1351 200.5
1352 );
1353
1354 histo->SetAxisRange(
1355 mBSLMean - 5,
1356 (mGainMean*(order+1)) + 10,
1357 "Y");
1358
1359 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1360 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1361 //histo->SetBit(TH2F::kCanRebin);
1362 histo->SetStats(mStats);
1363}
1364// end of MakeTH2Pretty
1365//----------------------------------------------------------------------------
1366
1367void
1368Pixel::MakeTProfilePretty(
1369 TProfile* histo,
1370 TString histName,
1371 TString histTitle,
1372 int order
1373 )
1374{
1375 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1376
1377 histo->SetNameTitle(
1378 HistoName(histName, order),
1379 HistoTitle(histTitle, order)
1380 );
1381
1382 histo->SetBins(
1383 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1384 (-1*mPixelOverlayXaxisLeft)-0.5,
1385 mPixelOverlayXaxisRight-0.5
1386 );
1387 histo->SetOption( "s" );
1388
1389 histo->SetAxisRange(
1390 mBSLMean - 5,
1391 (mGainMean*(order+1)) + 10,
1392 "Y");
1393
1394 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1395 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1396 //histo->SetBit(TH2F::kCanRebin);
1397 histo->SetStats(mStats);
1398}
1399// end of MakeTProfilePretty
1400//----------------------------------------------------------------------------
1401
1402
1403void
1404Pixel::ShiftHistoInY(
1405 TH1* histo,
1406 float shift
1407 )
1408{
1409 int min_bin = histo->GetXaxis()->GetFirst();
1410 int max_bin = histo->GetXaxis()->GetLast();
1411
1412 for (int bin = min_bin; bin <= max_bin; bin++)
1413 {
1414 histo->AddBinContent( bin, shift);
1415 }
1416
1417}
1418
1419void
1420Pixel::SetRangeUser(float xMin, float xMax, int order)
1421{
1422 hMaxOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1423 hEdgeOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1424
1425 hPixelMax[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1426 hPixelMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1427 hPixelMean[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1428
1429 hPixelEdgeMax[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1430 hPixelEdgeMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1431 hPixelEdgeMean[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1432
1433 return;
1434}
1435
1436void
1437Pixel::NormalizeSamplesTH2F(TH2F* histo)
1438{
1439
1440 int first = histo->GetXaxis()->GetFirst();
1441 int last = histo->GetXaxis()->GetLast();
1442
1443 TH2F *hTemp = new TH2F(*histo);
1444 hTemp->Reset();
1445
1446 for (int i = first; i < last; i++)
1447 {
1448 TH1* hTemp1D = histo->ProjectionY("_px1", i, i+1);
1449 double integral = hTemp1D->Integral();
1450 // double maximum = hTemp->GetBinContent(hTemp->GetMaximumBin());
1451 hTemp1D->Scale(1/integral);
1452 // hTemp->Scale(1/maximum);
1453 int first_sl = hTemp1D->GetXaxis()->GetFirst();
1454 int last_sl = hTemp1D->GetXaxis()->GetLast();
1455
1456 for (int j = first_sl; j < last_sl; j++)
1457 {
1458 hTemp->SetBinContent(i, j, hTemp->GetBinContent(j));
1459 }
1460 }
1461
1462 histo->Reset();
1463 histo->Add(hTemp);
1464
1465 delete hTemp;
1466 return;
1467}
1468
1469void
1470Pixel::Normalize2Dhistos(int order)
1471{
1472 NormalizeSamplesTH2F(hMaxOverlay[order]);
1473 NormalizeSamplesTH2F(hEdgeOverlay[order]);
1474 return;
1475}
1476
1477
Note: See TracBrowser for help on using the repository browser.