1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2009
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MJSimulation
|
---|
28 | //
|
---|
29 | //
|
---|
30 | // Force reading a corsika file even if the footer (RUNE-section) is missing
|
---|
31 | // by setting fForceMode to kTRUE or from the resource file by
|
---|
32 | //
|
---|
33 | // ForceMode: Yes
|
---|
34 | //
|
---|
35 | //
|
---|
36 | // To switch off the simulation of the camera electronics, use:
|
---|
37 | //
|
---|
38 | // Camera: Off
|
---|
39 | //
|
---|
40 | // Note, that the border of the camera and the propertied of the cones
|
---|
41 | // are still simulated (simply because it is fast). Furthermore, this
|
---|
42 | // switches off the trigger for the output, i.e. all data which deposits
|
---|
43 | // at least one photon in at least one pixel is written to the output file.
|
---|
44 | //
|
---|
45 | //
|
---|
46 | // In case of a pedestal or calibration run the artificial trigger can
|
---|
47 | // be "switched off" and the cosmics trrigger "switched on" by setting
|
---|
48 | // fForceTrigger to kTRUE or from the resource file by
|
---|
49 | //
|
---|
50 | // ForceTrigger: Yes
|
---|
51 | //
|
---|
52 | //
|
---|
53 | /////////////////////////////////////////////////////////////////////////////
|
---|
54 | #include "MJSimulation.h"
|
---|
55 |
|
---|
56 | #include <TEnv.h>
|
---|
57 | #include <TCanvas.h>
|
---|
58 |
|
---|
59 | // Core
|
---|
60 | #include "MLog.h"
|
---|
61 | #include "MLogManip.h"
|
---|
62 |
|
---|
63 | #include "MArgs.h"
|
---|
64 | #include "MDirIter.h"
|
---|
65 | #include "MParList.h"
|
---|
66 | #include "MTaskList.h"
|
---|
67 | #include "MEvtLoop.h"
|
---|
68 |
|
---|
69 | #include "MStatusDisplay.h"
|
---|
70 |
|
---|
71 | // Tasks
|
---|
72 | #include "MCorsikaRead.h"
|
---|
73 | #include "MContinue.h"
|
---|
74 | #include "MFillH.h"
|
---|
75 | #include "MGeomApply.h"
|
---|
76 | #include "MParameterCalc.h"
|
---|
77 | #include "MHillasCalc.h"
|
---|
78 | #include "MImgCleanStd.h"
|
---|
79 | #include "MWriteRootFile.h"
|
---|
80 | #include "MWriteFitsFile.h"
|
---|
81 |
|
---|
82 | #include "MSimMMCS.h"
|
---|
83 | #include "MSimAbsorption.h"
|
---|
84 | #include "MSimAtmosphere.h"
|
---|
85 | #include "MSimReflector.h"
|
---|
86 | #include "MSimPointingPos.h"
|
---|
87 | #include "MSimPSF.h"
|
---|
88 | #include "MSimGeomCam.h"
|
---|
89 | #include "MSimSignalCam.h"
|
---|
90 | #include "MSimAPD.h"
|
---|
91 | #include "MSimExcessNoise.h"
|
---|
92 | #include "MSimCamera.h"
|
---|
93 | #include "MSimTrigger.h"
|
---|
94 | #include "MSimReadout.h"
|
---|
95 | #include "MSimRandomPhotons.h"
|
---|
96 | #include "MSimBundlePhotons.h"
|
---|
97 | #include "MSimCalibrationSignal.h"
|
---|
98 |
|
---|
99 | // Histograms
|
---|
100 | #include "MBinning.h"
|
---|
101 |
|
---|
102 | #include "MHn.h"
|
---|
103 | #include "MHCamera.h"
|
---|
104 | #include "MHCamEvent.h"
|
---|
105 | #include "MHPhotonEvent.h"
|
---|
106 |
|
---|
107 | // Container
|
---|
108 | #include "MRawRunHeader.h"
|
---|
109 | #include "MParameters.h"
|
---|
110 | #include "MReflector.h"
|
---|
111 | #include "MParEnv.h"
|
---|
112 | #include "MSpline3.h"
|
---|
113 | #include "MParSpline.h"
|
---|
114 | #include "MGeomCam.h"
|
---|
115 |
|
---|
116 | #include "MPedestalCam.h"
|
---|
117 | #include "MPedestalPix.h"
|
---|
118 |
|
---|
119 | ClassImp(MJSimulation);
|
---|
120 |
|
---|
121 | using namespace std;
|
---|
122 |
|
---|
123 | // --------------------------------------------------------------------------
|
---|
124 | //
|
---|
125 | // Default constructor.
|
---|
126 | //
|
---|
127 | // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
|
---|
128 | //
|
---|
129 | MJSimulation::MJSimulation(const char *name, const char *title)
|
---|
130 | : fForceMode(kFALSE), fCamera(kTRUE), fForceTrigger(kFALSE),
|
---|
131 | fWriteFitsFile(kFALSE), fOperationMode(kModeData), fRunNumber(-1)
|
---|
132 | {
|
---|
133 | fName = name ? name : "MJSimulation";
|
---|
134 | fTitle = title ? title : "Standard analysis and reconstruction";
|
---|
135 | }
|
---|
136 |
|
---|
137 | Bool_t MJSimulation::CheckEnvLocal()
|
---|
138 | {
|
---|
139 | fForceMode = GetEnv("ForceMode", fForceMode);
|
---|
140 | fForceTrigger = GetEnv("ForceTrigger", fForceTrigger);
|
---|
141 | fCamera = GetEnv("Camera", fCamera);
|
---|
142 |
|
---|
143 | return kTRUE;
|
---|
144 | }
|
---|
145 | /*
|
---|
146 | TString MJSimulation::GetOutFile(const MSequence &seq) const
|
---|
147 | {
|
---|
148 | return seq.IsValid() ? Form("ceres%08d.root", seq.GetSequence()) : "ceres.root";
|
---|
149 | }
|
---|
150 | */
|
---|
151 |
|
---|
152 | Bool_t MJSimulation::WriteResult(const MParList &plist, const MSequence &seq, Int_t num)
|
---|
153 | {
|
---|
154 | if (fPathOut.IsNull())
|
---|
155 | {
|
---|
156 | *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
|
---|
157 | return kTRUE;
|
---|
158 | }
|
---|
159 |
|
---|
160 | TObjArray cont;
|
---|
161 | cont.Add(const_cast<TEnv*>(GetEnv()));
|
---|
162 | if (seq.IsValid())
|
---|
163 | cont.Add(const_cast<MSequence*>(&seq));
|
---|
164 |
|
---|
165 | cont.Add(plist.FindObject("PulseShape"));
|
---|
166 | cont.Add(plist.FindObject("Reflector"));
|
---|
167 | cont.Add(plist.FindObject("MGeomCam"));
|
---|
168 | cont.Add(plist.FindObject("GeomCones"));
|
---|
169 |
|
---|
170 | TNamed cmdline("CommandLine", fCommandLine.Data());
|
---|
171 | cont.Add(&cmdline);
|
---|
172 |
|
---|
173 | if (fDisplay)
|
---|
174 | {
|
---|
175 | TString title = "-- Ceres";
|
---|
176 | if (seq.IsValid())
|
---|
177 | {
|
---|
178 | title += ": ";
|
---|
179 | title += seq.GetSequence();
|
---|
180 | }
|
---|
181 | title += " --";
|
---|
182 | fDisplay->SetTitle("Ceres", kFALSE);
|
---|
183 |
|
---|
184 | cont.Add(fDisplay);
|
---|
185 | }
|
---|
186 |
|
---|
187 | const TString name = Form("ceres%08d.root", num);
|
---|
188 | return WriteContainer(cont, name, "RECREATE");
|
---|
189 | }
|
---|
190 |
|
---|
191 | void MJSimulation::SetupHist(MHn &hist) const
|
---|
192 | {
|
---|
193 | hist.AddHist("MCorsikaEvtHeader.fTotalEnergy");
|
---|
194 | hist.InitName("Energy");
|
---|
195 | hist.InitTitle("Energy;E [GeV]");
|
---|
196 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
---|
197 |
|
---|
198 | hist.AddHist("MPhotonEvent.GetNumExternal");
|
---|
199 | hist.InitName("Size");
|
---|
200 | hist.InitTitle("Size;S [#]");
|
---|
201 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
---|
202 |
|
---|
203 | /*
|
---|
204 | hist.AddHist("-MCorsikaEvtHeader.fX/100","-MCorsikaEvtHeader.fY/100");
|
---|
205 | hist.SetDrawOption("colz");
|
---|
206 | hist.InitName("Impact;Impact;Impact");
|
---|
207 | hist.InitTitle("Impact;West <--> East [m];South <--> North [m]");
|
---|
208 | hist.SetAutoRange();
|
---|
209 | */
|
---|
210 |
|
---|
211 | hist.AddHist("MCorsikaEvtHeader.GetImpact/100");
|
---|
212 | hist.InitName("Impact");
|
---|
213 | hist.InitTitle("Impact;Impact [m]");
|
---|
214 | hist.SetAutoRange();
|
---|
215 |
|
---|
216 | hist.AddHist("MCorsikaEvtHeader.fFirstInteractionHeight/100000");
|
---|
217 | hist.InitName("Height");
|
---|
218 | hist.InitTitle("FirstInteractionHeight;h [km]");
|
---|
219 |
|
---|
220 | hist.AddHist("(MCorsikaEvtHeader.fAz+MCorsikaRunHeader.fMagneticFieldAz)*TMath::RadToDeg()", "MCorsikaEvtHeader.fZd*TMath::RadToDeg()");
|
---|
221 | hist.InitName("SkyOrigin;Az;Zd");
|
---|
222 | hist.InitTitle("Sky Origin;Az [\\circ];Zd [\\circ]");
|
---|
223 | hist.SetDrawOption("colz");
|
---|
224 | hist.SetAutoRange();
|
---|
225 |
|
---|
226 | hist.AddHist("IncidentAngle.fVal");
|
---|
227 | hist.InitName("ViewCone");
|
---|
228 | hist.InitTitle("Incident Angle;\\alpha [\\circ]");
|
---|
229 | }
|
---|
230 |
|
---|
231 | void MJSimulation::SetupCommonFileStructure(MWriteRootFile &write) const
|
---|
232 | {
|
---|
233 | // Common run headers
|
---|
234 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
235 | write.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
236 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
237 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
238 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
239 |
|
---|
240 | // Common events
|
---|
241 | write.AddContainer("MCorsikaEvtHeader", "Events", kFALSE);
|
---|
242 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
243 | write.AddContainer("MMcEvt", "Events");
|
---|
244 | write.AddContainer("IncidentAngle", "Events", kFALSE);
|
---|
245 | }
|
---|
246 | //FIXME Etienne. I'm doing the same for fits and root. I probably should adapt somehow
|
---|
247 | void MJSimulation::SetupCommonFileStructure(MWriteFitsFile& write) const
|
---|
248 | {
|
---|
249 | // Common run headers
|
---|
250 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
251 | write.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
252 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
253 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
254 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
255 |
|
---|
256 | // Common events
|
---|
257 | write.AddContainer("MCorsikaEvtHeader", "Events", kFALSE);
|
---|
258 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
259 | write.AddContainer("MMcEvt", "Events");
|
---|
260 | write.AddContainer("IncidentAngle", "Events", kFALSE);
|
---|
261 | }
|
---|
262 | Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq)
|
---|
263 | {
|
---|
264 | /*
|
---|
265 | if (!fSequence.IsValid())
|
---|
266 | {
|
---|
267 | *fLog << err << "ERROR - Sequence invalid!" << endl;
|
---|
268 | return kFALSE;
|
---|
269 | }
|
---|
270 | */
|
---|
271 |
|
---|
272 | // if (!HasWritePermission(CombinePath(fPathOut, GetOutFile(seq))))
|
---|
273 | // return kFALSE;
|
---|
274 |
|
---|
275 | *fLog << inf;
|
---|
276 | fLog->Separator(GetDescriptor());
|
---|
277 |
|
---|
278 | if (!CheckEnv())
|
---|
279 | return kFALSE;
|
---|
280 |
|
---|
281 | if (seq.IsValid())
|
---|
282 | *fLog << fSequence.GetFileName() << endl;
|
---|
283 | else
|
---|
284 | *fLog << "Input: " << args.GetNumArguments() << "-files" << endl;
|
---|
285 | *fLog << endl;
|
---|
286 |
|
---|
287 | MDirIter iter;
|
---|
288 | if (seq.IsValid() && seq.GetRuns(iter, MSequence::kCorsika)<=0)
|
---|
289 | {
|
---|
290 | *fLog << err << "ERROR - Sequence valid but without files." << endl;
|
---|
291 | return kFALSE;
|
---|
292 | }
|
---|
293 |
|
---|
294 | // --------------------------------------------------------------------------------
|
---|
295 |
|
---|
296 | // Setup Parlist
|
---|
297 | MParList plist;
|
---|
298 | plist.AddToList(this); // take care of fDisplay!
|
---|
299 |
|
---|
300 | // setup TaskList
|
---|
301 | MTaskList tasks;
|
---|
302 | plist.AddToList(&tasks);
|
---|
303 |
|
---|
304 | // --------------------------------------------------------------------------------
|
---|
305 |
|
---|
306 | // FIXME: Allow empty GeomCones!
|
---|
307 | MParEnv env0("Reflector");
|
---|
308 | MParEnv env1("GeomCones");
|
---|
309 | MParEnv env2("MGeomCam");
|
---|
310 | env0.SetClassName("MReflector");
|
---|
311 | env1.SetClassName("MGeomCam");
|
---|
312 | env2.SetClassName("MGeomCam");
|
---|
313 | plist.AddToList(&env0);
|
---|
314 | plist.AddToList(&env1);
|
---|
315 | plist.AddToList(&env2);
|
---|
316 |
|
---|
317 | plist.FindCreateObj("MPedPhotCam", "MPedPhotFromExtractorRndm");
|
---|
318 |
|
---|
319 | MParSpline shape("PulseShape");
|
---|
320 | plist.AddToList(&shape);
|
---|
321 |
|
---|
322 | // *** FIXME *** FIXME *** FIXME ***
|
---|
323 | plist.FindCreateObj("MMcRunHeader");
|
---|
324 |
|
---|
325 | MRawRunHeader header;
|
---|
326 | header.SetValidMagicNumber();
|
---|
327 | //header.InitFadcType(3);
|
---|
328 |
|
---|
329 | switch (fOperationMode)
|
---|
330 | {
|
---|
331 | case kModeData:
|
---|
332 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
|
---|
333 | header.SetRunInfo(0, fRunNumber<0 ? 3 : fRunNumber);
|
---|
334 | break;
|
---|
335 |
|
---|
336 | case kModePed:
|
---|
337 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
|
---|
338 | header.SetSourceInfo("Pedestal");
|
---|
339 | header.SetRunInfo(0, fRunNumber<0 ? 1 : fRunNumber);
|
---|
340 | break;
|
---|
341 |
|
---|
342 | case kModeCal:
|
---|
343 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
|
---|
344 | header.SetSourceInfo("Calibration");
|
---|
345 | header.SetRunInfo(0, fRunNumber<0 ? 2 : fRunNumber);
|
---|
346 | break;
|
---|
347 |
|
---|
348 | case kModePointRun:
|
---|
349 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
|
---|
350 | header.SetRunInfo(0, fRunNumber<0 ? 0 : fRunNumber);
|
---|
351 | break;
|
---|
352 | }
|
---|
353 |
|
---|
354 | // FIXME: Move to MSimPointingPos, MSimCalibrationSignal
|
---|
355 | // Can we use this as input for MSimPointingPos?
|
---|
356 | header.SetObservation("On", "MonteCarlo");
|
---|
357 | plist.AddToList(&header);
|
---|
358 | // ++++++++ FIXME FIXME FIXME +++++++++++++
|
---|
359 |
|
---|
360 | /*
|
---|
361 | MPedestalCam pedcam;
|
---|
362 | pedcam.Init(geomcam.GetNumPixels());
|
---|
363 | for (UInt_t i=0; i<geomcam.GetNumPixels(); i++)
|
---|
364 | pedcam[i].Set(128./header.GetScale(), 22.5/header.GetScale());
|
---|
365 | plist.AddToList(&pedcam);
|
---|
366 | */
|
---|
367 |
|
---|
368 | // -------------------------------------------------------------------
|
---|
369 |
|
---|
370 | MCorsikaRead read;
|
---|
371 | read.SetForceMode(fForceMode);
|
---|
372 |
|
---|
373 | if (!seq.IsValid())
|
---|
374 | {
|
---|
375 | for (int i=0; i<args.GetNumArguments(); i++)
|
---|
376 | read.AddFile(args.GetArgumentStr(i));
|
---|
377 | }
|
---|
378 | else
|
---|
379 | read.AddFiles(iter);
|
---|
380 |
|
---|
381 | MContinue precut("", "PreCut");
|
---|
382 | precut.IsInverted();
|
---|
383 | precut.SetAllowEmpty();
|
---|
384 |
|
---|
385 | MSimMMCS simmmcs;
|
---|
386 |
|
---|
387 | MParSpline splinepde("PhotonDetectionEfficiency");
|
---|
388 | MParSpline splinemirror("MirrorReflectivity");
|
---|
389 | MParSpline splinecones("ConesAngularAcceptance");
|
---|
390 | MParSpline splinecones2("ConesTransmission");
|
---|
391 | plist.AddToList(&splinepde);
|
---|
392 | plist.AddToList(&splinemirror);
|
---|
393 | plist.AddToList(&splinecones);
|
---|
394 | plist.AddToList(&splinecones2);
|
---|
395 |
|
---|
396 | const TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
---|
397 | const TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
---|
398 | const TString cos = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())";
|
---|
399 |
|
---|
400 | const TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()";
|
---|
401 |
|
---|
402 | MParameterCalc calcangle(form, "CalcIncidentAngle");
|
---|
403 | calcangle.SetNameParameter("IncidentAngle");
|
---|
404 |
|
---|
405 | MSimAtmosphere simatm;
|
---|
406 | MSimAbsorption absapd("SimPhotonDetectionEfficiency");
|
---|
407 | MSimAbsorption absmir("SimMirrorReflectivity");
|
---|
408 | MSimAbsorption cones("SimConesAngularAcceptance");
|
---|
409 | MSimAbsorption cones2("SimConesTransmission");
|
---|
410 | absapd.SetParName("PhotonDetectionEfficiency");
|
---|
411 | absmir.SetParName("MirrorReflectivity");
|
---|
412 | cones.SetParName("ConesAngularAcceptance");
|
---|
413 | cones.SetUseTheta();
|
---|
414 | cones2.SetParName("ConesTransmission");
|
---|
415 |
|
---|
416 | MSimPointingPos pointing;
|
---|
417 |
|
---|
418 | MSimReflector reflect;
|
---|
419 | reflect.SetNameGeomCam("GeomCones");
|
---|
420 | reflect.SetNameReflector("Reflector");
|
---|
421 | // MSimStarField stars;
|
---|
422 |
|
---|
423 | MContinue cont1("MPhotonEvent.GetNumPhotons<1", "ContEmpty1");
|
---|
424 | MContinue cont2("MPhotonEvent.GetNumPhotons<1", "ContEmpty2");
|
---|
425 | MContinue cont3("MPhotonEvent.GetNumPhotons<2", "ContEmpty3");
|
---|
426 | cont1.SetAllowEmpty();
|
---|
427 | cont2.SetAllowEmpty();
|
---|
428 | cont3.SetAllowEmpty();
|
---|
429 |
|
---|
430 | // -------------------------------------------------------------------
|
---|
431 |
|
---|
432 | MBinning binse( 120, 1, 1000000, "BinningEnergy", "log");
|
---|
433 | MBinning binsth( 60, 0.9, 900000, "BinningThreshold", "log");
|
---|
434 | MBinning binsee( 36, 0.9, 900000, "BinningEnergyEst", "log");
|
---|
435 | MBinning binss( 100, 1, 10000000, "BinningSize", "log");
|
---|
436 | // MBinning binsi( 100, -500, 500, "BinningImpact");
|
---|
437 | MBinning binsi( 32, 0, 800, "BinningImpact");
|
---|
438 | MBinning binsh( 150, 0, 50, "BinningHeight");
|
---|
439 | MBinning binsaz(720, -360, 360, "BinningAz");
|
---|
440 | MBinning binszd( 70, 0, 70, "BinningZd");
|
---|
441 | MBinning binsvc( 35, 0, 7, "BinningViewCone");
|
---|
442 | MBinning binsel(150, 0, 50, "BinningTotLength");
|
---|
443 | MBinning binsew(150, 0, 15, "BinningMedLength");
|
---|
444 | MBinning binsd("BinningDistC");
|
---|
445 | MBinning binsd0("BinningDist");
|
---|
446 | MBinning binstr("BinningTrigPos");
|
---|
447 |
|
---|
448 | plist.AddToList(&binsee);
|
---|
449 | plist.AddToList(&binse);
|
---|
450 | plist.AddToList(&binsth);
|
---|
451 | plist.AddToList(&binss);
|
---|
452 | plist.AddToList(&binsi);
|
---|
453 | plist.AddToList(&binsh);
|
---|
454 | plist.AddToList(&binszd);
|
---|
455 | plist.AddToList(&binsaz);
|
---|
456 | plist.AddToList(&binsvc);
|
---|
457 | plist.AddToList(&binsel);
|
---|
458 | plist.AddToList(&binsew);
|
---|
459 | plist.AddToList(&binstr);
|
---|
460 | plist.AddToList(&binsd);
|
---|
461 | plist.AddToList(&binsd0);
|
---|
462 |
|
---|
463 | MHn mhn1, mhn2, mhn3, mhn4;
|
---|
464 | SetupHist(mhn1);
|
---|
465 | SetupHist(mhn2);
|
---|
466 | SetupHist(mhn3);
|
---|
467 | SetupHist(mhn4);
|
---|
468 |
|
---|
469 | MH3 mhtp("TriggerPos.fVal-IntendedPulsePos.fVal-PulseShape.GetWidth");
|
---|
470 | mhtp.SetName("TrigPos");
|
---|
471 | mhtp.SetTitle("Trigger position w.r.t. the first photon hitting a detector");
|
---|
472 |
|
---|
473 | MH3 mhew("MPhotonStatistics.fLength");
|
---|
474 | mhew.SetName("TotLength");
|
---|
475 | mhew.SetTitle("Time between first and last photon hitting a detector;L [ns]");
|
---|
476 |
|
---|
477 | MH3 mhed("MPhotonStatistics.fTimeMedDev");
|
---|
478 | mhed.SetName("MedLength");
|
---|
479 | mhed.SetTitle("Median deviation (1\\sigma);L [ns]");
|
---|
480 |
|
---|
481 | MFillH fillh1(&mhn1, "", "FillCorsika");
|
---|
482 | MFillH fillh2(&mhn2, "", "FillH2");
|
---|
483 | MFillH fillh3(&mhn3, "", "FillH3");
|
---|
484 | MFillH fillh4(&mhn4, "", "FillH4");
|
---|
485 | MFillH filltp(&mhtp, "", "FillTriggerPos");
|
---|
486 | MFillH fillew(&mhew, "", "FillEvtWidth");
|
---|
487 | MFillH filled(&mhed, "", "FillMedDev");
|
---|
488 | fillh1.SetNameTab("Corsika", "Distribution as simulated by Corsika");
|
---|
489 | fillh2.SetNameTab("Detectable", "Distribution of events hit the detector");
|
---|
490 | fillh3.SetNameTab("Triggered", "Distribution of triggered events");
|
---|
491 | fillh4.SetNameTab("Cleaned", "Distribution after cleaning and cuts");
|
---|
492 | filltp.SetNameTab("TrigPos", "TriggerPosition w.r.t the first photon");
|
---|
493 | fillew.SetNameTab("EvtWidth", "Time between first and last photon hitting a detector");
|
---|
494 | filled.SetNameTab("MedDev", "Median deviation of arrival time of photons hitting a detector");
|
---|
495 |
|
---|
496 | MHPhotonEvent planeG(1, "HPhotonEventGround"); // Get from MaxImpact
|
---|
497 | MHPhotonEvent plane0(2, "HMirrorPlane0"); // Get from MReflector
|
---|
498 | //MHPhotonEvent plane1(2, "HMirrorPlane1");
|
---|
499 | MHPhotonEvent plane2(2, "HMirrorPlane2");
|
---|
500 | MHPhotonEvent plane3(2, "HMirrorPlane3");
|
---|
501 | MHPhotonEvent plane4(2, "HMirrorPlane4");
|
---|
502 | MHPhotonEvent planeF1(6, "HPhotonEventCamera"); // Get from MGeomCam
|
---|
503 | MHPhotonEvent planeF2(header.IsPointRun()?4:6, "HPhotonEventCones"); // Get from MGeomCam
|
---|
504 |
|
---|
505 | plist.AddToList(&planeG);
|
---|
506 | plist.AddToList(&plane0);
|
---|
507 | plist.AddToList(&plane2);
|
---|
508 | plist.AddToList(&plane3);
|
---|
509 | plist.AddToList(&plane4);
|
---|
510 | plist.AddToList(&planeF1);
|
---|
511 | plist.AddToList(&planeF2);;
|
---|
512 |
|
---|
513 | //MHPSF psf;
|
---|
514 |
|
---|
515 | MFillH fillG(&planeG, "MPhotonEvent", "FillGround");
|
---|
516 | MFillH fill0(&plane0, "MirrorPlane0", "FillReflector");
|
---|
517 | //MFillH fill1(&plane1, "MirrorPlane1", "FillCamShadow");
|
---|
518 | MFillH fill2(&plane2, "MirrorPlane2", "FillCandidates");
|
---|
519 | MFillH fill3(&plane3, "MirrorPlane3", "FillReflected");
|
---|
520 | MFillH fill4(&plane4, "MirrorPlane4", "FillFocal");
|
---|
521 | MFillH fillF1(&planeF1, "MPhotonEvent", "FillCamera");
|
---|
522 | MFillH fillF2(&planeF2, "MPhotonEvent", "FillCones");
|
---|
523 | //MFillH fillP(&psf, "MPhotonEvent", "FillPSF");
|
---|
524 |
|
---|
525 | fillG.SetNameTab("Ground", "Photon distribution at ground");
|
---|
526 | fill0.SetNameTab("Reflector", "Photon distribution at reflector plane w/o camera shadow");
|
---|
527 | //fill1.SetNameTab("CamShadow", "Photon distribution at reflector plane w/ camera shadow");
|
---|
528 | fill2.SetNameTab("Candidates", "*Can hit* photon distribution at reflector plane w/ camera shadow");
|
---|
529 | fill3.SetNameTab("Reflected", "Photon distribution after reflector projected to reflector plane");
|
---|
530 | fill4.SetNameTab("Focal", "Photon distribution at focal plane");
|
---|
531 | fillF1.SetNameTab("Camera", "Photon distribution which hit the detector");
|
---|
532 | fillF2.SetNameTab("Cones", "Photon distribution after cones");
|
---|
533 | //fillP.SetNameTab("PSF", "Photon distribution after cones for all mirrors");
|
---|
534 |
|
---|
535 | // -------------------------------------------------------------------
|
---|
536 |
|
---|
537 | const char *fmt = Form("s/cer([0-9]+)([0-9][0-9][0-9])/%s\\/%08d.$2_%%c_MonteCarlo$1.root/", Esc(fPathOut).Data(), header.GetRunNumber());
|
---|
538 |
|
---|
539 | const TString rule1(Form(fmt, 'R'));
|
---|
540 | const TString rule2(Form(fmt, 'Y'));
|
---|
541 | const TString rule4(Form(fmt, 'I'));
|
---|
542 | TString rule3(Form(fmt, header.GetRunTypeChar()));
|
---|
543 | if (fWriteFitsFile)
|
---|
544 | rule3.ReplaceAll("$1.root/", "$1.fits/");
|
---|
545 |
|
---|
546 | MWriteRootFile write4a( 2, rule4, fOverwrite?"RECREATE":"NEW", "Star file");
|
---|
547 | MWriteRootFile write4b( 2, rule4, fOverwrite?"RECREATE":"NEW", "Star file");
|
---|
548 | MWriteRootFile write3b( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
|
---|
549 | MWriteRootFile write2a( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file");
|
---|
550 | MWriteRootFile write2b( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file");
|
---|
551 | MWriteRootFile write1a( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file");
|
---|
552 | MWriteRootFile write1b( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file");
|
---|
553 |
|
---|
554 | MWriteFitsFile write3af( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
|
---|
555 | MWriteRootFile write3ar( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
|
---|
556 |
|
---|
557 | MTask &write3a = fWriteFitsFile ? static_cast<MTask&>(write3af) : static_cast<MTask&>(write3ar);
|
---|
558 |
|
---|
559 | write3af.VetoColumn("MParameterD.fVal");
|
---|
560 | write3af.VetoColumn("MCorsikaEvtHeader.fEvtNumber");
|
---|
561 | write3af.VetoColumn("MCorsikaEvtHeader.fNumReuse");
|
---|
562 | write3af.VetoColumn("MCorsikaEvtHeader.fTotalEnergy");
|
---|
563 | write3af.VetoColumn("MCorsikaEvtHeader.fStartAltitude");
|
---|
564 | write3af.VetoColumn("MCorsikaEvtHeader.fFirstTargetNum");
|
---|
565 | write3af.VetoColumn("MCorsikaEvtHeader.fFirstInteractionHeight");
|
---|
566 | write3af.VetoColumn("MCorsikaEvtHeader.fMomentumX");
|
---|
567 | write3af.VetoColumn("MCorsikaEvtHeader.fMomentumY");
|
---|
568 | write3af.VetoColumn("MCorsikaEvtHeader.fMomentumZ");
|
---|
569 | write3af.VetoColumn("MCorsikaEvtHeader.fAz");
|
---|
570 | write3af.VetoColumn("MCorsikaEvtHeader.fWeightedNumPhotons");
|
---|
571 | write3af.VetoColumn("MCorsikaEvtHeader.fZd");
|
---|
572 | write3af.VetoColumn("MCorsikaEvtHeader.fAd");
|
---|
573 | write3af.VetoColumn("MCorsikaEvtHeader.fX");
|
---|
574 | write3af.VetoColumn("MCorsikaEvtHeader.fY");
|
---|
575 | write3af.VetoColumn("MCorsikaEvtHeader.fWeightNumPhotons");
|
---|
576 | write3af.VetoColumn("MMcEvt.fEvtNumber");
|
---|
577 | write3af.VetoColumn("MMcEvt.fThick0");
|
---|
578 | write3af.VetoColumn("MMcEvt.fFirstTarget");
|
---|
579 | write3af.VetoColumn("MMcEvt.fZFirstInteraction");
|
---|
580 | write3af.VetoColumn("MMcEvt.fCoreD");
|
---|
581 | write3af.VetoColumn("MMcEvt.fCoreX");
|
---|
582 | write3af.VetoColumn("MMcEvt.fCoreY");
|
---|
583 | write3af.VetoColumn("MMcEvt.fTimeFirst");
|
---|
584 | write3af.VetoColumn("MMcEvt.fTimeLast");
|
---|
585 | write3af.VetoColumn("MMcEvt.fLongiNmax");
|
---|
586 | write3af.VetoColumn("MMcEvt.fLongit0");
|
---|
587 | write3af.VetoColumn("MMcEvt.fLongitmax");
|
---|
588 | write3af.VetoColumn("MMcEvt.fLongia");
|
---|
589 | write3af.VetoColumn("MMcEvt.fLongib");
|
---|
590 | write3af.VetoColumn("MMcEvt.fLongic");
|
---|
591 | write3af.VetoColumn("MMcEvt.fLongichi2");
|
---|
592 | write3af.VetoColumn("MMcEvt.fPhotIni");
|
---|
593 | write3af.VetoColumn("MMcEvt.fPassPhotAtm");
|
---|
594 | write3af.VetoColumn("MMcEvt.fPassPhotRef");
|
---|
595 | write3af.VetoColumn("MMcEvt.fPassPhotCone");
|
---|
596 | write3af.VetoColumn("MMcEvt.fPhotElfromShower");
|
---|
597 | write3af.VetoColumn("MMcEvt.fPhotElinCamera");
|
---|
598 | write3af.VetoColumn("MMcEvt.fElecCphFraction");
|
---|
599 | write3af.VetoColumn("MMcEvt.fMuonCphFraction");
|
---|
600 | write3af.VetoColumn("MMcEvt.fOtherCphFraction");
|
---|
601 | write3af.VetoColumn("MMcEvt.fFadcTimeJitter");
|
---|
602 | write3af.VetoColumn("MMcEvt.fEventReuse");
|
---|
603 |
|
---|
604 | write3af.VetoColumn("MRawEvtData.fHiGainPixId");
|
---|
605 | write3af.VetoColumn("MRawEvtData.fLoGainPixId");
|
---|
606 | write3af.VetoColumn("MRawEvtData.fLoGainFadcSamples");
|
---|
607 | write3af.VetoColumn("MRawEvtData.fABFlags");
|
---|
608 | write3af.VetoColumn("MRawEvtData.fStartCells");
|
---|
609 | write3af.VetoColumn("MRawEvtData.fNumBytesPerSample");
|
---|
610 | write3af.VetoColumn("MRawEvtData.fIsSigned");
|
---|
611 | write3af.VetoColumn("MRawEvtHeader.fDAQEvtNumber"); //EventNum ?
|
---|
612 | write3af.VetoColumn("MRawEvtHeader.fNumTrigLvl1");
|
---|
613 | write3af.VetoColumn("MRawEvtHeader.fNumTrigLvl2");
|
---|
614 | write3af.VetoColumn("MRawEvtHeader.fTrigPattern");
|
---|
615 | write3af.VetoColumn("MRawEvtHeader.fNumLoGainOn");
|
---|
616 |
|
---|
617 | write3af.SetBytesPerSample("Data", 2);
|
---|
618 |
|
---|
619 | write1a.SetName("WriteRefData");
|
---|
620 | write1b.SetName("WriteRefMC");
|
---|
621 | write2a.SetName("WriteSigData");
|
---|
622 | write2b.SetName("WriteSigMC");
|
---|
623 | write3a.SetName("WriteCamData");
|
---|
624 | write3b.SetName("WriteCamMC");
|
---|
625 | write4a.SetName("WriteImgData");
|
---|
626 | write4b.SetName("WriteImgMC");
|
---|
627 |
|
---|
628 | SetupCommonFileStructure(write1a);
|
---|
629 | SetupCommonFileStructure(write2a);
|
---|
630 | SetupCommonFileStructure(write3ar);
|
---|
631 | SetupCommonFileStructure(write3af);
|
---|
632 | SetupCommonFileStructure(write4a);
|
---|
633 |
|
---|
634 | // R: Dedicated file structure
|
---|
635 | write1a.AddContainer("MPhotonEvent", "Events");
|
---|
636 |
|
---|
637 | // Y: Dedicated file structure
|
---|
638 | write2a.AddContainer("MPedPhotFromExtractorRndm", "RunHeaders"); // FIXME: Needed for the signal files to be display in MARS
|
---|
639 | write2a.AddContainer("MSignalCam", "Events");
|
---|
640 |
|
---|
641 | // D: Dedicated file structure
|
---|
642 | write3af.AddContainer("ElectronicNoise", "RunHeaders");
|
---|
643 | write3af.AddContainer("IntendedPulsePos", "RunHeaders");
|
---|
644 | write3af.AddContainer("MRawEvtData", "Events");
|
---|
645 |
|
---|
646 | write3ar.AddContainer("ElectronicNoise", "RunHeaders");
|
---|
647 | write3ar.AddContainer("IntendedPulsePos", "RunHeaders");
|
---|
648 | write3ar.AddContainer("MRawEvtData", "Events");
|
---|
649 | // It doesn't make much sene to write this information
|
---|
650 | // to the file because the units are internal units not
|
---|
651 | // related to the output samples
|
---|
652 | // if (header.IsDataRun() || fForceTrigger)
|
---|
653 | // write3a.AddContainer("TriggerPos", "Events");
|
---|
654 |
|
---|
655 | // I: Dedicated file structure
|
---|
656 | write4a.AddContainer("MHillas", "Events");
|
---|
657 | write4a.AddContainer("MHillasSrc", "Events");
|
---|
658 | write4a.AddContainer("MImagePar", "Events");
|
---|
659 | write4a.AddContainer("MNewImagePar", "Events");
|
---|
660 |
|
---|
661 | // Basic MC data
|
---|
662 | write1b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
663 | write2b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
664 | write3b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
665 | write4b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
666 |
|
---|
667 | // -------------------------------------------------------------------
|
---|
668 |
|
---|
669 | MGeomApply apply;
|
---|
670 |
|
---|
671 | MSimPSF simpsf;
|
---|
672 |
|
---|
673 | MSimGeomCam simgeom;
|
---|
674 | simgeom.SetNameGeomCam("GeomCones");
|
---|
675 |
|
---|
676 | MSimCalibrationSignal simcal;
|
---|
677 | simcal.SetNameGeomCam("GeomCones");
|
---|
678 |
|
---|
679 | // Sky Quality Meter: 21.82M = 2.02e-4cd/m^2
|
---|
680 | // 1cd = 12.566 lm / 4pi sr
|
---|
681 |
|
---|
682 | // FIXME: Simulate photons before cones and QE!
|
---|
683 |
|
---|
684 | MSimRandomPhotons simnsb;
|
---|
685 | simnsb.SetFreq(5.8, 0.004); // ph/m^2/nm/sr/ns NSB, 4MHz dark count rate
|
---|
686 | simnsb.SetNameGeomCam("GeomCones");
|
---|
687 |
|
---|
688 | // FIXME: How do we handle star-light? We need the rate but we also
|
---|
689 | // need to process it through the mirror!
|
---|
690 |
|
---|
691 | MSimAPD simapd;
|
---|
692 | simapd.SetNameGeomCam("GeomCones");
|
---|
693 |
|
---|
694 | MSimExcessNoise simexcnoise;
|
---|
695 | MSimBundlePhotons simsum;
|
---|
696 | MSimSignalCam simsignal;
|
---|
697 | MSimCamera simcam;
|
---|
698 | MSimTrigger simtrig;
|
---|
699 | MSimReadout simdaq;
|
---|
700 |
|
---|
701 | MContinue conttrig("TriggerPos.fVal<0", "ContTrigger");
|
---|
702 |
|
---|
703 | MParameterD pulpos("IntendedPulsePos");
|
---|
704 | // FIXME: Set a default which could be 1/3 of the digitization window
|
---|
705 | // pulpos.SetVal(40); // [ns]
|
---|
706 | plist.AddToList(&pulpos);
|
---|
707 |
|
---|
708 | MParameterD trigger("TriggerPos");
|
---|
709 | trigger.SetVal(0);
|
---|
710 | plist.AddToList(&trigger);
|
---|
711 |
|
---|
712 | // -------------------------------------------------------------------
|
---|
713 |
|
---|
714 | // Remove isolated pixels
|
---|
715 | MImgCleanStd clean(0, 0);
|
---|
716 | //clean.SetCleanLvl0(0); // The level above which isolated pixels are kept
|
---|
717 | clean.SetCleanRings(0);
|
---|
718 | clean.SetMethod(MImgCleanStd::kAbsolute);
|
---|
719 |
|
---|
720 | //clean.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
721 |
|
---|
722 | MHillasCalc hcalc;
|
---|
723 | hcalc.Disable(MHillasCalc::kCalcConc);
|
---|
724 |
|
---|
725 | MHCamEvent evt0a(/*10*/3, "Signal", "Average signal (absolute);;S [ph]");
|
---|
726 | MHCamEvent evt0c(/*10*/3, "MaxSignal", "Maximum signal (absolute);;S [ph]");
|
---|
727 | MHCamEvent evt0d(/*11*/8, "ArrTm", "Time after first photon;;T [ns]");
|
---|
728 | evt0a.SetErrorSpread(kFALSE);
|
---|
729 | evt0c.SetCollectMax();
|
---|
730 |
|
---|
731 | MContinue cut("", "Cut");
|
---|
732 |
|
---|
733 | MFillH fillx0a(&evt0a, "MSignalCam", "FillAvgSignal");
|
---|
734 | MFillH fillx0c(&evt0c, "MSignalCam", "FillMaxSignal");
|
---|
735 | MFillH fillx0d(&evt0d, "MSignalCam", "FillArrTm");
|
---|
736 | MFillH fillx1("MHHillas", "MHillas", "FillHillas");
|
---|
737 | MFillH fillx3("MHHillasSrc", "MHillasSrc", "FillHillasSrc");
|
---|
738 | MFillH fillx4("MHNewImagePar", "MNewImagePar", "FillNewImagePar");
|
---|
739 | MFillH fillth("MHThreshold", "", "FillThreshold");
|
---|
740 | MFillH fillca("MHCollectionArea", "", "FillTrigArea");
|
---|
741 |
|
---|
742 | fillth.SetNameTab("Threshold");
|
---|
743 | fillca.SetNameTab("TrigArea");
|
---|
744 |
|
---|
745 | // -------------------------------------------------------------------
|
---|
746 |
|
---|
747 | if (header.IsDataRun())
|
---|
748 | {
|
---|
749 | tasks.AddToList(&read);
|
---|
750 | tasks.AddToList(&precut);
|
---|
751 | tasks.AddToList(&pointing);
|
---|
752 | tasks.AddToList(&simmmcs);
|
---|
753 | if (!fPathOut.IsNull() && !HasNullOut())
|
---|
754 | {
|
---|
755 | //tasks.AddToList(&write1b);
|
---|
756 | tasks.AddToList(&write2b);
|
---|
757 | if (fCamera)
|
---|
758 | tasks.AddToList(&write3b);
|
---|
759 | if (header.IsDataRun())
|
---|
760 | tasks.AddToList(&write4b);
|
---|
761 | }
|
---|
762 | // if (header.IsPointRun())
|
---|
763 | // tasks.AddToList(&stars);
|
---|
764 | if (1)
|
---|
765 | tasks.AddToList(&simatm); // Here because before fillh1
|
---|
766 | tasks.AddToList(&calcangle);
|
---|
767 | tasks.AddToList(&fillh1);
|
---|
768 | tasks.AddToList(&fillG);
|
---|
769 | if (!header.IsPointRun())
|
---|
770 | {
|
---|
771 | tasks.AddToList(&absapd);
|
---|
772 | tasks.AddToList(&absmir);
|
---|
773 | if (0)
|
---|
774 | tasks.AddToList(&simatm); // FASTER?
|
---|
775 | }
|
---|
776 | tasks.AddToList(&reflect);
|
---|
777 | if (!header.IsPointRun())
|
---|
778 | {
|
---|
779 | tasks.AddToList(&fill0);
|
---|
780 | //tasks.AddToList(&fill1);
|
---|
781 | tasks.AddToList(&fill2);
|
---|
782 | tasks.AddToList(&fill3);
|
---|
783 | tasks.AddToList(&fill4);
|
---|
784 | tasks.AddToList(&fillF1);
|
---|
785 | }
|
---|
786 | tasks.AddToList(&cones);
|
---|
787 | tasks.AddToList(&cones2);
|
---|
788 | //if (header.IsPointRun())
|
---|
789 | // tasks.AddToList(&fillP);
|
---|
790 | tasks.AddToList(&cont1);
|
---|
791 | }
|
---|
792 | // -------------------------------
|
---|
793 | tasks.AddToList(&apply);
|
---|
794 | if (header.IsDataRun())
|
---|
795 | {
|
---|
796 | tasks.AddToList(&simpsf);
|
---|
797 | tasks.AddToList(&simgeom);
|
---|
798 | tasks.AddToList(&cont2);
|
---|
799 | if (!header.IsPointRun())
|
---|
800 | {
|
---|
801 | tasks.AddToList(&fillF2);
|
---|
802 | tasks.AddToList(&fillh2);
|
---|
803 | }
|
---|
804 | tasks.AddToList(&cont3);
|
---|
805 | }
|
---|
806 | if (fCamera)
|
---|
807 | {
|
---|
808 | if (header.IsPedestalRun() || header.IsCalibrationRun())
|
---|
809 | tasks.AddToList(&simcal);
|
---|
810 | tasks.AddToList(&simnsb);
|
---|
811 | tasks.AddToList(&simapd);
|
---|
812 | tasks.AddToList(&simexcnoise);
|
---|
813 | }
|
---|
814 | tasks.AddToList(&simsum);
|
---|
815 | if (fCamera)
|
---|
816 | {
|
---|
817 | tasks.AddToList(&simcam);
|
---|
818 | if (header.IsDataRun() || fForceTrigger)
|
---|
819 | tasks.AddToList(&simtrig);
|
---|
820 | tasks.AddToList(&conttrig);
|
---|
821 | tasks.AddToList(&simdaq);
|
---|
822 | }
|
---|
823 | tasks.AddToList(&simsignal); // What do we do if signal<0?
|
---|
824 | if (!fPathOut.IsNull() && !HasNullOut())
|
---|
825 | {
|
---|
826 | //tasks.AddToList(&write1a);
|
---|
827 | if (!header.IsPedestalRun())
|
---|
828 | tasks.AddToList(&write2a);
|
---|
829 | if (fCamera)
|
---|
830 | tasks.AddToList(&write3a);
|
---|
831 | }
|
---|
832 | // -------------------------------
|
---|
833 | if (fCamera)
|
---|
834 | {
|
---|
835 | // FIXME: MHCollectionArea Trigger Area!
|
---|
836 | if (header.IsDataRun())
|
---|
837 | tasks.AddToList(&fillh3);
|
---|
838 | tasks.AddToList(&filltp);
|
---|
839 | }
|
---|
840 | if (header.IsDataRun())
|
---|
841 | {
|
---|
842 | tasks.AddToList(&fillew);
|
---|
843 | tasks.AddToList(&filled);
|
---|
844 | }
|
---|
845 | if (!header.IsPedestalRun())
|
---|
846 | {
|
---|
847 | tasks.AddToList(&fillx0a);
|
---|
848 | tasks.AddToList(&fillx0c);
|
---|
849 | }
|
---|
850 | if (header.IsDataRun())
|
---|
851 | {
|
---|
852 | tasks.AddToList(&clean);
|
---|
853 | tasks.AddToList(&hcalc);
|
---|
854 | tasks.AddToList(&cut);
|
---|
855 | tasks.AddToList(&fillx0d);
|
---|
856 | tasks.AddToList(&fillx1);
|
---|
857 | //tasks.AddToList(&fillx2);
|
---|
858 | tasks.AddToList(&fillx3);
|
---|
859 | tasks.AddToList(&fillx4);
|
---|
860 | if (!HasNullOut())
|
---|
861 | tasks.AddToList(&write4a);
|
---|
862 | //tasks.AddToList(&fillx5);
|
---|
863 |
|
---|
864 | tasks.AddToList(&fillh4);
|
---|
865 | tasks.AddToList(&fillth);
|
---|
866 | tasks.AddToList(&fillca);
|
---|
867 | }
|
---|
868 | //-------------------------------------------
|
---|
869 |
|
---|
870 | tasks.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime);
|
---|
871 |
|
---|
872 | // Create and setup the eventloop
|
---|
873 | MEvtLoop evtloop(fName);
|
---|
874 | evtloop.SetParList(&plist);
|
---|
875 | evtloop.SetDisplay(fDisplay);
|
---|
876 | evtloop.SetLogStream(&gLog);
|
---|
877 | if (!SetupEnv(evtloop))
|
---|
878 | return kFALSE;
|
---|
879 |
|
---|
880 | // FIXME: If pedestal file given use the values from this file
|
---|
881 | //-------------------------------------------
|
---|
882 |
|
---|
883 | MGeomCam *cam = static_cast<MGeomCam*>(env2.GetCont());
|
---|
884 |
|
---|
885 | if (binstr.IsDefault())
|
---|
886 | binstr.SetEdgesLin(150, -shape.GetWidth(),
|
---|
887 | header.GetFreqSampling()/1000.*header.GetNumSamples()+shape.GetWidth());
|
---|
888 |
|
---|
889 | if (binsd.IsDefault() && cam)
|
---|
890 | binsd.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
|
---|
891 |
|
---|
892 | if (binsd0.IsDefault() && cam)
|
---|
893 | binsd0.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
|
---|
894 |
|
---|
895 |
|
---|
896 | header.Print();
|
---|
897 |
|
---|
898 | // FIXME: Display acceptance curves!
|
---|
899 |
|
---|
900 | if (fDisplay)
|
---|
901 | {
|
---|
902 | TCanvas &c = fDisplay->AddTab("Info");
|
---|
903 | c.Divide(2,2);
|
---|
904 |
|
---|
905 | c.cd(1);
|
---|
906 | gPad->SetBorderMode(0);
|
---|
907 | gPad->SetFrameBorderMode(0);
|
---|
908 | gPad->SetGridx();
|
---|
909 | gPad->SetGridy();
|
---|
910 | gROOT->SetSelectedPad(0);
|
---|
911 | shape.DrawClone()->SetBit(kCanDelete);
|
---|
912 |
|
---|
913 | if (env0.GetCont() && (header.IsDataRun() || header.IsPointRun()))
|
---|
914 | {
|
---|
915 | c.cd(3);
|
---|
916 | gPad->SetBorderMode(0);
|
---|
917 | gPad->SetFrameBorderMode(0);
|
---|
918 | gPad->SetGridx();
|
---|
919 | gPad->SetGridy();
|
---|
920 | gROOT->SetSelectedPad(0);
|
---|
921 | static_cast<MReflector*>(env0.GetCont())->DrawClone("line")->SetBit(kCanDelete);
|
---|
922 | }
|
---|
923 |
|
---|
924 | if (fCamera)
|
---|
925 | {
|
---|
926 | if (env1.GetCont())
|
---|
927 | {
|
---|
928 | c.cd(2);
|
---|
929 | gPad->SetBorderMode(0);
|
---|
930 | gPad->SetFrameBorderMode(0);
|
---|
931 | gPad->SetGridx();
|
---|
932 | gPad->SetGridy();
|
---|
933 | gROOT->SetSelectedPad(0);
|
---|
934 | MHCamera *c = new MHCamera(static_cast<MGeomCam&>(*env1.GetCont()));
|
---|
935 | c->SetStats(kFALSE);
|
---|
936 | c->SetBit(MHCamera::kNoLegend);
|
---|
937 | c->SetBit(kCanDelete);
|
---|
938 | c->Draw();
|
---|
939 | }
|
---|
940 |
|
---|
941 | if (cam)
|
---|
942 | {
|
---|
943 | c.cd(4);
|
---|
944 | gPad->SetBorderMode(0);
|
---|
945 | gPad->SetFrameBorderMode(0);
|
---|
946 | gPad->SetGridx();
|
---|
947 | gPad->SetGridy();
|
---|
948 | gROOT->SetSelectedPad(0);
|
---|
949 | MHCamera *c = new MHCamera(*cam);
|
---|
950 | c->SetStats(kFALSE);
|
---|
951 | c->SetBit(MHCamera::kNoLegend);
|
---|
952 | c->SetBit(kCanDelete);
|
---|
953 | c->Draw();
|
---|
954 | }
|
---|
955 | }
|
---|
956 |
|
---|
957 | TCanvas &d = fDisplay->AddTab("Info2");
|
---|
958 | d.Divide(2,3);
|
---|
959 |
|
---|
960 | d.cd(1);
|
---|
961 | gPad->SetBorderMode(0);
|
---|
962 | gPad->SetFrameBorderMode(0);
|
---|
963 | gPad->SetGridx();
|
---|
964 | gPad->SetGridy();
|
---|
965 | gROOT->SetSelectedPad(0);
|
---|
966 | splinepde.DrawClone()->SetBit(kCanDelete);
|
---|
967 |
|
---|
968 | d.cd(3);
|
---|
969 | gPad->SetBorderMode(0);
|
---|
970 | gPad->SetFrameBorderMode(0);
|
---|
971 | gPad->SetGridx();
|
---|
972 | gPad->SetGridy();
|
---|
973 | gROOT->SetSelectedPad(0);
|
---|
974 | splinecones2.DrawClone()->SetBit(kCanDelete);
|
---|
975 |
|
---|
976 | d.cd(5);
|
---|
977 | gPad->SetBorderMode(0);
|
---|
978 | gPad->SetFrameBorderMode(0);
|
---|
979 | gPad->SetGridx();
|
---|
980 | gPad->SetGridy();
|
---|
981 | gROOT->SetSelectedPad(0);
|
---|
982 | splinemirror.DrawClone()->SetBit(kCanDelete);
|
---|
983 |
|
---|
984 | d.cd(2);
|
---|
985 | gPad->SetBorderMode(0);
|
---|
986 | gPad->SetFrameBorderMode(0);
|
---|
987 | gPad->SetGridx();
|
---|
988 | gPad->SetGridy();
|
---|
989 | gROOT->SetSelectedPad(0);
|
---|
990 | splinecones.DrawClone()->SetBit(kCanDelete);
|
---|
991 | //splinecones2.DrawClone("same")->SetBit(kCanDelete);
|
---|
992 |
|
---|
993 | d.cd(6);
|
---|
994 | gPad->SetBorderMode(0);
|
---|
995 | gPad->SetFrameBorderMode(0);
|
---|
996 | gPad->SetGridx();
|
---|
997 | gPad->SetGridy();
|
---|
998 | gROOT->SetSelectedPad(0);
|
---|
999 | MParSpline *all = (MParSpline*)splinepde.DrawClone();
|
---|
1000 | //all->SetTitle("Combined acceptance");
|
---|
1001 | all->SetBit(kCanDelete);
|
---|
1002 | if (splinemirror.GetSpline())
|
---|
1003 | all->Multiply(*splinemirror.GetSpline());
|
---|
1004 | if (splinecones2.GetSpline())
|
---|
1005 | all->Multiply(*splinecones2.GetSpline());
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | //-------------------------------------------
|
---|
1009 |
|
---|
1010 | // Execute first analysis
|
---|
1011 | if (!evtloop.Eventloop(fMaxEvents))
|
---|
1012 | {
|
---|
1013 | gLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
1014 | return kFALSE;
|
---|
1015 | }
|
---|
1016 |
|
---|
1017 | //-------------------------------------------
|
---|
1018 | // FIXME: Display Spline in tab
|
---|
1019 | // FIXME: Display Reflector in tab
|
---|
1020 | // FIXME: Display Routing(?) in tab
|
---|
1021 | // FIXME: Display Camera(s) in tab
|
---|
1022 | //-------------------------------------------
|
---|
1023 |
|
---|
1024 | if (!WriteResult(plist, seq, header.GetRunNumber()))
|
---|
1025 | return kFALSE;
|
---|
1026 |
|
---|
1027 | *fLog << all << GetDescriptor() << ": Done." << endl << endl << endl;;
|
---|
1028 |
|
---|
1029 | return kTRUE;
|
---|
1030 | }
|
---|