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

Last change on this file since 13465 was 13465, checked in by Jens Buss, 13 years ago
initial commit
File size: 11.7 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 = 0,
22 int maxPulsorder = 1,
23 int verbosityLevel = 0,
24 int pixelOverlayXaxisLeft,
25 int pixelOverlayXaxisRight,
26 int bSLMean,
27 int gainMean,
28 const char* 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 hEdgeOverlay = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F));
42 hMaxProfile = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
43 hEdgeProfile = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
44
45 if (mOptions == "S")
46 hSlopeRisingEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
47 if (mOptions == "R")
48 hRisingToMaxEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
49 if (mOptions == "P")
50 hPosOfMax = (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
51
52 hList = new TObjArray;
53
54 BookPixelHistos();
55 BookDistributionHistos()
56}
57
58Pixel::~Pixel()
59{
60 if (mVerbosityLevel > 2) cout << endl << "...delete current pixel histograms" ;
61 for (int order = 0;
62 order < mMaxPulseOrder;
63 order ++)
64 {
65 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay" << mHistogramId;
66 delete hMaxOverlay[order];
67 hMaxOverlay = NULL;
68 if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay" << mHistogramId;
69 delete hEdgeOverlay[order];
70 hEdgeOverlay = NULL;
71 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile" << mHistogramId;
72 delete hMaxProfile[order];
73 hMaxProfile = NULL;
74 if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile2" << mHistogramId;
75 delete hEdgeProfile[order];
76 hEdgeProfile = NULL;
77 }
78 if (mVerbosityLevel > 3) cout << endl << "...deleting hList";
79 delete hList;
80 if (mVerbosityLevel > 2) cout << endl << "...done" << endl;
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 for (int order = 0; order < mMaxPulseOrder; order ++)
100 {
101/*
102 SetHistogramAttributes(
103 "PeakMaxGaus",
104 order,
105 gMaxGausAttrib,
106 MaxAmplOfFirstPulse
107 );
108 */
109 histo_name = "hMaxOverlay";
110 histo_name += order;
111 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
112 hMaxOverlay[order] = TH2F(
113 histo_name,
114 "Overlay of detected pulses of one pulse order for one Pixel",
115 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
116 (-1*mPixelOverlayXaxisLeft)-0.5,
117 mPixelOverlayXaxisRight-0.5 ,
118 512,
119 -55.5,
120 200.5
121 );
122 hMaxOverlay[order]->SetAxisRange(
123 mBSLMean - 5,
124 (mGainMean*(order+1)) + 10,
125 "Y");
126 hMaxOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
127 hMaxOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
128 //hMaxProfile->SetBit(TH2F::kCanRebin);
129 hList->Add( hMaxOverlay[order] );
130
131//------------------------------------------------------------------------
132/*
133 SetHistogramAttributes(
134 "PeakMaxGaus",
135 order,
136 gMaxGausAttrib,
137 MaxAmplOfFirstPulse
138 );
139 */
140 histo_name = "hEdgeOverlay";
141 histo_name += order;
142 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
143 hEdgeOverlay[order] = TH2F(
144 histo_name,
145 "Overlay at rising edge of detected pulses of one pulse order for one Pixel ",
146 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
147 (-1*mPixelOverlayXaxisLeft)-0.5,
148 mPixelOverlayXaxisRight-0.5 ,
149 512,
150 -55.5,
151 200.5
152 );
153
154 hEdgeOverlay[order]->SetAxisRange(
155 mBSLMean - 5,
156 (mGainMean*(order+1)) + 10,
157 "Y");
158 hEdgeOverlay[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
159 hEdgeOverlay[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
160 hList->Add( hEdgeOverlay[order] );
161
162 //------------------------------------------------------------------------
163/*
164 SetHistogramAttributes(
165 "PeakMaxGaus",
166 order,
167 gMaxGausAttrib,
168 MaxAmplOfFirstPulse
169 );
170 */
171 histo_name = "hMaxProfile";
172 histo_name += order;
173 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
174 hMaxProfile[order] = TProfile(
175 histo_name,
176 "Mean value of each slice in overlay plot (Tprofile)",
177 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
178 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
179 mPixelOverlayXaxisRight-0.5 , //xup
180 // 512, //nbinsy
181 -55.5, //ylow
182 300.5, //yup
183 "s"); //option
184 hMaxProfile[order]->SetAxisRange(
185 mBSLMean - 5,
186 (mGainMean*(order+1)) + 10,
187 "Y");
188 hMaxProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
189 hMaxProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
190 //hMaxProfile->SetBit(TH2F::kCanRebin);
191 hList->Add( hMaxProfile[order] );
192
193
194 //------------------------------------------------------------------------
195/*
196 SetHistogramAttributes(
197 "PeakMaxGaus",
198 order,
199 gMaxGausAttrib,
200 MaxAmplOfFirstPulse
201 );
202 */
203 histo_name = "hEdgeProfile";
204 histo_name += order;
205 if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
206 hEdgeProfile[order] = TProfile(
207 histo_name,
208 "Mean value of each slice in overlay plot (Tprofile)",
209 mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
210 (-1*mPixelOverlayXaxisLeft)-0.5, //xlow
211 mPixelOverlayXaxisRight-0.5 , //xup
212 // 512, //nbinsy
213 -55.5, //ylow
214 300.5, //yup
215 "s"); //option
216 hEdgeProfile[order]->SetLineColor(kRed);
217 hEdgeProfile[order]->SetAxisRange(
218 mBSLMean - 5,
219 (mGainMean*(order+1)) + 10,
220 "Y");
221 hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
222 hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
223 //hMaxProfile->SetBit(TH2F::kCanRebin);
224 }
225 if (mVerbosityLevel > 2) cout << "...done" << endl;
226}
227//end of BookPixelHistos
228//----------------------------------------------------------------------------
229
230
231void
232Pixel::DrawHistograms(
233 TCanvas* pixelCanvas = NULL,
234 int* histoFrameNr = NULL
235 )
236{
237 if (mVerbosityLevel > 2) cout << endl << "...drawing pulse histograms" ;
238 for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
239 {
240 pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
241 hMaxOverlay[pulse_order]->Draw("COLZ");
242 pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
243 hMaxProfile[pulse_order]->Draw("COLZ");
244 hMaxProfile2[pulse_order]->Draw("SAME");
245
246 pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
247 hEdgeOverlay[pulse_order]->Draw("COLZ");
248 }
249}
250// end of DrawPulseHistograms
251//----------------------------------------------------------------------------
252
253
254void
255Pixel::BookDistributionHistos( )
256{
257 if (mOptions != "")
258 {
259 if (mVerbosityLevel > 2) cout << endl
260 << "...book distribution histograms"
261 << endl;
262
263 if (mOptions != "S")
264 {
265 hSlopeRisingEdge = TH1F (
266 "hSlopeRisingEdge",
267 "Distribution of rising edge",
268 600,
269 -10.1,
270 10.1
271 );
272 hSlopeRisingEdge->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
273 hSlopeRisingEdge->GetYaxis()->SetTitle( "counts" );
274 }
275
276 if (mOptions != "R")
277 {
278 hRisingToMaxEdge = TH1F (
279 "hRisingToMaxEdge",
280 "Deviation of rising edge and maximum",
281 600,
282 -10.1,
283 10.1
284 );
285 hRisingToMaxEdge->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
286 hRisingToMaxEdge->GetYaxis()->SetTitle( "counts" );
287 }
288
289 if (mOptions != "P")
290 {
291 hPosOfMax = TH1F (
292 "hPosOfMax",
293 "Deviation of rising edge and maximum",
294 600,
295 -10.1,
296 10.1
297 );
298 hPosOfMax->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
299 hPosOfMax->GetYaxis()->SetTitle( "counts" );
300 }
301
302 if (mVerbosityLevel > 2) cout << "...done" << endl;
303 }
304}
305
306
307
308
309//============================= ACESS ===================================
310//============================= INQUIRY ===================================
311/////////////////////////////// PROTECTED ///////////////////////////////////
312
313/////////////////////////////// PRIVATE ///////////////////////////////////
314
315
316
317
318
319
320
321
Note: See TracBrowser for help on using the repository browser.