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