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

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