source: trunk/MagicSoft/Mars/macros/starmc.C@ 3183

Last change on this file since 3183 was 2981, checked in by moralejo, 21 years ago
*** empty log message ***
File size: 5.6 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// STARMC - STandard Analysis and Reconstruction (MC example)
29//
30// This macro is a version of the standard converter to convert raw data
31// into image parameters, made to show how to run analysis on MC files.
32//
33/////////////////////////////////////////////////////////////////////////////
34
35#include "MImgCleanStd.h"
36
37void starmc()
38{
39 //
40 // This is a demonstration program which calculates the image
41 // parameters from Magic Monte Carlo files (output of camera).
42
43
44 // ------------- user change -----------------
45
46 TString* CalibrationFilename;
47
48 //
49 // Comment out next line to disable calibration. In that case the units of the
50 // MHillas.fSize parameter will be ADC counts (rather, equivalent ADC counts in
51 // inner pixels, since we correct for the possible differences in gain of outer
52 // pixels)
53 //
54 CalibrationFilename = new TString("nonoise/Gamma_zbin0_0*.root");
55 // File to be used in the calibration (must be a camera file without added noise)
56
57 Char_t* AnalysisFilename = "Gamma_zbin0*.root"; // File to be analyzed
58 Char_t* OutFilename = "star_mc.root"; // Output file name
59
60 Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
61
62 Int_t BinsHigh[2] = {5, 9}; // First and last FADC bin of the range to be integrated,
63 Int_t BinsLow[2] = {5, 9}; // for high and low gain respectively.
64
65 // -------------------------------------------
66
67 //
68 // Create a empty Parameter List and an empty Task List
69 // The tasklist is identified in the eventloop by its name
70 //
71 MParList plist;
72
73 MTaskList tlist;
74
75 plist.AddToList(&tlist);
76
77 MSrcPosCam src;
78 src.SetReadyToSave();
79
80 plist.AddToList(&src);
81
82 //
83 // Now setup the tasks and tasklist:
84 // ---------------------------------
85 //
86 MReadMarsFile read("Events");
87
88 if (CalibrationFilename)
89 read.AddFile(CalibrationFilename->Data());
90
91 read.DisableAutoScheme();
92
93 MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
94 // several parameter containers.
95
96 MMcPedestalCopy pcopy;
97 // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
98
99 MExtractSignal sigextract;
100 // Define ADC slices to be integrated in high and low gain:
101 sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
102
103 MMcCalibrationUpdate mccalibupdate;
104
105 MCalibrate calib; // Transforms signals from ADC counts into photons.
106
107 // MBlindPixelCalc blind;
108 // blind.SetUseInterpolation();
109
110 MImgCleanStd clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
111
112 MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
113 MHillasSrcCalc scalc; // Calculates source-dependent Hillas parameters
114
115 MMcCalibrationCalc mccalibcalc;
116
117 tlist.AddToList(&read);
118 tlist.AddToList(&geom);
119 tlist.AddToList(&pcopy);
120
121 tlist.AddToList(&sigextract);
122 tlist.AddToList(&mccalibupdate);
123 tlist.AddToList(&calib);
124 tlist.AddToList(&clean);
125 // tlist.AddToList(&blind);
126 tlist.AddToList(&hcalc);
127
128 tlist.AddToList(&mccalibcalc);
129
130 //
131 // Open output file:
132 //
133 MWriteRootFile write(OutFilename); // Writes output
134 write.AddContainer("MRawRunHeader", "RunHeaders");
135 write.AddContainer("MMcRunHeader", "RunHeaders");
136 write.AddContainer("MSrcPosCam", "RunHeaders");
137 write.AddContainer("MMcEvt", "Events");
138 write.AddContainer("MHillas", "Events");
139 write.AddContainer("MHillasExt", "Events");
140 write.AddContainer("MHillasSrc", "Events");
141 write.AddContainer("MNewImagePar", "Events");
142
143 //
144 // First loop: Calibration loop
145 //
146
147 MProgressBar bar;
148 bar.SetWindowName("Calibrating...");
149
150 MEvtLoop evtloop;
151 evtloop.SetProgressBar(&bar);
152 evtloop.SetParList(&plist);
153
154 if (CalibrationFilename)
155 {
156 if (!evtloop.Eventloop())
157 return;
158 mccalibcalc->GetHist()->Write();
159 }
160
161 //
162 // Second loop: analysis loop
163 //
164
165 //
166 // Change the read task by another one which reads the file we want to analyze:
167 //
168
169 MReadMarsFile read2("Events");
170 read2.AddFile(AnalysisFilename);
171 read2.DisableAutoScheme();
172 tlist.AddToListBefore(&read2, &read, "All");
173 tlist.RemoveFromList(&read);
174
175 bar.SetWindowName("Analyzing...");
176
177 tlist.RemoveFromList(&mccalibcalc); // Removes calibration task from list.
178
179 tlist.AddToList(&scalc); // Calculates Source-dependent Hillas parameters
180
181 tlist.AddToList(&write); // Add task to write output.
182
183 if (!evtloop.Eventloop())
184 return;
185
186
187 tlist.PrintStatistics();
188}
Note: See TracBrowser for help on using the repository browser.