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 | ! Author(s): Josep Flix, 01/2004 <mailto:jflix@ifae.es>
|
---|
18 | ! Javier Rico, 01/2004 <mailto:jrico@ifae.es>
|
---|
19 | !
|
---|
20 | ! (based on bootcampstandardanalysis.C by Javier López)
|
---|
21 | !
|
---|
22 | !
|
---|
23 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
24 | !
|
---|
25 | !
|
---|
26 | \* ======================================================================== */
|
---|
27 |
|
---|
28 | #include "MParList.h"
|
---|
29 | #include "MTaskList.h"
|
---|
30 | #include "MPedestalCam.h"
|
---|
31 | #include "MReadMarsFile.h"
|
---|
32 | #include "MGeomApply.h"
|
---|
33 | #include "MPedCalcPedRun.h"
|
---|
34 | #include "MGeomCamMagic.h"
|
---|
35 | #include "MEvtLoop.h"
|
---|
36 | #include "MCalibrationCam.h"
|
---|
37 | #include "MExtractedSignalCam.h"
|
---|
38 | #include "MExtractSignal.h"
|
---|
39 | #include "MCalibrationCalc.h"
|
---|
40 | #include "MCerPhotEvt.h"
|
---|
41 | #include "MCalibrate.h"
|
---|
42 | #include "MPedPhotCalc.h"
|
---|
43 | #include "MPedPhotCam.h"
|
---|
44 | #include "MHCamera.h"
|
---|
45 |
|
---|
46 | #include "TTimer.h"
|
---|
47 | #include "TString.h"
|
---|
48 | #include "TCanvas.h"
|
---|
49 |
|
---|
50 | #include <iostream>
|
---|
51 |
|
---|
52 |
|
---|
53 | const TString pedfile="/disc02/Data/rootdata/Miscellaneous/2003_12_19/20031218_03522_P_Park_E.root";
|
---|
54 | const TString calfile="/disc02/Data/rootdata/Miscellaneous/2003_12_19/20031218_03527_C_Park_E.root";
|
---|
55 |
|
---|
56 | void pedphotcalc(TString pedname=pedfile,TString calname=calfile)
|
---|
57 | {
|
---|
58 |
|
---|
59 | /*
|
---|
60 | This macro is an example of the use of MPedPhotCalc. It computes
|
---|
61 | the pedestal mean and rms from pedestal files undergoing the
|
---|
62 | signal extraction + calibration chain, in units of photons. It
|
---|
63 | produces plots of the relevant computed quantities.
|
---|
64 | */
|
---|
65 |
|
---|
66 | /************************************/
|
---|
67 | /* FIRST LOOP: PEDESTAL COMPUTATION */
|
---|
68 | /************************************/
|
---|
69 |
|
---|
70 | MParList plist;
|
---|
71 | MTaskList tlist;
|
---|
72 | plist.AddToList(&tlist);
|
---|
73 |
|
---|
74 | // containers
|
---|
75 | MPedestalCam pedcam;
|
---|
76 | plist.AddToList(&pedcam);
|
---|
77 |
|
---|
78 | //tasks
|
---|
79 | MReadMarsFile read("Events", pedname);
|
---|
80 | MGeomApply geomapl;
|
---|
81 | MPedCalcPedRun pedcalc;
|
---|
82 | MGeomCamMagic geomcam;
|
---|
83 |
|
---|
84 | read.DisableAutoScheme();
|
---|
85 |
|
---|
86 | tlist.AddToList(&read);
|
---|
87 | tlist.AddToList(&geomapl);
|
---|
88 | tlist.AddToList(&pedcalc);
|
---|
89 |
|
---|
90 | // Create and execute the event looper
|
---|
91 | MEvtLoop evtloop;
|
---|
92 | evtloop.SetParList(&plist);
|
---|
93 |
|
---|
94 | cout << "*************************" << endl;
|
---|
95 | cout << "** COMPUTING PEDESTALS **" << endl;
|
---|
96 | cout << "*************************" << endl;
|
---|
97 | if (!evtloop.Eventloop())
|
---|
98 | return;
|
---|
99 |
|
---|
100 | tlist.PrintStatistics();
|
---|
101 |
|
---|
102 | /****************************/
|
---|
103 | /* SECOND LOOP: CALIBRATION */
|
---|
104 | /****************************/
|
---|
105 |
|
---|
106 | MParList plist2;
|
---|
107 | MTaskList tlist2;
|
---|
108 | plist2.AddToList(&tlist2);
|
---|
109 |
|
---|
110 | // containers
|
---|
111 | MCalibrationCam calcam;
|
---|
112 | MExtractedSignalCam sigcam;
|
---|
113 |
|
---|
114 | plist2.AddToList(&geomcam);
|
---|
115 | plist2.AddToList(&pedcam);
|
---|
116 | plist2.AddToList(&calcam);
|
---|
117 | plist2.AddToList(&sigcam);
|
---|
118 |
|
---|
119 | //tasks
|
---|
120 | MReadMarsFile read2("Events", calname);
|
---|
121 | read2.DisableAutoScheme();
|
---|
122 |
|
---|
123 | MExtractPINDiode pincalc;
|
---|
124 | MExtractBlindPixel blindcalc;
|
---|
125 | MExtractSignal sigcalc;
|
---|
126 | MCalibrationCalc calcalc;
|
---|
127 |
|
---|
128 | MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
|
---|
129 | //
|
---|
130 | // Apply a filter against cosmics
|
---|
131 | // (was directly in MCalibrationCalc in earlier versions)
|
---|
132 | //
|
---|
133 | MFCosmics cosmics;
|
---|
134 | MContinue cont(&cosmics);
|
---|
135 |
|
---|
136 | //
|
---|
137 | // As long as we don't have digital modules,
|
---|
138 | // we have to set the color of the pulser LED by hand
|
---|
139 | //
|
---|
140 | calcalc.SetPulserColor(MCalibrationCalc::kECT1);
|
---|
141 |
|
---|
142 | tlist2.AddToList(&read2);
|
---|
143 | tlist2.AddToList(&geomapl);
|
---|
144 | tlist2.AddToList(&blindcalc);
|
---|
145 | tlist2.AddToList(&pincalc);
|
---|
146 | tlist2.AddToList(&sigcalc);
|
---|
147 | //
|
---|
148 | // In case, you want to skip the cosmics rejection,
|
---|
149 | // uncomment the next line
|
---|
150 | //
|
---|
151 | tlist2.AddToList(&cont);
|
---|
152 | //
|
---|
153 | tlist2.AddToList(&calcalc);
|
---|
154 | tlist2.AddToList(&fillpin);
|
---|
155 |
|
---|
156 | // Execute second loop (calibration)
|
---|
157 | MEvtLoop evtloop2;
|
---|
158 | evtloop2.SetParList(&plist2);
|
---|
159 |
|
---|
160 | cout << "***********************************" << endl;
|
---|
161 | cout << "** COMPUTING CALIBRATION FACTORS **" << endl;
|
---|
162 | cout << "***********************************" << endl;
|
---|
163 | if (!evtloop2.Eventloop())
|
---|
164 | return;
|
---|
165 |
|
---|
166 | tlist2.PrintStatistics();
|
---|
167 |
|
---|
168 |
|
---|
169 | /************************************************************************/
|
---|
170 | /* THIRD LOOP: PEDESTAL COMPUTATION USING EXTRACTED SIGNAL (IN PHOTONS) */
|
---|
171 | /************************************************************************/
|
---|
172 |
|
---|
173 | // Create an empty Parameter List and an empty Task List
|
---|
174 | MParList plist3;
|
---|
175 | MTaskList tlist3;
|
---|
176 | plist3.AddToList(&tlist3);
|
---|
177 |
|
---|
178 | // containers
|
---|
179 | MCerPhotEvt photcam;
|
---|
180 | MPedPhotCam pedphotcam;
|
---|
181 | MExtractedSignalCam extedsig;
|
---|
182 |
|
---|
183 | plist3.AddToList(&geomcam);
|
---|
184 | plist3.AddToList(&pedcam);
|
---|
185 | plist3.AddToList(&calcam);
|
---|
186 | plist3.AddToList(&photcam);
|
---|
187 | plist3.AddToList(&extedsig);
|
---|
188 | plist3.AddToList(&pedphotcam);
|
---|
189 |
|
---|
190 | //tasks
|
---|
191 | MReadMarsFile read3("Events", pedname);
|
---|
192 | MCalibrate photcalc;
|
---|
193 | MPedPhotCalc pedphotcalc;
|
---|
194 |
|
---|
195 | read3.DisableAutoScheme();
|
---|
196 |
|
---|
197 | tlist3.AddToList(&read3);
|
---|
198 | tlist3.AddToList(&geomapl);
|
---|
199 | tlist3.AddToList(&sigcalc);
|
---|
200 | tlist3.AddToList(&photcalc);
|
---|
201 | tlist3.AddToList(&pedphotcalc);
|
---|
202 |
|
---|
203 | // Create and execute eventloop
|
---|
204 | MEvtLoop evtloop3;
|
---|
205 | evtloop3.SetParList(&plist3);
|
---|
206 |
|
---|
207 | cout << "*************************************************************" << endl;
|
---|
208 | cout << "** COMPUTING PEDESTALS USING EXTRACTED SIGNAL (IN PHOTONS) **" << endl;
|
---|
209 | cout << "*************************************************************" << endl;
|
---|
210 |
|
---|
211 | if (!evtloop3.Eventloop())
|
---|
212 | return;
|
---|
213 | tlist3.PrintStatistics();
|
---|
214 |
|
---|
215 |
|
---|
216 | /**********************/
|
---|
217 | /* PRODUCE NICE PLOTS */
|
---|
218 | /**********************/
|
---|
219 |
|
---|
220 | const UShort_t npix = 577;
|
---|
221 |
|
---|
222 | // declare histograms
|
---|
223 | // pedestals
|
---|
224 | TH1F* pedhist = new TH1F("pedhist","Pedestal",npix,0,npix);
|
---|
225 | TH1F* pedrmshist = new TH1F("pedrmshist","Pedestal RMS",npix,0,npix);
|
---|
226 | TH1F* peddist = new TH1F("peddist","Pedestal",100,0,20);
|
---|
227 | TH1F* pedrmsdist = new TH1F("pedrmsdist","Pedestal RMS",100,0,15);
|
---|
228 |
|
---|
229 | // calibration factors
|
---|
230 | TH1F* calhist = new TH1F("calhist","Calibration factors",npix,0,npix);
|
---|
231 | TH1F* caldist = new TH1F("caldist","Calibration factors",100,0,1);
|
---|
232 |
|
---|
233 | // pedestal signals
|
---|
234 | TH1F* pedphothist = new TH1F("pedphothist","Pedestal Signal",npix,0,npix);
|
---|
235 | TH1F* pedphotrmshist = new TH1F("pedphotrmshist","Pedestal Signal RMS",npix,0,npix);
|
---|
236 | TH1F* pedphotdist = new TH1F("pedphotdist","Pedestal Signal",100,-0.4,0.4);
|
---|
237 | TH1F* pedphotrmsdist = new TH1F("pedphotrmsdist","Pedestal Signal RMS",100,0,25);
|
---|
238 |
|
---|
239 | // fill histograms
|
---|
240 | for(int i=0;i<npix;i++)
|
---|
241 | {
|
---|
242 | const Float_t ped = pedcam[i].GetPedestal();
|
---|
243 | const Float_t pedrms = pedcam[i].GetPedestalRms();
|
---|
244 | const Float_t cal = calcam[i].GetMeanConversionBlindPixelMethod();
|
---|
245 | const Float_t calerr = calcam[i].GetErrorConversionBlindPixelMethod();
|
---|
246 | const Float_t pedphot = pedphotcam[i].GetMean();
|
---|
247 | const Float_t pedphotrms = pedphotcam[i].GetRms();
|
---|
248 |
|
---|
249 | pedhist->Fill(i,ped);
|
---|
250 | peddist->Fill(ped);
|
---|
251 | pedrmshist->Fill(i,pedrms);
|
---|
252 | pedrmsdist->Fill(pedrms);
|
---|
253 |
|
---|
254 | calhist->Fill(i,cal);
|
---|
255 | caldist->Fill(cal);
|
---|
256 |
|
---|
257 | pedphothist->Fill(i,pedphot);
|
---|
258 | pedphotdist->Fill(pedphot);
|
---|
259 | pedphotrmshist->Fill(i,pedphotrms);
|
---|
260 | pedphotrmsdist->Fill(pedphotrms);
|
---|
261 | }
|
---|
262 |
|
---|
263 | // Draw
|
---|
264 | gROOT->Reset();
|
---|
265 | gStyle->SetCanvasColor(0);
|
---|
266 | TCanvas* canvas = new TCanvas("canvas","pedphotcalc.C", 0, 100, 650, 800);
|
---|
267 | canvas->SetBorderMode(0); // Delete the Canvas' border line
|
---|
268 | canvas->cd();
|
---|
269 | canvas->SetBorderMode(0);
|
---|
270 |
|
---|
271 | canvas->Divide(2,4);
|
---|
272 |
|
---|
273 | // draw pedestal histo
|
---|
274 | canvas->cd(1);
|
---|
275 | gPad->cd();
|
---|
276 | gPad->SetBorderMode(0);
|
---|
277 |
|
---|
278 | pedhist->SetStats(kFALSE);
|
---|
279 | pedhist->GetXaxis()->SetTitle("Pixel SW Id");
|
---|
280 | pedhist->GetYaxis()->SetTitle("Pedestal (ADC counts)");
|
---|
281 | pedrmshist->SetStats(kFALSE);
|
---|
282 | pedrmshist->SetLineColor(2);
|
---|
283 | pedhist->Draw();
|
---|
284 | pedrmshist->Draw("same");
|
---|
285 |
|
---|
286 | TLegend* leg1 = new TLegend(.14,.68,.39,.88);
|
---|
287 | leg1->SetHeader("");
|
---|
288 | leg1->AddEntry(pedhist,"Pedestal","L");
|
---|
289 | leg1->AddEntry(pedrmshist,"Pedestal RMS","L");
|
---|
290 | leg1->SetFillColor(0);
|
---|
291 | leg1->SetLineColor(0);
|
---|
292 | leg1->SetBorderSize(0);
|
---|
293 | leg1->Draw();
|
---|
294 |
|
---|
295 | // draw pedestal distribution
|
---|
296 | canvas->cd(2);
|
---|
297 | gPad->cd();
|
---|
298 | gPad->SetBorderMode(0);
|
---|
299 | peddist->GetXaxis()->SetTitle("Pedestal (ADC counts)");
|
---|
300 | pedrmsdist->SetLineColor(2);
|
---|
301 | peddist->Draw();
|
---|
302 | pedrmsdist->Draw("same");
|
---|
303 |
|
---|
304 |
|
---|
305 | TLegend* leg2 = new TLegend(.14,.68,.39,.88);
|
---|
306 | leg2->SetHeader("");
|
---|
307 | leg2->AddEntry(pedhist,"Pedestal","L");
|
---|
308 | leg2->AddEntry(pedrmshist,"Pedestal RMS","L");
|
---|
309 | leg2->SetFillColor(0);
|
---|
310 | leg2->SetLineColor(0);
|
---|
311 | leg2->SetBorderSize(0);
|
---|
312 | leg2->Draw();
|
---|
313 |
|
---|
314 | // draw calibration histo
|
---|
315 | canvas->cd(3);
|
---|
316 | gPad->cd();
|
---|
317 | gPad->SetBorderMode(0);
|
---|
318 | calhist->GetXaxis()->SetTitle("Pixel SW Id");
|
---|
319 | calhist->SetMaximum(1);
|
---|
320 | calhist->SetMinimum(0);
|
---|
321 | calhist->GetYaxis()->SetTitle("Calibration factor (photon/ADC count)");
|
---|
322 | calhist->SetStats(kFALSE);
|
---|
323 | calhist->Draw();
|
---|
324 |
|
---|
325 | // draw calibration distribution
|
---|
326 | canvas->cd(4);
|
---|
327 | gPad->cd();
|
---|
328 | gPad->SetBorderMode(0);
|
---|
329 | caldist->GetXaxis()->SetTitle("Calibration factor (photon/ADC count)");
|
---|
330 | caldist->Draw();
|
---|
331 |
|
---|
332 | // draw pedestal signal histo
|
---|
333 | canvas->cd(5);
|
---|
334 | gPad->cd();
|
---|
335 | gPad->SetBorderMode(0);
|
---|
336 | pedphothist->GetXaxis()->SetTitle("Pixel SW Id");
|
---|
337 | pedphothist->GetYaxis()->SetTitle("Pedestal signal (photons)");
|
---|
338 | pedphothist->SetStats(kFALSE);
|
---|
339 | pedphothist->Draw();
|
---|
340 |
|
---|
341 | // draw pedestal signal distribution
|
---|
342 | canvas->cd(6);
|
---|
343 | gPad->cd();
|
---|
344 | gPad->SetBorderMode(0);
|
---|
345 | pedphotdist->GetXaxis()->SetTitle("Pedestal signal (photons)");
|
---|
346 | pedphotdist->Draw();
|
---|
347 |
|
---|
348 | // draw pedestal signal rms histo
|
---|
349 | canvas->cd(7);
|
---|
350 | gPad->cd();
|
---|
351 | gPad->SetBorderMode(0);
|
---|
352 | pedphotrmshist->GetXaxis()->SetTitle("Pixel SW Id");
|
---|
353 | pedphotrmshist->GetYaxis()->SetTitle("Pedestal signal rms (photons)");
|
---|
354 | pedphotrmshist->SetStats(kFALSE);
|
---|
355 | pedphotrmshist->Draw();
|
---|
356 |
|
---|
357 | // draw pedestal signal rms distribution
|
---|
358 | canvas->cd(8);
|
---|
359 | gPad->cd();
|
---|
360 | gPad->SetBorderMode(0);
|
---|
361 | pedphotrmsdist->GetXaxis()->SetTitle("Pedestal signal rms (photons)");
|
---|
362 | pedphotrmsdist->Draw();
|
---|
363 |
|
---|
364 | return;
|
---|
365 | }
|
---|
366 |
|
---|