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