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 | // MMCALIBRATE - Calibration of MC data
|
---|
29 | //
|
---|
30 | // This macro is a version of the standard procedure to convert raw MC data
|
---|
31 | // into calibrated data (photons per pixel)
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | #include "MImgCleanStd.h"
|
---|
36 |
|
---|
37 | void mccalibrate()
|
---|
38 | {
|
---|
39 | //
|
---|
40 | // This is a demonstration program which reads in MC camera files
|
---|
41 | // and produces and output with calibrated events (signal in photons
|
---|
42 | // for all pixels, in MCerPhotEvt containers).
|
---|
43 | //
|
---|
44 |
|
---|
45 |
|
---|
46 | // ------------- user change -----------------
|
---|
47 | TString* CalibrationFilename;
|
---|
48 | CalibrationFilename = new TString("nonoise/Gamma_zbin0_0*.root");
|
---|
49 | // File to be used for the calibration (must be a camera file without added noise)
|
---|
50 |
|
---|
51 | Char_t* AnalysisFilename = "Gamma_zbin0*.root"; // File to be analyzed
|
---|
52 |
|
---|
53 | Char_t* OutFilename = "calibrated_data.root"; // Output file name
|
---|
54 |
|
---|
55 |
|
---|
56 | Int_t BinsHigh[2] = {5, 9}; // First and last FADC bin of the range to be integrated,
|
---|
57 | Int_t BinsLow[2] = {5, 9}; // for high and low gain respectively.
|
---|
58 |
|
---|
59 | // -------------------------------------------
|
---|
60 |
|
---|
61 | //
|
---|
62 | // Create a empty Parameter List and an empty Task List
|
---|
63 | // The tasklist is identified in the eventloop by its name
|
---|
64 | //
|
---|
65 | MParList plist;
|
---|
66 |
|
---|
67 | MTaskList tlist;
|
---|
68 |
|
---|
69 | plist.AddToList(&tlist);
|
---|
70 |
|
---|
71 | MSrcPosCam src;
|
---|
72 | src.SetReadyToSave();
|
---|
73 | plist.AddToList(&src);
|
---|
74 |
|
---|
75 | MBadPixelsCam badpix;
|
---|
76 | plist.AddToList(&badpix);
|
---|
77 |
|
---|
78 |
|
---|
79 | //
|
---|
80 | // Now setup the tasks and tasklist:
|
---|
81 | // ---------------------------------
|
---|
82 | //
|
---|
83 | MReadMarsFile read("Events");
|
---|
84 |
|
---|
85 | if (CalibrationFilename)
|
---|
86 | read.AddFile(CalibrationFilename->Data());
|
---|
87 |
|
---|
88 | read.DisableAutoScheme();
|
---|
89 |
|
---|
90 | MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
|
---|
91 | // several parameter containers.
|
---|
92 |
|
---|
93 | MMcPedestalCopy pcopy;
|
---|
94 | // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
|
---|
95 |
|
---|
96 | MExtractSignal sigextract;
|
---|
97 | // Define ADC slices to be integrated in high and low gain:
|
---|
98 | sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
|
---|
99 |
|
---|
100 | MMcCalibrationUpdate mccalibupdate;
|
---|
101 |
|
---|
102 | MCalibrate calib; // Transforms signals from ADC counts into photons.
|
---|
103 |
|
---|
104 | // MBlindPixelCalc blind;
|
---|
105 | // blind.SetUseInterpolation();
|
---|
106 |
|
---|
107 | //
|
---|
108 | // Applies tail cuts to image. Since the calibration is performed on
|
---|
109 | // noiseless camera files, the precise values of the cleaning levels
|
---|
110 | // are unimportant (in any case, only pixels without any C-photon will
|
---|
111 | // be rejected).
|
---|
112 | //
|
---|
113 | MImgCleanStd clean;
|
---|
114 |
|
---|
115 |
|
---|
116 | MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
|
---|
117 |
|
---|
118 | MMcCalibrationCalc mccalibcalc;
|
---|
119 |
|
---|
120 | tlist.AddToList(&read);
|
---|
121 | tlist.AddToList(&geom);
|
---|
122 | tlist.AddToList(&pcopy);
|
---|
123 |
|
---|
124 | tlist.AddToList(&sigextract);
|
---|
125 | tlist.AddToList(&mccalibupdate);
|
---|
126 | tlist.AddToList(&calib);
|
---|
127 | tlist.AddToList(&clean);
|
---|
128 | // tlist.AddToList(&blind);
|
---|
129 | tlist.AddToList(&hcalc);
|
---|
130 |
|
---|
131 | tlist.AddToList(&mccalibcalc);
|
---|
132 |
|
---|
133 | //
|
---|
134 | // Open output file:
|
---|
135 | //
|
---|
136 | MWriteRootFile write(OutFilename); // Writes output
|
---|
137 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
138 | write.AddContainer("MMcConfigRunHeader", "RunHeaders");
|
---|
139 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
|
---|
140 | write.AddContainer("MMcFadcHeader", "RunHeaders");
|
---|
141 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
142 | write.AddContainer("MMcTrigHeader", "RunHeaders");
|
---|
143 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
144 | write.AddContainer("MSrcPosCam", "RunHeaders");
|
---|
145 |
|
---|
146 |
|
---|
147 | write.AddContainer("MMcEvt", "Events");
|
---|
148 | write.AddContainer("MMcTrig", "Events");
|
---|
149 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
150 | write.AddContainer("MCerPhotEvt", "Events");
|
---|
151 | write.AddContainer("MPedPhotCam", "Events");
|
---|
152 |
|
---|
153 | //
|
---|
154 | // First loop: Calibration loop
|
---|
155 | //
|
---|
156 |
|
---|
157 | MProgressBar bar;
|
---|
158 | bar.SetWindowName("Calibrating...");
|
---|
159 |
|
---|
160 | MEvtLoop evtloop;
|
---|
161 | evtloop.SetProgressBar(&bar);
|
---|
162 | evtloop.SetParList(&plist);
|
---|
163 |
|
---|
164 | if (CalibrationFilename)
|
---|
165 | {
|
---|
166 | if (!evtloop.Eventloop())
|
---|
167 | return;
|
---|
168 | mccalibcalc->GetHist()->Write();
|
---|
169 | }
|
---|
170 |
|
---|
171 | //
|
---|
172 | // Second loop: analysis loop
|
---|
173 | //
|
---|
174 |
|
---|
175 | //
|
---|
176 | // Change the read task by another one which reads the file we want to analyze:
|
---|
177 | //
|
---|
178 |
|
---|
179 | MReadMarsFile read2("Events");
|
---|
180 | read2.AddFile(AnalysisFilename);
|
---|
181 | read2.DisableAutoScheme();
|
---|
182 | tlist.AddToListBefore(&read2, &read, "All");
|
---|
183 | tlist.RemoveFromList(&read);
|
---|
184 |
|
---|
185 | bar.SetWindowName("Writing...");
|
---|
186 |
|
---|
187 | tlist.RemoveFromList(&clean);
|
---|
188 | tlist.RemoveFromList(&hcalc);
|
---|
189 | tlist.RemoveFromList(&mccalibcalc);
|
---|
190 |
|
---|
191 | tlist.AddToList(&write); // Add task to write output.
|
---|
192 |
|
---|
193 | if (!evtloop.Eventloop())
|
---|
194 | return;
|
---|
195 |
|
---|
196 |
|
---|
197 | tlist.PrintStatistics();
|
---|
198 | }
|
---|