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

Last change on this file since 18752 was 15369, checked in by Jens Buss, 12 years ago
additional histos
File size: 52.0 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]->SetDrawOption("colz");
445 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
446 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
447 //hMaxProfile->SetBit(TH2F::kCanRebin);
448 hMaxOverlay[order]->SetStats(mStats);
449 hList->Add( hMaxOverlay[order] );
450
451//------------------------------------------------------------------------
452
453 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeOverlay", order) << endl;
454 hEdgeOverlay[order] = new TH2F(
455 HistoName("hEdgeOverlay", order),
456 HistoTitle("Overlay at rising edge of detected pulses of", order),
457 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
458 (-1*mPixelOverlayXaxisLeft)-0.5,
459 mPixelOverlayXaxisRight-0.5 ,
460 512,
461 -55.5,
462 200.5
463 );
464
465 hEdgeOverlay[order]->SetAxisRange(
466 mBSLMean - 5,
467 (mGainMean*(order+1)) + 10,
468 "Y");
469 hEdgeOverlay[order]->SetDrawOption("colz");
470 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
471 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
472 hEdgeOverlay[order]->SetStats(mStats);
473 hList->Add( hEdgeOverlay[order] );
474
475 //------------------------------------------------------------------------
476
477 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hMaxProfile", order) << endl;
478 hMaxProfile[order] = new TProfile(
479 HistoName("hMaxProfile", order),
480 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
481 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
482 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
483 mPixelOverlayXaxisRight-0.5 , //xup
484 // 512, //nbinsy
485 -55.5, //ylow
486 300.5, //yup
487 "s"); //option
488 hMaxProfile[order]->SetAxisRange(
489 mBSLMean - 5,
490 (mGainMean*(order+1)) + 10,
491 "Y");
492 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
493 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
494 //hMaxProfile->SetBit(TH2F::kCanRebin);
495 hMaxProfile[order]->SetStats(mStats);
496 hList->Add( hMaxProfile[order] );
497
498
499 //------------------------------------------------------------------------
500
501 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hEdgeProfile", order) << endl;
502 hEdgeProfile[order] = new TProfile(
503 HistoName("hEdgeProfile", order),
504 HistoTitle("Mean value of each slice in overlay plot (Tprofile)", order),
505 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
506 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
507 mPixelOverlayXaxisRight-0.5 , //xup
508 // 512, //nbinsy
509 -55.5, //ylow
510 300.5, //yup
511 "s"); //option
512 hEdgeProfile[order]->SetLineColor(kRed);
513 hEdgeProfile[order]->SetAxisRange(
514 mBSLMean - 5,
515 (mGainMean*(order+1)) + 10,
516 "Y");
517 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
518 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
519 //hMaxProfile->SetBit(TH2F::kCanRebin);
520 hEdgeProfile[order]->SetStats(mStats);
521 hList->Add( hEdgeProfile[order] );
522
523 }
524 if (mVerbosityLevel > 2) cout << "...done" << endl;
525}
526//end of BookPixelHistos
527//----------------------------------------------------------------------------
528
529void
530Pixel::BookDistributionHistos( )
531{
532 if (!mOptions.IsNull() )
533 {
534 int x_min = 0;
535 int x_max = 0;
536
537 for (int order =0; order < mMaxPulseOrder; order++)
538 {
539 if (mVerbosityLevel > 2) cout << endl
540 << "...book distribution histograms"
541 << endl;
542
543 if (mOptions.Contains("S"))
544 {
545 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
546 hSlopeRisingEdge[order] = new TH1F (
547 HistoName("hSlopeRisingEdge", order),
548 HistoTitle("Distribution of rising edge's slope", order),
549 600,
550 -10.1,
551 10.1
552 );
553 hSlopeRisingEdge[order]->SetAxisRange(
554 -1,
555 7,
556 "X");
557 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Slope Amplitude/time [mV/timeslices]" );
558 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
559 hSlopeRisingEdge[order]->SetStats(mStats);
560 hList->Add( hSlopeRisingEdge[order] );
561 }
562
563 if (mOptions.Contains("R"))
564 {
565 x_min = -15;
566 x_max = 35;
567
568 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hRisingEdgeToMax", order) << endl;
569 hRisingEdgeToMax[order] = new TH1I (
570 HistoName("hRisingEdgeToMax", order),
571 HistoTitle("Distribution of distance between rising edge and pulse's maximum", order),
572 x_max -x_min,
573 x_min,
574 x_max
575 );
576 hSlopeRisingEdge[order]->SetAxisRange(
577 -5,
578 25,
579 "X");
580 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
581 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
582 hRisingEdgeToMax[order]->SetStats(mStats);
583 hList->Add( hRisingEdgeToMax[order] );
584 }
585
586 if (mOptions.Contains("M"))
587 {
588 x_min = 10;
589 x_max = 290;
590 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPosOfMax", order) << endl;
591 hPosOfMax[order] = new TH1I (
592 HistoName("hPosOfMax", order),
593 HistoTitle("Distribution of pulse's maximum's positon", order),
594 x_max - x_min,
595 x_min,
596 x_max
597 );
598 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
599 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
600 hRisingEdgeToMax[order]->SetStats(mStats);
601 hList->Add( hPosOfMax[order] );
602 }
603
604 if (mOptions.Contains("C"))
605 {
606 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hSlopeRisingEdge", order) << endl;
607 hChi2EdgetoMax[order] = new TH1F (
608 HistoName("hChi2EdgetoMax", order),
609 HistoTitle("Distribution of CHI2 comparison of Edge and Max", order),
610 600,
611 -299,
612 300
613 );
614 hChi2EdgetoMax[order]->SetAxisRange(
615 -1,
616 7,
617 "X");
618 hChi2EdgetoMax[order]->GetXaxis()->SetTitle( "p-Value" );
619 hChi2EdgetoMax[order]->GetYaxis()->SetTitle( "counts" );
620 hChi2EdgetoMax[order]->SetStats(mStats);
621// hList->Add( hChi2EdgetoMax[order] );
622 }
623
624 if (mVerbosityLevel > 2) cout << "...done" << endl;
625 }
626
627 // Arrival Time Distributions
628 //----------------------------------
629 if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxPos" << endl;
630 hMaxPos = new TH1F (
631 "hMaxPos",
632 "Distribution of arrival times according to the EdgePos",
633 1025,
634 -1,
635 1024
636 );
637// hMaxPos->SetAxisRange(
638// 0,
639// 1024,
640// "X");
641 hMaxPos->SetDrawOption("colz");
642 hMaxPos->GetXaxis()->SetTitle( " arrival time [timeslices]" );
643 hMaxPos->GetYaxis()->SetTitle( "counts" );
644 hMaxPos->SetStats(mStats);
645 hList->Add( hMaxPos );
646
647 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgePos" << endl;
648 hEdgePos = new TH1F (
649 "hEdgePos",
650 "Distribution of arrival times according to the EdgePos",
651 1125,
652 -1,
653 1124
654 );
655// hEdgePos->SetAxisRange(
656// 0,
657// 1024,
658// "X");
659 hEdgePos->SetDrawOption("colz");
660 hEdgePos->GetXaxis()->SetTitle( " arrival time [timeslices]" );
661 hEdgePos->GetYaxis()->SetTitle( "counts" );
662 hEdgePos->SetStats(mStats);
663 hList->Add( hEdgePos );
664
665 // Edge Slope Distributions
666 //----------------------------------
667 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeSlope" << endl;
668 hEdgeSlope = new TH1F (
669 "hEdgeSlope",
670 "Distribution of slope of leading edges",
671 100,
672 -1.55,
673 8.45
674 );
675 hEdgeSlope->SetAxisRange(
676 0.5,
677 7,
678 "X");
679 hEdgeSlope->SetDrawOption("colz");
680 hEdgeSlope->GetXaxis()->SetTitle( " slope [a.u.]" );
681 hEdgeSlope->GetYaxis()->SetTitle( "counts" );
682 hEdgeSlope->SetStats(mStats);
683 hList->Add( hEdgeSlope );
684
685 // Edge Slope Distributions
686 //----------------------------------
687 if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxEdgeSlope" << endl;
688 hMaxEdgeSlope = new TH1F (
689 "hMaxEdgeSlope",
690 "Distribution of maximum slope in slices of leading edges",
691 100,
692 -1.55,
693 8.45
694 );
695 hMaxEdgeSlope->SetAxisRange(
696 0.5,
697 7,
698 "X");
699 hMaxEdgeSlope->SetDrawOption("colz");
700 hMaxEdgeSlope->GetXaxis()->SetTitle( " slope [a.u.]" );
701 hMaxEdgeSlope->GetYaxis()->SetTitle( "counts" );
702 hMaxEdgeSlope->SetStats(mStats);
703 hList->Add( hMaxEdgeSlope );
704
705 // Intercept Distributions
706 //----------------------------------
707 if (mVerbosityLevel > 3) cout << "\t...booking " << "hIntercept" << endl;
708 hIntercept = new TH1F (
709 "hIntercept",
710 "Distribution of Intercept of leading edges",
711 1041,
712 -1,
713 1040
714 );
715 hIntercept->SetAxisRange(
716 -100,
717 100,
718 "X");
719 hIntercept->SetDrawOption("colz");
720 hIntercept->GetXaxis()->SetTitle( " Intercept [a.u.]" );
721 hIntercept->GetYaxis()->SetTitle( "counts" );
722 hIntercept->SetStats(mStats);
723 hList->Add( hIntercept );
724
725 // Edge lengt Distributions
726 //----------------------------------
727 if (mVerbosityLevel > 3) cout << "\t...booking " << "hEdgeLength" << endl;
728 hEdgeLength = new TH1F (
729 "hEdgeLength",
730 "Distribution of hEdgeLength of leading edges",
731 200,
732 -0.5,
733 199.5
734 );
735 hEdgeLength->SetAxisRange(
736 0,
737 100,
738 "X");
739 hEdgeLength->SetDrawOption("colz");
740 hEdgeLength->GetXaxis()->SetTitle( " edge length [a.u.]" );
741 hEdgeLength->GetYaxis()->SetTitle( "counts" );
742 hEdgeLength->SetStats(mStats);
743 hList->Add( hEdgeLength );
744
745 // Pulse length Distributions
746 //----------------------------------
747 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLength" << endl;
748 hPulseLength = new TH1F (
749 "hPulseLength",
750 "Distribution of pulse lengthes",
751 1024,
752 -0.5,
753 1023.5
754 );
755 hPulseLength->SetAxisRange(
756 0,
757 600,
758 "X");
759 hPulseLength->SetDrawOption("colz");
760 hPulseLength->GetXaxis()->SetTitle( " pulse length [samples]" );
761 hPulseLength->GetYaxis()->SetTitle( "counts" );
762 hPulseLength->SetStats(mStats);
763 hList->Add( hPulseLength );
764
765 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthAPcutoff" << endl;
766 hPulseLengthAPcutoff = new TH1F (
767 "hPulseLengthAPcutoff",
768 "Distribution of pulse lengthes due to afterpulse cut off",
769 1024,
770 -0.5,
771 1023.5
772 );
773// hPulseLength->SetAxisRange(
774// 0,
775// 1024,
776// "X");
777 hPulseLengthAPcutoff->SetDrawOption("colz");
778 hPulseLengthAPcutoff->GetXaxis()->SetTitle( " pulse length [samples]" );
779 hPulseLengthAPcutoff->GetYaxis()->SetTitle( "counts" );
780 hPulseLengthAPcutoff->SetStats(mStats);
781 hList->Add( hPulseLengthAPcutoff );
782
783 if (mVerbosityLevel > 3) cout << "\t...booking " << "hPulseLengthTLcutoff" << endl;
784 hPulseLengthTLcutoff = new TH1F (
785 "hPulseLengthTLcutoff",
786 "Distribution of pulse lengthes due to time line cut off",
787 1024,
788 -0.5,
789 1023.5
790 );
791// hPulseLengthTLcutoff->SetAxisRange(
792// 0,
793// 1024,
794// "X");
795 hPulseLengthTLcutoff->SetDrawOption("colz");
796 hPulseLengthTLcutoff->GetXaxis()->SetTitle( " pulse length [samples]" );
797 hPulseLengthTLcutoff->GetYaxis()->SetTitle( "counts" );
798 hPulseLengthTLcutoff->SetStats(mStats);
799 hList->Add( hPulseLengthTLcutoff );
800
801 // Amplitude Distributions
802 //----------------------------------
803
804 if (mVerbosityLevel > 3) cout << "\t...booking " << "hMaxAmpl" << endl;
805 hMaxAmpl = new TH1F (
806 "hMaxAmpl",
807 "Distribution of MaxAmpl of leading edges",
808 100*10,
809 0,
810 100
811 );
812// hMaxAmpl->SetAxisRange(
813// 0,
814// 1024,
815// "X");
816 hMaxAmpl->SetDrawOption("colz");
817 hMaxAmpl->GetXaxis()->SetTitle( " Amplitude [a.u.]" );
818 hMaxAmpl->GetYaxis()->SetTitle( "counts" );
819 hMaxAmpl->SetStats(mStats);
820 hList->Add( hMaxAmpl );
821
822 // Discarted Pulses Distributions
823 //----------------------------------
824 if (mVerbosityLevel > 3) cout << "\t...booking " << "hDiscartedPulses" << endl;
825 hDiscartedPulses=new TProfile(
826 "hDiscartedPulses",
827 "DiscartedPulses vs. preperation step",
828 15 ,
829 -0.5,
830 14.5 /*,
831 100,
832 0,
833 1*/
834 );
835
836// hDiscartedPulses->SetAxisRange(
837// 0,
838// 50,
839// "Y");
840 hDiscartedPulses->SetAxisRange(
841 -0.5,
842 9.5,
843 "X");
844 hDiscartedPulses->SetDrawOption("colz");
845 hDiscartedPulses->GetXaxis()->SetTitle( "step [a.u.]" );
846 hDiscartedPulses->GetYaxis()->SetTitle( "# discartep pulses [a.u.]" );
847 //hDiscartedPulses->SetBit(TH2F::kCanRebin);
848 hDiscartedPulses->SetStats(mStats);
849 hList->Add( hDiscartedPulses );
850
851 // Afterpulse Distributions
852 //----------------------------------
853 if (mVerbosityLevel > 3) cout << "\t...booking " << "hAfterPulses" << endl;
854 hAfterPulses=new TH2F(
855 "hAfterPulses",
856 "amplitude distribution of pulses after trigger pulse",
857 1024 ,
858 0,
859 1024 ,
860 10*70,
861 -9,
862 60
863 );
864
865// hMaxOverlay[order]->SetAxisRange(
866// mBSLMean - 5,
867// (mGainMean*(order+1)) + 10,
868// "Y");
869 hAfterPulses->SetDrawOption("colz");
870 hAfterPulses->GetXaxis()->SetTitle( "delay [sample/ 0.5 ns]" );
871 hAfterPulses->GetYaxis()->SetTitle( "amplitude [mV]" );
872 //hDiscartedPulses->SetBit(TH2F::kCanRebin);
873 hAfterPulses->SetStats(mStats);
874 hList->Add( hAfterPulses );
875
876 }
877}
878//end of BookDistributionHistos
879//----------------------------------------------------------------------------
880
881void
882Pixel::BookTemplateHistos()
883{
884 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
885 for (int order = 0; order < mMaxPulseOrder; order++)
886 {
887 if (mVerbosityLevel > 3)
888 {
889 cout << "\t...booking " << HistoName("hPixelMax", order) << endl;
890 }
891
892 hPixelMax[order]=new TH1F(
893 HistoName("hPixelMax", order),
894 HistoTitle("Maximum value of each slice in overlay plot of", order),
895 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
896 (-1*mPixelOverlayXaxisLeft)-0.5,
897 mPixelOverlayXaxisRight-0.5
898 );
899
900 hPixelMax[order]->SetAxisRange(
901 mBSLMean - 5,
902 (mGainMean*(order+1)) + 10,
903 "Y");
904 hPixelMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
905 hPixelMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
906 //hMaxProfile->SetBit(TH2F::kCanRebin);
907 hPixelMax[order]->SetStats(mStats);
908 hList->Add( hPixelMax[order] );
909
910//------------------------------------------------------------------------
911
912 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMean", order) << endl;
913 hPixelMean[order] = new TH1F(
914 HistoName("hPixelMean", order),
915 HistoTitle("Mean value of each slice in overlay plot of", order),
916 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
917 (-1*mPixelOverlayXaxisLeft)-0.5,
918 mPixelOverlayXaxisRight-0.5
919 );
920 hPixelMean[order]->SetLineColor(kBlue);
921 hPixelMean[order]->SetAxisRange(
922 mBSLMean - 5,
923 (mGainMean*(order+1)) + 10,
924 "Y");
925 hPixelMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
926 hPixelMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
927 hPixelMean[order]->SetStats(mStats);
928 hList->Add( hPixelMean[order] );
929
930 //------------------------------------------------------------------------
931
932 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelMedian", order) << endl;
933 hPixelMedian[order] = new TH1F(
934 HistoName("hPixelMedian", order),
935 HistoTitle("Median value of each slice in overlay plot of", order),
936 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
937 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
938 mPixelOverlayXaxisRight-0.5 //xup
939 );
940 hPixelMedian[order]->SetLineColor(kRed);
941 hPixelMedian[order]->SetAxisRange(
942 mBSLMean - 5,
943 (mGainMean*(order+1)) + 10,
944 "Y");
945 hPixelMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
946 hPixelMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
947 //hMaxProfile->SetBit(TH2F::kCanRebin);
948 hPixelMedian[order]->SetStats(mStats);
949 hList->Add( hPixelMedian[order] );
950
951 }
952 if (mVerbosityLevel > 2) cout << "...done" << endl;
953}
954//end of BookTemplateHistos
955//----------------------------------------------------------------------------
956
957void
958Pixel::BookEdgeTemplateHistos()
959{
960 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
961 for (int order = 0; order < mMaxPulseOrder; order++)
962 {
963 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMax", order) << endl;
964 hPixelEdgeMax[order]=new TH1F(
965 HistoName("hPixelEdgeMax", order),
966 HistoTitle("Maximum value of each slice in overlay plot of", order),
967 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
968 (-1*mPixelOverlayXaxisLeft)-0.5,
969 mPixelOverlayXaxisRight-0.5
970 );
971
972 hPixelEdgeMax[order]->SetAxisRange(
973 mBSLMean - 5,
974 (mGainMean*(order+1)) + 10,
975 "Y");
976 hPixelEdgeMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
977 hPixelEdgeMax[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
978 //hMaxProfile->SetBit(TH2F::kCanRebin);
979 hPixelEdgeMax[order]->SetStats(mStats);
980 hList->Add( hPixelEdgeMax[order] );
981
982//------------------------------------------------------------------------
983
984 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMean", order) << endl;
985 hPixelEdgeMean[order] = new TH1F(
986 HistoName("hPixelEdgeMean", order),
987 HistoTitle("Mean value of each slice in overlay plot of", order),
988 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
989 (-1*mPixelOverlayXaxisLeft)-0.5,
990 mPixelOverlayXaxisRight-0.5
991 );
992 hPixelEdgeMean[order]->SetLineColor(kBlue);
993 hPixelEdgeMean[order]->SetAxisRange(
994 mBSLMean - 5,
995 (mGainMean*(order+1)) + 10,
996 "Y");
997 hPixelEdgeMean[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
998 hPixelEdgeMean[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
999 hPixelEdgeMean[order]->SetStats(mStats);
1000 hList->Add( hPixelEdgeMean[order] );
1001
1002 //------------------------------------------------------------------------
1003
1004 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName("hPixelEdgeMedian", order) << endl;
1005 hPixelEdgeMedian[order] = new TH1F(
1006 HistoName("hPixelEdgeMedian", order),
1007 HistoTitle("Median value of each slice in overlay plot of", order),
1008 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
1009 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
1010 mPixelOverlayXaxisRight-0.5 //xup
1011 );
1012 hPixelEdgeMedian[order]->SetLineColor(kRed);
1013 hPixelEdgeMedian[order]->SetAxisRange(
1014 mBSLMean - 5,
1015 (mGainMean*(order+1)) + 10,
1016 "Y");
1017 hPixelEdgeMedian[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1018 hPixelEdgeMedian[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
1019 //hMaxProfile->SetBit(TH2F::kCanRebin);
1020 hPixelEdgeMedian[order]->SetStats(mStats);
1021 hList->Add( hPixelEdgeMedian[order] );
1022
1023 }
1024 if (mVerbosityLevel > 2) cout << "...done" << endl;
1025}
1026//end of BookEdgeTemplateHistos
1027//----------------------------------------------------------------------------
1028
1029void
1030Pixel::LoadPulseHistos()
1031{
1032 mRootFile->cd();
1033
1034 if (mVerbosityLevel > 2)
1035 {
1036 if (mVerbosityLevel > 3)
1037 {
1038 mRootFile->ls();
1039 }
1040 cout << "loading current File: " ;
1041 gFile->pwd();
1042 }
1043
1044 mRootFile->cd( CreateSubDirName( mChid ) ); //Go to pixel's subdirectory
1045 mDirectory = gDirectory;
1046
1047 if (mVerbosityLevel > 2)
1048 {
1049 if (mVerbosityLevel > 3)
1050 {
1051 gDirectory->ls();
1052 }
1053 cout << "Current Directory: " ;
1054 gDirectory->pwd();
1055 }
1056
1057
1058 if (mVerbosityLevel > 2) cout << endl << "...load pixel histograms" << endl;
1059 for (int order = 0; order < mMaxPulseOrder; order++)
1060 {
1061
1062 if (mVerbosityLevel > 3) cout << "\t...loading " << ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) << endl;
1063 hMaxOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxOverlay", order), 1) );
1064
1065 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeOverlay", order) << endl;
1066 hEdgeOverlay[order] = (TH2F*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeOverlay", order), 1) );
1067
1068 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hMaxProfile", order) << endl;
1069 hMaxProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hMaxProfile", order), 1) );
1070
1071 if (mVerbosityLevel > 3) cout << "\t...loading " << HistoName("hEdgeProfile", order) << endl;
1072 hEdgeProfile[order] = (TProfile*)mDirectory->Get( ChooseCycleNumber( HistoName("hEdgeProfile", order), 1) );
1073
1074
1075 }
1076 // mPixelOverlayXaxisRight =70; ///TODO: get it from the root file
1077 // mPixelOverlayXaxisLeft =230; ///TODO: get it from the root file
1078// mBSLMean =-2; ///TODO: get it from the root file
1079// mGainMean =11; ///TODO: get it from the root file
1080 // mOptions ="SRM"; ///TODO: get it from the root file
1081
1082// mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetXaxis()->GetBinLowEdge(
1083// hEdgeOverlay[0]->GetXaxis()->GetFirst()
1084// );
1085
1086// mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetXaxis()->GetBinUpEdge(
1087// hEdgeOverlay[0]->GetXaxis()->GetLast()
1088// );
1089
1090 mPixelOverlayXaxisLeft = hEdgeOverlay[0]->GetBinCenter(
1091 hEdgeOverlay[0]->GetXaxis()->GetFirst()
1092 );
1093
1094 mPixelOverlayXaxisLeft *= -1;
1095
1096 mPixelOverlayXaxisRight = hEdgeOverlay[0]->GetBinCenter(
1097 hEdgeOverlay[0]->GetXaxis()->GetLast()
1098 );
1099
1100}
1101// end of LoadPulseHistos
1102//----------------------------------------------------------------------------
1103
1104void
1105Pixel::DeletePixelHistos()
1106{
1107 if (mVerbosityLevel > 2)
1108 {
1109 cout << endl
1110 << endl
1111 << "\t...delete current overlay histograms of Pixel# " << mChid;
1112 }
1113 for (int order = 0;
1114 order < mMaxPulseOrder;
1115 order ++)
1116 {
1117 if (mVerbosityLevel > 3)
1118 cout << endl << "\t\t...deleting hMaxOverlay"
1119 << mChid << "_" << order;
1120
1121 delete hMaxOverlay[order];
1122 hMaxOverlay[order] = NULL;
1123
1124 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
1125 << mChid << "_" << order ;
1126 delete hEdgeOverlay[order];
1127 hEdgeOverlay[order] = NULL;
1128
1129 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
1130 << mChid << "_" << order ;
1131 delete hMaxProfile[order];
1132 hMaxProfile[order] = NULL;
1133
1134 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
1135 << mChid << "_" << order ;
1136 delete hEdgeProfile[order];
1137 hEdgeProfile[order] = NULL;
1138 }
1139 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1140
1141 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
1142 delete[] hMaxOverlay;
1143 hMaxOverlay = NULL;
1144
1145 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
1146 delete[] hEdgeOverlay;
1147 hEdgeOverlay = NULL;
1148
1149 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
1150 delete[] hMaxProfile;
1151 hMaxProfile = NULL;
1152
1153 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
1154 delete[] hEdgeProfile;
1155 hEdgeProfile = NULL;
1156}
1157// end of DeletePixelHistos
1158//----------------------------------------------------------------------------
1159
1160void
1161Pixel::DeleteDistributionHistos()
1162{
1163 if (mVerbosityLevel > 2)
1164 {
1165 cout << endl
1166 << "\t...delete current distribution histograms" ;
1167 }
1168
1169 delete hMaxPos;
1170 delete hEdgePos;
1171 delete hEdgeSlope;
1172 delete hMaxEdgeSlope;
1173 delete hIntercept;
1174 delete hEdgeLength;
1175 delete hPulseLength;
1176 delete hPulseLengthAPcutoff;
1177 delete hPulseLengthTLcutoff;
1178 delete hMaxAmpl;
1179 delete hDiscartedPulses;
1180 delete hAfterPulses;
1181
1182 for (int order = 0;
1183 order < mMaxPulseOrder;
1184 order ++)
1185 {
1186 if (mOptions.Contains("S"))
1187 {
1188 if (mVerbosityLevel > 3) cout << endl
1189 << "\t\t...deleting hSlopeRisingEdge"
1190 << mChid << "_" << order ;
1191 delete hSlopeRisingEdge[order];
1192 }
1193
1194 if (mOptions.Contains("R"))
1195 {
1196 if (mVerbosityLevel > 3) cout << endl
1197 << "\t\t...deleting hRisingEdgeToMax"
1198 << mChid << "_" << order ;
1199 delete hRisingEdgeToMax[order];
1200 }
1201
1202 if (mOptions.Contains("M"))
1203 {
1204 if (mVerbosityLevel > 3) cout << endl
1205 << "\t\t...deleting hPosOfMax"
1206 << mChid << "_" << order ;
1207
1208 delete hPosOfMax[order];
1209 }
1210
1211 }
1212 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1213
1214 if (mOptions.Contains("S"))
1215 {
1216 if (mVerbosityLevel > 3)
1217 cout << endl << "\t\t...deleting hSlopeRisingEdge";
1218 delete[] hSlopeRisingEdge;
1219 hSlopeRisingEdge = NULL;
1220 }
1221
1222 if (mOptions.Contains("R"))
1223 {
1224 if (mVerbosityLevel > 3)
1225 cout << endl << "\t\t...deleting hRisingEdgeToMax";
1226 delete[] hRisingEdgeToMax;
1227 hRisingEdgeToMax = NULL;
1228 }
1229
1230 if (mOptions.Contains("M"))
1231 {
1232 if (mVerbosityLevel > 3)
1233 cout << endl << "\t\t...deleting hPosOfMax";
1234 delete[] hPosOfMax;
1235 hPosOfMax = NULL;
1236 }
1237}
1238// end of DeletePixelHistos
1239//----------------------------------------------------------------------------
1240
1241void
1242Pixel::DeleteTemplateHistos()
1243{
1244 if (mVerbosityLevel > 2)
1245 {
1246 cout << endl
1247 << "\t...delete current template histograms of Pixel# " << mChid;
1248 }
1249 for (int order = 0;
1250 order < mMaxPulseOrder;
1251 order ++)
1252 {
1253 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean"
1254 << mChid << "_" << order ;
1255 delete hPixelMean[order];
1256 hPixelMean[order] = NULL;
1257
1258 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian"
1259 << mChid << "_" << order ;
1260 delete hPixelMedian[order];
1261 hPixelMedian[order] = NULL;
1262
1263 if (mVerbosityLevel > 3)
1264 cout << endl << "\t\t...deleting hPixelMax"
1265 << mChid << "_" << order;
1266 delete hPixelMax[order];
1267 hPixelMax[order] = NULL;
1268
1269 }
1270 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1271
1272 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMax";
1273 delete[] hPixelMax;
1274 hPixelMax = NULL;
1275
1276 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMedian";
1277 delete[] hPixelMedian;
1278 hPixelMedian = NULL;
1279
1280 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelMean";
1281 delete[] hPixelMean;
1282 hPixelMean = NULL;
1283}
1284// end of DeleteTemplateHistos
1285//----------------------------------------------------------------------------
1286
1287void
1288Pixel::DeleteEdgeTemplateHistos()
1289{
1290 if (mVerbosityLevel > 2)
1291 {
1292 cout << endl
1293 << "\t...delete current Edge template histograms of Pixel# " << mChid;
1294 }
1295 for (int order = 0;
1296 order < mMaxPulseOrder;
1297 order ++)
1298 {
1299 if (mVerbosityLevel > 3)
1300 cout << endl << "\t\t...deleting hPixelEdgeMax"
1301 << mChid << "_" << order;
1302
1303 delete hPixelEdgeMax[order];
1304 hPixelEdgeMax[order] = NULL;
1305
1306 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian"
1307 << mChid << "_" << order ;
1308 delete hPixelEdgeMedian[order];
1309 hPixelEdgeMedian[order] = NULL;
1310
1311 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean"
1312 << mChid << "_" << order ;
1313 delete hPixelEdgeMean[order];
1314 hPixelEdgeMean[order] = NULL;
1315
1316 }
1317 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
1318
1319 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMax";
1320 delete[] hPixelEdgeMax;
1321 hPixelEdgeMax = NULL;
1322
1323 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMedian";
1324 delete[] hPixelEdgeMedian;
1325 hPixelEdgeMedian = NULL;
1326
1327 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPixelEdgeMean";
1328 delete[] hPixelEdgeMean;
1329 hPixelEdgeMean = NULL;
1330}
1331// end of DeleteTemplateHistos
1332//----------------------------------------------------------------------------
1333
1334void
1335Pixel::MakeTH1Pretty(
1336 TH1* histo,
1337 TString histName,
1338 TString histTitle,
1339 int order
1340 )
1341{
1342 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1343
1344 histo->SetNameTitle(
1345 HistoName(histName, order),
1346 HistoTitle(histTitle, order)
1347 );
1348
1349 histo->SetBins(
1350 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1351 (-1*mPixelOverlayXaxisLeft)-0.5,
1352 mPixelOverlayXaxisRight-0.5
1353 );
1354
1355 histo->SetAxisRange(
1356 mBSLMean - 5,
1357 (mGainMean*(order+1)) + 10,
1358 "Y");
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
1367
1368void
1369Pixel::MakeTH2Pretty(
1370 TH2* histo,
1371 TString histName,
1372 TString histTitle,
1373 int order
1374 )
1375{
1376 if (mVerbosityLevel > 3) cout << "\t...designing " << HistoName(histName, order) << endl;
1377
1378 histo->SetNameTitle(
1379 HistoName(histName, order),
1380 HistoTitle(histTitle, order)
1381 );
1382
1383 histo->SetBins(
1384 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1385 (-1*mPixelOverlayXaxisLeft)-0.5,
1386 mPixelOverlayXaxisRight-0.5 ,
1387 512,
1388 -55.5,
1389 200.5
1390 );
1391
1392 histo->SetAxisRange(
1393 mBSLMean - 5,
1394 (mGainMean*(order+1)) + 10,
1395 "Y");
1396
1397 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1398 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1399 //histo->SetBit(TH2F::kCanRebin);
1400 histo->SetStats(mStats);
1401}
1402// end of MakeTH2Pretty
1403//----------------------------------------------------------------------------
1404
1405void
1406Pixel::MakeTProfilePretty(
1407 TProfile* histo,
1408 TString histName,
1409 TString histTitle,
1410 int order
1411 )
1412{
1413 if (mVerbosityLevel > 3) cout << "\t...booking " << HistoName(histName, order) << endl;
1414
1415 histo->SetNameTitle(
1416 HistoName(histName, order),
1417 HistoTitle(histTitle, order)
1418 );
1419
1420 histo->SetBins(
1421 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
1422 (-1*mPixelOverlayXaxisLeft)-0.5,
1423 mPixelOverlayXaxisRight-0.5
1424 );
1425 histo->SetOption( "s" );
1426
1427 histo->SetAxisRange(
1428 mBSLMean - 5,
1429 (mGainMean*(order+1)) + 10,
1430 "Y");
1431
1432 histo->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
1433 histo->GetYaxis()->SetTitle( "Amplitude [mV]" );
1434 //histo->SetBit(TH2F::kCanRebin);
1435 histo->SetStats(mStats);
1436}
1437// end of MakeTProfilePretty
1438//----------------------------------------------------------------------------
1439
1440
1441void
1442Pixel::ShiftHistoInY(
1443 TH1* histo,
1444 float shift
1445 )
1446{
1447 int min_bin = histo->GetXaxis()->GetFirst();
1448 int max_bin = histo->GetXaxis()->GetLast();
1449
1450 for (int bin = min_bin; bin <= max_bin; bin++)
1451 {
1452 histo->AddBinContent( bin, shift);
1453 }
1454
1455}
1456
1457void
1458Pixel::SetRangeUser(float xMin, float xMax, int order)
1459{
1460 hMaxOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1461 hEdgeOverlay[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1462
1463 hPixelMax[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1464 hPixelMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1465 hPixelMean[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1466
1467 hPixelEdgeMax[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1468 hPixelEdgeMedian[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1469 hPixelEdgeMean[order]->GetXaxis()->SetRangeUser(xMin, xMax);
1470
1471 return;
1472}
1473
1474void
1475Pixel::NormalizeSamplesTH2F(TH2F* histo)
1476{
1477
1478 int first = histo->GetXaxis()->GetFirst();
1479 int last = histo->GetXaxis()->GetLast();
1480
1481 TH2F *hTemp = new TH2F(*histo);
1482 hTemp->Reset();
1483
1484 for (int i = first; i < last; i++)
1485 {
1486 TH1* hTemp1D = histo->ProjectionY("_px1", i, i+1);
1487 double integral = hTemp1D->Integral();
1488 // double maximum = hTemp->GetBinContent(hTemp->GetMaximumBin());
1489 hTemp1D->Scale(1/integral);
1490 // hTemp->Scale(1/maximum);
1491 int first_sl = hTemp1D->GetXaxis()->GetFirst();
1492 int last_sl = hTemp1D->GetXaxis()->GetLast();
1493
1494 for (int j = first_sl; j < last_sl; j++)
1495 {
1496 hTemp->SetBinContent(i, j, hTemp->GetBinContent(j));
1497 }
1498 }
1499
1500 histo->Reset();
1501 histo->Add(hTemp);
1502
1503 delete hTemp;
1504 return;
1505}
1506
1507void
1508Pixel::Normalize2Dhistos(int order)
1509{
1510 NormalizeSamplesTH2F(hMaxOverlay[order]);
1511 NormalizeSamplesTH2F(hEdgeOverlay[order]);
1512 return;
1513}
1514
1515
Note: See TracBrowser for help on using the repository browser.