1 | #include <sstream>
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | #include "MLog.h"
|
---|
5 | #include "MLogManip.h"
|
---|
6 |
|
---|
7 | #include "TH1F.h"
|
---|
8 | #include "TFile.h"
|
---|
9 | #include "TStyle.h"
|
---|
10 | #include "TGraph.h"
|
---|
11 | #include "TLine.h"
|
---|
12 |
|
---|
13 | #include "DrsCalib.h"
|
---|
14 | #include "factfits.h"
|
---|
15 | #include "MDrsCalibration.h"
|
---|
16 | #include "MExtralgoSpline.h"
|
---|
17 | #include "MSequence.h"
|
---|
18 | #include "MStatusArray.h"
|
---|
19 | #include "MHCamera.h"
|
---|
20 | #include "MJob.h"
|
---|
21 | #include "MWriteRootFile.h"
|
---|
22 | #include "MHCamera.h"
|
---|
23 | #include "MBadPixelsCam.h"
|
---|
24 | #include "MBadPixelsPix.h"
|
---|
25 | #include "MDirIter.h"
|
---|
26 | #include "MTaskList.h"
|
---|
27 | #include "MFDataPhrase.h"
|
---|
28 | #include "MArrayF.h"
|
---|
29 | #include "MBadPixelsTreat.h"
|
---|
30 | #include "MCalibrateDrsTimes.h"
|
---|
31 | #include "MHSectorVsTime.h"
|
---|
32 | #include "MHCamEvent.h"
|
---|
33 | #include "MExtractFACT.h"
|
---|
34 | #include "MFillH.h"
|
---|
35 | #include "MDrsCalibApply.h"
|
---|
36 | #include "MGeomApply.h"
|
---|
37 | #include "MContinue.h"
|
---|
38 | #include "MRawFitsRead.h"
|
---|
39 | #include "MReadMarsFile.h"
|
---|
40 | #include "MEvtLoop.h"
|
---|
41 | #include "MParList.h"
|
---|
42 | #include "MStatusDisplay.h"
|
---|
43 | #include "MDrsCalibrationTime.h"
|
---|
44 | #include "MH3.h"
|
---|
45 | #include "MGeomCamFACT.h"
|
---|
46 | #include "MCalibrateFact.h"
|
---|
47 | #include "MParameters.h"
|
---|
48 | #include "MWriteAsciiFile.h"
|
---|
49 | #include "MFilterData.h"
|
---|
50 | #include "MTreatSaturation.h"
|
---|
51 |
|
---|
52 | using namespace std;
|
---|
53 |
|
---|
54 | int callisto(
|
---|
55 | const char *seqfile="seq/2012/01/23/20120123_023.seq",
|
---|
56 | const char *outpath = "output",
|
---|
57 | bool use_delays=false,
|
---|
58 | const char *drs_time_file_path=""
|
---|
59 | )
|
---|
60 | {
|
---|
61 | // ======================================================
|
---|
62 |
|
---|
63 | // true: Display correctly mapped pixels in the camera displays
|
---|
64 | // but the value-vs-index plot is in software/spiral indices
|
---|
65 | // false: Display pixels in hardware/linear indices,
|
---|
66 | // but the order is the camera display is distorted
|
---|
67 | bool usemap = true;
|
---|
68 |
|
---|
69 | // map file to use (get that from La Palma!)
|
---|
70 | // const char *map = usemap ? "/home/fact/FACT++/FACTmap111030.txt" : NULL;
|
---|
71 | const char *map = usemap ? "/scratch/fact/FACTmap111030.txt" : NULL;
|
---|
72 |
|
---|
73 | // ------------------------------------------------------
|
---|
74 |
|
---|
75 | MStatusDisplay *d = new MStatusDisplay;
|
---|
76 |
|
---|
77 | MBadPixelsCam badpixels;
|
---|
78 | badpixels.InitSize(1440);
|
---|
79 | badpixels[ 424].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
80 | badpixels[ 583].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
81 | badpixels[ 830].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
82 | badpixels[ 923].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
83 | badpixels[1208].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
84 | badpixels[1399].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
85 | // Twin pixel
|
---|
86 | // 113
|
---|
87 | // 115
|
---|
88 | // 354
|
---|
89 | // 423
|
---|
90 | // 1195
|
---|
91 | // 1393
|
---|
92 |
|
---|
93 | // ------------------------------------------------------
|
---|
94 |
|
---|
95 | // ------------------------------------------------------
|
---|
96 |
|
---|
97 | // Calib: 51 / 90 / 197 (20% TH)
|
---|
98 | // Data: 52 / 64 / 104 (20% TH)
|
---|
99 |
|
---|
100 | // Extraction range in slices. It will always(!) contain the full range
|
---|
101 | // of integration
|
---|
102 | const int first_slice = 25; // 10ns
|
---|
103 | const int last_slice = 225; // 125ns
|
---|
104 |
|
---|
105 | //const double heighttm = 0.5; // IntegralAbs { 1.5pe * 9.6mV/pe } / IntegralRel { 0.5 }
|
---|
106 |
|
---|
107 | Long_t max = 0; // All
|
---|
108 | Long_t max1 = max; // Light pulser
|
---|
109 | //Long_t max2 = 3000; // Calibration ratio
|
---|
110 | Long_t max3 = max; // Pedestal Rndm
|
---|
111 | Long_t max4 = max; // Pedestal Ext
|
---|
112 | Long_t max5 = max; // Data
|
---|
113 |
|
---|
114 | // ========================= Result ==================================
|
---|
115 |
|
---|
116 | //double scale = 0.1;
|
---|
117 | double scale = 0.1024;
|
---|
118 |
|
---|
119 | // ======================================================
|
---|
120 |
|
---|
121 | if (map && gSystem->AccessPathName(map, kFileExists))
|
---|
122 | {
|
---|
123 | gLog << err << "ERROR - Cannot access mapping file '" << map << "'" << endl;
|
---|
124 | return 1;
|
---|
125 | }
|
---|
126 |
|
---|
127 | // The sequence file which defines the files for the analysis
|
---|
128 | MSequence seq(seqfile);
|
---|
129 | if (!seq.IsValid())
|
---|
130 | {
|
---|
131 | gLog << err << "ERROR - Sequence '" << seqfile << "' invalid!" << endl;
|
---|
132 | return 2;
|
---|
133 | }
|
---|
134 |
|
---|
135 | // --------------------------------------------------------------------------------
|
---|
136 |
|
---|
137 | gLog.Separator("Callisto");
|
---|
138 | gLog << all << "Calibrate data of sequence '" << seq.GetFileName() << "'" << endl;
|
---|
139 | gLog << endl;
|
---|
140 |
|
---|
141 | // ------------------------------------------------------
|
---|
142 |
|
---|
143 | ostringstream drsname;
|
---|
144 | drsname << gSystem->DirName(seqfile) << "/";
|
---|
145 | drsname << seq.GetNight().GetNightAsInt() << "_";
|
---|
146 | drsname << Form("%03d", seq.GetDrsSequence()) << ".drs.seq";
|
---|
147 |
|
---|
148 | MSequence drs(drsname.str().c_str());
|
---|
149 | if (!drs.IsValid())
|
---|
150 | {
|
---|
151 | gLog << err << "ERROR - DRS sequence invalid!" << endl;
|
---|
152 | return 3;
|
---|
153 | }
|
---|
154 |
|
---|
155 | gLog << all << "DRS sequence file: " << drsname.str() << '\n' << endl;
|
---|
156 |
|
---|
157 | TString drsfile = seq.GetFileName(0, MSequence::kRawDrs);
|
---|
158 | if (drsfile.IsNull())
|
---|
159 | {
|
---|
160 | gLog << err << "No DRS file available in sequence." << endl;
|
---|
161 | return 4;
|
---|
162 | }
|
---|
163 |
|
---|
164 | TString timfile = drs.GetFileName(0, MSequence::kFitsDat);
|
---|
165 | TString drs1024 = drs.GetFileName(0, MSequence::kFitsDrs);
|
---|
166 | TString pedfile = seq.GetFileName(0, MSequence::kFitsPed);
|
---|
167 | TString calfile = seq.GetFileName(0, MSequence::kFitsCal);
|
---|
168 |
|
---|
169 | gLog << all;
|
---|
170 | gLog << "DRS calib 300: " << drsfile << '\n';
|
---|
171 | gLog << "DRS calib 1024: " << drs1024 << "\n\n";
|
---|
172 |
|
---|
173 | MDrsCalibration drscalib300;
|
---|
174 | if (!drscalib300.ReadFits(drsfile.Data()))
|
---|
175 | return 5;
|
---|
176 |
|
---|
177 | MDrsCalibration drscalib1024;
|
---|
178 | if (!drscalib1024.ReadFits(drs1024.Data()))
|
---|
179 | return 6;
|
---|
180 |
|
---|
181 | gLog << all;
|
---|
182 | gLog << "Time calibration : " << timfile << '\n';
|
---|
183 | gLog << "Pedestal file: " << pedfile << '\n';
|
---|
184 | gLog << "Light Pulser file: " << calfile << '\n' << endl;
|
---|
185 |
|
---|
186 | // ------------------------------------------------------
|
---|
187 |
|
---|
188 | MDirIter iter;
|
---|
189 | if (seq.GetRuns(iter, MSequence::kFitsDat)<=0)
|
---|
190 | {
|
---|
191 | gLog << err << "ERROR - Sequence valid but without files." << endl;
|
---|
192 | return 7;
|
---|
193 | }
|
---|
194 | iter.Print();
|
---|
195 |
|
---|
196 | // ======================================================
|
---|
197 |
|
---|
198 | /*
|
---|
199 | MStatusArray arrt, arrp;
|
---|
200 |
|
---|
201 | TFile ft(lp_template);
|
---|
202 | if (arrt.Read()<=0)
|
---|
203 | {
|
---|
204 | gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
|
---|
205 | return 100;
|
---|
206 | }
|
---|
207 |
|
---|
208 | MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
|
---|
209 | if (!lpref)
|
---|
210 | {
|
---|
211 | gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
|
---|
212 | return 101;
|
---|
213 | }
|
---|
214 | lpref->SetDirectory(0);
|
---|
215 |
|
---|
216 | MHCamera *gain = (MHCamera*)arrt.FindObjectInCanvas("gain", "MHCamera", "Gain");
|
---|
217 | if (!gain)
|
---|
218 | {
|
---|
219 | gLog << err << "ERROR - Gain not found in " << lp_template << endl;
|
---|
220 | return 101;
|
---|
221 | }
|
---|
222 | gain->SetDirectory(0);
|
---|
223 |
|
---|
224 | TFile fp(pulse_template);
|
---|
225 | if (arrp.Read()<=0)
|
---|
226 | {
|
---|
227 | gLog << err << "ERROR - Reading Pulse template from " << pulse_template << endl;
|
---|
228 | return 102;
|
---|
229 | }
|
---|
230 |
|
---|
231 | TH1F *hpulse = (TH1F*)arrp.FindObjectInCanvas("hPixelEdgeMean0_0", "TH1F", "cgpPixelPulses0");
|
---|
232 | if (!hpulse)
|
---|
233 | {
|
---|
234 | gLog << err << "ERROR - Pulse Template not found in " << pulse_template << endl;
|
---|
235 | return 103;
|
---|
236 | }
|
---|
237 | hpulse->SetDirectory(0);
|
---|
238 | */
|
---|
239 | // ======================================================
|
---|
240 |
|
---|
241 | // Plot the trigger pattern rates vs. run-number
|
---|
242 | MH3 hrate("MRawRunHeader.GetFileID", "MRawEvtHeader.GetTriggerID&0xff00");
|
---|
243 | hrate.SetWeight("1./TMath::Max(MRawRunHeader.GetRunLength,1)");
|
---|
244 | hrate.SetName("Rate");
|
---|
245 | hrate.SetTitle("Event rate [Hz];File Id;Trigger Type;");
|
---|
246 | hrate.InitLabels(MH3::kLabelsXY);
|
---|
247 | hrate.DefineLabelY( 0, "Data"); // What if TriggerID==0 already???
|
---|
248 | hrate.DefineLabelY(0x100, "Cal");
|
---|
249 | hrate.DefineLabelY(0x400, "Ped");
|
---|
250 | // hrate.DefaultLabelY("ERROR");
|
---|
251 |
|
---|
252 | MDrsCalibrationTime timecam;
|
---|
253 |
|
---|
254 | gStyle->SetOptFit(kTRUE);
|
---|
255 |
|
---|
256 | // ======================================================
|
---|
257 |
|
---|
258 | gLog << endl;
|
---|
259 | gLog.Separator("Reading DRS timing calibration constants");
|
---|
260 | factfits drs_time_file(drs_time_file_path);
|
---|
261 |
|
---|
262 | const int NumberOfChips = drs_time_file.GetInt("NCHIPS");
|
---|
263 | const int NumberOfCells = drs_time_file.GetInt("NCELLS");
|
---|
264 | timecam.fStat.resize(NumberOfChips * NumberOfCells);
|
---|
265 | double *drs_sampling_time_deviations = new double[NumberOfChips * NumberOfCells];
|
---|
266 |
|
---|
267 | drs_time_file.SetPtrAddress("SamplingTimeDeviation", drs_sampling_time_deviations);
|
---|
268 | drs_time_file.GetNextRow();
|
---|
269 | for (int i=0; i<NumberOfChips * NumberOfCells; i++){
|
---|
270 | timecam.fStat[i].first = drs_sampling_time_deviations[i];
|
---|
271 | }
|
---|
272 | delete[] drs_sampling_time_deviations;
|
---|
273 | drs_sampling_time_deviations = NULL;
|
---|
274 | drs_time_file.close();
|
---|
275 |
|
---|
276 | // ======================================================
|
---|
277 |
|
---|
278 | gLog << endl;
|
---|
279 | gLog.Separator("Processing external light pulser run");
|
---|
280 |
|
---|
281 | MTaskList tlist1;
|
---|
282 |
|
---|
283 | MParList plist1;
|
---|
284 | plist1.AddToList(&tlist1);
|
---|
285 | plist1.AddToList(&drscalib300);
|
---|
286 | plist1.AddToList(&badpixels);
|
---|
287 | plist1.AddToList(&timecam);
|
---|
288 |
|
---|
289 | MEvtLoop loop1("DetermineCalConst");
|
---|
290 | loop1.SetDisplay(d);
|
---|
291 | loop1.SetParList(&plist1);
|
---|
292 |
|
---|
293 | // ------------------ Setup the tasks ---------------
|
---|
294 |
|
---|
295 | MRawFitsRead read1;
|
---|
296 | read1.LoadMap(map);
|
---|
297 | read1.AddFile(calfile);
|
---|
298 |
|
---|
299 | MContinue cont1("(MRawEvtHeader.GetTriggerID&0xff00)!=0x100", "SelectCal");
|
---|
300 |
|
---|
301 | MGeomApply apply1;
|
---|
302 |
|
---|
303 | MDrsCalibApply drsapply1;
|
---|
304 | //drsapply1.SetRemoveSpikes(4);
|
---|
305 |
|
---|
306 | MFilterData filterdata1;
|
---|
307 |
|
---|
308 | // ---
|
---|
309 |
|
---|
310 | MExtractFACT extractor1b("ExtractPulse");
|
---|
311 | extractor1b.SetRange(first_slice, last_slice);
|
---|
312 | extractor1b.SetNoiseCalculation(kFALSE);
|
---|
313 |
|
---|
314 | // ---
|
---|
315 |
|
---|
316 | MHCamEvent evt1f(0, "ExtCalSig", "Extracted calibration signal;;S [mV·sl]");
|
---|
317 | MHCamEvent evt1g(4, "ExtCalTm", "Extracted arrival times;;T [sl]");
|
---|
318 | MHCamEvent evt1h(6, "CalCalTm", "Calibrated arrival times;;T [sl]");
|
---|
319 |
|
---|
320 | MHSectorVsTime hist1rmsb("ExtSigVsTm");
|
---|
321 | MHSectorVsTime hist1tmb("CalTmVsTm");
|
---|
322 | hist1rmsb.SetTitle("Extracted calibration vs event number;;S [mV·sl]");
|
---|
323 | hist1rmsb.SetType(0);
|
---|
324 | hist1tmb.SetTitle("Extracted arrival time vs event number;;T [sl]");
|
---|
325 | //hist1tmb.SetType(4);
|
---|
326 | hist1tmb.SetType(6);
|
---|
327 |
|
---|
328 | MFillH fill1f(&evt1f, "MExtractedSignalCam", "FillExtSig");
|
---|
329 | MFillH fill1g(&evt1g, "MArrivalTimeCam", "FillExtTm");
|
---|
330 | MFillH fill1h(&evt1h, "MSignalCam", "FillCalTm");
|
---|
331 | MFillH fill1r(&hist1rmsb, "MExtractedSignalCam", "FillExtSigVsTm");
|
---|
332 | //MFillH fill1j(&hist1tmb, "MArrivalTimeCam", "FillExtTmVsTm");
|
---|
333 | MFillH fill1j(&hist1tmb, "MSignalCam", "FillCalTmVsTm");
|
---|
334 |
|
---|
335 | fill1f.SetDrawOption("gaus");
|
---|
336 | fill1h.SetDrawOption("gaus");
|
---|
337 |
|
---|
338 | // ---
|
---|
339 |
|
---|
340 | MCalibrateDrsTimes calctm1a("CalibrateCalEvents");
|
---|
341 | calctm1a.SetNameUncalibrated("UncalibratedTimes");
|
---|
342 |
|
---|
343 | MBadPixelsTreat treat1;
|
---|
344 | treat1.SetProcessPedestalRun(kFALSE);
|
---|
345 | treat1.SetProcessPedestalEvt(kFALSE);
|
---|
346 |
|
---|
347 | // ---
|
---|
348 |
|
---|
349 | MHCamEvent evt1c(6, "ExtCalTmShift", "Relative extracted arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
|
---|
350 | MHCamEvent evt1d(6, "CalCalTmShift", "Relative calibrated arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
|
---|
351 |
|
---|
352 | evt1c.SetMedianShift();
|
---|
353 | evt1d.SetMedianShift();
|
---|
354 |
|
---|
355 | MFillH fill1c(&evt1c, "UncalibratedTimes", "FillExtCalTm");
|
---|
356 | MFillH fill1d(&evt1d, "MSignalCam", "FillCalCalTm");
|
---|
357 | fill1d.SetDrawOption("gaus");
|
---|
358 |
|
---|
359 | // ------------------ Setup eventloop and run analysis ---------------
|
---|
360 |
|
---|
361 | tlist1.AddToList(&read1);
|
---|
362 | tlist1.AddToList(&apply1);
|
---|
363 | tlist1.AddToList(&drsapply1);
|
---|
364 | tlist1.AddToList(&cont1);
|
---|
365 | tlist1.AddToList(&filterdata1);
|
---|
366 | tlist1.AddToList(&extractor1b);
|
---|
367 | tlist1.AddToList(&calctm1a);
|
---|
368 | tlist1.AddToList(&treat1);
|
---|
369 | tlist1.AddToList(&fill1f);
|
---|
370 | tlist1.AddToList(&fill1g);
|
---|
371 | tlist1.AddToList(&fill1h);
|
---|
372 | tlist1.AddToList(&fill1r);
|
---|
373 | tlist1.AddToList(&fill1j);
|
---|
374 | tlist1.AddToList(&fill1c);
|
---|
375 | tlist1.AddToList(&fill1d);
|
---|
376 |
|
---|
377 | if (!loop1.Eventloop(max1))
|
---|
378 | return 10;
|
---|
379 |
|
---|
380 | if (!loop1.GetDisplay())
|
---|
381 | return 11;
|
---|
382 |
|
---|
383 | if (use_delays)
|
---|
384 | timecam.SetDelays(*evt1h.GetHist());
|
---|
385 |
|
---|
386 | // ======================================================
|
---|
387 |
|
---|
388 | gLog << endl;
|
---|
389 | gLog.Separator("Extracting random pedestal");
|
---|
390 |
|
---|
391 | MTaskList tlist3;
|
---|
392 |
|
---|
393 | MParList plist3;
|
---|
394 | plist3.AddToList(&tlist3);
|
---|
395 | plist3.AddToList(&drscalib300);
|
---|
396 | plist3.AddToList(&badpixels);
|
---|
397 | plist3.AddToList(&timecam);
|
---|
398 |
|
---|
399 | MEvtLoop loop3("DetermineRndmPed");
|
---|
400 | loop3.SetDisplay(d);
|
---|
401 | loop3.SetParList(&plist3);
|
---|
402 |
|
---|
403 | // ------------------ Setup the tasks ---------------
|
---|
404 |
|
---|
405 | MRawFitsRead read3;
|
---|
406 | read3.LoadMap(map);
|
---|
407 | read3.AddFile(pedfile);
|
---|
408 |
|
---|
409 | MFillH fill3a(&hrate);
|
---|
410 |
|
---|
411 | MContinue cont3("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
|
---|
412 |
|
---|
413 | MGeomApply apply3;
|
---|
414 |
|
---|
415 | MDrsCalibApply drsapply3;
|
---|
416 | //drsapply3.SetRemoveSpikes(4);
|
---|
417 |
|
---|
418 | MFilterData filterdata3;
|
---|
419 |
|
---|
420 | //---
|
---|
421 |
|
---|
422 | MExtractFACT extractor3;
|
---|
423 | extractor3.SetRange(first_slice, last_slice);
|
---|
424 | extractor3.SetNoiseCalculation(kTRUE);
|
---|
425 |
|
---|
426 | MCalibrateFact conv3;
|
---|
427 | conv3.SetScale(scale);
|
---|
428 | //conv3.SetCalibConst(calib);
|
---|
429 |
|
---|
430 | MBadPixelsTreat treat3;
|
---|
431 | treat3.SetProcessPedestalRun(kFALSE);
|
---|
432 | treat3.SetProcessPedestalEvt(kFALSE);
|
---|
433 | treat3.SetProcessTimes(kFALSE);
|
---|
434 |
|
---|
435 | MHCamEvent evt3b(0, "PedRdm","Interpolated random pedestal;;Signal [~phe]");
|
---|
436 | //evt2b.SetErrorSpread(kFALSE);
|
---|
437 |
|
---|
438 | MFillH fill3b(&evt3b, "MSignalCam", "FillPedRdm");
|
---|
439 | fill3b.SetDrawOption("gaus");
|
---|
440 |
|
---|
441 | // ------------------ Setup eventloop and run analysis ---------------
|
---|
442 |
|
---|
443 | tlist3.AddToList(&read3);
|
---|
444 | tlist3.AddToList(&apply3);
|
---|
445 | tlist3.AddToList(&drsapply3);
|
---|
446 | tlist3.AddToList(&cont3);
|
---|
447 | tlist3.AddToList(&filterdata3);
|
---|
448 | tlist3.AddToList(&extractor3);
|
---|
449 | // tlist3.AddToList(&fill3a);
|
---|
450 | tlist3.AddToList(&conv3);
|
---|
451 | tlist3.AddToList(&treat3);
|
---|
452 | tlist3.AddToList(&fill3b);
|
---|
453 |
|
---|
454 | if (!loop3.Eventloop(max3))
|
---|
455 | return 14;
|
---|
456 |
|
---|
457 | if (!loop3.GetDisplay())
|
---|
458 | return 15;
|
---|
459 |
|
---|
460 | // ======================================================
|
---|
461 |
|
---|
462 | gLog << endl;
|
---|
463 | gLog.Separator("Extracting pedestal");
|
---|
464 |
|
---|
465 | MTaskList tlist4;
|
---|
466 |
|
---|
467 | MParList plist4;
|
---|
468 | plist4.AddToList(&tlist4);
|
---|
469 | plist4.AddToList(&drscalib300);
|
---|
470 | plist4.AddToList(&badpixels);
|
---|
471 | plist4.AddToList(&timecam);
|
---|
472 |
|
---|
473 | MEvtLoop loop4("DetermineExtractedPed");
|
---|
474 | loop4.SetDisplay(d);
|
---|
475 | loop4.SetParList(&plist4);
|
---|
476 |
|
---|
477 | // ------------------ Setup the tasks ---------------
|
---|
478 |
|
---|
479 | MRawFitsRead read4;
|
---|
480 | read4.LoadMap(map);
|
---|
481 | read4.AddFile(pedfile);
|
---|
482 |
|
---|
483 | MContinue cont4("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
|
---|
484 |
|
---|
485 | MGeomApply apply4;
|
---|
486 |
|
---|
487 | MDrsCalibApply drsapply4;
|
---|
488 | //drsapply4.SetRemoveSpikes(4);
|
---|
489 |
|
---|
490 | MFilterData filterdata4;
|
---|
491 |
|
---|
492 | MExtractFACT extractor4;
|
---|
493 | extractor4.SetRange(first_slice, last_slice);
|
---|
494 | extractor4.SetNoiseCalculation(kFALSE);
|
---|
495 |
|
---|
496 | MCalibrateFact conv4;
|
---|
497 | conv4.SetScale(scale);
|
---|
498 | //conv4.SetCalibConst(calib);
|
---|
499 |
|
---|
500 | MBadPixelsTreat treat4;
|
---|
501 | treat4.SetProcessPedestalRun(kFALSE);
|
---|
502 | treat4.SetProcessPedestalEvt(kFALSE);
|
---|
503 |
|
---|
504 | MHCamEvent evt4b(0, "PedExt","Interpolated extracted pedestal;;Signal [~phe]");
|
---|
505 | //evt4b.SetErrorSpread(kFALSE);
|
---|
506 |
|
---|
507 | MFillH fill4b(&evt4b, "MSignalCam", "FillPedExt");
|
---|
508 | fill4b.SetDrawOption("gaus");
|
---|
509 |
|
---|
510 | // ------------------ Setup eventloop and run analysis ---------------
|
---|
511 |
|
---|
512 | tlist4.AddToList(&read4);
|
---|
513 | tlist4.AddToList(&apply4);
|
---|
514 | tlist4.AddToList(&drsapply4);
|
---|
515 | tlist4.AddToList(&cont4);
|
---|
516 | tlist4.AddToList(&filterdata4);
|
---|
517 | tlist4.AddToList(&extractor4);
|
---|
518 | tlist4.AddToList(&conv4);
|
---|
519 | tlist4.AddToList(&treat4);
|
---|
520 | tlist4.AddToList(&fill4b);
|
---|
521 |
|
---|
522 | if (!loop4.Eventloop(max4))
|
---|
523 | return 15;
|
---|
524 |
|
---|
525 | if (!loop4.GetDisplay())
|
---|
526 | return 16;
|
---|
527 |
|
---|
528 | // ===================================================================
|
---|
529 |
|
---|
530 | gLog << endl;
|
---|
531 | gLog.Separator("Extracting and calibration data");
|
---|
532 |
|
---|
533 | MTaskList tlist5;
|
---|
534 |
|
---|
535 | MParList plist5;
|
---|
536 | plist5.AddToList(&tlist5);
|
---|
537 | plist5.AddToList(&drscalib300);
|
---|
538 | plist5.AddToList(&badpixels);
|
---|
539 | plist5.AddToList(&timecam);
|
---|
540 |
|
---|
541 | MEvtLoop loop5("CalibratingData");
|
---|
542 | loop5.SetDisplay(d);
|
---|
543 | loop5.SetParList(&plist5);
|
---|
544 |
|
---|
545 | // ------------------ Setup the tasks ---------------
|
---|
546 |
|
---|
547 | MRawFitsRead read5;
|
---|
548 | read5.LoadMap(map);
|
---|
549 | read5.AddFiles(iter);
|
---|
550 |
|
---|
551 | MFillH fill5a(&hrate);
|
---|
552 |
|
---|
553 | MGeomApply apply5;
|
---|
554 |
|
---|
555 | MDrsCalibApply drsapply5;
|
---|
556 | //drsapply5.SetRemoveSpikes(4);
|
---|
557 |
|
---|
558 | MTreatSaturation treatsat5;
|
---|
559 |
|
---|
560 | MFilterData filterdata5;
|
---|
561 |
|
---|
562 | MFDataPhrase filterdat("(MRawEvtHeader.GetTriggerID&0xff00)==0", "SelectDat");
|
---|
563 | MFDataPhrase filtercal("(MRawEvtHeader.GetTriggerID&0xff00)==0x100", "SelectCal");
|
---|
564 | MFDataPhrase filterped("(MRawEvtHeader.GetTriggerID&0xff00)==0x400", "SelectPed");
|
---|
565 | MFDataPhrase filterncl("(MRawEvtHeader.GetTriggerID&0xff00)!=0x100", "SelectNonCal");
|
---|
566 |
|
---|
567 | //MContinue cont4("MRawEvtHeader.GetTriggerID!=4", "SelectData");
|
---|
568 |
|
---|
569 | // ---
|
---|
570 |
|
---|
571 | MExtractFACT extractor5dat;
|
---|
572 | extractor5dat.SetRange(first_slice, last_slice);
|
---|
573 | extractor5dat.SetNoiseCalculation(kFALSE);
|
---|
574 |
|
---|
575 | MExtractFACT extractor5cal;
|
---|
576 | extractor5cal.SetRange(first_slice, last_slice);
|
---|
577 | extractor5cal.SetNoiseCalculation(kFALSE);
|
---|
578 |
|
---|
579 | MExtractFACT extractor5tm("ExtractTM");
|
---|
580 | extractor5tm.SetRange(last_slice, 294);
|
---|
581 | extractor5tm.SetNoiseCalculation(kFALSE);
|
---|
582 | extractor5tm.SetNameSignalCam("TimeMarkerAmplitude");
|
---|
583 | extractor5tm.SetNameTimeCam("TimeMarkerTime");
|
---|
584 |
|
---|
585 | extractor5dat.SetFilter(&filterncl);
|
---|
586 | extractor5cal.SetFilter(&filtercal);
|
---|
587 | //extractor4tm.SetFilter(&filtercal);
|
---|
588 |
|
---|
589 | // ---
|
---|
590 | MCalibrateFact conv5;
|
---|
591 | conv5.SetScale(scale);
|
---|
592 | //conv5.SetCalibConst(calib);
|
---|
593 |
|
---|
594 | MCalibrateDrsTimes calctm5;
|
---|
595 | calctm5.SetNameUncalibrated("UncalibratedTimes");
|
---|
596 |
|
---|
597 | MCalibrateDrsTimes calctm5tm("CalibrateTimeMarker");
|
---|
598 | calctm5tm.SetNameArrivalTime("TimeMarkerTime");
|
---|
599 | calctm5tm.SetNameUncalibrated("UncalTimeMarker");
|
---|
600 | calctm5tm.SetNameCalibrated("TimeMarker");
|
---|
601 | calctm5tm.SetTimeMarker();
|
---|
602 | //calctm4tm.SetFilter(&filtercal);
|
---|
603 |
|
---|
604 | MHCamEvent evt5m(6, "ExtTm", "Extracted arrival times of calibration pulse;;\\Delta T [ns]");
|
---|
605 | MHCamEvent evt5n(6, "CalTm", "Calibrated arrival times of calibration pulse;;\\Delta T [ns]");
|
---|
606 | MHCamEvent evt5q(6, "ExtTmShift", "Relative extracted arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
|
---|
607 | MHCamEvent evt5r(6, "CalTmShift", "Relative calibrated arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");
|
---|
608 | MHCamEvent evt5s(6, "ExtTM", "Extracted absolute time marker position;;T [sl]");
|
---|
609 | MHCamEvent evt5t(6, "CalTM", "Calibrated absolute time marker position;;T [ns]");
|
---|
610 | MHCamEvent evt5u(6, "ExtTMshift", "Relative extracted time marker position (w.r.t. event-median);;\\Delta T [ns]");
|
---|
611 | MHCamEvent evt5v(6, "CalTMshift", "Relative calibrated time marker position (w.r.t. event-median);;\\Delta T [ns]");
|
---|
612 | MHCamEvent evt5w(6, "ExtDiff", "Difference between extracted arrival time of time marker and calibration pulse;;\\Delta T [ns]");
|
---|
613 | MHCamEvent evt5x(6, "CalDiff", "Difference between calibrated arrival time of time marker and calibration pulse;;\\Delta T [ns]");
|
---|
614 |
|
---|
615 | evt5w.SetNameSub("UncalibratedTimes");
|
---|
616 | evt5x.SetNameSub("MSignalCam");
|
---|
617 |
|
---|
618 | evt5q.SetMedianShift();
|
---|
619 | evt5r.SetMedianShift();
|
---|
620 | evt5u.SetMedianShift();
|
---|
621 | evt5v.SetMedianShift();
|
---|
622 | //evt4w.SetMedianShift();
|
---|
623 | //evt4x.SetMedianShift();
|
---|
624 |
|
---|
625 | MFillH fill5m(&evt5m, "UncalibratedTimes", "FillExtTm");
|
---|
626 | MFillH fill5n(&evt5n, "MSignalCam", "FillCalTm");
|
---|
627 | MFillH fill5q(&evt5q, "UncalibratedTimes", "FillExtTmShift");
|
---|
628 | MFillH fill5r(&evt5r, "MSignalCam" , "FillCalTmShift");
|
---|
629 | MFillH fill5s(&evt5s, "UncalTimeMarker", "FillExtTM");
|
---|
630 | MFillH fill5t(&evt5t, "TimeMarker", "FillCalTM");
|
---|
631 | MFillH fill5u(&evt5u, "UncalTimeMarker", "FillExtTMshift");
|
---|
632 | MFillH fill5v(&evt5v, "TimeMarker", "FillCalTMshift");
|
---|
633 | MFillH fill5w(&evt5w, "UncalTimeMarker", "FillExtDiff");
|
---|
634 | MFillH fill5x(&evt5x, "TimeMarker", "FillCalDiff");
|
---|
635 |
|
---|
636 | fill5m.SetDrawOption("gaus");
|
---|
637 | fill5n.SetDrawOption("gaus");
|
---|
638 | fill5q.SetDrawOption("gaus");
|
---|
639 | fill5r.SetDrawOption("gaus");
|
---|
640 | //fill5s.SetDrawOption("gaus");
|
---|
641 | //fill5t.SetDrawOption("gaus");
|
---|
642 | //fill5u.SetDrawOption("gaus");
|
---|
643 | //fill5v.SetDrawOption("gaus");
|
---|
644 | //fill5w.SetDrawOption("gaus");
|
---|
645 | //fill5x.SetDrawOption("gaus");
|
---|
646 |
|
---|
647 |
|
---|
648 | MBadPixelsTreat treat5;
|
---|
649 | treat5.SetProcessPedestalRun(kFALSE);
|
---|
650 | treat5.SetProcessPedestalEvt(kFALSE);
|
---|
651 |
|
---|
652 | MHSectorVsTime hist5cal("CalVsTm");
|
---|
653 | MHSectorVsTime hist5ped("PedVsTm");
|
---|
654 | hist5cal.SetTitle("Median calibrated calibration signal vs event number;;Signal [~phe]");
|
---|
655 | hist5ped.SetTitle("Median calibrated pedestal signal vs event number;;Signal [~phe]");
|
---|
656 | hist5cal.SetType(0);
|
---|
657 | hist5ped.SetType(0);
|
---|
658 | hist5cal.SetMinimum(0);
|
---|
659 | hist5ped.SetMinimum(0);
|
---|
660 | hist5cal.SetUseMedian();
|
---|
661 | hist5ped.SetUseMedian();
|
---|
662 | hist5cal.SetNameTime("MTime");
|
---|
663 | hist5ped.SetNameTime("MTime");
|
---|
664 |
|
---|
665 | MFillH fill5cal(&hist5cal, "MSignalCam", "FillCalVsTm");
|
---|
666 | MFillH fill5ped(&hist5ped, "MSignalCam", "FillPedVsTm");
|
---|
667 | fill5cal.SetFilter(&filtercal);
|
---|
668 | fill5ped.SetFilter(&filterped);
|
---|
669 |
|
---|
670 | MHCamEvent evt5b(0, "ExtSig", "Extracted signal;;S [mV·sl]");
|
---|
671 | MHCamEvent evt5c(0, "CalSig", "Calibrated and interpolated signal;;S [~phe]");
|
---|
672 | MHCamEvent evt5d(4, "ExtSigTm", "Extracted time;;T [sl]");
|
---|
673 | MHCamEvent evt5e(6, "CalSigTm", "Calibrated and interpolated time;;T [ns]");
|
---|
674 |
|
---|
675 | MFillH fill5b(&evt5b, "MExtractedSignalCam", "FillExtSig");
|
---|
676 | MFillH fill5c(&evt5c, "MSignalCam", "FillCalSig");
|
---|
677 | MFillH fill5d(&evt5d, "MArrivalTimeCam", "FillExtTm");
|
---|
678 | MFillH fill5e(&evt5e, "MSignalCam", "FillCalTm");
|
---|
679 |
|
---|
680 | fill5c.SetDrawOption("gaus");
|
---|
681 | fill5d.SetDrawOption("gaus");
|
---|
682 | fill5e.SetDrawOption("gaus");
|
---|
683 |
|
---|
684 | /*
|
---|
685 | fill4b.SetFilter(&filterdat);
|
---|
686 | fill4c.SetFilter(&filterdat);
|
---|
687 | fill4d.SetFilter(&filterdat);
|
---|
688 | fill4e.SetFilter(&filterdat);
|
---|
689 | */
|
---|
690 |
|
---|
691 | //MFSoftwareTrigger swtrig;
|
---|
692 | //MContinue contsw(&swtrig, "FilterSwTrigger", "Software trigger");
|
---|
693 | //contsw.SetInverted();
|
---|
694 |
|
---|
695 | const TString fname(Form("s/([0-9]+_[0-9]+)[.]fits([.][fg]z)?$/%s\\/$1_C.root/",
|
---|
696 | MJob::Esc(outpath).Data()));
|
---|
697 |
|
---|
698 | // The second rule is for the case reading raw-files!
|
---|
699 | MWriteRootFile write5(2, fname, "RECREATE", "Calibrated Data");
|
---|
700 | write5.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
701 | write5.AddContainer("MGeomCam", "RunHeaders");
|
---|
702 | write5.AddContainer("MSignalCam", "Events");
|
---|
703 | write5.AddContainer("MTime", "Events");
|
---|
704 | write5.AddContainer("MRawEvtHeader", "Events");
|
---|
705 | //write.AddContainer("MTriggerPattern", "Events");
|
---|
706 |
|
---|
707 | // ------------------ Setup histograms and fill tasks ----------------
|
---|
708 |
|
---|
709 | MContinue test;
|
---|
710 | test.SetFilter(&filterncl);
|
---|
711 |
|
---|
712 | MTaskList tlist5tm;
|
---|
713 | tlist5tm.AddToList(&extractor5tm);
|
---|
714 | tlist5tm.AddToList(&calctm5tm);
|
---|
715 | tlist5tm.AddToList(&fill5m);
|
---|
716 | tlist5tm.AddToList(&fill5n);
|
---|
717 | tlist5tm.AddToList(&fill5q);
|
---|
718 | tlist5tm.AddToList(&fill5r);
|
---|
719 | //tlist5tm.AddToList(&fill5s);
|
---|
720 | //tlist5tm.AddToList(&fill5t);
|
---|
721 | tlist5tm.AddToList(&fill5u);
|
---|
722 | tlist5tm.AddToList(&fill5v);
|
---|
723 | tlist5tm.AddToList(&fill5w);
|
---|
724 | tlist5tm.AddToList(&fill5x);
|
---|
725 | tlist5tm.SetFilter(&filtercal);
|
---|
726 |
|
---|
727 | MTaskList tlist5dat;
|
---|
728 | tlist5dat.AddToList(&fill5b);
|
---|
729 | tlist5dat.AddToList(&fill5c);
|
---|
730 | tlist5dat.AddToList(&fill5d);
|
---|
731 | tlist5dat.AddToList(&fill5e);
|
---|
732 | tlist5dat.SetFilter(&filterdat);
|
---|
733 |
|
---|
734 | tlist5.AddToList(&read5);
|
---|
735 | tlist5.AddToList(&apply5);
|
---|
736 | tlist5.AddToList(&drsapply5);
|
---|
737 | tlist5.AddToList(&filterncl);
|
---|
738 | //tlist5.AddToList(&test);
|
---|
739 | tlist5.AddToList(&filterdat);
|
---|
740 | tlist5.AddToList(&filtercal);
|
---|
741 | tlist5.AddToList(&filterped);
|
---|
742 | tlist5.AddToList(&fill5a);
|
---|
743 | tlist5.AddToList(&treatsat5);
|
---|
744 | tlist5.AddToList(&filterdata5);
|
---|
745 | tlist5.AddToList(&extractor5dat);
|
---|
746 | tlist5.AddToList(&extractor5cal);
|
---|
747 | tlist5.AddToList(&calctm5);
|
---|
748 | tlist5.AddToList(&tlist5tm);
|
---|
749 | tlist5.AddToList(&conv5);
|
---|
750 | tlist5.AddToList(&treat5);
|
---|
751 | tlist5.AddToList(&fill5ped);
|
---|
752 | tlist5.AddToList(&fill5cal);
|
---|
753 | tlist5.AddToList(&tlist5dat);
|
---|
754 | tlist5.AddToList(&write5);
|
---|
755 |
|
---|
756 | if (!loop5.Eventloop(max5))
|
---|
757 | return 18;
|
---|
758 |
|
---|
759 | if (!loop5.GetDisplay())
|
---|
760 | return 19;
|
---|
761 |
|
---|
762 | TString title = "-- Calibrated signal #";
|
---|
763 | title += seq.GetSequence();
|
---|
764 | title += " (";
|
---|
765 | title += drsfile;
|
---|
766 | title += ") --";
|
---|
767 | d->SetTitle(title, kFALSE);
|
---|
768 |
|
---|
769 | TString path;
|
---|
770 | path += Form("%s/20%6d_%03d-calibration.root", outpath,
|
---|
771 | seq.GetSequence()/1000, seq.GetSequence()%1000);
|
---|
772 |
|
---|
773 | d->SaveAs(path);
|
---|
774 |
|
---|
775 | return 0;
|
---|
776 | }
|
---|