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

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