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