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 |
|
---|
74 | plist.AddToList(&src);
|
---|
75 |
|
---|
76 | //
|
---|
77 | // Now setup the tasks and tasklist:
|
---|
78 | // ---------------------------------
|
---|
79 | //
|
---|
80 | MReadMarsFile read("Events");
|
---|
81 |
|
---|
82 | if (CalibrationFilename)
|
---|
83 | read.AddFile(CalibrationFilename->Data());
|
---|
84 |
|
---|
85 | read.DisableAutoScheme();
|
---|
86 |
|
---|
87 | MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
|
---|
88 | // several parameter containers.
|
---|
89 |
|
---|
90 | MMcPedestalCopy pcopy;
|
---|
91 | // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
|
---|
92 |
|
---|
93 | MExtractSignal sigextract;
|
---|
94 | // Define ADC slices to be integrated in high and low gain:
|
---|
95 | sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
|
---|
96 |
|
---|
97 | MMcCalibrationUpdate mccalibupdate;
|
---|
98 |
|
---|
99 | MCalibrate calib; // Transforms signals from ADC counts into photons.
|
---|
100 |
|
---|
101 | // MBlindPixelCalc blind;
|
---|
102 | // blind.SetUseInterpolation();
|
---|
103 |
|
---|
104 | //
|
---|
105 | // Applies tail cuts to image. Since the calibration is performed on
|
---|
106 | // noiseless camera files, the precise values of the cleaning levels
|
---|
107 | // are unimportant (in any case, only pixels without any C-photon will
|
---|
108 | // be rejected).
|
---|
109 | //
|
---|
110 | MImgCleanStd clean;
|
---|
111 |
|
---|
112 |
|
---|
113 | MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
|
---|
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("MGeomCam", "RunHeaders");
|
---|
135 | write.AddContainer("MMcConfigRunHeader", "RunHeaders");
|
---|
136 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
|
---|
137 | write.AddContainer("MMcFadcHeader", "RunHeaders");
|
---|
138 | write.AddContainer("MMcRunHeader", "RunHeaders");
|
---|
139 | write.AddContainer("MMcTrigHeader", "RunHeaders");
|
---|
140 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
141 | write.AddContainer("MSrcPosCam", "RunHeaders");
|
---|
142 |
|
---|
143 |
|
---|
144 | write.AddContainer("MMcEvt", "Events");
|
---|
145 | write.AddContainer("MMcTrig", "Events");
|
---|
146 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
147 | write.AddContainer("MCerPhotEvt", "Events");
|
---|
148 | write.AddContainer("MPedPhotCam", "Events");
|
---|
149 |
|
---|
150 | //
|
---|
151 | // First loop: Calibration loop
|
---|
152 | //
|
---|
153 |
|
---|
154 | MProgressBar bar;
|
---|
155 | bar.SetWindowName("Calibrating...");
|
---|
156 |
|
---|
157 | MEvtLoop evtloop;
|
---|
158 | evtloop.SetProgressBar(&bar);
|
---|
159 | evtloop.SetParList(&plist);
|
---|
160 |
|
---|
161 | if (CalibrationFilename)
|
---|
162 | {
|
---|
163 | if (!evtloop.Eventloop())
|
---|
164 | return;
|
---|
165 | mccalibcalc->GetHist()->Write();
|
---|
166 | }
|
---|
167 |
|
---|
168 | //
|
---|
169 | // Second loop: analysis loop
|
---|
170 | //
|
---|
171 |
|
---|
172 | //
|
---|
173 | // Change the read task by another one which reads the file we want to analyze:
|
---|
174 | //
|
---|
175 |
|
---|
176 | MReadMarsFile read2("Events");
|
---|
177 | read2.AddFile(AnalysisFilename);
|
---|
178 | read2.DisableAutoScheme();
|
---|
179 | tlist.AddToListBefore(&read2, &read, "All");
|
---|
180 | tlist.RemoveFromList(&read);
|
---|
181 |
|
---|
182 | bar.SetWindowName("Writing...");
|
---|
183 |
|
---|
184 | tlist.RemoveFromList(&clean);
|
---|
185 | tlist.RemoveFromList(&hcalc);
|
---|
186 | tlist.RemoveFromList(&mccalibcalc);
|
---|
187 |
|
---|
188 | tlist.AddToList(&write); // Add task to write output.
|
---|
189 |
|
---|
190 | if (!evtloop.Eventloop())
|
---|
191 | return;
|
---|
192 |
|
---|
193 |
|
---|
194 | tlist.PrintStatistics();
|
---|
195 | }
|
---|