source: trunk/MagicSoft/Mars/macros/starmc2.C@ 6362

Last change on this file since 6362 was 6357, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 6.1 KB
Line 
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
38void 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 MImgCleanStd clean(4.5, 3.); // Applies tail cuts to image.
51 // WARNING: the tightness of the tail cuts depends on the signal extraction method
52 // used in mccalibrate.C!! (some methods result in positively biased signals)
53
54 // ------------------------------------------------------------------
55
56 //
57 // Create a empty Parameter List and an empty Task List
58 // The tasklist is identified in the eventloop by its name
59 //
60 MParList plist;
61
62 MTaskList tlist;
63
64 plist.AddToList(&tlist);
65
66 MSrcPosCam src;
67 //
68 // FOR WOBBLE MODE!! Set source position on camera here.
69 // src.SetX(120.); // units: mm
70
71 src.SetReadyToSave();
72
73 plist.AddToList(&src);
74
75 //
76 // Now setup the tasks and tasklist:
77 // ---------------------------------
78 //
79 MReadMarsFile read("Events");
80
81 read.AddFile(AnalysisFilename);
82
83 read.DisableAutoScheme();
84
85
86 MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
87 hcalc.Enable(MHillasCalc::kCalcHillasSrc);
88
89 tlist.AddToList(&read);
90 tlist.AddToList(&clean);
91 tlist.AddToList(&hcalc);
92
93 //
94 // Open output file(s):
95 //
96 MWriteRootFile write1(OutFilename1->Data()); // Writes output
97 //
98 // Add MC containers only if they exist. In this way you can also run on real calibrated data.
99 //
100 write1.AddContainer("MRawRunHeader", "RunHeaders");
101 write1.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
102 write1.AddContainer("MGeomCam", "RunHeaders", kFALSE);
103 write1.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
104 write1.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
105 write1.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
106 write1.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
107
108 write1.AddContainer("MMcEvt", "Events", kFALSE);
109 write1.AddContainer("MPointingPos", "Events", kFALSE);
110 write1.AddContainer("MMcTrig", "Events", kFALSE);
111 write1.AddContainer("MSrcPosCam", "Events", kFALSE);
112 write1.AddContainer("MRawEvtHeader", "Events");
113 write1.AddContainer("MHillas", "Events");
114 write1.AddContainer("MHillasExt", "Events");
115 write1.AddContainer("MHillasSrc", "Events");
116 write1.AddContainer("MImagePar", "Events");
117 write1.AddContainer("MNewImagePar", "Events");
118 write1.AddContainer("MConcentration","Events");
119
120 if (OutFilename2) // Second output file, in case we want a split output
121 {
122 MWriteRootFile write2(OutFilename2->Data()); // Writes output
123 write2.AddContainer("MRawRunHeader", "RunHeaders");
124 write2.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
125 write2.AddContainer("MGeomCam", "RunHeaders", kFALSE);
126 write2.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
127 write2.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
128 write2.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
129 write2.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
130
131 write2.AddContainer("MMcEvt", "Events", kFALSE);
132 write2.AddContainer("MPointingPos", "Events", kFALSE);
133 write2.AddContainer("MMcTrig", "Events", kFALSE);
134 write2.AddContainer("MSrcPosCam", "Events", kFALSE);
135 write2.AddContainer("MRawEvtHeader", "Events");
136 write2.AddContainer("MHillas", "Events");
137 write2.AddContainer("MHillasExt", "Events");
138 write2.AddContainer("MHillasSrc", "Events");
139 write2.AddContainer("MImagePar", "Events");
140 write2.AddContainer("MNewImagePar", "Events");
141 write2.AddContainer("MConcentration","Events");
142
143 //
144 // Divide output in train and test samples, using the event number
145 // (odd/even) to achieve otherwise unbiased event samples:
146 //
147
148 MF filter1("{MMcEvt.fEvtNumber%2}>0.5");
149 MF filter2("{MMcEvt.fEvtNumber%2}<0.5");
150
151 write1.SetFilter(&filter1);
152 write2.SetFilter(&filter2);
153
154 tlist.AddToList(&filter1);
155 tlist.AddToList(&filter2);
156 }
157
158
159 tlist.AddToList(&write1);
160
161 if (OutFilename2)
162 tlist.AddToList(&write2);
163
164
165 //
166 // analysis loop
167 //
168
169 MEvtLoop evtloop;
170 MProgressBar bar;
171 bar.SetWindowName("Analyzing...");
172 evtloop.SetProgressBar(&bar);
173 evtloop.SetParList(&plist);
174
175 if (!evtloop.Eventloop())
176 return;
177
178 tlist.PrintStatistics();
179
180 return;
181}
Note: See TracBrowser for help on using the repository browser.