1 | #include <sstream>
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | #include "MLog.h"
|
---|
5 | #include "MLogManip.h"
|
---|
6 |
|
---|
7 | #if (!defined(__CINT__) && !defined(__CLING__)) || 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 "../mcore/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 |
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | /* Maybe you wanna use this macro like this:
|
---|
56 | *
|
---|
57 | * 0.) ---- call root ----
|
---|
58 | * root -b
|
---|
59 | *
|
---|
60 | * 1.) ---- compile the stuff ----
|
---|
61 | * .L fact/analysis/callisto_buildable_no_sequence_file.C++
|
---|
62 | * <read a lot of warnings>
|
---|
63 | *
|
---|
64 | * 2.) ---- you can call it then ----
|
---|
65 | * Therefore you need to specify all the paths ... see below.
|
---|
66 | *
|
---|
67 | * When you wanna call the stuff directly from the bash make sure to
|
---|
68 | * escape the bracets and quotes correctly.
|
---|
69 | *
|
---|
70 | * your can do:
|
---|
71 | * root -b -q callisto_buildable_no_sequence_file.C++'("path1","path2",...)'
|
---|
72 | * or:
|
---|
73 | * root -b -q callisto_buildable_no_sequence_file.C++(\"path1\",\"$HOME\",...)
|
---|
74 | * using bash enviroment variables like $HOME is not possible in the upper variant.
|
---|
75 | */
|
---|
76 |
|
---|
77 | int callisto(const TString drsfile="test300samples2.drs.fits.gz",
|
---|
78 | const TString pedfile="00000001.001_P_MonteCarlo000_Events.fits",
|
---|
79 | const TString datfile="00000003.387_D_MonteCarlo010_Events.fits",
|
---|
80 | TString outpath = "",
|
---|
81 | TString displayfile = "", TString displaytitle = "")
|
---|
82 | {
|
---|
83 |
|
---|
84 | // ======================================================
|
---|
85 |
|
---|
86 | if (displaytitle.IsNull())
|
---|
87 | displaytitle = gSystem->BaseName(datfile);
|
---|
88 |
|
---|
89 | FileStat_t fstat;
|
---|
90 | int rc = gSystem->GetPathInfo(outpath, fstat);
|
---|
91 | bool isdir = !rc || R_ISDIR(fstat.fMode);
|
---|
92 |
|
---|
93 | TString filename = datfile + "_callisto.root";
|
---|
94 | filename.Replace(0, filename.Last('/')+1, "");
|
---|
95 | const char *buf = gSystem->ConcatFileName(outpath, filename);
|
---|
96 | TString outfile = buf;
|
---|
97 | delete [] buf;
|
---|
98 |
|
---|
99 | if (displayfile.IsNull())
|
---|
100 | {
|
---|
101 | displayfile = outfile;
|
---|
102 | displayfile.Insert(displayfile.Last('.'), "-display");
|
---|
103 | }
|
---|
104 | else
|
---|
105 | {
|
---|
106 | if (isdir && gSystem->DirName(displayfile)==TString("."))
|
---|
107 | {
|
---|
108 | buf = gSystem->ConcatFileName(outfile, displayfile);
|
---|
109 | displayfile = buf;
|
---|
110 | delete [] buf;
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | // ======================================================
|
---|
115 |
|
---|
116 | // true: Display correctly mapped pixels in the camera displays
|
---|
117 | // but the value-vs-index plot is in software/spiral indices
|
---|
118 | // false: Display pixels in hardware/linear indices,
|
---|
119 | // but the order is the camera display is distorted
|
---|
120 | bool usemap = true;
|
---|
121 |
|
---|
122 | // map file to use (get that from La Palma!)
|
---|
123 | const char *pmap = usemap ? "/home/isdc/toscanos/FACT/Mars_svn/resources/FACTmap111030.txt" : NULL;
|
---|
124 |
|
---|
125 | // ------------------------------------------------------
|
---|
126 |
|
---|
127 | MStatusDisplay *d = new MStatusDisplay;
|
---|
128 |
|
---|
129 | MBadPixelsCam badpixels;
|
---|
130 | badpixels.InitSize(1440);
|
---|
131 | badpixels[ 424].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
132 | badpixels[ 583].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
133 | badpixels[ 830].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
134 | badpixels[ 923].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
135 | badpixels[1208].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
136 | badpixels[1399].SetUnsuitable(MBadPixelsPix::kUnsuitable);
|
---|
137 | // Twin pixel
|
---|
138 | // 113
|
---|
139 | // 115
|
---|
140 | // 354
|
---|
141 | // 423
|
---|
142 | // 1195
|
---|
143 | // 1393
|
---|
144 |
|
---|
145 | // ------------------------------------------------------
|
---|
146 |
|
---|
147 | // Calib: 51 / 90 / 197 (20% TH)
|
---|
148 | // Data: 52 / 64 / 104 (20% TH)
|
---|
149 |
|
---|
150 | // Extraction range in slices. It will always(!) contain the full range
|
---|
151 | // of integration
|
---|
152 | const int first_slice = 25; // 10ns
|
---|
153 | const int last_slice = 225; // 125ns
|
---|
154 |
|
---|
155 | Long_t max = 0; // All
|
---|
156 | Long_t max3 = max; // Pedestal Rndm
|
---|
157 | Long_t max4 = max; // Pedestal Ext
|
---|
158 |
|
---|
159 | // ======================================================
|
---|
160 |
|
---|
161 | //double scale = 0.1;
|
---|
162 | double scale = 0.1024;
|
---|
163 |
|
---|
164 | // ======================================================
|
---|
165 |
|
---|
166 | if (pmap && gSystem->AccessPathName(pmap, kFileExists))
|
---|
167 | {
|
---|
168 | gLog << err << "ERROR - Cannot access mapping file '" << pmap << "'" << endl;
|
---|
169 | return 1;
|
---|
170 | }
|
---|
171 |
|
---|
172 | gLog.Separator("Callisto");
|
---|
173 | gLog << all;
|
---|
174 | gLog << "Data File: " << datfile << '\n';
|
---|
175 | gLog << "DRS calib 300: " << drsfile << endl;;
|
---|
176 |
|
---|
177 | MDrsCalibration drscalib300;
|
---|
178 | if (!drscalib300.ReadFits(drsfile.Data())) {
|
---|
179 | gLog << err << "ERROR - Cannot access drscallib300 file '" << drsfile << "'" << endl;
|
---|
180 | return 5;
|
---|
181 | }
|
---|
182 | gLog << all;
|
---|
183 | gLog << "Pedestal file: " << pedfile << '\n';
|
---|
184 | gLog << "Output file: " << outfile << '\n';
|
---|
185 | gLog << "Display file: " << displayfile << '\n';
|
---|
186 | gLog << "Display title: " << displaytitle << endl;
|
---|
187 |
|
---|
188 | // ------------------------------------------------------
|
---|
189 | /*
|
---|
190 | MStatusArray arrt, arrp;
|
---|
191 |
|
---|
192 | TFile ft(lp_template);
|
---|
193 | if (arrt.Read()<=0)
|
---|
194 | {
|
---|
195 | gLog << err << "ERROR - Reading LP template from " << lp_template << endl;
|
---|
196 | return 100;
|
---|
197 | }
|
---|
198 |
|
---|
199 | MHCamera *lpref = (MHCamera*)arrt.FindObjectInCanvas("ExtCalSig;avg", "MHCamera", "Cam");
|
---|
200 | if (!lpref)
|
---|
201 | {
|
---|
202 | gLog << err << "ERROR - LP Template not found in " << lp_template << endl;
|
---|
203 | return 101;
|
---|
204 | }
|
---|
205 | lpref->SetDirectory(0);
|
---|
206 |
|
---|
207 | MHCamera *gain = (MHCamera*)arrt.FindObjectInCanvas("gain", "MHCamera", "Gain");
|
---|
208 | if (!gain)
|
---|
209 | {
|
---|
210 | gLog << err << "ERROR - Gain not found in " << lp_template << endl;
|
---|
211 | return 101;
|
---|
212 | }
|
---|
213 | gain->SetDirectory(0);
|
---|
214 |
|
---|
215 | TFile fp(pulse_template);
|
---|
216 | if (arrp.Read()<=0)
|
---|
217 | {
|
---|
218 | gLog << err << "ERROR - Reading Pulse template from " << pulse_template << endl;
|
---|
219 | return 102;
|
---|
220 | }
|
---|
221 |
|
---|
222 | TH1F *hpulse = (TH1F*)arrp.FindObjectInCanvas("hPixelEdgeMean0_0", "TH1F", "cgpPixelPulses0");
|
---|
223 | if (!hpulse)
|
---|
224 | {
|
---|
225 | gLog << err << "ERROR - Pulse Template not found in " << pulse_template << endl;
|
---|
226 | return 103;
|
---|
227 | }
|
---|
228 | hpulse->SetDirectory(0);
|
---|
229 | */
|
---|
230 | // ======================================================
|
---|
231 |
|
---|
232 | MDrsCalibrationTime timecam;
|
---|
233 |
|
---|
234 | // Plot the trigger pattern rates vs. run-number
|
---|
235 | MH3 hrate("MRawRunHeader.GetFileID", "MRawEvtHeader.GetTriggerID&0xff00");
|
---|
236 | hrate.SetWeight("1./TMath::Max(MRawRunHeader.GetRunLength,1)");
|
---|
237 | hrate.SetName("Rate");
|
---|
238 | hrate.SetTitle("Event rate [Hz];File Id;Trigger Type;");
|
---|
239 | hrate.InitLabels(MH3::kLabelsXY);
|
---|
240 | hrate.DefineLabelY( 0, "Data"); // What if TriggerID==0 already???
|
---|
241 | hrate.DefineLabelY(0x100, "Cal");
|
---|
242 | hrate.DefineLabelY(0x400, "Ped");
|
---|
243 | // hrate.DefaultLabelY("ERROR");
|
---|
244 | gStyle->SetOptFit(kTRUE);
|
---|
245 |
|
---|
246 |
|
---|
247 | // ========================= Result ==================================
|
---|
248 | /*
|
---|
249 | //~ Double_t avgS = evt1f.GetHist()->GetMean();
|
---|
250 | //~ Double_t medS = evt1f.GetHist()->GetMedian();
|
---|
251 | //~ Double_t rmsS = evt1f.GetHist()->GetRMS();
|
---|
252 | //~ Double_t maxS = evt1f.GetHist()->GetMaximum();
|
---|
253 |
|
---|
254 | MArrayF der1(hpulse->GetNbinsX());
|
---|
255 | MArrayF der2(hpulse->GetNbinsX());
|
---|
256 |
|
---|
257 | MExtralgoSpline spline(hpulse->GetArray()+1, hpulse->GetNbinsX(),
|
---|
258 | der1.GetArray(), der2.GetArray());
|
---|
259 | spline.SetRiseFallTime(rise_time_dat, fall_time_dat);
|
---|
260 | spline.SetExtractionType(type);
|
---|
261 | spline.SetHeightTm(heighttm);
|
---|
262 |
|
---|
263 | spline.Extract(hpulse->GetMaximumBin()-1);
|
---|
264 |
|
---|
265 | // The pulser signal is most probably around 400mV/9.5mV
|
---|
266 | // IntegraFixed 2/48 corresponds to roughly 215mV*50slices
|
---|
267 | Double_t scale = 1./spline.GetSignal();
|
---|
268 |
|
---|
269 | MArrayD calib(1440);
|
---|
270 | for (int i=0; i<1440; i++)
|
---|
271 | calib[i] =1.;
|
---|
272 |
|
---|
273 | gROOT->SetSelectedPad(0);
|
---|
274 | d->AddTab("PulseTemp");
|
---|
275 | gPad->SetGrid();
|
---|
276 | hpulse->SetNameTitle("Pulse", "Single p.e. pulse template");
|
---|
277 | hpulse->SetDirectory(0);
|
---|
278 | hpulse->SetLineColor(kBlack);
|
---|
279 | hpulse->DrawCopy();
|
---|
280 |
|
---|
281 | TAxis *ax = hpulse->GetXaxis();
|
---|
282 |
|
---|
283 | Double_t w = hpulse->GetBinWidth(1);
|
---|
284 | Double_t T = w*(spline.GetTime()+0.5) +ax->GetXmin();
|
---|
285 | //~ Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin();
|
---|
286 |
|
---|
287 | TLine line;
|
---|
288 | line.SetLineColor(kRed);
|
---|
289 | line.DrawLine(T-rise_time_dat*w, spline.GetHeight(),
|
---|
290 | T+fall_time_dat*w, spline.GetHeight());
|
---|
291 | line.DrawLine(T, spline.GetHeight()/4, T, 3*spline.GetHeight()/4);
|
---|
292 | line.DrawLine(T-rise_time_dat*w, 0,
|
---|
293 | T-rise_time_dat*w, spline.GetHeight());
|
---|
294 | line.DrawLine(T+fall_time_dat*w, 0,
|
---|
295 | T+fall_time_dat*w, spline.GetHeight());
|
---|
296 |
|
---|
297 | TGraph gg;
|
---|
298 | for (int ix=1; ix<=hpulse->GetNbinsX(); ix++)
|
---|
299 | for (int i=0; i<10; i++)
|
---|
300 | {
|
---|
301 | Double_t x = hpulse->GetBinLowEdge(ix)+i*hpulse->GetBinWidth(ix)/10.;
|
---|
302 | gg.SetPoint(gg.GetN(), x+w/2, spline.EvalAt(ix-1+i/10.));
|
---|
303 | }
|
---|
304 |
|
---|
305 | gg.SetLineColor(kBlue);
|
---|
306 | gg.SetMarkerColor(kBlue);
|
---|
307 | gg.SetMarkerStyle(kFullDotMedium);
|
---|
308 | gg.DrawClone("L");
|
---|
309 |
|
---|
310 | gROOT->SetSelectedPad(0);
|
---|
311 | d->AddTab("CalConst");
|
---|
312 | MGeomCamFACT fact;
|
---|
313 | MHCamera hcalco(fact);
|
---|
314 | hcalco.SetName("CalConst");
|
---|
315 | hcalco.SetTitle(Form("Relative calibration constant [%.0f/pe]", 1./scale));
|
---|
316 | hcalco.SetCamContent(calib);
|
---|
317 | hcalco.SetAllUsed();
|
---|
318 | //hcalco.Scale(scale);
|
---|
319 | hcalco.DrawCopy();
|
---|
320 | */
|
---|
321 | // ======================================================
|
---|
322 |
|
---|
323 | gLog << endl;
|
---|
324 | gLog.Separator("Extracting random pedestal");
|
---|
325 |
|
---|
326 | MTaskList tlist3;
|
---|
327 |
|
---|
328 | MParList plist3;
|
---|
329 | plist3.AddToList(&tlist3);
|
---|
330 | plist3.AddToList(&drscalib300);
|
---|
331 | plist3.AddToList(&badpixels);
|
---|
332 | plist3.AddToList(&timecam);
|
---|
333 |
|
---|
334 | MEvtLoop loop3("DetermineRndmPed");
|
---|
335 | loop3.SetDisplay(d);
|
---|
336 | loop3.SetParList(&plist3);
|
---|
337 |
|
---|
338 | // ------------------ Setup the tasks ---------------
|
---|
339 |
|
---|
340 | MRawFitsRead read3;
|
---|
341 | read3.LoadMap(pmap);
|
---|
342 | read3.AddFile(pedfile);
|
---|
343 |
|
---|
344 | MFillH fill3a(&hrate);
|
---|
345 |
|
---|
346 | MContinue cont3("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
|
---|
347 |
|
---|
348 | MGeomApply apply3;
|
---|
349 |
|
---|
350 | MDrsCalibApply drsapply3;
|
---|
351 |
|
---|
352 | MFilterData filterdata3;
|
---|
353 |
|
---|
354 | //---
|
---|
355 |
|
---|
356 | MExtractFACT extractor3;
|
---|
357 | extractor3.SetRange(first_slice, last_slice);
|
---|
358 | extractor3.SetNoiseCalculation(kTRUE);
|
---|
359 |
|
---|
360 | MCalibrateFact conv3;
|
---|
361 | conv3.SetScale(scale);
|
---|
362 | //conv3.SetCalibConst(calib);
|
---|
363 |
|
---|
364 | MBadPixelsTreat treat3;
|
---|
365 | treat3.SetProcessPedestalRun(kFALSE);
|
---|
366 | treat3.SetProcessPedestalEvt(kFALSE);
|
---|
367 | treat3.SetProcessTimes(kFALSE);
|
---|
368 |
|
---|
369 | MHCamEvent evt3b(0, "PedRdm","Interpolated random pedestal;;Signal [~phe]");
|
---|
370 | //evt2b.SetErrorSpread(kFALSE);
|
---|
371 |
|
---|
372 | MFillH fill3b(&evt3b, "MSignalCam", "FillPedRdm");
|
---|
373 | fill3b.SetDrawOption("gaus");
|
---|
374 |
|
---|
375 | // ------------------ Setup eventloop and run analysis ---------------
|
---|
376 |
|
---|
377 | tlist3.AddToList(&read3);
|
---|
378 | tlist3.AddToList(&apply3);
|
---|
379 | tlist3.AddToList(&drsapply3);
|
---|
380 | tlist3.AddToList(&cont3);
|
---|
381 | tlist3.AddToList(&filterdata3);
|
---|
382 | tlist3.AddToList(&extractor3);
|
---|
383 | // tlist3.AddToList(&fill3a);
|
---|
384 | tlist3.AddToList(&conv3);
|
---|
385 | tlist3.AddToList(&treat3);
|
---|
386 | tlist3.AddToList(&fill3b);
|
---|
387 |
|
---|
388 | if (!loop3.Eventloop(max3))
|
---|
389 | return 14;
|
---|
390 |
|
---|
391 | if (!loop3.GetDisplay())
|
---|
392 | return 15;
|
---|
393 |
|
---|
394 | // ======================================================
|
---|
395 |
|
---|
396 | gLog << endl;
|
---|
397 | gLog.Separator("Extracting pedestal");
|
---|
398 |
|
---|
399 | MTaskList tlist4;
|
---|
400 |
|
---|
401 | MParList plist4;
|
---|
402 | plist4.AddToList(&tlist4);
|
---|
403 | plist4.AddToList(&drscalib300);
|
---|
404 | plist4.AddToList(&badpixels);
|
---|
405 | plist4.AddToList(&timecam);
|
---|
406 |
|
---|
407 | MEvtLoop loop4("DetermineExtractedPed");
|
---|
408 | loop4.SetDisplay(d);
|
---|
409 | loop4.SetParList(&plist4);
|
---|
410 |
|
---|
411 | // ------------------ Setup the tasks ---------------
|
---|
412 |
|
---|
413 | MRawFitsRead read4;
|
---|
414 | read4.LoadMap(pmap);
|
---|
415 | read4.AddFile(pedfile);
|
---|
416 |
|
---|
417 | MContinue cont4("(MRawEvtHeader.GetTriggerID&0xff00)!=0x400", "SelectPed");
|
---|
418 |
|
---|
419 | MGeomApply apply4;
|
---|
420 |
|
---|
421 | MDrsCalibApply drsapply4;
|
---|
422 |
|
---|
423 | MFilterData filterdata4;
|
---|
424 |
|
---|
425 | MExtractFACT extractor4;
|
---|
426 | extractor4.SetRange(first_slice, last_slice);
|
---|
427 | extractor4.SetNoiseCalculation(kFALSE);
|
---|
428 |
|
---|
429 | MCalibrateFact conv4;
|
---|
430 | conv4.SetScale(scale);
|
---|
431 | //conv4.SetCalibConst(calib);
|
---|
432 |
|
---|
433 | MBadPixelsTreat treat4;
|
---|
434 | treat4.SetProcessPedestalRun(kFALSE);
|
---|
435 | treat4.SetProcessPedestalEvt(kFALSE);
|
---|
436 |
|
---|
437 | MHCamEvent evt4b(0, "PedExt","Interpolated extracted pedestal;;Signal [~phe]");
|
---|
438 | //evt4b.SetErrorSpread(kFALSE);
|
---|
439 |
|
---|
440 | MFillH fill4b(&evt4b, "MSignalCam", "FillPedExt");
|
---|
441 | fill4b.SetDrawOption("gaus");
|
---|
442 |
|
---|
443 | // ------------------ Setup eventloop and run analysis ---------------
|
---|
444 |
|
---|
445 | tlist4.AddToList(&read4);
|
---|
446 | tlist4.AddToList(&apply4);
|
---|
447 | tlist4.AddToList(&drsapply4);
|
---|
448 | tlist4.AddToList(&cont4);
|
---|
449 | tlist4.AddToList(&filterdata4);
|
---|
450 | tlist4.AddToList(&extractor4);
|
---|
451 | tlist4.AddToList(&conv4);
|
---|
452 | tlist4.AddToList(&treat4);
|
---|
453 | tlist4.AddToList(&fill4b);
|
---|
454 |
|
---|
455 | if (!loop4.Eventloop(max4))
|
---|
456 | return 15;
|
---|
457 |
|
---|
458 | if (!loop4.GetDisplay())
|
---|
459 | return 16;
|
---|
460 |
|
---|
461 | // ===================================================================
|
---|
462 |
|
---|
463 | gLog << endl;
|
---|
464 | gLog.Separator("Extracting and calibration data");
|
---|
465 |
|
---|
466 | MTaskList tlist5;
|
---|
467 |
|
---|
468 | MParList plist5;
|
---|
469 | plist5.AddToList(&tlist5);
|
---|
470 | plist5.AddToList(&drscalib300);
|
---|
471 | plist5.AddToList(&badpixels);
|
---|
472 | plist5.AddToList(&timecam);
|
---|
473 |
|
---|
474 | MEvtLoop loop5("CalibratingData");
|
---|
475 | loop5.SetDisplay(d);
|
---|
476 | loop5.SetParList(&plist5);
|
---|
477 |
|
---|
478 | // ------------------ Setup the tasks ---------------
|
---|
479 |
|
---|
480 | MRawFitsRead read5a;
|
---|
481 | MReadMarsFile read5b("Events");
|
---|
482 | read5a.LoadMap(pmap);
|
---|
483 | read5a.AddFile(datfile);
|
---|
484 | read5b.DisableAutoScheme();
|
---|
485 | read5b.AddFile(datfile);
|
---|
486 |
|
---|
487 | MRead &read5 = datfile.EndsWith(".root") ? static_cast<MRead&>(read5b) : static_cast<MRead&>(read5a);
|
---|
488 |
|
---|
489 | MFillH fill5a(&hrate);
|
---|
490 |
|
---|
491 | MGeomApply apply5;
|
---|
492 |
|
---|
493 | MDrsCalibApply drsapply5;
|
---|
494 |
|
---|
495 | MTreatSaturation treatsat5;
|
---|
496 |
|
---|
497 | MFilterData filterdata5;
|
---|
498 |
|
---|
499 | MFDataPhrase filterdat("(MRawEvtHeader.GetTriggerID&0xff00)==0", "SelectDat");
|
---|
500 | MFDataPhrase filtercal("(MRawEvtHeader.GetTriggerID&0xff00)==0x100", "SelectCal");
|
---|
501 | MFDataPhrase filterped("(MRawEvtHeader.GetTriggerID&0xff00)==0x400", "SelectPed");
|
---|
502 | MFDataPhrase filterncl("(MRawEvtHeader.GetTriggerID&0xff00)!=0x100", "SelectNonCal");
|
---|
503 |
|
---|
504 | //MContinue cont4("MRawEvtHeader.GetTriggerID!=4", "SelectData");
|
---|
505 |
|
---|
506 | // ---
|
---|
507 |
|
---|
508 | MExtractFACT extractor5dat;
|
---|
509 | extractor5dat.SetRange(first_slice, last_slice);
|
---|
510 | extractor5dat.SetNoiseCalculation(kFALSE);
|
---|
511 |
|
---|
512 | MExtractFACT extractor5cal;
|
---|
513 | extractor5cal.SetRange(first_slice, last_slice);
|
---|
514 | extractor5cal.SetNoiseCalculation(kFALSE);
|
---|
515 |
|
---|
516 | MExtractFACT extractor5tm("ExtractTM");
|
---|
517 | extractor5tm.SetRange(last_slice, 294);
|
---|
518 | extractor5tm.SetNoiseCalculation(kFALSE);
|
---|
519 | extractor5tm.SetNameSignalCam("TimeMarkerAmplitude");
|
---|
520 | extractor5tm.SetNameTimeCam("TimeMarkerTime");
|
---|
521 |
|
---|
522 | extractor5dat.SetFilter(&filterncl);
|
---|
523 | extractor5cal.SetFilter(&filtercal);
|
---|
524 | //extractor4tm.SetFilter(&filtercal);
|
---|
525 |
|
---|
526 | // ---
|
---|
527 | MCalibrateFact conv5;
|
---|
528 | conv5.SetScale(scale);
|
---|
529 | //conv5.SetCalibConst(calib);
|
---|
530 |
|
---|
531 | MCalibrateDrsTimes calctm5;
|
---|
532 | calctm5.SetNameUncalibrated("UncalibratedTimes");
|
---|
533 |
|
---|
534 | MCalibrateDrsTimes calctm5tm("CalibrateTimeMarker");
|
---|
535 | calctm5tm.SetNameArrivalTime("TimeMarkerTime");
|
---|
536 | calctm5tm.SetNameUncalibrated("UncalTimeMarker");
|
---|
537 | calctm5tm.SetNameCalibrated("TimeMarker");
|
---|
538 | calctm5tm.SetTimeMarker();
|
---|
539 | //calctm4tm.SetFilter(&filtercal);
|
---|
540 |
|
---|
541 | MBadPixelsTreat treat5;
|
---|
542 | treat5.SetProcessPedestalRun(kFALSE);
|
---|
543 | treat5.SetProcessPedestalEvt(kFALSE);
|
---|
544 |
|
---|
545 | MHCamEvent evt5b(0, "ExtSig", "Extracted signal;;S [mV#dot sl]");
|
---|
546 | MHCamEvent evt5c(0, "CalSig", "Calibrated and interpolated signal;;S [~phe]");
|
---|
547 | MHCamEvent evt5d(4, "ExtSigTm", "Extracted time;;T [sl]");
|
---|
548 | MHCamEvent evt5e(6, "CalSigTm", "Calibrated and interpolated time;;T [ns]");
|
---|
549 |
|
---|
550 | MFillH fill5b(&evt5b, "MExtractedSignalCam", "FillExtSig");
|
---|
551 | MFillH fill5c(&evt5c, "MSignalCam", "FillCalSig");
|
---|
552 | MFillH fill5d(&evt5d, "MArrivalTimeCam", "FillExtTm");
|
---|
553 | MFillH fill5e(&evt5e, "MSignalCam", "FillCalTm");
|
---|
554 |
|
---|
555 | fill5c.SetDrawOption("gaus");
|
---|
556 | fill5d.SetDrawOption("gaus");
|
---|
557 | fill5e.SetDrawOption("gaus");
|
---|
558 |
|
---|
559 | /*
|
---|
560 | fill4b.SetFilter(&filterdat);
|
---|
561 | fill4c.SetFilter(&filterdat);
|
---|
562 | fill4d.SetFilter(&filterdat);
|
---|
563 | fill4e.SetFilter(&filterdat);
|
---|
564 | */
|
---|
565 |
|
---|
566 | //MFSoftwareTrigger swtrig;
|
---|
567 | //MContinue contsw(&swtrig, "FilterSwTrigger", "Software trigger");
|
---|
568 | //contsw.SetInverted();
|
---|
569 |
|
---|
570 | // The second rule is for the case reading raw-files!
|
---|
571 |
|
---|
572 | MWriteRootFile write5(outfile, "RECREATE", "Calibrated Data", 2);
|
---|
573 | write5.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
574 | write5.AddContainer("MGeomCam", "RunHeaders");
|
---|
575 | write5.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
576 | write5.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
577 | write5.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
578 |
|
---|
579 | // Common events
|
---|
580 | write5.AddContainer("MCorsikaEvtHeader", "Events", kFALSE);
|
---|
581 | write5.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
582 | write5.AddContainer("IncidentAngle", "Events", kFALSE);
|
---|
583 | write5.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
584 | write5.AddContainer("MSignalCam", "Events");
|
---|
585 | write5.AddContainer("MTime", "Events", kFALSE);
|
---|
586 | write5.AddContainer("MRawEvtHeader", "Events");
|
---|
587 | //write.AddContainer("MTriggerPattern", "Events");
|
---|
588 |
|
---|
589 | // ------------------ Setup histograms and fill tasks ----------------
|
---|
590 |
|
---|
591 | MContinue test;
|
---|
592 | test.SetFilter(&filterncl);
|
---|
593 |
|
---|
594 | MTaskList tlist5tm;
|
---|
595 | tlist5tm.AddToList(&extractor5tm);
|
---|
596 | tlist5tm.AddToList(&calctm5tm);
|
---|
597 | tlist5tm.SetFilter(&filtercal);
|
---|
598 |
|
---|
599 | MTaskList tlist5dat;
|
---|
600 | tlist5dat.AddToList(&fill5b);
|
---|
601 | tlist5dat.AddToList(&fill5c);
|
---|
602 | tlist5dat.AddToList(&fill5d);
|
---|
603 | tlist5dat.AddToList(&fill5e);
|
---|
604 | tlist5dat.SetFilter(&filterdat);
|
---|
605 |
|
---|
606 | tlist5.AddToList(&read5);
|
---|
607 | tlist5.AddToList(&apply5);
|
---|
608 | tlist5.AddToList(&drsapply5);
|
---|
609 | tlist5.AddToList(&filterncl);
|
---|
610 | //tlist5.AddToList(&test);
|
---|
611 | tlist5.AddToList(&filterdat);
|
---|
612 | tlist5.AddToList(&filtercal);
|
---|
613 | tlist5.AddToList(&filterped);
|
---|
614 | tlist5.AddToList(&fill5a);
|
---|
615 | tlist5.AddToList(&treatsat5);
|
---|
616 | tlist5.AddToList(&filterdata5);
|
---|
617 | tlist5.AddToList(&extractor5dat);
|
---|
618 | tlist5.AddToList(&extractor5cal);
|
---|
619 | tlist5.AddToList(&calctm5);
|
---|
620 | tlist5.AddToList(&tlist5tm);
|
---|
621 | tlist5.AddToList(&conv5);
|
---|
622 | tlist5.AddToList(&treat5);
|
---|
623 | tlist5.AddToList(&tlist5dat);
|
---|
624 | tlist5.AddToList(&write5);
|
---|
625 |
|
---|
626 | if (!loop5.Eventloop(max4))
|
---|
627 | return 18;
|
---|
628 |
|
---|
629 | if (!loop5.GetDisplay())
|
---|
630 | return 19;
|
---|
631 |
|
---|
632 | d->SetTitle(displaytitle, kFALSE);
|
---|
633 | d->SaveAs(displayfile);
|
---|
634 |
|
---|
635 | return 0;
|
---|
636 | }
|
---|