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 "MHillasCalc.h"
|
---|
77 | #include "MImgCleanStd.h"
|
---|
78 | #include "MWriteRootFile.h"
|
---|
79 |
|
---|
80 | #include "MSimMMCS.h"
|
---|
81 | #include "MSimAbsorption.h"
|
---|
82 | #include "MSimAtmosphere.h"
|
---|
83 | #include "MSimReflector.h"
|
---|
84 | #include "MSimPointingPos.h"
|
---|
85 | #include "MSimPSF.h"
|
---|
86 | #include "MSimGeomCam.h"
|
---|
87 | #include "MSimSignalCam.h"
|
---|
88 | #include "MSimAPD.h"
|
---|
89 | #include "MSimExcessNoise.h"
|
---|
90 | #include "MSimCamera.h"
|
---|
91 | #include "MSimTrigger.h"
|
---|
92 | #include "MSimReadout.h"
|
---|
93 | #include "MSimRandomPhotons.h"
|
---|
94 | #include "MSimBundlePhotons.h"
|
---|
95 | #include "MSimCalibrationSignal.h"
|
---|
96 |
|
---|
97 | // Histograms
|
---|
98 | #include "MBinning.h"
|
---|
99 |
|
---|
100 | #include "MHn.h"
|
---|
101 | #include "MHCamera.h"
|
---|
102 | #include "MHCamEvent.h"
|
---|
103 | #include "MHPhotonEvent.h"
|
---|
104 |
|
---|
105 | // Container
|
---|
106 | #include "MRawRunHeader.h"
|
---|
107 | #include "MParameters.h"
|
---|
108 | #include "MReflector.h"
|
---|
109 | #include "MParEnv.h"
|
---|
110 | #include "MSpline3.h"
|
---|
111 | #include "MParSpline.h"
|
---|
112 | #include "MGeomCam.h"
|
---|
113 |
|
---|
114 | #include "MPedestalCam.h"
|
---|
115 | #include "MPedestalPix.h"
|
---|
116 |
|
---|
117 | ClassImp(MJSimulation);
|
---|
118 |
|
---|
119 | using namespace std;
|
---|
120 |
|
---|
121 | // --------------------------------------------------------------------------
|
---|
122 | //
|
---|
123 | // Default constructor.
|
---|
124 | //
|
---|
125 | // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
|
---|
126 | //
|
---|
127 | MJSimulation::MJSimulation(const char *name, const char *title)
|
---|
128 | : fForceMode(kFALSE), fCamera(kTRUE) ,fForceTrigger(kFALSE)
|
---|
129 | {
|
---|
130 | fName = name ? name : "MJSimulation";
|
---|
131 | fTitle = title ? title : "Standard analysis and reconstruction";
|
---|
132 | }
|
---|
133 |
|
---|
134 | Bool_t MJSimulation::CheckEnvLocal()
|
---|
135 | {
|
---|
136 | fForceMode = GetEnv("ForceMode", fForceMode);
|
---|
137 | fForceTrigger = GetEnv("ForceTrigger", fForceTrigger);
|
---|
138 | fCamera = GetEnv("Camera", fCamera);
|
---|
139 |
|
---|
140 | return kTRUE;
|
---|
141 | }
|
---|
142 |
|
---|
143 | Bool_t MJSimulation::WriteResult(const MParList &plist)
|
---|
144 | {
|
---|
145 | if (fPathOut.IsNull())
|
---|
146 | {
|
---|
147 | *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
|
---|
148 | return kTRUE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | TObjArray cont;
|
---|
152 | cont.Add(const_cast<TEnv*>(GetEnv()));
|
---|
153 | //cont.Add(const_cast<MSequence*>(&fSequence));
|
---|
154 |
|
---|
155 | cont.Add(plist.FindObject("PulseShape"));
|
---|
156 | cont.Add(plist.FindObject("Reflector"));
|
---|
157 | cont.Add(plist.FindObject("MGeomCam"));
|
---|
158 | cont.Add(plist.FindObject("GeomCones"));
|
---|
159 |
|
---|
160 | if (fDisplay)
|
---|
161 | {
|
---|
162 | // TString title = "-- Reflector: ";
|
---|
163 | // title += fSequence.GetSequence();
|
---|
164 | // title += " --";
|
---|
165 | // fDisplay->SetTitle(title, kFALSE);
|
---|
166 | fDisplay->SetTitle("Ceres", kFALSE);
|
---|
167 |
|
---|
168 | cont.Add(fDisplay);
|
---|
169 | }
|
---|
170 |
|
---|
171 | // const TString oname = Form("reflector%08d.root", fSequence.GetSequence());
|
---|
172 | const TString oname = "ceres.root";
|
---|
173 | return WriteContainer(cont, oname, "RECREATE");
|
---|
174 | }
|
---|
175 |
|
---|
176 | void MJSimulation::SetupHist(MHn &hist) const
|
---|
177 | {
|
---|
178 | hist.AddHist("MCorsikaEvtHeader.fTotalEnergy");
|
---|
179 | hist.InitName("Energy");
|
---|
180 | hist.InitTitle("Energy;E [GeV]");
|
---|
181 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
---|
182 |
|
---|
183 | hist.AddHist("MPhotonEvent.GetNumExternal");
|
---|
184 | hist.InitName("Size");
|
---|
185 | hist.InitTitle("Size;S [#]");
|
---|
186 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
---|
187 |
|
---|
188 | /*
|
---|
189 | hist.AddHist("-MCorsikaEvtHeader.fX/100","-MCorsikaEvtHeader.fY/100");
|
---|
190 | hist.SetDrawOption("colz");
|
---|
191 | hist.InitName("Impact;Impact;Impact");
|
---|
192 | hist.InitTitle("Impact;West <--> East [m];South <--> North [m]");
|
---|
193 | hist.SetAutoRange();
|
---|
194 | */
|
---|
195 |
|
---|
196 | hist.AddHist("MCorsikaEvtHeader.GetImpact/100");
|
---|
197 | hist.InitName("Impact");
|
---|
198 | hist.InitTitle("Impact;Impact [m]");
|
---|
199 | hist.SetAutoRange();
|
---|
200 |
|
---|
201 | hist.AddHist("MCorsikaEvtHeader.fFirstInteractionHeight/100000");
|
---|
202 | hist.InitName("Height");
|
---|
203 | hist.InitTitle("FirstInteractionHeight;h [km]");
|
---|
204 |
|
---|
205 | hist.AddHist("(MCorsikaEvtHeader.fAz+MCorsikaRunHeader.fMagneticFieldAz)*TMath::RadToDeg()", "MCorsikaEvtHeader.fZd*TMath::RadToDeg()");
|
---|
206 | hist.InitName("SkyOrigin;Az;Zd");
|
---|
207 | hist.InitTitle("Sky Origin;Az [\\deg];Zd [\\deg]");
|
---|
208 | hist.SetDrawOption("colz");
|
---|
209 | hist.SetAutoRange();
|
---|
210 |
|
---|
211 | TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
---|
212 | TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
---|
213 | TString cos = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())";
|
---|
214 |
|
---|
215 | TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()";
|
---|
216 |
|
---|
217 | hist.AddHist(form);
|
---|
218 | hist.InitName("ViewCone");
|
---|
219 | hist.InitTitle("Incident Angle;\\alpha [\\deg]");
|
---|
220 | }
|
---|
221 |
|
---|
222 | void MJSimulation::SetupCommonFileStructure(MWriteRootFile &write) const
|
---|
223 | {
|
---|
224 | // Common run headers
|
---|
225 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
226 | write.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
227 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
228 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
229 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
230 |
|
---|
231 | // Common events
|
---|
232 | write.AddContainer("MCorsikaEvtHeader", "Events", kFALSE);
|
---|
233 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
234 | write.AddContainer("MMcEvt", "Events");
|
---|
235 | }
|
---|
236 |
|
---|
237 | Bool_t MJSimulation::Process(const MArgs &args)
|
---|
238 | {
|
---|
239 | /*
|
---|
240 | if (!fSequence.IsValid())
|
---|
241 | {
|
---|
242 | *fLog << err << "ERROR - Sequence invalid!" << endl;
|
---|
243 | return kFALSE;
|
---|
244 | }
|
---|
245 | */
|
---|
246 |
|
---|
247 | //if (!HasWritePermission(GetPathOut()))
|
---|
248 | // return kFALSE;
|
---|
249 |
|
---|
250 | *fLog << inf;
|
---|
251 | fLog->Separator(GetDescriptor());
|
---|
252 |
|
---|
253 | if (!CheckEnv())
|
---|
254 | return kFALSE;
|
---|
255 |
|
---|
256 | *fLog << warn << "FIXME: Monte Carlo simulation: Sequences not supported yet.";
|
---|
257 | //*fLog << fSequence.GetFileName() << endl;
|
---|
258 | *fLog << endl;
|
---|
259 |
|
---|
260 | // --------------------------------------------------------------------------------
|
---|
261 |
|
---|
262 | //MDirIter iter;
|
---|
263 | //if (fSequence.GetRuns(iter, MSequence::kCalibrated)<=0)
|
---|
264 | // return kFALSE;
|
---|
265 |
|
---|
266 | // Setup Parlist
|
---|
267 | MParList plist;
|
---|
268 | plist.AddToList(this); // take care of fDisplay!
|
---|
269 |
|
---|
270 | // setup TaskList
|
---|
271 | MTaskList tasks;
|
---|
272 | plist.AddToList(&tasks);
|
---|
273 |
|
---|
274 | // --------------------------------------------------------------------------------
|
---|
275 |
|
---|
276 | // FIXME: Allow empty GeomCones!
|
---|
277 | MParEnv env0("Reflector");
|
---|
278 | MParEnv env1("GeomCones");
|
---|
279 | MParEnv env2("MGeomCam");
|
---|
280 | env0.SetClassName("MReflector");
|
---|
281 | env1.SetClassName("MGeomCam");
|
---|
282 | env2.SetClassName("MGeomCam");
|
---|
283 | plist.AddToList(&env0);
|
---|
284 | plist.AddToList(&env1);
|
---|
285 | plist.AddToList(&env2);
|
---|
286 |
|
---|
287 | plist.FindCreateObj("MPedPhotCam", "MPedPhotFromExtractorRndm");
|
---|
288 |
|
---|
289 | MParSpline shape("PulseShape");
|
---|
290 | plist.AddToList(&shape);
|
---|
291 |
|
---|
292 | // *** FIXME *** FIXME *** FIXME ***
|
---|
293 | plist.FindCreateObj("MMcRunHeader");
|
---|
294 |
|
---|
295 | MRawRunHeader header;
|
---|
296 | header.SetValidMagicNumber();
|
---|
297 | //header.InitFadcType(3);
|
---|
298 |
|
---|
299 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
|
---|
300 | if (args.GetNumArguments()==1)
|
---|
301 | {
|
---|
302 | if (!args.GetArgumentStr(0).CompareTo("pedestal", TString::kIgnoreCase))
|
---|
303 | {
|
---|
304 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
|
---|
305 | header.SetSourceInfo("Pedestal");
|
---|
306 | }
|
---|
307 | if (!args.GetArgumentStr(0).CompareTo("calibration", TString::kIgnoreCase))
|
---|
308 | {
|
---|
309 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
|
---|
310 | header.SetSourceInfo("Calibration");
|
---|
311 | }
|
---|
312 | if (!args.GetArgumentStr(0).CompareTo("pointrun", TString::kIgnoreCase))
|
---|
313 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
|
---|
314 | }
|
---|
315 |
|
---|
316 | // FIXME: Move to MSimPointingPos, MSimCalibrationSignal
|
---|
317 | // Can we use this as input for MSimPointingPos?
|
---|
318 | header.SetObservation("On", "MonteCarlo");
|
---|
319 | plist.AddToList(&header);
|
---|
320 | // ++++++++ FIXME FIXME FIXME +++++++++++++
|
---|
321 |
|
---|
322 | /*
|
---|
323 | MPedestalCam pedcam;
|
---|
324 | pedcam.Init(geomcam.GetNumPixels());
|
---|
325 | for (UInt_t i=0; i<geomcam.GetNumPixels(); i++)
|
---|
326 | pedcam[i].Set(128./header.GetScale(), 22.5/header.GetScale());
|
---|
327 | plist.AddToList(&pedcam);
|
---|
328 | */
|
---|
329 |
|
---|
330 | // -------------------------------------------------------------------
|
---|
331 |
|
---|
332 | MCorsikaRead read;
|
---|
333 | read.SetForceMode(fForceMode);
|
---|
334 |
|
---|
335 | for (int i=0; i<args.GetNumArguments(); i++)
|
---|
336 | read.AddFile(args.GetArgumentStr(i));
|
---|
337 |
|
---|
338 | MSimMMCS simmmcs;
|
---|
339 |
|
---|
340 | MParSpline splinepde("PhotonDetectionEfficiency");
|
---|
341 | MParSpline splinemirror("MirrorReflectivity");
|
---|
342 | MParSpline splinecones("ConesAngularAcceptance");
|
---|
343 | plist.AddToList(&splinepde);
|
---|
344 | plist.AddToList(&splinemirror);
|
---|
345 | plist.AddToList(&splinecones);
|
---|
346 |
|
---|
347 | MSimAtmosphere simatm;
|
---|
348 | MSimAbsorption absapd("SimPhotonDetectionEfficiency");
|
---|
349 | MSimAbsorption absmir("SimMirrorReflectivity");
|
---|
350 | MSimAbsorption cones("SimConesAngularAcceptance");
|
---|
351 | absapd.SetParName("PhotonDetectionEfficiency");
|
---|
352 | absmir.SetParName("MirrorReflectivity");
|
---|
353 | cones.SetParName("ConesAngularAcceptance");
|
---|
354 | cones.SetUseTheta();
|
---|
355 |
|
---|
356 | MSimPointingPos pointing;
|
---|
357 |
|
---|
358 | MSimReflector reflect;
|
---|
359 | reflect.SetNameGeomCam("GeomCones");
|
---|
360 | // MSimStarField stars;
|
---|
361 |
|
---|
362 | MContinue cont1("MPhotonEvent.GetNumPhotons<1", "ContEmpty1");
|
---|
363 | MContinue cont2("MPhotonEvent.GetNumPhotons<1", "ContEmpty2");
|
---|
364 | MContinue cont3("MPhotonEvent.GetNumPhotons<2", "ContEmpty3");
|
---|
365 |
|
---|
366 | // -------------------------------------------------------------------
|
---|
367 |
|
---|
368 | MBinning binse( 100, 1, 100000, "BinningEnergy", "log");
|
---|
369 | MBinning binsth( 70, 0.9, 900000, "BinningThreshold", "log");
|
---|
370 | MBinning binsee( 35, 0.9, 900000, "BinningEnergyEst", "log");
|
---|
371 | MBinning binss( 100, 1, 10000000, "BinningSize", "log");
|
---|
372 | // MBinning binsi( 100, -500, 500, "BinningImpact");
|
---|
373 | MBinning binsi( 55, 0, 1100, "BinningImpact");
|
---|
374 | MBinning binsh( 150, 0, 50, "BinningHeight");
|
---|
375 | MBinning binsaz(720, -360, 360, "BinningAz");
|
---|
376 | MBinning binszd( 70, 0, 70, "BinningZd");
|
---|
377 | MBinning binsvc( 45, 0, 9, "BinningViewCone");
|
---|
378 | MBinning binsel(150, 0, 50, "BinningTotLength");
|
---|
379 | MBinning binsew(150, 0, 15, "BinningMedLength");
|
---|
380 | MBinning binsd("BinningDistC");
|
---|
381 | MBinning binsd0("BinningDist");
|
---|
382 | MBinning binstr("BinningTrigPos");
|
---|
383 |
|
---|
384 | plist.AddToList(&binsee);
|
---|
385 | plist.AddToList(&binse);
|
---|
386 | plist.AddToList(&binsth);
|
---|
387 | plist.AddToList(&binss);
|
---|
388 | plist.AddToList(&binsi);
|
---|
389 | plist.AddToList(&binsh);
|
---|
390 | plist.AddToList(&binszd);
|
---|
391 | plist.AddToList(&binsaz);
|
---|
392 | plist.AddToList(&binsvc);
|
---|
393 | plist.AddToList(&binsel);
|
---|
394 | plist.AddToList(&binsew);
|
---|
395 | plist.AddToList(&binstr);
|
---|
396 | plist.AddToList(&binsd);
|
---|
397 | plist.AddToList(&binsd0);
|
---|
398 |
|
---|
399 | MHn mhn1, mhn2, mhn3, mhn4;
|
---|
400 | SetupHist(mhn1);
|
---|
401 | SetupHist(mhn2);
|
---|
402 | SetupHist(mhn3);
|
---|
403 | SetupHist(mhn4);
|
---|
404 |
|
---|
405 | MH3 mhtp("TriggerPos.fVal-IntendedPulsePos.fVal-PulseShape.GetWidth");
|
---|
406 | mhtp.SetName("TrigPos");
|
---|
407 | mhtp.SetTitle("Trigger position w.r.t. the first photon hitting a detector");
|
---|
408 |
|
---|
409 | MH3 mhew("MPhotonStatistics.fLength");
|
---|
410 | mhew.SetName("TotLength");
|
---|
411 | mhew.SetTitle("Time between first and last photon hitting a detector;L [ns]");
|
---|
412 |
|
---|
413 | MH3 mhed("MPhotonStatistics.fTimeMedDev");
|
---|
414 | mhed.SetName("MedLength");
|
---|
415 | mhed.SetTitle("Median deviation (1\\sigma);L [ns]");
|
---|
416 |
|
---|
417 | MFillH fillh1(&mhn1, "", "FillCorsika");
|
---|
418 | MFillH fillh2(&mhn2, "", "FillH2");
|
---|
419 | MFillH fillh3(&mhn3, "", "FillH3");
|
---|
420 | MFillH fillh4(&mhn4, "", "FillH4");
|
---|
421 | MFillH filltp(&mhtp, "", "FillTriggerPos");
|
---|
422 | MFillH fillew(&mhew, "", "FillEvtWidth");
|
---|
423 | MFillH filled(&mhed, "", "FillMedDev");
|
---|
424 | fillh1.SetNameTab("Corsika", "Distribution as simulated by Corsika");
|
---|
425 | fillh2.SetNameTab("Detectable", "Distribution of events hit the detector");
|
---|
426 | fillh3.SetNameTab("Triggered", "Distribution of triggered events");
|
---|
427 | fillh4.SetNameTab("Cleaned", "Distribution after cleaning and cuts");
|
---|
428 | filltp.SetNameTab("TrigPos", "TriggerPosition w.r.t the first photon");
|
---|
429 | fillew.SetNameTab("EvtWidth", "Time between first and last photon hitting a detector");
|
---|
430 | filled.SetNameTab("MedDev", "Time between first and last photon hitting a detector");
|
---|
431 |
|
---|
432 | MHPhotonEvent planeG(1); // Get from MaxImpact
|
---|
433 | MHPhotonEvent plane0(2); // Get from MReflector
|
---|
434 | MHPhotonEvent plane1(2);
|
---|
435 | MHPhotonEvent plane2(2);
|
---|
436 | MHPhotonEvent plane3(2);
|
---|
437 | MHPhotonEvent plane4(2);
|
---|
438 | MHPhotonEvent planeF1(3); // Get from MGeomCam
|
---|
439 | MHPhotonEvent planeF2(header.IsPointRun()?4:3); // Get from MGeomCam
|
---|
440 |
|
---|
441 | //MHPSF psf;
|
---|
442 |
|
---|
443 | MFillH fillG(&planeG, "MPhotonEvent", "FillGround");
|
---|
444 | MFillH fill0(&plane0, "MirrorPlane0", "FillReflector");
|
---|
445 | //MFillH fill1(&plane1, "MirrorPlane1", "FillCamShadow");
|
---|
446 | MFillH fill2(&plane2, "MirrorPlane2", "FillCandidates");
|
---|
447 | MFillH fill3(&plane3, "MirrorPlane3", "FillReflected");
|
---|
448 | MFillH fill4(&plane4, "MirrorPlane4", "FillFocal");
|
---|
449 | MFillH fillF1(&planeF1, "MPhotonEvent", "FillCamera");
|
---|
450 | MFillH fillF2(&planeF2, "MPhotonEvent", "FillCones");
|
---|
451 | //MFillH fillP(&psf, "MPhotonEvent", "FillPSF");
|
---|
452 |
|
---|
453 | fillG.SetNameTab("Ground", "Photon distribution at ground");
|
---|
454 | fill0.SetNameTab("Reflector", "Photon distribution at reflector plane w/o camera shadow");
|
---|
455 | //fill1.SetNameTab("CamShadow", "Photon distribution at reflector plane w/ camera shadow");
|
---|
456 | fill2.SetNameTab("Candidates", "'Can hit' photon distribution at reflector plane w/ camera shadow");
|
---|
457 | fill3.SetNameTab("Reflected", "Photon distribution after reflector projected to reflector plane");
|
---|
458 | fill4.SetNameTab("Focal", "Photon distribution at focal plane");
|
---|
459 | fillF1.SetNameTab("Camera", "Photon distribution which hit the detector");
|
---|
460 | fillF2.SetNameTab("Cones", "Photon distribution after cones");
|
---|
461 | //fillP.SetNameTab("PSF", "Photon distribution after cones for all mirrors");
|
---|
462 |
|
---|
463 | // -------------------------------------------------------------------
|
---|
464 |
|
---|
465 | // FIXME: Pedestal and Calibration runs should get P and C
|
---|
466 | const TString rule1(Form("s/cer([0-9]+)/%s\\/00$1_R_MonteCarlo.root/", Esc(fPathOut).Data()));
|
---|
467 | const TString rule2(Form("s/cer([0-9]+)/%s\\/00$1_Y_MonteCarlo.root/", Esc(fPathOut).Data()));
|
---|
468 | const TString rule3(Form("s/cer([0-9]+)/%s\\/00$1_D_MonteCarlo.root/", Esc(fPathOut).Data()));
|
---|
469 |
|
---|
470 | MWriteRootFile write3a( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
|
---|
471 | MWriteRootFile write3b( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
|
---|
472 | MWriteRootFile write2a( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file");
|
---|
473 | MWriteRootFile write2b( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file");
|
---|
474 | MWriteRootFile write1a( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file");
|
---|
475 | MWriteRootFile write1b( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file");
|
---|
476 |
|
---|
477 | write1a.SetName("WriteRefData");
|
---|
478 | write1b.SetName("WriteRefMC");
|
---|
479 | write2a.SetName("WriteSigData");
|
---|
480 | write2b.SetName("WriteSigMC");
|
---|
481 | write3a.SetName("WriteCamData");
|
---|
482 | write3b.SetName("WriteCamMC");
|
---|
483 |
|
---|
484 | SetupCommonFileStructure(write1a);
|
---|
485 | SetupCommonFileStructure(write2a);
|
---|
486 | SetupCommonFileStructure(write3a);
|
---|
487 |
|
---|
488 | // R: Dedicated file structureedicated events
|
---|
489 | write1a.AddContainer("MPhotonEvent", "Events");
|
---|
490 |
|
---|
491 | // I: Dedicated file structureedicated events
|
---|
492 | write2a.AddContainer("MPedPhotFromExtractorRndm", "RunHeaders"); // FIXME: Needed for the signal files to be display in MARS
|
---|
493 | write2a.AddContainer("MSignalCam", "Events");
|
---|
494 |
|
---|
495 | // D: Dedicated file structureedicated events
|
---|
496 | write3a.AddContainer("ElectronicNoise", "RunHeaders");
|
---|
497 | write3a.AddContainer("MRawEvtData", "Events");
|
---|
498 |
|
---|
499 | // Basic MC data
|
---|
500 | write1b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
501 | write2b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
502 | write3b.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
503 |
|
---|
504 | // -------------------------------------------------------------------
|
---|
505 |
|
---|
506 | MGeomApply apply;
|
---|
507 |
|
---|
508 | MSimPSF simpsf;
|
---|
509 |
|
---|
510 | MSimGeomCam simgeom;
|
---|
511 | simgeom.SetNameGeomCam("GeomCones");
|
---|
512 |
|
---|
513 | MSimCalibrationSignal simcal;
|
---|
514 | simcal.SetNameGeomCam("GeomCones");
|
---|
515 |
|
---|
516 | // FIXME: Simulate photons before cones and QE!
|
---|
517 |
|
---|
518 | MSimRandomPhotons simnsb;
|
---|
519 | simnsb.SetFreq(5.8, 0.004); // ph/m^2/nm/sr/ns NSB, 4MHz dark count rate
|
---|
520 | simnsb.SetNameGeomCam("GeomCones");
|
---|
521 |
|
---|
522 | // FIXME: How do we handle star-light? We need the rate but we also
|
---|
523 | // need to process it through the mirror!
|
---|
524 |
|
---|
525 | MSimAPD simapd;
|
---|
526 | simapd.SetNameGeomCam("GeomCones");
|
---|
527 |
|
---|
528 | MSimExcessNoise simexcnoise;
|
---|
529 | MSimBundlePhotons simsum;
|
---|
530 | MSimSignalCam simsignal;
|
---|
531 | MSimCamera simcam;
|
---|
532 | MSimTrigger simtrig;
|
---|
533 | MSimReadout simdaq;
|
---|
534 |
|
---|
535 | MContinue conttrig("TriggerPos.fVal<0", "ContTrigger");
|
---|
536 |
|
---|
537 | MParameterD pulpos("IntendedPulsePos");
|
---|
538 | // FIXME: Set a default which could be 1/3 of the digitization window
|
---|
539 | // pulpos.SetVal(40); // [ns]
|
---|
540 | plist.AddToList(&pulpos);
|
---|
541 |
|
---|
542 | MParameterD trigger("TriggerPos");
|
---|
543 | trigger.SetVal(0);
|
---|
544 | plist.AddToList(&trigger);
|
---|
545 |
|
---|
546 | // -------------------------------------------------------------------
|
---|
547 |
|
---|
548 | // Remove isolated pixels
|
---|
549 | MImgCleanStd clean(0, 0);
|
---|
550 | clean.SetCleanLvl0(0); // The level above which isolated pixels are kept
|
---|
551 | clean.SetCleanRings(0);
|
---|
552 | clean.SetMethod(MImgCleanStd::kAbsolute);
|
---|
553 |
|
---|
554 | //clean.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
555 |
|
---|
556 | MHillasCalc hcalc;
|
---|
557 | hcalc.Disable(MHillasCalc::kCalcConc);
|
---|
558 |
|
---|
559 | MHCamEvent evt0a(/*10*/3, "Signal", "Average signal (absolute);;S [ph]");
|
---|
560 | MHCamEvent evt0c(/*10*/3, "MaxSignal", "Maximum signal (absolute);;S [ph]");
|
---|
561 | MHCamEvent evt0d(/*11*/8, "ArrTm", "Time after first photon;;T [ns]");
|
---|
562 | evt0a.SetErrorSpread(kFALSE);
|
---|
563 | evt0c.SetCollectMax();
|
---|
564 |
|
---|
565 | MContinue cut("", "Cut");
|
---|
566 |
|
---|
567 | MFillH fillx0a(&evt0a, "MSignalCam", "FillAvgSignal");
|
---|
568 | MFillH fillx0c(&evt0c, "MSignalCam", "FillMaxSignal");
|
---|
569 | MFillH fillx0d(&evt0d, "MSignalCam", "FillArrTm");
|
---|
570 | MFillH fillx1("MHHillas", "MHillas", "FillHillas");
|
---|
571 | MFillH fillx3("MHHillasSrc", "MHillasSrc", "FillHillasSrc");
|
---|
572 | MFillH fillx4("MHNewImagePar", "MNewImagePar", "FillNewImagePar");
|
---|
573 | MFillH fillth("MHThreshold", "", "FillThreshold");
|
---|
574 | MFillH fillca("MHCollectionArea", "", "FillTrigArea");
|
---|
575 |
|
---|
576 | fillth.SetNameTab("Threshold");
|
---|
577 | fillca.SetNameTab("TrigArea");
|
---|
578 |
|
---|
579 | // -------------------------------------------------------------------
|
---|
580 |
|
---|
581 | if (header.IsDataRun())
|
---|
582 | {
|
---|
583 | tasks.AddToList(&read);
|
---|
584 | tasks.AddToList(&pointing);
|
---|
585 | tasks.AddToList(&simmmcs);
|
---|
586 | if (!fPathOut.IsNull() && !HasNullOut())
|
---|
587 | {
|
---|
588 | tasks.AddToList(&write1b);
|
---|
589 | tasks.AddToList(&write2b);
|
---|
590 | if (fCamera)
|
---|
591 | tasks.AddToList(&write3b);
|
---|
592 | }
|
---|
593 | // if (header.IsPointRun())
|
---|
594 | // tasks.AddToList(&stars);
|
---|
595 | if (1)
|
---|
596 | tasks.AddToList(&simatm); // Here because before fillh1
|
---|
597 | tasks.AddToList(&fillh1);
|
---|
598 | tasks.AddToList(&fillG);
|
---|
599 | if (!header.IsPointRun())
|
---|
600 | {
|
---|
601 | tasks.AddToList(&absapd);
|
---|
602 | tasks.AddToList(&absmir);
|
---|
603 | if (0)
|
---|
604 | tasks.AddToList(&simatm); // FASTER?
|
---|
605 | }
|
---|
606 | tasks.AddToList(&reflect);
|
---|
607 | if (!header.IsPointRun())
|
---|
608 | {
|
---|
609 | tasks.AddToList(&fill0);
|
---|
610 | //tasks.AddToList(&fill1);
|
---|
611 | tasks.AddToList(&fill2);
|
---|
612 | tasks.AddToList(&fill3);
|
---|
613 | tasks.AddToList(&fill4);
|
---|
614 | tasks.AddToList(&fillF1);
|
---|
615 | }
|
---|
616 | tasks.AddToList(&cones);
|
---|
617 | //if (header.IsPointRun())
|
---|
618 | // tasks.AddToList(&fillP);
|
---|
619 | tasks.AddToList(&cont1);
|
---|
620 | }
|
---|
621 | // -------------------------------
|
---|
622 | tasks.AddToList(&apply);
|
---|
623 | if (header.IsDataRun())
|
---|
624 | {
|
---|
625 | tasks.AddToList(&simpsf);
|
---|
626 | tasks.AddToList(&simgeom);
|
---|
627 | tasks.AddToList(&cont2);
|
---|
628 | if (!header.IsPointRun())
|
---|
629 | {
|
---|
630 | tasks.AddToList(&fillF2);
|
---|
631 | tasks.AddToList(&fillh2);
|
---|
632 | }
|
---|
633 | tasks.AddToList(&cont3);
|
---|
634 | }
|
---|
635 | if (fCamera)
|
---|
636 | {
|
---|
637 | if (header.IsPedestalRun() || header.IsCalibrationRun())
|
---|
638 | tasks.AddToList(&simcal);
|
---|
639 | tasks.AddToList(&simnsb);
|
---|
640 | tasks.AddToList(&simapd);
|
---|
641 | tasks.AddToList(&simexcnoise);
|
---|
642 | }
|
---|
643 | tasks.AddToList(&simsum);
|
---|
644 | if (fCamera)
|
---|
645 | {
|
---|
646 | tasks.AddToList(&simcam);
|
---|
647 | if (header.IsDataRun() || fForceTrigger)
|
---|
648 | tasks.AddToList(&simtrig);
|
---|
649 | tasks.AddToList(&conttrig);
|
---|
650 | tasks.AddToList(&simdaq);
|
---|
651 | }
|
---|
652 | tasks.AddToList(&simsignal); // What do we do if signal<0?
|
---|
653 | if (!fPathOut.IsNull() && !HasNullOut())
|
---|
654 | {
|
---|
655 | tasks.AddToList(&write1a);
|
---|
656 | if (!header.IsPedestalRun())
|
---|
657 | tasks.AddToList(&write2a);
|
---|
658 | if (fCamera)
|
---|
659 | tasks.AddToList(&write3a);
|
---|
660 | }
|
---|
661 | // -------------------------------
|
---|
662 | if (fCamera)
|
---|
663 | {
|
---|
664 | // FIXME: MHCollectionArea Trigger Area!
|
---|
665 | if (header.IsDataRun())
|
---|
666 | tasks.AddToList(&fillh3);
|
---|
667 | tasks.AddToList(&filltp);
|
---|
668 | }
|
---|
669 | if (header.IsDataRun())
|
---|
670 | {
|
---|
671 | tasks.AddToList(&fillew);
|
---|
672 | tasks.AddToList(&filled);
|
---|
673 | }
|
---|
674 | if (!header.IsPedestalRun())
|
---|
675 | {
|
---|
676 | tasks.AddToList(&fillx0a);
|
---|
677 | tasks.AddToList(&fillx0c);
|
---|
678 | if (!header.IsCalibrationRun())
|
---|
679 | tasks.AddToList(&clean);
|
---|
680 | tasks.AddToList(&hcalc);
|
---|
681 | tasks.AddToList(&cut);
|
---|
682 | tasks.AddToList(&fillx0d);
|
---|
683 | tasks.AddToList(&fillx1);
|
---|
684 | //tasks.AddToList(&fillx2);
|
---|
685 | tasks.AddToList(&fillx3);
|
---|
686 | tasks.AddToList(&fillx4);
|
---|
687 | //tasks.AddToList(&fillx5);
|
---|
688 | }
|
---|
689 | if (header.IsDataRun())
|
---|
690 | {
|
---|
691 | tasks.AddToList(&fillh4);
|
---|
692 | tasks.AddToList(&fillth);
|
---|
693 | tasks.AddToList(&fillca);
|
---|
694 | }
|
---|
695 | //-------------------------------------------
|
---|
696 |
|
---|
697 | tasks.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime);
|
---|
698 |
|
---|
699 | // Create and setup the eventloop
|
---|
700 | MEvtLoop evtloop(fName);
|
---|
701 | evtloop.SetParList(&plist);
|
---|
702 | evtloop.SetDisplay(fDisplay);
|
---|
703 | evtloop.SetLogStream(&gLog);
|
---|
704 | if (!SetupEnv(evtloop))
|
---|
705 | return kFALSE;
|
---|
706 |
|
---|
707 | // FIXME: If pedestal file given use the values from this file
|
---|
708 | //-------------------------------------------
|
---|
709 |
|
---|
710 | MGeomCam *cam = static_cast<MGeomCam*>(env2.GetCont());
|
---|
711 |
|
---|
712 | if (binstr.IsDefault())
|
---|
713 | binstr.SetEdgesLin(150, -shape.GetWidth(),
|
---|
714 | header.GetFreqSampling()/1000.*header.GetNumSamples()+shape.GetWidth());
|
---|
715 |
|
---|
716 | if (binsd.IsDefault() && cam)
|
---|
717 | binsd.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
|
---|
718 |
|
---|
719 | if (binsd0.IsDefault() && cam)
|
---|
720 | binsd0.SetEdgesLin(100, 0, cam->GetMaxRadius()*cam->GetConvMm2Deg());
|
---|
721 |
|
---|
722 |
|
---|
723 | header.Print();
|
---|
724 |
|
---|
725 | // FIXME: Display acceptance curves!
|
---|
726 |
|
---|
727 | if (fDisplay)
|
---|
728 | {
|
---|
729 | TCanvas &c = fDisplay->AddTab("Info");
|
---|
730 | c.Divide(2,2);
|
---|
731 |
|
---|
732 | c.cd(1);
|
---|
733 | gPad->SetBorderMode(0);
|
---|
734 | gPad->SetFrameBorderMode(0);
|
---|
735 | gPad->SetGridx();
|
---|
736 | gPad->SetGridy();
|
---|
737 | gROOT->SetSelectedPad(0);
|
---|
738 | shape.DrawClone()->SetBit(kCanDelete);
|
---|
739 |
|
---|
740 | if (env0.GetCont() && (header.IsDataRun() || header.IsPointRun()))
|
---|
741 | {
|
---|
742 | c.cd(3);
|
---|
743 | gPad->SetBorderMode(0);
|
---|
744 | gPad->SetFrameBorderMode(0);
|
---|
745 | gPad->SetGridx();
|
---|
746 | gPad->SetGridy();
|
---|
747 | gROOT->SetSelectedPad(0);
|
---|
748 | static_cast<MReflector*>(env0.GetCont())->DrawClone("line")->SetBit(kCanDelete);
|
---|
749 | }
|
---|
750 |
|
---|
751 | if (fCamera)
|
---|
752 | {
|
---|
753 | if (env1.GetCont())
|
---|
754 | {
|
---|
755 | c.cd(2);
|
---|
756 | gPad->SetBorderMode(0);
|
---|
757 | gPad->SetFrameBorderMode(0);
|
---|
758 | gPad->SetGridx();
|
---|
759 | gPad->SetGridy();
|
---|
760 | gROOT->SetSelectedPad(0);
|
---|
761 | MHCamera *c = new MHCamera(static_cast<MGeomCam&>(*env1.GetCont()));
|
---|
762 | c->SetStats(kFALSE);
|
---|
763 | c->SetBit(MHCamera::kNoLegend);
|
---|
764 | c->SetBit(kCanDelete);
|
---|
765 | c->Draw();
|
---|
766 | }
|
---|
767 |
|
---|
768 | if (cam)
|
---|
769 | {
|
---|
770 | c.cd(4);
|
---|
771 | gPad->SetBorderMode(0);
|
---|
772 | gPad->SetFrameBorderMode(0);
|
---|
773 | gPad->SetGridx();
|
---|
774 | gPad->SetGridy();
|
---|
775 | gROOT->SetSelectedPad(0);
|
---|
776 | MHCamera *c = new MHCamera(*cam);
|
---|
777 | c->SetStats(kFALSE);
|
---|
778 | c->SetBit(MHCamera::kNoLegend);
|
---|
779 | c->SetBit(kCanDelete);
|
---|
780 | c->Draw();
|
---|
781 | }
|
---|
782 | }
|
---|
783 |
|
---|
784 | TCanvas &d = fDisplay->AddTab("Info2");
|
---|
785 | d.Divide(2,2);
|
---|
786 |
|
---|
787 | d.cd(1);
|
---|
788 | gPad->SetBorderMode(0);
|
---|
789 | gPad->SetFrameBorderMode(0);
|
---|
790 | gPad->SetGridx();
|
---|
791 | gPad->SetGridy();
|
---|
792 | gROOT->SetSelectedPad(0);
|
---|
793 | splinepde.DrawClone()->SetBit(kCanDelete);
|
---|
794 |
|
---|
795 | d.cd(2);
|
---|
796 | gPad->SetBorderMode(0);
|
---|
797 | gPad->SetFrameBorderMode(0);
|
---|
798 | gPad->SetGridx();
|
---|
799 | gPad->SetGridy();
|
---|
800 | gROOT->SetSelectedPad(0);
|
---|
801 | splinemirror.DrawClone()->SetBit(kCanDelete);
|
---|
802 |
|
---|
803 | d.cd(3);
|
---|
804 | gPad->SetBorderMode(0);
|
---|
805 | gPad->SetFrameBorderMode(0);
|
---|
806 | gPad->SetGridx();
|
---|
807 | gPad->SetGridy();
|
---|
808 | gROOT->SetSelectedPad(0);
|
---|
809 | splinecones.DrawClone()->SetBit(kCanDelete);
|
---|
810 |
|
---|
811 | d.cd(4);
|
---|
812 | gPad->SetBorderMode(0);
|
---|
813 | gPad->SetFrameBorderMode(0);
|
---|
814 | gPad->SetGridx();
|
---|
815 | gPad->SetGridy();
|
---|
816 | gROOT->SetSelectedPad(0);
|
---|
817 | MParSpline *all = (MParSpline*)splinepde.DrawClone();
|
---|
818 | //all->SetTitle("Combined acceptance");
|
---|
819 | all->SetBit(kCanDelete);
|
---|
820 | all->Multiply(*splinemirror.GetSpline());
|
---|
821 | }
|
---|
822 |
|
---|
823 | //-------------------------------------------
|
---|
824 |
|
---|
825 | // Execute first analysis
|
---|
826 | if (!evtloop.Eventloop(fMaxEvents))
|
---|
827 | {
|
---|
828 | gLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
829 | return kFALSE;
|
---|
830 | }
|
---|
831 |
|
---|
832 | //-------------------------------------------
|
---|
833 | // FIXME: Display Spline in tab
|
---|
834 | // FIXME: Display Reflector in tab
|
---|
835 | // FIXME: Display Routing(?) in tab
|
---|
836 | // FIXME: Display Camera(s) in tab
|
---|
837 | //-------------------------------------------
|
---|
838 |
|
---|
839 | if (!WriteResult(plist))
|
---|
840 | return kFALSE;
|
---|
841 |
|
---|
842 | *fLog << all << GetDescriptor() << ": Done." << endl << endl << endl;;
|
---|
843 |
|
---|
844 | return kTRUE;
|
---|
845 | }
|
---|