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

Last change on this file since 6491 was 6403, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 5.2 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_train.root"; // File to be analyzed
41 // Char_t* AnalysisFilename = "calibrated_gamma_test.root"; // File to be analyzed
42
43 TString* OutFilename;
44
45 // Output file name
46 OutFilename = new TString("star_gamma_train.root"); // Output file name
47 // OutFilename = new TString("star_gamma_test.root"); // Output file name
48
49 MImgCleanStd clean(4.5, 3.); // Applies tail cuts to image.
50 // WARNING: the tightness of the tail cuts depends on the signal extraction method
51 // used in mccalibrate.C!! (some methods result in positively biased signals)
52
53 // ------------------------------------------------------------------
54
55 //
56 // Create a empty Parameter List and an empty Task List
57 // The tasklist is identified in the eventloop by its name
58 //
59 MParList plist;
60
61 MTaskList tlist;
62
63 plist.AddToList(&tlist);
64
65 MSrcPosCam src;
66 //
67 // FOR WOBBLE MODE!! Set source position on camera here.
68 // src.SetX(120.);
69 // units: mm. This 120 mm correspond to MC wobble mode w+ for zbin>0
70 //
71
72 src.SetReadyToSave();
73
74 plist.AddToList(&src);
75
76 //
77 // Now setup the tasks and tasklist:
78 // ---------------------------------
79 //
80 MReadMarsFile read("Events");
81
82 read.AddFile(AnalysisFilename);
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 write(OutFilename->Data()); // Writes output
97 //
98 // Add MC containers only if they exist.
99 // In this way you can also run on real calibrated data.
100 //
101 write.AddContainer("MRawRunHeader", "RunHeaders");
102 write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
103 write.AddContainer("MGeomCam", "RunHeaders", kFALSE);
104 write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
105 write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
106 write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
107 write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
108
109 write.AddContainer("MMcEvt", "Events", kFALSE);
110 write.AddContainer("MPointingPos", "Events", kFALSE);
111 write.AddContainer("MMcTrig", "Events", kFALSE);
112 write.AddContainer("MSrcPosCam", "Events", kFALSE);
113 write.AddContainer("MRawEvtHeader", "Events");
114 write.AddContainer("MHillas", "Events");
115 write.AddContainer("MHillasExt", "Events");
116 write.AddContainer("MHillasSrc", "Events");
117 write.AddContainer("MImagePar", "Events");
118 write.AddContainer("MNewImagePar", "Events");
119 write.AddContainer("MConcentration","Events");
120
121 tlist.AddToList(&write);
122
123 //
124 // analysis loop
125 //
126
127 MEvtLoop evtloop;
128 MProgressBar bar;
129 bar.SetWindowName("Analyzing...");
130 evtloop.SetProgressBar(&bar);
131 evtloop.SetParList(&plist);
132
133 if (!evtloop.Eventloop())
134 return;
135
136 tlist.PrintStatistics();
137
138 ////////////////////////////////////////////////////////////////////
139 //
140 // Second event loop: simply copy the tree MMcEvtBasic in the tree
141 // "OriginalMC" from the input file to the output file:
142
143 MParList plist2;
144 MTaskList tlist2;
145
146 plist2.AddToList(&tlist2);
147
148 MReadMarsFile read2("OriginalMC");
149 read2.AddFile(AnalysisFilename);
150 read2.DisableAutoScheme();
151
152 tlist2.AddToList(&read2);
153
154 MWriteRootFile writeOrig(OutFilename->Data(),"UPDATE");
155 writeOrig.AddContainer("MMcEvtBasic", "OriginalMC", kFALSE);
156
157 tlist2.AddToList(&writeOrig);
158
159 MEvtLoop evtloop2;
160 bar.SetWindowName("Copying OriginalMC tree...");
161 evtloop2.SetProgressBar(&bar);
162 evtloop2.SetParList(&plist2);
163
164 if (!evtloop2.Eventloop())
165 return;
166
167 tlist2.PrintStatistics();
168
169 return;
170}
Note: See TracBrowser for help on using the repository browser.