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

Last change on this file since 13503 was 13501, checked in by Jens Buss, 14 years ago
took of unused cout
File size: 16.1 KB
Line 
1#include "pixel.h" // class implemented
2using namespace std;
3
4/////////////////////////////// PUBLIC ///////////////////////////////////////
5
6//============================= LIFECYCLE ====================================
7
8//Pixel::Pixel(int pixelID)
9//{
10// Chid = pixelID;
11// max_puslse_order = 1;
12// hMaxOverlay = NULL;
13// hEdgeOverlay = NULL;
14// hMaxProfile = NULL;
15// hEdgeProfile = NULL;
16// hList = NULL;
17
18//}
19
20Pixel::Pixel(
21 int pixelID,
22 int maxPulsorder,
23 int verbosityLevel,
24 int pixelOverlayXaxisLeft,
25 int pixelOverlayXaxisRight,
26 int bSLMean,
27 int gainMean,
28 TString options
29 )
30{
31 mChid = pixelID;
32 mMaxPulseOrder = maxPulsorder;
33 mVerbosityLevel = verbosityLevel;
34 mOptions = options;
35 mPixelOverlayXaxisLeft = pixelOverlayXaxisLeft;
36 mPixelOverlayXaxisRight = pixelOverlayXaxisRight;
37 mBSLMean = bSLMean;
38 mGainMean = gainMean;
39
40 hMaxOverlay = new TH2F*[mMaxPulseOrder];
41 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
42 hMaxProfile = new TProfile*[mMaxPulseOrder];
43 hEdgeProfile = new TProfile*[mMaxPulseOrder];
44
45 if (mOptions.Contains("S") )
46 {
47 hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
48 }
49
50 if (mOptions.Contains("R") )
51 {
52 hRisingEdgeToMax = new TH1F*[mMaxPulseOrder];
53 }
54
55 if (mOptions.Contains("P") )
56 {
57 hPosOfMax = new TH1F*[mMaxPulseOrder];
58 }
59
60 hList = new TObjArray;
61
62 BookPixelHistos();
63 BookDistributionHistos();
64}
65
66Pixel::~Pixel()
67{
68 if (mVerbosityLevel > 2) cout << endl << "...delete current pixel histograms" ;
69
70 DeletePixelHistos();
71 DeleteDistributionHistos();
72 delete hList;
73 hList = NULL;
74
75}// ~Pixel
76
77
78//============================= OPERATORS ====================================
79
80//XX&
81//XX::operator=(const XX&);
82//{
83// return *this;
84
85//}// =
86
87//============================= OPERATIONS ===================================
88void
89Pixel::BookPixelHistos()
90{
91 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
92 TString histo_name;
93
94 for (int order = 0; order < mMaxPulseOrder; order++)
95 {
96 histo_name = "hMaxOverlay";
97 histo_name += mChid;
98 histo_name += "_";
99 histo_name += order;
100 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
101 hMaxOverlay[order]=new TH2F(
102 histo_name,
103 "Overlay of detected pulses of one pulse order for one Pixel",
104 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
105 (-1*mPixelOverlayXaxisLeft)-0.5,
106 mPixelOverlayXaxisRight-0.5 ,
107 512,
108 -55.5,
109 200.5
110 );
111/*
112 SetHistogramAttributes(
113 "PeakMaxGaus",
114 order,
115 gMaxGausAttrib,
116 MaxAmplOfFirstPulse
117 );
118 */
119 hMaxOverlay[order]->SetAxisRange(
120 mBSLMean - 5,
121 (mGainMean*(order+1)) + 10,
122 "Y");
123 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
124 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
125 //hMaxProfile->SetBit(TH2F::kCanRebin);
126 hList->Add( hMaxOverlay[order] );
127
128//------------------------------------------------------------------------
129/*
130 SetHistogramAttributes(
131 "PeakMaxGaus",
132 order,
133 gMaxGausAttrib,
134 MaxAmplOfFirstPulse
135 );
136 */
137 histo_name = "hEdgeOverlay";
138 histo_name += mChid;
139 histo_name += "_";
140 histo_name += order;
141 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
142 hEdgeOverlay[order] = new TH2F(
143 histo_name,
144 "Overlay at rising edge of detected pulses of one pulse order for one Pixel ",
145 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
146 (-1*mPixelOverlayXaxisLeft)-0.5,
147 mPixelOverlayXaxisRight-0.5 ,
148 512,
149 -55.5,
150 200.5
151 );
152
153 hEdgeOverlay[order]->SetAxisRange(
154 mBSLMean - 5,
155 (mGainMean*(order+1)) + 10,
156 "Y");
157 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
158 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
159 hList->Add( hEdgeOverlay[order] );
160
161 //------------------------------------------------------------------------
162/*
163 SetHistogramAttributes(
164 "PeakMaxGaus",
165 order,
166 gMaxGausAttrib,
167 MaxAmplOfFirstPulse
168 );
169 */
170 histo_name = "hMaxProfile";
171 histo_name += mChid;
172 histo_name += "_";
173 histo_name += order;
174 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
175 hMaxProfile[order] = new TProfile(
176 histo_name,
177 "Mean value of each slice in overlay plot (Tprofile)",
178 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
179 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
180 mPixelOverlayXaxisRight-0.5 , //xup
181 // 512, //nbinsy
182 -55.5, //ylow
183 300.5, //yup
184 "s"); //option
185 hMaxProfile[order]->SetAxisRange(
186 mBSLMean - 5,
187 (mGainMean*(order+1)) + 10,
188 "Y");
189 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
190 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
191 //hMaxProfile->SetBit(TH2F::kCanRebin);
192 hList->Add( hMaxProfile[order] );
193
194
195 //------------------------------------------------------------------------
196/*
197 SetHistogramAttributes(
198 "PeakMaxGaus",
199 order,
200 gMaxGausAttrib,
201 MaxAmplOfFirstPulse
202 );
203 */
204 histo_name = "hEdgeProfile";
205 histo_name += mChid;
206 histo_name += "_";
207 histo_name += order;
208 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
209 hEdgeProfile[order] = new TProfile(
210 histo_name,
211 "Mean value of each slice in overlay plot (Tprofile)",
212 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
213 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
214 mPixelOverlayXaxisRight-0.5 , //xup
215 // 512, //nbinsy
216 -55.5, //ylow
217 300.5, //yup
218 "s"); //option
219 hEdgeProfile[order]->SetLineColor(kRed);
220 hEdgeProfile[order]->SetAxisRange(
221 mBSLMean - 5,
222 (mGainMean*(order+1)) + 10,
223 "Y");
224 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
225 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
226 //hMaxProfile->SetBit(TH2F::kCanRebin);
227 hList->Add( hEdgeProfile[order] );
228
229 }
230 if (mVerbosityLevel > 2) cout << "...done" << endl;
231}
232//end of BookPixelHistos
233//----------------------------------------------------------------------------
234
235
236void
237Pixel::DrawHistograms(
238 TCanvas* pixelCanvas,
239 int* histoFrameNr
240 )
241{
242 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
243 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
244 {
245 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
246 hMaxOverlay[pulse_order]->Draw("COLZ");
247 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
248 hMaxProfile[pulse_order]->Draw("COLZ");
249 hEdgeProfile[pulse_order]->Draw("SAME");
250
251 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
252 hEdgeOverlay[pulse_order]->Draw("COLZ");
253 }
254}
255// end of DrawPulseHistograms
256//----------------------------------------------------------------------------
257
258
259void
260Pixel::BookDistributionHistos( )
261{
262 if (!mOptions.IsNull() )
263 {
264 TString histo_name;
265 for (int order =0; order < mMaxPulseOrder; order++)
266 {
267 if (mVerbosityLevel > 2) cout << endl
268 << "...book distribution histograms"
269 << endl;
270
271 if (mOptions.Contains("S"))
272 {
273 histo_name = "hSlopeRisingEdge";
274 histo_name += mChid;
275 histo_name += "_";
276 histo_name += order;
277 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
278 hSlopeRisingEdge[order] = new TH1F (
279 histo_name,
280 "Distribution of rising edge",
281 600,
282 -10.1,
283 10.1
284 );
285 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
286 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
287 hList->Add( hSlopeRisingEdge[order] );
288 }
289
290 if (mOptions.Contains("R"))
291 {
292 histo_name = "hRisingEdgeToMax";
293 histo_name += mChid;
294 histo_name += "_";
295 histo_name += order;
296 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
297 hRisingEdgeToMax[order] = new TH1F (
298 histo_name,
299 "Deviation of rising edge and maximum",
300 600,
301 -10.1,
302 10.1
303 );
304 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
305 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
306 hList->Add( hRisingEdgeToMax[order] );
307 }
308
309 if (mOptions.Contains("P"))
310 {
311 histo_name = "hPosOfMax";
312 histo_name += mChid;
313 histo_name += "_";
314 histo_name += order;
315 if (mVerbosityLevel > 3) cout << "\t...booking " << histo_name << endl;
316 hPosOfMax[order] = new TH1F (
317 histo_name,
318 "Deviation of rising edge and maximum",
319 600,
320 -10.1,
321 10.1
322 );
323 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
324 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
325 hList->Add( hPosOfMax[order] );
326 }
327
328 if (mVerbosityLevel > 2) cout << "...done" << endl;
329 }
330 }
331}
332
333void
334Pixel::DrawDistributionHistograms(
335 TCanvas* pixelCanvas,
336 int* histoFrameNr
337 )
338{
339 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
340 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
341 {
342 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
343 hSlopeRisingEdge[pulse_order]->Draw();
344 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
345 hRisingEdgeToMax[pulse_order]->Draw();
346
347 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
348 hPosOfMax[pulse_order]->Draw();
349 }
350}
351// end of DrawDistributionHistograms
352//----------------------------------------------------------------------------
353
354void
355Pixel::SavePixelHistograms(
356 const char* outRootFileName,
357 bool saveResults
358 )
359{
360 if (!saveResults) return;
361 SaveHistograms(
362 outRootFileName,
363 CreateSubDirName( mChid ),
364 hList,
365 saveResults,
366 mVerbosityLevel
367 );
368}
369// end of SavePixelHistograms
370//----------------------------------------------------------------------------
371
372void
373Pixel::DeletePixelHistos()
374{
375 if (mVerbosityLevel > 2) cout << endl << "\t...delete current overlay histograms" ;
376
377 for (int order = 0;
378 order < mMaxPulseOrder;
379 order ++)
380 {
381 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
382 delete hMaxOverlay[order];
383
384 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
385 delete hEdgeOverlay[order];
386
387 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
388 delete hMaxProfile[order];
389
390 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2";
391 delete hEdgeProfile[order];
392 }
393 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
394 delete[] hMaxOverlay;
395 hMaxOverlay = NULL;
396
397 delete[] hEdgeOverlay;
398 hEdgeOverlay = NULL;
399
400 delete[] hMaxProfile;
401 hMaxProfile = NULL;
402
403 delete[] hEdgeProfile;
404 hEdgeProfile = NULL;
405}
406// end of DeletePixelHistos
407//----------------------------------------------------------------------------
408
409void
410Pixel::DeleteDistributionHistos()
411{
412 if (mVerbosityLevel > 2) cout << endl
413 << "\t...delete current distribution histograms" ;
414
415 for (int order = 0;
416 order < mMaxPulseOrder;
417 order ++)
418 {
419 if (mOptions.Contains("S"))
420 {
421 if (mVerbosityLevel > 3) cout << endl
422 << "\t\t...deleting hSlopeRisingEdge"
423 << mChid << "_" << order ;
424 delete hSlopeRisingEdge[order];
425 }
426
427 if (mOptions.Contains("R"))
428 {
429 if (mVerbosityLevel > 3) cout << endl
430 << "\t\t...deleting hRisingEdgeToMax"
431 << mChid << "_" << order ;
432// delete hRisingEdgeToMax[order];
433 }
434
435 if (mOptions.Contains("P"))
436 {
437 if (mVerbosityLevel > 3) cout << endl
438 << "\t\t...deleting hPosOfMax"
439 << mChid << "_" << order ;
440
441// delete hPosOfMax[order];
442 }
443
444 }
445 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
446
447 if (mOptions.Contains("S"))
448 {
449 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge";
450// delete[] hSlopeRisingEdge;
451 hSlopeRisingEdge = NULL;
452 }
453
454 if (mOptions.Contains("R"))
455 {
456 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax";
457// delete[] hRisingEdgeToMax;
458 hRisingEdgeToMax = NULL;
459 }
460
461 if (mOptions.Contains("P"))
462 {
463 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax";
464// delete[] hPosOfMax;
465 hPosOfMax = NULL;
466 }
467}
468// end of DeletePixelHistos
469//----------------------------------------------------------------------------
470
471//============================= ACESS ===================================
472//============================= INQUIRY ===================================
473/////////////////////////////// PROTECTED ///////////////////////////////////
474
475/////////////////////////////// PRIVATE ///////////////////////////////////
476
477
478
479
480
481
482
483
Note: See TracBrowser for help on using the repository browser.