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

Last change on this file since 13487 was 13487, checked in by Jens Buss, 14 years ago
modified the destructor for array usage
File size: 13.6 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 = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
41 hMaxOverlay = new TH2F*[mMaxPulseOrder];
42// hEdgeOverlay = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
43 hEdgeOverlay = new TH2F*[mMaxPulseOrder];
44// hMaxProfile = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
45 hMaxProfile = new TProfile*[mMaxPulseOrder];
46// hEdgeProfile = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
47 hEdgeProfile = new TProfile*[mMaxPulseOrder];
48 if (mOptions == "S")
49 {
50// hSlopeRisingEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
51 hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
52 }
53 if (mOptions == "R")
54 {
55// hRisingEdgeToMax= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
56 hRisingEdgeToMax = new TH1F*[mMaxPulseOrder];
57 }
58 if (mOptions == "P")
59 {
60// hPosOfMax = (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
61 hPosOfMax = new TH1F*[mMaxPulseOrder];
62 }
63
64 hList = new TObjArray;
65
66 BookPixelHistos();
67 BookDistributionHistos();
68}
69
70Pixel::~Pixel()
71{
72 if (mVerbosityLevel > 2) cout << endl << "...delete current pixel histograms" ;
73
74 for (int order = 0;
75 order < mMaxPulseOrder;
76 order ++)
77 {
78 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay";
79 delete hMaxOverlay[order];
80
81 if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay";
82 delete hEdgeOverlay[order];
83
84 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile";
85 delete hMaxProfile[order];
86
87 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile2";
88 delete hEdgeProfile[order];
89 }
90 if (mVerbosityLevel > 3) cout << endl << "...deleting histogram Arrays";
91 delete[] hMaxOverlay;
92 hMaxOverlay = NULL;
93
94 delete[] hEdgeOverlay;
95 hEdgeOverlay = NULL;
96
97 delete[] hMaxProfile;
98 hMaxProfile = NULL;
99
100 delete[] hEdgeProfile;
101 hEdgeProfile = NULL;
102
103 if (mVerbosityLevel > 3) cout << endl << "...deleting hList";
104 delete hList;
105 if (mVerbosityLevel > 2) cout << endl << "...done" << endl;
106}// ~Pixel
107
108
109//============================= OPERATORS ====================================
110
111//XX&
112//XX::operator=(const XX&);
113//{
114// return *this;
115
116//}// =
117
118//============================= OPERATIONS ===================================
119void
120Pixel::BookPixelHistos()
121{
122 if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
123 TString histo_name;
124
125 for (int order =0; order > mMaxPulseOrder; order++)
126 {
127 histo_name = "hMaxOverlay";
128 histo_name += order;
129 hMaxOverlay[order]=new TH2F(
130 histo_name,
131 "Overlay of detected pulses of one pulse order for one Pixel",
132 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
133 (-1*mPixelOverlayXaxisLeft)-0.5,
134 mPixelOverlayXaxisRight-0.5 ,
135 512,
136 -55.5,
137 200.5
138 );
139/*
140 SetHistogramAttributes(
141 "PeakMaxGaus",
142 order,
143 gMaxGausAttrib,
144 MaxAmplOfFirstPulse
145 );
146 */
147 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
148 hMaxOverlay[order]->SetAxisRange(
149 mBSLMean - 5,
150 (mGainMean*(order+1)) + 10,
151 "Y");
152 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
153 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
154 //hMaxProfile->SetBit(TH2F::kCanRebin);
155 hList->Add( hMaxOverlay[order] );
156 }
157
158 for (int order = 0; order < mMaxPulseOrder; order ++)
159 {
160
161//------------------------------------------------------------------------
162/*
163 SetHistogramAttributes(
164 "PeakMaxGaus",
165 order,
166 gMaxGausAttrib,
167 MaxAmplOfFirstPulse
168 );
169 */
170 histo_name = "hEdgeOverlay";
171 histo_name += order;
172 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
173 hEdgeOverlay[order] = new TH2F(
174 histo_name,
175 "Overlay at rising edge of detected pulses of one pulse order for one Pixel ",
176 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
177 (-1*mPixelOverlayXaxisLeft)-0.5,
178 mPixelOverlayXaxisRight-0.5 ,
179 512,
180 -55.5,
181 200.5
182 );
183
184 hEdgeOverlay[order]->SetAxisRange(
185 mBSLMean - 5,
186 (mGainMean*(order+1)) + 10,
187 "Y");
188 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
189 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
190 hList->Add( hEdgeOverlay[order] );
191
192 //------------------------------------------------------------------------
193/*
194 SetHistogramAttributes(
195 "PeakMaxGaus",
196 order,
197 gMaxGausAttrib,
198 MaxAmplOfFirstPulse
199 );
200 */
201 histo_name = "hMaxProfile";
202 histo_name += order;
203 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
204 hMaxProfile[order] = new TProfile(
205 histo_name,
206 "Mean value of each slice in overlay plot (Tprofile)",
207 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
208 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
209 mPixelOverlayXaxisRight-0.5 , //xup
210 // 512, //nbinsy
211 -55.5, //ylow
212 300.5, //yup
213 "s"); //option
214 hMaxProfile[order]->SetAxisRange(
215 mBSLMean - 5,
216 (mGainMean*(order+1)) + 10,
217 "Y");
218 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
219 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
220 //hMaxProfile->SetBit(TH2F::kCanRebin);
221 hList->Add( hMaxProfile[order] );
222
223
224 //------------------------------------------------------------------------
225/*
226 SetHistogramAttributes(
227 "PeakMaxGaus",
228 order,
229 gMaxGausAttrib,
230 MaxAmplOfFirstPulse
231 );
232 */
233 histo_name = "hEdgeProfile";
234 histo_name += order;
235 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
236 hEdgeProfile[order] = new TProfile(
237 histo_name,
238 "Mean value of each slice in overlay plot (Tprofile)",
239 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
240 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
241 mPixelOverlayXaxisRight-0.5 , //xup
242 // 512, //nbinsy
243 -55.5, //ylow
244 300.5, //yup
245 "s"); //option
246 hEdgeProfile[order]->SetLineColor(kRed);
247 hEdgeProfile[order]->SetAxisRange(
248 mBSLMean - 5,
249 (mGainMean*(order+1)) + 10,
250 "Y");
251 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
252 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
253 //hMaxProfile->SetBit(TH2F::kCanRebin);
254 hList->Add( hEdgeProfile[order] );
255
256 }
257 if (mVerbosityLevel > 2) cout << "...done" << endl;
258}
259//end of BookPixelHistos
260//----------------------------------------------------------------------------
261
262
263void
264Pixel::DrawHistograms(
265 TCanvas* pixelCanvas,
266 int* histoFrameNr
267 )
268{
269 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
270 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
271 {
272 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
273 hMaxOverlay[pulse_order]->Draw("COLZ");
274 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
275 hMaxProfile[pulse_order]->Draw("COLZ");
276 hEdgeProfile[pulse_order]->Draw("SAME");
277
278 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
279 hEdgeOverlay[pulse_order]->Draw("COLZ");
280 }
281}
282// end of DrawPulseHistograms
283//----------------------------------------------------------------------------
284
285
286void
287Pixel::BookDistributionHistos( )
288{
289 if (mOptions != "")
290 {
291 TString histo_name;
292 for (int order =0; order > mMaxPulseOrder; order++)
293 {
294 if (mVerbosityLevel > 2) cout << endl
295 << "...book distribution histograms"
296 << endl;
297
298 if (mOptions.Contains("S"))
299 {
300 histo_name = "hSlopeRisingEdge";
301 histo_name += order;
302 hSlopeRisingEdge[order] = new TH1F (
303 histo_name,
304 "Distribution of rising edge",
305 600,
306 -10.1,
307 10.1
308 );
309 hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
310 hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
311 hList->Add( hSlopeRisingEdge[order] );
312 }
313
314 if (mOptions.Contains("R"))
315 {
316 histo_name = "hRisingEdgeToMax";
317 histo_name += order;
318 hRisingEdgeToMax[order] = new TH1F (
319 histo_name,
320 "Deviation of rising edge and maximum",
321 600,
322 -10.1,
323 10.1
324 );
325 hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
326 hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
327 hList->Add( hRisingEdgeToMax[order] );
328 }
329
330 if (mOptions.Contains("P"))
331 {
332 histo_name = "hPosOfMax";
333 histo_name += order;
334 hPosOfMax[order] = new TH1F (
335 histo_name,
336 "Deviation of rising edge and maximum",
337 600,
338 -10.1,
339 10.1
340 );
341 hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
342 hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
343 hList->Add( hPosOfMax[order] );
344 }
345
346 if (mVerbosityLevel > 2) cout << "...done" << endl;
347 }
348 }
349}
350
351void
352Pixel::DrawDistributionHistograms(
353 TCanvas* pixelCanvas,
354 int* histoFrameNr
355 )
356{
357 if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
358 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
359 {
360 pixelCanvas[pulse_order].cd( histoFrameNr[0] );
361 hSlopeRisingEdge[pulse_order]->Draw();
362 pixelCanvas[pulse_order].cd( histoFrameNr[1] );
363 hRisingEdgeToMax[pulse_order]->Draw();
364
365 pixelCanvas[pulse_order].cd( histoFrameNr[2] );
366 hPosOfMax[pulse_order]->Draw();
367 }
368}
369// end of DrawDistributionHistograms
370//----------------------------------------------------------------------------
371
372void
373Pixel::SavePixelHistograms(
374 const char* outRootFileName
375 )
376{
377 SaveHistograms(
378 outRootFileName,
379 CreateSubDirName( mChid ),
380 hList,
381 mVerbosityLevel
382 );
383}
384
385
386//============================= ACESS ===================================
387//============================= INQUIRY ===================================
388/////////////////////////////// PROTECTED ///////////////////////////////////
389
390/////////////////////////////// PRIVATE ///////////////////////////////////
391
392
393
394
395
396
397
398
Note: See TracBrowser for help on using the repository browser.