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