source: branches/Mars_use_drstimefiles/fact/analysis/callisto_drstime.C@ 17994

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