source: branches/Mars_McMismatchStudy/fact/analysis/callisto_data_and_mc.C@ 18295

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