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): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | /////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // calibration.C
|
---|
27 | //
|
---|
28 | // Needs as arguments the run number of a calibration file ("*_C_*.root") and
|
---|
29 | // the run number of the corresponding pedestal file ("*_P_*.root").
|
---|
30 | //
|
---|
31 | // The TString inpath has to be set correctly.
|
---|
32 | //
|
---|
33 | // The macro searches for the pulser colour which corresponds to the calibration
|
---|
34 | // run number. If the run number is smaller than 20000, pulser colour "CT1"
|
---|
35 | // is assumed, otherwise, it searches for the strings "green", "blue", "uv" or
|
---|
36 | // "ct1" in the filenames. If no colour or multiple colours are found, the
|
---|
37 | // execution is aborted.
|
---|
38 | //
|
---|
39 | // The container MBadPixelsCam is created and followed during the execution of the
|
---|
40 | // rest of the macro.
|
---|
41 | //
|
---|
42 | // A first loop over the pedestal file is performed using the class MJPedestal
|
---|
43 | //
|
---|
44 | // The container MCalibrationQECam is created and followed during the execution of the
|
---|
45 | // rest of the macro.
|
---|
46 | //
|
---|
47 | // A loop over the calibration files is performed using the class MJCalibration.
|
---|
48 | // The results are displayed using the MJCalibration::SetNormalDisplay() facility,
|
---|
49 | // but other displays can easily be uncommented.
|
---|
50 | // The call to MJCalibration skips the relative time calibration, which can be
|
---|
51 | // uncommented as well.
|
---|
52 | //
|
---|
53 | /////////////////////////////////////////////////////////////////////////////
|
---|
54 | const TString inpath = "/home/rootdata/BlindPixel/";
|
---|
55 | const Int_t pedrun = 20491;
|
---|
56 | const Int_t calrun1 = 20494;
|
---|
57 | const Int_t calrun2 = 20496;
|
---|
58 |
|
---|
59 | void calibration(const Int_t prun=pedrun, const Int_t crun1=calrun1, const Int_t crun2=calrun2)
|
---|
60 | {
|
---|
61 |
|
---|
62 | MRunIter pruns;
|
---|
63 | MRunIter cruns;
|
---|
64 |
|
---|
65 | pruns.AddRun(prun,inpath);
|
---|
66 |
|
---|
67 | if (crun2==0)
|
---|
68 | cruns.AddRun(crun1,inpath);
|
---|
69 | else
|
---|
70 | cruns.AddRuns(crun1,crun2,inpath);
|
---|
71 |
|
---|
72 | MCalibrationCam::PulserColor_t color;
|
---|
73 |
|
---|
74 | if (crun1 < 20000)
|
---|
75 | color = MCalibrationCam::kCT1;
|
---|
76 | else
|
---|
77 | color = FindColor((MDirIter*)&cruns);
|
---|
78 |
|
---|
79 | if (color == MCalibrationCam::kNONE)
|
---|
80 | return;
|
---|
81 |
|
---|
82 | MCalibrationQECam qecam;
|
---|
83 | MBadPixelsCam badcam;
|
---|
84 |
|
---|
85 | //
|
---|
86 | // If you want to exclude pixels from the beginning, read
|
---|
87 | // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
|
---|
88 | //
|
---|
89 | // badcam.AsciiRead("badpixels.dat");
|
---|
90 |
|
---|
91 | for (Int_t i=0;i<badcam.GetSize();i++)
|
---|
92 | if (badcam[i].IsBad())
|
---|
93 | cout << "Bad Pixel: " << i << endl;
|
---|
94 |
|
---|
95 | MStatusDisplay *display = new MStatusDisplay;
|
---|
96 | display->SetUpdateTime(3000);
|
---|
97 | display->Resize(850,700);
|
---|
98 |
|
---|
99 | /************************************/
|
---|
100 | /* FIRST LOOP: PEDESTAL COMPUTATION */
|
---|
101 | /************************************/
|
---|
102 |
|
---|
103 | MJPedestal pedloop;
|
---|
104 | pedloop.SetInput(&pruns);
|
---|
105 | pedloop.SetDisplay(display);
|
---|
106 | pedloop.SetBadPixels(badcam);
|
---|
107 |
|
---|
108 | if (!pedloop.Process())
|
---|
109 | return;
|
---|
110 |
|
---|
111 | //
|
---|
112 | // Create a empty Parameter List and an empty Task List
|
---|
113 | // The tasklist is identified in the eventloop by its name
|
---|
114 | //
|
---|
115 | MParList plist0;
|
---|
116 | MTaskList tlist0;
|
---|
117 | plist0.AddToList(&tlist0);
|
---|
118 |
|
---|
119 | //
|
---|
120 | // Now setup the tasks and tasklist for the pedestals:
|
---|
121 | // ---------------------------------------------------
|
---|
122 | //
|
---|
123 | MReadMarsFile read("Events");
|
---|
124 | read.DisableAutoScheme();
|
---|
125 | static_cast<MRead&>(read).AddFiles(pruns);
|
---|
126 |
|
---|
127 | MJCalibration calloop;
|
---|
128 | calloop.SetColor(color);
|
---|
129 |
|
---|
130 | //
|
---|
131 | // If you want only the most necessary plots, choose:
|
---|
132 | // calloop.SetDataCheck();
|
---|
133 | //
|
---|
134 | // For everything, you ever dreamed of, choose:
|
---|
135 | // calloop.SetFullDisplay();
|
---|
136 |
|
---|
137 | //
|
---|
138 | // If you want to calibrate the times as well, choose:
|
---|
139 | //
|
---|
140 | // calloop.SetRelTimeCalibration();
|
---|
141 | calloop.SetInput(&cruns);
|
---|
142 | calloop.SetDisplay(display);
|
---|
143 | calloop.SetQECam(qecam);
|
---|
144 | calloop.SetBadPixels(pedloop.GetBadPixels());
|
---|
145 | if (!calloop.Process(pedloop.GetPedestalCam()))
|
---|
146 | return;
|
---|
147 |
|
---|
148 | }
|
---|
149 |
|
---|
150 | MCalibrationCam::PulserColor_t FindColor(MDirIter* run)
|
---|
151 | {
|
---|
152 |
|
---|
153 | MCalibrationCam::PulserColor_t col = MCalibrationCam::kNONE;
|
---|
154 |
|
---|
155 | TString filenames;
|
---|
156 |
|
---|
157 | while (!(filenames=run->Next()).IsNull())
|
---|
158 | {
|
---|
159 |
|
---|
160 | filenames.ToLower();
|
---|
161 |
|
---|
162 | if (filenames.Contains("green"))
|
---|
163 | if (col == MCalibrationCam::kNONE)
|
---|
164 | {
|
---|
165 | cout << "Found colour: Green in " << filenames << endl;
|
---|
166 | col = MCalibrationCam::kGREEN;
|
---|
167 | }
|
---|
168 | else if (col != MCalibrationCam::kGREEN)
|
---|
169 | {
|
---|
170 | cout << "Different colour found in " << filenames << "... abort" << endl;
|
---|
171 | return MCalibrationCam::kNONE;
|
---|
172 | }
|
---|
173 |
|
---|
174 | if (filenames.Contains("blue"))
|
---|
175 | if (col == MCalibrationCam::kNONE)
|
---|
176 | {
|
---|
177 | cout << "Found colour: Blue in " << filenames << endl;
|
---|
178 | col = MCalibrationCam::kBLUE;
|
---|
179 | }
|
---|
180 | else if (col != MCalibrationCam::kBLUE)
|
---|
181 | {
|
---|
182 | cout << "Different colour found in " << filenames << "... abort" << endl;
|
---|
183 | return MCalibrationCam::kNONE;
|
---|
184 | }
|
---|
185 |
|
---|
186 | if (filenames.Contains("uv"))
|
---|
187 | if (col == MCalibrationCam::kNONE)
|
---|
188 | {
|
---|
189 | cout << "Found colour: Uv in " << filenames << endl;
|
---|
190 | col = MCalibrationCam::kUV;
|
---|
191 | }
|
---|
192 | else if (col != MCalibrationCam::kUV)
|
---|
193 | {
|
---|
194 | cout << "Different colour found in " << filenames << "... abort" << endl;
|
---|
195 | return MCalibrationCam::kNONE;
|
---|
196 | }
|
---|
197 |
|
---|
198 | if (filenames.Contains("ct1"))
|
---|
199 | if (col == MCalibrationCam::kNONE)
|
---|
200 | {
|
---|
201 | cout << "Found colour: Ct1 in " << filenames << endl;
|
---|
202 | col = MCalibrationCam::kCT1;
|
---|
203 | }
|
---|
204 | else if (col != MCalibrationCam::kCT1)
|
---|
205 | {
|
---|
206 | cout << "Different colour found in " << filenames << "... abort" << endl;
|
---|
207 | return MCalibrationCam::kNONE;
|
---|
208 | }
|
---|
209 |
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 |
|
---|
214 | if (col == MCalibrationCam::kNONE)
|
---|
215 | cout << "No colour found in filenames of runs: " << ((MRunIter*)run)->GetRunsAsString()
|
---|
216 | << "... abort" << endl;
|
---|
217 |
|
---|
218 | return col;
|
---|
219 | }
|
---|