1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | #include "MAGIC.h"
|
---|
25 |
|
---|
26 |
|
---|
27 | void calibration()
|
---|
28 | {
|
---|
29 |
|
---|
30 | // const char *inpath = "/remote/home/pc2/operator/NewCalBoxTest/";
|
---|
31 | // const char *inpath = "/remote/home/pc2/operator/Crab20040214/";
|
---|
32 | const char *inpath = "./";
|
---|
33 | //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
|
---|
34 | //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_01_26/";
|
---|
35 | //const TString inpath = "/mnt/Data/rootdata/Miscellaneous/2003_12_19/";
|
---|
36 |
|
---|
37 | MRunIter pruns;
|
---|
38 | MRunIter cruns;
|
---|
39 |
|
---|
40 | pruns.AddRun(14400,inpath);
|
---|
41 | cruns.AddRuns(14401,14409,inpath);
|
---|
42 | // pruns.AddRuns(15487,15494,inpath);
|
---|
43 | // cruns.AddRuns(15495,15508,inpath);
|
---|
44 | // pruns.AddRun(19816,inpath); // CalboxTest
|
---|
45 | // cruns.AddRun(19820,inpath); // 3blue
|
---|
46 | // cruns.AddRun(19820,inpath); // 1blue
|
---|
47 |
|
---|
48 | gStyle->SetOptStat(1111);
|
---|
49 | gStyle->SetOptFit();
|
---|
50 |
|
---|
51 | MStatusDisplay *display = new MStatusDisplay;
|
---|
52 | display->SetUpdateTime(3000);
|
---|
53 | display->Resize(850,700);
|
---|
54 |
|
---|
55 | MJPedestal pedloop;
|
---|
56 | pedloop.SetInput(&pruns);
|
---|
57 | pedloop.SetDisplay(display);
|
---|
58 |
|
---|
59 | if (!pedloop.Process())
|
---|
60 | return;
|
---|
61 |
|
---|
62 | //
|
---|
63 | // Now the short version:
|
---|
64 | //
|
---|
65 | /*
|
---|
66 | MJCalibration calloop;
|
---|
67 | calloop.SetInput(&cruns);
|
---|
68 | calloop.SetDisplay(display);
|
---|
69 | if (!calloop.Process(pedloop.GetPedestalCam()))
|
---|
70 | return;
|
---|
71 | #if 0
|
---|
72 | */
|
---|
73 | //
|
---|
74 | // The longer version:
|
---|
75 | //
|
---|
76 |
|
---|
77 | //
|
---|
78 | // Create a empty Parameter List and an empty Task List
|
---|
79 | //
|
---|
80 | MParList plist;
|
---|
81 | MTaskList tlist;
|
---|
82 | plist.AddToList(&tlist);
|
---|
83 | plist.AddToList(&pedloop.GetPedestalCam());
|
---|
84 |
|
---|
85 | gLog << endl;;
|
---|
86 | gLog << "Calculate MCalibrationCam from Runs " << cruns.GetRunsAsString() << endl;
|
---|
87 | gLog << endl;
|
---|
88 |
|
---|
89 | MReadMarsFile read("Events");
|
---|
90 | read.DisableAutoScheme();
|
---|
91 | static_cast<MRead&>(read).AddFiles(cruns);
|
---|
92 |
|
---|
93 | MGeomCamMagic geomcam;
|
---|
94 | MExtractedSignalCam sigcam;
|
---|
95 | MArrivalTimeCam timecam;
|
---|
96 | MCalibrationChargeCam calcam;
|
---|
97 | MCalibrationChargePINDiode pindiode;
|
---|
98 | MCalibrationChargeBlindPix blindpix;
|
---|
99 |
|
---|
100 | MHCalibrationRelTimeCam histtime;
|
---|
101 | MHCalibrationChargeCam histcharge;
|
---|
102 | MHCalibrationChargePINDiode histpin;
|
---|
103 | MHCalibrationChargeBlindPix histblind;
|
---|
104 | // histblind.SetSinglePheCut(80);
|
---|
105 | //
|
---|
106 | // As long, as we don't have digital modules,
|
---|
107 | // we have to set the color of the pulser LED by hand
|
---|
108 | //
|
---|
109 | blindpix.SetColor(kCT1);
|
---|
110 | pindiode.SetColor(kCT1);
|
---|
111 | //
|
---|
112 | // Get the previously created MPedestalCam into the new Parameter List
|
---|
113 | //
|
---|
114 | plist.AddToList(&geomcam);
|
---|
115 | plist.AddToList(&sigcam);
|
---|
116 | plist.AddToList(&timecam);
|
---|
117 | plist.AddToList(&calcam);
|
---|
118 | plist.AddToList(&histtime);
|
---|
119 | plist.AddToList(&histcharge);
|
---|
120 | // plist.AddToList(&histpin);
|
---|
121 | plist.AddToList(&histblind);
|
---|
122 |
|
---|
123 | //
|
---|
124 | // We saw that the signal jumps between slices,
|
---|
125 | // thus take the sliding window
|
---|
126 | //
|
---|
127 | MExtractSignal2 sigcalc2;
|
---|
128 | MExtractPINDiode pincalc;
|
---|
129 | MExtractBlindPixel blindcalc;
|
---|
130 | // blindcalc.SetRange(11,16);
|
---|
131 |
|
---|
132 | MArrivalTimeCalc2 timecalc;
|
---|
133 | MCalibrationChargeCalc calcalc;
|
---|
134 | MGeomApply geomapl;
|
---|
135 |
|
---|
136 | MFillH filltime( "MHCalibrationRelTimeCam" , "MArrivalTimeCam");
|
---|
137 | // MFillH fillpin ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
|
---|
138 | MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
|
---|
139 | MFillH fillcam ("MHCalibrationChargeCam" , "MExtractedSignalCam");
|
---|
140 |
|
---|
141 | //
|
---|
142 | // Skip the HiGain vs. LoGain calibration
|
---|
143 | //
|
---|
144 | calcalc.SkipHiLoGainCalibration();
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Apply a filter against cosmics
|
---|
148 | // (was directly in MCalibrationCalc in earlier versions)
|
---|
149 | //
|
---|
150 | MFCosmics cosmics;
|
---|
151 | cosmics.SetMaxEmptyPixels(0.4);
|
---|
152 | MContinue cont(&cosmics);
|
---|
153 |
|
---|
154 | tlist.AddToList(&read);
|
---|
155 | tlist.AddToList(&geomapl);
|
---|
156 | tlist.AddToList(&sigcalc2);
|
---|
157 | tlist.AddToList(&blindcalc);
|
---|
158 | // tlist.AddToList(&pincalc);
|
---|
159 | //
|
---|
160 | // In case, you want to skip the cosmics rejection,
|
---|
161 | // uncomment the next line
|
---|
162 | //
|
---|
163 | tlist.AddToList(&cont);
|
---|
164 | //
|
---|
165 | // In case, you want to skip the somewhat lengthy calculation
|
---|
166 | // of the arrival times using a spline, uncomment the next two lines
|
---|
167 | //
|
---|
168 | tlist.AddToList(&timecalc);
|
---|
169 | tlist.AddToList(&filltime);
|
---|
170 | // tlist.AddToList(&fillpin);
|
---|
171 | tlist.AddToList(&fillblind);
|
---|
172 | tlist.AddToList(&fillcam);
|
---|
173 | //
|
---|
174 | tlist.AddToList(&calcalc);
|
---|
175 | //
|
---|
176 | // Create and setup the eventloop
|
---|
177 | //
|
---|
178 | MEvtLoop evtloop;
|
---|
179 | evtloop.SetParList(&plist);
|
---|
180 | evtloop.SetDisplay(display);
|
---|
181 |
|
---|
182 | //
|
---|
183 | // Execute second analysis
|
---|
184 | //
|
---|
185 | if (!evtloop.Eventloop())
|
---|
186 | return;
|
---|
187 |
|
---|
188 | tlist.PrintStatistics();
|
---|
189 |
|
---|
190 | //
|
---|
191 | // print the most important results of all pixels to a file
|
---|
192 | //
|
---|
193 | MLog gauglog;
|
---|
194 | gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
|
---|
195 | calcam.SetLogStream(&gauglog);
|
---|
196 | calcam.Print();
|
---|
197 | calcam.SetLogStream(&gLog);
|
---|
198 | //
|
---|
199 | // just one example how to get the plots of individual pixels
|
---|
200 | //
|
---|
201 | histblind.DrawClone("all");
|
---|
202 | histcharge[5].DrawClone("all");
|
---|
203 | histcharge(5).DrawClone("all");
|
---|
204 | histtime[5].DrawClone("fourierevents");
|
---|
205 |
|
---|
206 | // Create histograms to display
|
---|
207 | MHCamera disp1 (geomcam, "Cal;Charge", "Fitted Mean Charges");
|
---|
208 | MHCamera disp2 (geomcam, "Cal;SigmaCharge", "Sigma of Fitted Charges");
|
---|
209 | MHCamera disp3 (geomcam, "Cal;FitProb", "Probability of Fit");
|
---|
210 | MHCamera disp4 (geomcam, "Cal;RSigma", "Reduced Sigmas");
|
---|
211 | MHCamera disp5 (geomcam, "Cal;RSigma/Charge", "Reduced Sigma per Charge");
|
---|
212 | MHCamera disp6 (geomcam, "Cal;FFactorPh", "Nr. of Photo-electrons (F-Factor Method)");
|
---|
213 | MHCamera disp7 (geomcam, "Cal;FFactorConv", "Conversion Factor to photons (F-Factor Method)");
|
---|
214 | MHCamera disp8 (geomcam, "Cal;FFactorFFactor", "Total F-Factor (F-Factor Method)");
|
---|
215 | MHCamera disp9 (geomcam, "Cal;BlindPixPh", "Photon flux inside plexiglass (Blind Pixel Method)");
|
---|
216 | MHCamera disp10 (geomcam, "Cal;BlindPixConv", "Conversion Factor to photons (Blind Pixel Method)");
|
---|
217 | MHCamera disp11 (geomcam, "Cal;BlindPixFFactor","Total F-Factor (Blind Pixel Method)");
|
---|
218 | MHCamera disp12 (geomcam, "Cal;PINDiodePh", "Photon flux outside plexiglass (PIN Diode Method)");
|
---|
219 | MHCamera disp13 (geomcam, "Cal;PINDiodeConv", "Conversion Factor tp photons (PIN Diode Method)");
|
---|
220 | MHCamera disp14 (geomcam, "Cal;PINDiodeFFactor","Total F-Factor (PIN Diode Method)");
|
---|
221 | MHCamera disp15 (geomcam, "Cal;Excluded", "Pixels previously excluded");
|
---|
222 | MHCamera disp16 (geomcam, "Cal;NotFitted", "Pixels that could not be fitted");
|
---|
223 | MHCamera disp17 (geomcam, "Cal;NotFitValid", "Pixels with not valid fit results");
|
---|
224 | MHCamera disp18 (geomcam, "Cal;HiGainOscillating", "Oscillating Pixels HI Gain");
|
---|
225 | MHCamera disp19 (geomcam, "Cal;LoGainOscillating", "Oscillating Pixels LO Gain");
|
---|
226 | MHCamera disp20 (geomcam, "Cal;HiGainPickup", "Number Pickup events Hi Gain");
|
---|
227 | MHCamera disp21 (geomcam, "Cal;LoGainPickup", "Number Pickup events Lo Gain");
|
---|
228 | MHCamera disp22 (geomcam, "Cal;Saturation", "Pixels with saturated Hi Gain");
|
---|
229 | MHCamera disp23 (geomcam, "Cal;FFactorValid", "Pixels with valid F-Factor calibration");
|
---|
230 | MHCamera disp24 (geomcam, "Cal;BlindPixelValid", "Pixels with valid BlindPixel calibration");
|
---|
231 | MHCamera disp25 (geomcam, "Cal;PINdiodeFFactorValid", "Pixels with valid PINDiode calibration");
|
---|
232 |
|
---|
233 | MHCamera disp26 (geomcam, "Cal;Ped", "Pedestals");
|
---|
234 | MHCamera disp27 (geomcam, "Cal;PedRms", "Pedestal RMS");
|
---|
235 |
|
---|
236 | MHCamera disp28 (geomcam, "time;Time", "Rel. Arrival Times");
|
---|
237 | MHCamera disp29 (geomcam, "time;SigmaTime", "Sigma of Rel. Arrival Times");
|
---|
238 | MHCamera disp30 (geomcam, "time;TimeProb", "Probability of Time Fit");
|
---|
239 | MHCamera disp31 (geomcam, "time;NotFitValid", "Pixels with not valid fit results");
|
---|
240 | MHCamera disp32 (geomcam, "time;Oscillating", "Oscillating Pixels");
|
---|
241 |
|
---|
242 | MHCamera disp33 (geomcam, "Cal;AbsTimeMean", "Abs. Arrival Times");
|
---|
243 | MHCamera disp34 (geomcam, "Cal;AbsTimeRms", "RMS of Arrival Times");
|
---|
244 |
|
---|
245 | // Fitted charge means and sigmas
|
---|
246 | disp1.SetCamContent(calcam, 0);
|
---|
247 | disp1.SetCamError( calcam, 1);
|
---|
248 | disp2.SetCamContent(calcam, 2);
|
---|
249 | disp2.SetCamError( calcam, 3);
|
---|
250 |
|
---|
251 | // Fit probabilities
|
---|
252 | disp3.SetCamContent(calcam, 4);
|
---|
253 |
|
---|
254 | // Reduced Sigmas and reduced sigmas per charge
|
---|
255 | disp4.SetCamContent(calcam, 5);
|
---|
256 | disp4.SetCamError( calcam, 6);
|
---|
257 | disp5.SetCamContent(calcam, 7);
|
---|
258 | disp5.SetCamError( calcam, 8);
|
---|
259 |
|
---|
260 | // F-Factor Method
|
---|
261 | disp6.SetCamContent(calcam, 9);
|
---|
262 | disp6.SetCamError( calcam, 10);
|
---|
263 | disp7.SetCamContent(calcam, 11);
|
---|
264 | disp7.SetCamError( calcam, 12);
|
---|
265 | disp8.SetCamContent(calcam, 13);
|
---|
266 | disp8.SetCamError( calcam, 14);
|
---|
267 |
|
---|
268 | /// Blind Pixel Method
|
---|
269 | disp9.SetCamContent(calcam, 15);
|
---|
270 | disp9.SetCamError( calcam, 16);
|
---|
271 | disp10.SetCamContent(calcam,17);
|
---|
272 | disp10.SetCamError( calcam,18);
|
---|
273 | disp11.SetCamContent(calcam,19);
|
---|
274 | disp11.SetCamError( calcam,20);
|
---|
275 |
|
---|
276 | // PIN Diode Method
|
---|
277 | disp12.SetCamContent(calcam,21);
|
---|
278 | disp12.SetCamError( calcam,22);
|
---|
279 | disp13.SetCamContent(calcam,23);
|
---|
280 | disp13.SetCamError( calcam,24);
|
---|
281 | disp14.SetCamContent(calcam,25);
|
---|
282 | disp14.SetCamError( calcam,26);
|
---|
283 |
|
---|
284 | // Pixels with defects
|
---|
285 | disp15.SetCamContent(calcam,27);
|
---|
286 | disp16.SetCamContent(calcam,28);
|
---|
287 | disp17.SetCamContent(calcam,29);
|
---|
288 | disp18.SetCamContent(calcam,30);
|
---|
289 | disp19.SetCamContent(calcam,31);
|
---|
290 | disp20.SetCamContent(calcam,32);
|
---|
291 | disp21.SetCamContent(calcam,33);
|
---|
292 |
|
---|
293 | // Lo Gain calibration
|
---|
294 | disp22.SetCamContent(calcam,34);
|
---|
295 |
|
---|
296 | // Valid flags
|
---|
297 | disp23.SetCamContent(calcam,35);
|
---|
298 | disp24.SetCamContent(calcam,36);
|
---|
299 | disp25.SetCamContent(calcam,37);
|
---|
300 |
|
---|
301 | // Pedestals
|
---|
302 | disp26.SetCamContent(calcam,38);
|
---|
303 | disp26.SetCamError( calcam,39);
|
---|
304 | disp27.SetCamContent(calcam,40);
|
---|
305 | disp27.SetCamError( calcam,41);
|
---|
306 |
|
---|
307 | // Relative Times
|
---|
308 | disp28.SetCamContent(timecam,0);
|
---|
309 | disp28.SetCamError( timecam,1);
|
---|
310 | disp29.SetCamContent(timecam,2);
|
---|
311 | disp29.SetCamError( timecam,3);
|
---|
312 | disp30.SetCamContent(timecam,4);
|
---|
313 | disp31.SetCamContent(timecam,5);
|
---|
314 | disp32.SetCamContent(timecam,6);
|
---|
315 |
|
---|
316 | // Absolute Times
|
---|
317 | disp33.SetCamContent(calcam,42);
|
---|
318 | disp33.SetCamError( calcam,43);
|
---|
319 | disp34.SetCamContent(calcam,43);
|
---|
320 |
|
---|
321 | disp1.SetYTitle("Charge [FADC units]");
|
---|
322 | disp2.SetYTitle("\\sigma_{Charge} [FADC units]");
|
---|
323 | disp3.SetYTitle("P_{Charge} [1]");
|
---|
324 |
|
---|
325 | disp4.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
|
---|
326 | disp5.SetYTitle("Reduced Sigma / Mean Charge [1]");
|
---|
327 |
|
---|
328 | disp6.SetYTitle("Nr. Photo-electrons [1]");
|
---|
329 | disp7.SetYTitle("Conversion Factor [Ph/FADC Count]");
|
---|
330 | disp8.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1] ");
|
---|
331 |
|
---|
332 | disp9.SetYTitle("Photon flux [ph/mm^2]");
|
---|
333 | disp10.SetYTitle("Conversion Factor [Phot/FADC Count]");
|
---|
334 | disp11.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
|
---|
335 |
|
---|
336 | disp12.SetYTitle("Photon flux [ph/mm^2]");
|
---|
337 | disp13.SetYTitle("Conversion Factor [Phot/FADC Count]");
|
---|
338 | disp14.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
|
---|
339 |
|
---|
340 | disp15.SetYTitle("[1]");
|
---|
341 | disp16.SetYTitle("[1]");
|
---|
342 | disp17.SetYTitle("[1]");
|
---|
343 | disp18.SetYTitle("[1]");
|
---|
344 | disp19.SetYTitle("[1]");
|
---|
345 | disp20.SetYTitle("[1]");
|
---|
346 | disp21.SetYTitle("[1]");
|
---|
347 | disp22.SetYTitle("[1]");
|
---|
348 | disp23.SetYTitle("[1]");
|
---|
349 | disp24.SetYTitle("[1]");
|
---|
350 | disp25.SetYTitle("[1]");
|
---|
351 |
|
---|
352 | disp26.SetYTitle("Ped [FADC Counts ]");
|
---|
353 | disp27.SetYTitle("RMS_{Ped} [FADC Counts ]");
|
---|
354 |
|
---|
355 | disp28.SetYTitle("Time Offset [ns]");
|
---|
356 | disp29.SetYTitle("Timing resolution [ns]");
|
---|
357 | disp30.SetYTitle("P_{Time} [1]");
|
---|
358 |
|
---|
359 | disp31.SetYTitle("[1]");
|
---|
360 | disp32.SetYTitle("[1]");
|
---|
361 |
|
---|
362 | disp33.SetYTitle("Mean Abs. Time [FADC slice]");
|
---|
363 | disp34.SetYTitle("RMS Abs. Time [FADC slices]");
|
---|
364 |
|
---|
365 | gStyle->SetOptStat(1111);
|
---|
366 | gStyle->SetOptFit();
|
---|
367 |
|
---|
368 | // Charges
|
---|
369 | TCanvas &c1 = display->AddTab("Fit.Charge");
|
---|
370 | c1.Divide(2, 3);
|
---|
371 |
|
---|
372 | CamDraw(c1, disp1,calcam,1, 2 , 2);
|
---|
373 | CamDraw(c1, disp2,calcam,2, 2 , 2);
|
---|
374 |
|
---|
375 | // Fit Probability
|
---|
376 | TCanvas &c2 = display->AddTab("Fit.Prob");
|
---|
377 | c2.Divide(1,3);
|
---|
378 |
|
---|
379 | CamDraw(c2, disp3,calcam,1, 1 , 4);
|
---|
380 |
|
---|
381 | // Reduced Sigmas
|
---|
382 | TCanvas &c3 = display->AddTab("Red.Sigma");
|
---|
383 | c3.Divide(2,3);
|
---|
384 |
|
---|
385 | CamDraw(c3, disp4,calcam,1, 2 , 2);
|
---|
386 | CamDraw(c3, disp5,calcam,2, 2 , 2);
|
---|
387 |
|
---|
388 | // F-Factor Method
|
---|
389 | TCanvas &c4 = display->AddTab("F-Factor");
|
---|
390 | c4.Divide(3,3);
|
---|
391 |
|
---|
392 | CamDraw(c4, disp6,calcam,1, 3 , 2);
|
---|
393 | CamDraw(c4, disp7,calcam,2, 3 , 2);
|
---|
394 | CamDraw(c4, disp8,calcam,3, 3 , 2);
|
---|
395 |
|
---|
396 | // Blind Pixel Method
|
---|
397 | TCanvas &c5 = display->AddTab("BlindPix");
|
---|
398 | c5.Divide(3, 3);
|
---|
399 |
|
---|
400 | CamDraw(c5, disp9,calcam,1, 3 , 9);
|
---|
401 | CamDraw(c5, disp10,calcam,2, 3 , 2);
|
---|
402 | CamDraw(c5, disp11,calcam,3, 3 , 2);
|
---|
403 |
|
---|
404 | // PIN Diode Method
|
---|
405 | TCanvas &c6 = display->AddTab("PINDiode");
|
---|
406 | c6.Divide(3,3);
|
---|
407 |
|
---|
408 | CamDraw(c6, disp12,calcam,1, 3 , 9);
|
---|
409 | CamDraw(c6, disp13,calcam,2, 3 , 2);
|
---|
410 | CamDraw(c6, disp14,calcam,3, 3 , 2);
|
---|
411 |
|
---|
412 | // Defects
|
---|
413 | TCanvas &c7 = display->AddTab("Defects");
|
---|
414 | c7.Divide(7,2);
|
---|
415 |
|
---|
416 | CamDraw(c7, disp15,calcam,1,7, 0);
|
---|
417 | CamDraw(c7, disp16,calcam,2,7, 0);
|
---|
418 | CamDraw(c7, disp17,calcam,3,7, 0);
|
---|
419 | CamDraw(c7, disp18,calcam,4,7, 0);
|
---|
420 | CamDraw(c7, disp19,calcam,5,7, 0);
|
---|
421 | CamDraw(c7, disp20,calcam,6,7, 0);
|
---|
422 | CamDraw(c7, disp21,calcam,7,7, 0);
|
---|
423 |
|
---|
424 | // Valid flags
|
---|
425 | TCanvas &c8 = display->AddTab("Validity");
|
---|
426 | c8.Divide(4,2);
|
---|
427 |
|
---|
428 | CamDraw(c8, disp22,calcam,1,4,0);
|
---|
429 | CamDraw(c8, disp23,calcam,2,4,0);
|
---|
430 | CamDraw(c8, disp24,calcam,3,4,0);
|
---|
431 | CamDraw(c8, disp25,calcam,4,4,0);
|
---|
432 |
|
---|
433 |
|
---|
434 | // Pedestals
|
---|
435 | TCanvas &c9 = display->AddTab("Pedestals");
|
---|
436 | c9.Divide(2,3);
|
---|
437 |
|
---|
438 | CamDraw(c9,disp26,calcam,1,2,1);
|
---|
439 | CamDraw(c9,disp27,calcam,2,2,2);
|
---|
440 |
|
---|
441 | // Rel. Times
|
---|
442 | TCanvas &c10 = display->AddTab("Fitted Rel. Times");
|
---|
443 | c10.Divide(3,3);
|
---|
444 |
|
---|
445 | CamDraw(c10,disp28,calcam,1,3,2);
|
---|
446 | CamDraw(c10,disp29,calcam,2,3,2);
|
---|
447 | CamDraw(c10,disp30,calcam,3,3,4);
|
---|
448 |
|
---|
449 | // Time Defects
|
---|
450 | TCanvas &c11 = display->AddTab("Time Def.");
|
---|
451 | c11.Divide(2,2);
|
---|
452 |
|
---|
453 | CamDraw(c11, disp31,calcam,1,2, 0);
|
---|
454 | CamDraw(c11, disp32,calcam,2,2, 0);
|
---|
455 |
|
---|
456 | // Abs. Times
|
---|
457 | TCanvas &c12 = display->AddTab("Abs. Times");
|
---|
458 | c12.Divide(2,3);
|
---|
459 |
|
---|
460 | CamDraw(c12,disp33,calcam,1,2,2);
|
---|
461 | CamDraw(c12,disp34,calcam,2,2,2);
|
---|
462 |
|
---|
463 | #endif
|
---|
464 | }
|
---|
465 |
|
---|
466 | void CamDraw(TCanvas &c, MHCamera &cam, MCamEvent &evt, Int_t i, Int_t j, Int_t fit)
|
---|
467 | {
|
---|
468 |
|
---|
469 | c.cd(i);
|
---|
470 | gPad->SetBorderMode(0);
|
---|
471 | MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
|
---|
472 | // obj1->AddNotify(evt);
|
---|
473 |
|
---|
474 | c.cd(i+j);
|
---|
475 | gPad->SetBorderMode(0);
|
---|
476 | obj1->Draw();
|
---|
477 | ((MHCamera*)obj1)->SetPrettyPalette();
|
---|
478 |
|
---|
479 | if (fit != 0)
|
---|
480 | {
|
---|
481 | c.cd(i+2*j);
|
---|
482 | gPad->SetBorderMode(0);
|
---|
483 | TH1D *obj2 = (TH1D*)obj1->Projection(obj1.GetName());
|
---|
484 |
|
---|
485 | // obj2->Sumw2();
|
---|
486 | obj2->Draw();
|
---|
487 | obj2->SetBit(kCanDelete);
|
---|
488 |
|
---|
489 | const Double_t min = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
|
---|
490 | const Double_t max = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
|
---|
491 | const Double_t integ = obj2->Integral("width")/2.5066283;
|
---|
492 | const Double_t mean = obj2->GetMean();
|
---|
493 | const Double_t rms = obj2->GetRMS();
|
---|
494 | const Double_t width = max-min;
|
---|
495 |
|
---|
496 | if (rms == 0. || width == 0. )
|
---|
497 | return;
|
---|
498 |
|
---|
499 | switch (fit)
|
---|
500 | {
|
---|
501 | case 1:
|
---|
502 | TF1 *sgaus = new TF1("sgaus","gaus(0)",min,max);
|
---|
503 | sgaus->SetBit(kCanDelete);
|
---|
504 | sgaus->SetParNames("Area","#mu","#sigma");
|
---|
505 | sgaus->SetParameters(integ/rms,mean,rms);
|
---|
506 | sgaus->SetParLimits(0,0.,integ);
|
---|
507 | sgaus->SetParLimits(1,min,max);
|
---|
508 | sgaus->SetParLimits(2,0,width/1.5);
|
---|
509 | obj2->Fit("sgaus","QLR");
|
---|
510 | obj2->GetFunction("sgaus")->SetLineColor(kYellow);
|
---|
511 | break;
|
---|
512 |
|
---|
513 | case 2:
|
---|
514 | TString dgausform = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
|
---|
515 | dgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
|
---|
516 | TF1 *dgaus = new TF1("dgaus",dgausform.Data(),min,max);
|
---|
517 | dgaus->SetBit(kCanDelete);
|
---|
518 | dgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}","A_{2}","#mu_{2}","#sigma_{2}");
|
---|
519 | dgaus->SetParameters(integ,(min+mean)/2.,width/4.,
|
---|
520 | integ/width/2.,(max+mean)/2.,width/4.);
|
---|
521 | // The left-sided Gauss
|
---|
522 | dgaus->SetParLimits(0,integ-1.5,integ+1.5);
|
---|
523 | dgaus->SetParLimits(1,min+(width/10.),mean);
|
---|
524 | dgaus->SetParLimits(2,0,width/2.);
|
---|
525 | // The right-sided Gauss
|
---|
526 | dgaus->SetParLimits(3,0,integ);
|
---|
527 | dgaus->SetParLimits(4,mean,max-(width/10.));
|
---|
528 | dgaus->SetParLimits(5,0,width/2.);
|
---|
529 | obj2->Fit("dgaus","QLRM");
|
---|
530 | obj2->GetFunction("dgaus")->SetLineColor(kYellow);
|
---|
531 | break;
|
---|
532 |
|
---|
533 | case 3:
|
---|
534 | TString tgausform = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
|
---|
535 | tgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
|
---|
536 | tgausform += "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
|
---|
537 | TF1 *tgaus = new TF1("tgaus",tgausform.Data(),min,max);
|
---|
538 | tgaus->SetBit(kCanDelete);
|
---|
539 | tgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
|
---|
540 | "A_{2}","#mu_{2}","#sigma_{2}",
|
---|
541 | "A_{3}","#mu_{3}","#sigma_{3}");
|
---|
542 | tgaus->SetParameters(integ,(min+mean)/2,width/4.,
|
---|
543 | integ/width/3.,(max+mean)/2.,width/4.,
|
---|
544 | integ/width/3.,mean,width/2.);
|
---|
545 | // The left-sided Gauss
|
---|
546 | tgaus->SetParLimits(0,integ-1.5,integ+1.5);
|
---|
547 | tgaus->SetParLimits(1,min+(width/10.),mean);
|
---|
548 | tgaus->SetParLimits(2,width/15.,width/2.);
|
---|
549 | // The right-sided Gauss
|
---|
550 | tgaus->SetParLimits(3,0.,integ);
|
---|
551 | tgaus->SetParLimits(4,mean,max-(width/10.));
|
---|
552 | tgaus->SetParLimits(5,width/15.,width/2.);
|
---|
553 | // The Gauss describing the outliers
|
---|
554 | tgaus->SetParLimits(6,0.,integ);
|
---|
555 | tgaus->SetParLimits(7,min,max);
|
---|
556 | tgaus->SetParLimits(8,width/4.,width/1.5);
|
---|
557 | obj2->Fit("tgaus","QLRM");
|
---|
558 | obj2->GetFunction("tgaus")->SetLineColor(kYellow);
|
---|
559 | break;
|
---|
560 | case 4:
|
---|
561 | obj2->Fit("pol0","Q");
|
---|
562 | obj2->GetFunction("pol0")->SetLineColor(kYellow);
|
---|
563 | break;
|
---|
564 | case 9:
|
---|
565 | break;
|
---|
566 | default:
|
---|
567 | obj2->Fit("gaus","Q");
|
---|
568 | obj2->GetFunction("gaus")->SetLineColor(kYellow);
|
---|
569 | break;
|
---|
570 | }
|
---|
571 |
|
---|
572 | // Just to get the right (maximum) binning
|
---|
573 | TH1D *half[2];
|
---|
574 | half[0] = obj1->Projection("Sector 6-1-2");
|
---|
575 | half[1] = obj1->Projection("Sector 3-4-5");
|
---|
576 |
|
---|
577 | half[0]->Reset();
|
---|
578 | half[1]->Reset();
|
---|
579 |
|
---|
580 | TH1D *dummy = obj1->Projection("Dummy");
|
---|
581 |
|
---|
582 | for (int i=1; i<7/*obj1->GetGeomCam().GetNumSectors()*/; i++)
|
---|
583 | half[(i/3)%2]->Add(obj1->ProjectionS(i, "Dummy"));
|
---|
584 |
|
---|
585 | for (int i=0; i<2; i++)
|
---|
586 | {
|
---|
587 | half[i]->SetLineColor(kRed+i);
|
---|
588 | half[i]->SetDirectory(0);
|
---|
589 | half[i]->SetBit(kCanDelete);
|
---|
590 | half[i]->Draw("same");
|
---|
591 | }
|
---|
592 |
|
---|
593 | delete dummy;
|
---|
594 |
|
---|
595 | gPad->Modified();
|
---|
596 | gPad->Update();
|
---|
597 |
|
---|
598 | }
|
---|
599 | }
|
---|
600 |
|
---|
601 |
|
---|