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): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
|
---|
19 | ! Thomas Bretz 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // STARMC2 - STandard Analysis and Reconstruction (MC example)
|
---|
29 | //
|
---|
30 | // This macro converts into image parameters an input file of MC data
|
---|
31 | // previously calibrated (see mccalibrate.C).
|
---|
32 | //
|
---|
33 | //
|
---|
34 | /////////////////////////////////////////////////////////////////////////////
|
---|
35 |
|
---|
36 | #include "MImgCleanStd.h"
|
---|
37 |
|
---|
38 | void starmc2()
|
---|
39 | {
|
---|
40 | Char_t* AnalysisFilename = "../calibrated_gamma.root"; // File to be analyzed
|
---|
41 |
|
---|
42 | TString* OutFilename1;
|
---|
43 | TString* OutFilename2;
|
---|
44 |
|
---|
45 | // Change output file names as desired. If you want only one output, comment
|
---|
46 | // out the initialization of OutFilename2:
|
---|
47 | OutFilename1 = new TString("star_gamma_train.root"); // Output file name 1 (test)
|
---|
48 | OutFilename2 = new TString("star_gamma_test.root"); // Output file name 2 (train)
|
---|
49 |
|
---|
50 | Float_t CleanLev[2] = {3.84, 2.56}; // Tail cuts for image analysis
|
---|
51 |
|
---|
52 | // ------------------------------------------------------------------
|
---|
53 |
|
---|
54 | //
|
---|
55 | // Create a empty Parameter List and an empty Task List
|
---|
56 | // The tasklist is identified in the eventloop by its name
|
---|
57 | //
|
---|
58 | MParList plist;
|
---|
59 |
|
---|
60 | MTaskList tlist;
|
---|
61 |
|
---|
62 | plist.AddToList(&tlist);
|
---|
63 |
|
---|
64 | MSrcPosCam src;
|
---|
65 | //
|
---|
66 | // FOR WOBBLE MODE!! Set source position on camera here.
|
---|
67 | src.SetX(120.); // units: mm
|
---|
68 |
|
---|
69 | src.SetReadyToSave();
|
---|
70 |
|
---|
71 | plist.AddToList(&src);
|
---|
72 |
|
---|
73 | //
|
---|
74 | // Now setup the tasks and tasklist:
|
---|
75 | // ---------------------------------
|
---|
76 | //
|
---|
77 | MReadMarsFile read("Events");
|
---|
78 |
|
---|
79 | read.AddFile(AnalysisFilename);
|
---|
80 |
|
---|
81 | read.DisableAutoScheme();
|
---|
82 |
|
---|
83 | MImgCleanStd clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
|
---|
84 |
|
---|
85 | MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
|
---|
86 | hcalc.Enable(MHillasCalc::kCalcHillasSrc);
|
---|
87 |
|
---|
88 | tlist.AddToList(&read);
|
---|
89 | tlist.AddToList(&clean);
|
---|
90 | tlist.AddToList(&hcalc);
|
---|
91 |
|
---|
92 | //
|
---|
93 | // Open output file(s):
|
---|
94 | //
|
---|
95 | MWriteRootFile write1(OutFilename1->Data()); // Writes output
|
---|
96 | //
|
---|
97 | // Add MC containers only if they exist. In this way you can also run on real calibrated data.
|
---|
98 | //
|
---|
99 | write1.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
100 | write1.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
101 | write1.AddContainer("MGeomCam", "RunHeaders", kFALSE);
|
---|
102 | write1.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
103 | write1.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
104 | write1.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
---|
105 | write1.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
106 |
|
---|
107 | write1.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
108 | write1.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
109 | write1.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
110 | write1.AddContainer("MSrcPosCam", "Events", kFALSE);
|
---|
111 | write1.AddContainer("MRawEvtHeader", "Events");
|
---|
112 | write1.AddContainer("MHillas", "Events");
|
---|
113 | write1.AddContainer("MHillasExt", "Events");
|
---|
114 | write1.AddContainer("MHillasSrc", "Events");
|
---|
115 | write1.AddContainer("MImagePar", "Events");
|
---|
116 | write1.AddContainer("MNewImagePar", "Events");
|
---|
117 |
|
---|
118 | if (OutFilename2) // Second output file, in case we want a split output
|
---|
119 | {
|
---|
120 | MWriteRootFile write2(OutFilename2->Data()); // Writes output
|
---|
121 | write2.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
122 | write2.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
123 | write2.AddContainer("MGeomCam", "RunHeaders", kFALSE);
|
---|
124 | write2.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
125 | write2.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
126 | write2.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
---|
127 | write2.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
128 |
|
---|
129 | write2.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
130 | write2.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
131 | write2.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
132 | write2.AddContainer("MSrcPosCam", "Events", kFALSE);
|
---|
133 | write2.AddContainer("MRawEvtHeader", "Events");
|
---|
134 | write2.AddContainer("MHillas", "Events");
|
---|
135 | write2.AddContainer("MHillasExt", "Events");
|
---|
136 | write2.AddContainer("MHillasSrc", "Events");
|
---|
137 | write2.AddContainer("MImagePar", "Events");
|
---|
138 | write2.AddContainer("MNewImagePar", "Events");
|
---|
139 |
|
---|
140 | //
|
---|
141 | // Divide output in train and test samples, using the event number
|
---|
142 | // (odd/even) to achieve otherwise unbiased event samples:
|
---|
143 | //
|
---|
144 |
|
---|
145 | MF filter1("{MMcEvt.fEvtNumber%2}>0.5");
|
---|
146 | MF filter2("{MMcEvt.fEvtNumber%2}<0.5");
|
---|
147 |
|
---|
148 | write1.SetFilter(&filter1);
|
---|
149 | write2.SetFilter(&filter2);
|
---|
150 |
|
---|
151 | tlist.AddToList(&filter1);
|
---|
152 | tlist.AddToList(&filter2);
|
---|
153 | }
|
---|
154 |
|
---|
155 |
|
---|
156 | tlist.AddToList(&write1);
|
---|
157 |
|
---|
158 | if (OutFilename2)
|
---|
159 | tlist.AddToList(&write2);
|
---|
160 |
|
---|
161 |
|
---|
162 | //
|
---|
163 | // analysis loop
|
---|
164 | //
|
---|
165 |
|
---|
166 | MEvtLoop evtloop;
|
---|
167 | MProgressBar bar;
|
---|
168 | bar.SetWindowName("Analyzing...");
|
---|
169 | evtloop.SetProgressBar(&bar);
|
---|
170 | evtloop.SetParList(&plist);
|
---|
171 |
|
---|
172 | if (!evtloop.Eventloop())
|
---|
173 | return;
|
---|
174 |
|
---|
175 | tlist.PrintStatistics();
|
---|
176 |
|
---|
177 | return;
|
---|
178 | }
|
---|