source: branches/MarsMoreSimulationTruth/fact/analysis/callisto.C@ 19811

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