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

Last change on this file since 13560 was 13559, checked in by Jens Buss, 13 years ago
changed naming of histograms
File size: 18.5 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("P") )
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("P"))
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 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
389 {
390 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
391 hSlopeRisingEdge[pulse_order]->Draw();
392 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
393 hRisingEdgeToMax[pulse_order]->Draw();
394
395 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
396 hPosOfMax[pulse_order]->Draw();
397 }
398}
399// end of DrawDistributionHistograms
400//----------------------------------------------------------------------------
401
402void
403Pixel::SavePixelHistograms(
404 const char* outRootFileName,
405 bool saveResults
406 )
407{
408 if (mVerbosityLevel > 2) cout << endl << "Saving histograms of Pixel# " << mChid;
409 if (!saveResults) return;
410 SaveHistograms(
411 outRootFileName,
412 CreateSubDirName( mChid ),
413 hList,
414 saveResults,
415 mVerbosityLevel
416 );
417}
418// end of SavePixelHistograms
419//----------------------------------------------------------------------------
420
421void
422Pixel::DeletePixelHistos()
423{
424 if (mVerbosityLevel > 2)
425 {
426 cout << endl
427 << "\t...delete current overlay histograms of Pixel# " << mChid;
428 }
429 for (int order = 0;
430 order < mMaxPulseOrder;
431 order ++)
432 {
433 if (mVerbosityLevel > 3)
434 cout << endl << "\t\t...deleting hMaxOverlay"
435 << mChid << "_" << order
436 << " hMaxOverlay[order] adr " << hMaxOverlay[order]
437 << " hMaxOverlay adr " << hMaxOverlay
438 ;
439
440 delete hMaxOverlay[order];
441 hMaxOverlay[order] = NULL;
442
443 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay"
444 << mChid << "_" << order ;
445 delete hEdgeOverlay[order];
446 hEdgeOverlay[order] = NULL;
447
448 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile"
449 << mChid << "_" << order ;
450 delete hMaxProfile[order];
451 hMaxProfile[order] = NULL;
452
453 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile2"
454 << mChid << "_" << order ;
455 delete hEdgeProfile[order];
456 hEdgeProfile[order] = NULL;
457 }
458 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
459
460 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxOverlay";
461 delete[] hMaxOverlay;
462 hMaxOverlay = NULL;
463
464 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeOverlay";
465 delete[] hEdgeOverlay;
466 hEdgeOverlay = NULL;
467
468 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hMaxProfile";
469 delete[] hMaxProfile;
470 hMaxProfile = NULL;
471
472 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hEdgeProfile";
473 delete[] hEdgeProfile;
474 hEdgeProfile = NULL;
475}
476// end of DeletePixelHistos
477//----------------------------------------------------------------------------
478
479void
480Pixel::DeleteDistributionHistos()
481{
482 if (mVerbosityLevel > 2)
483 {
484 cout << endl
485 << "\t...delete current distribution histograms" ;
486 }
487
488 for (int order = 0;
489 order < mMaxPulseOrder;
490 order ++)
491 {
492 if (mOptions.Contains("S"))
493 {
494 if (mVerbosityLevel > 3) cout << endl
495 << "\t\t...deleting hSlopeRisingEdge"
496 << mChid << "_" << order ;
497 delete hSlopeRisingEdge[order];
498 }
499
500 if (mOptions.Contains("R"))
501 {
502 if (mVerbosityLevel > 3) cout << endl
503 << "\t\t...deleting hRisingEdgeToMax"
504 << mChid << "_" << order ;
505// delete hRisingEdgeToMax[order];
506 }
507
508 if (mOptions.Contains("P"))
509 {
510 if (mVerbosityLevel > 3) cout << endl
511 << "\t\t...deleting hPosOfMax"
512 << mChid << "_" << order ;
513
514// delete hPosOfMax[order];
515 }
516
517 }
518 if (mVerbosityLevel > 3) cout << endl << "\t...deleting histogram Arrays";
519
520 if (mOptions.Contains("S"))
521 {
522 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hSlopeRisingEdge";
523 delete[] hSlopeRisingEdge;
524 hSlopeRisingEdge = NULL;
525 }
526
527 if (mOptions.Contains("R"))
528 {
529 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hRisingEdgeToMax";
530 delete[] hRisingEdgeToMax;
531 hRisingEdgeToMax = NULL;
532 }
533
534 if (mOptions.Contains("P"))
535 {
536 if (mVerbosityLevel > 3) cout << endl << "\t\t...deleting hPosOfMax";
537 delete[] hPosOfMax;
538 hPosOfMax = NULL;
539 }
540}
541// end of DeletePixelHistos
542//----------------------------------------------------------------------------
543
544//============================= ACESS ===================================
545//============================= INQUIRY ===================================
546/////////////////////////////// PROTECTED ///////////////////////////////////
547
548/////////////////////////////// PRIVATE ///////////////////////////////////
549
550
551
552
553
554
555
556
Note: See TracBrowser for help on using the repository browser.