source: trunk/MagicSoft/Mars/macros/calibration.C@ 3745

Last change on this file since 3745 was 3745, checked in by gaug, 21 years ago
*** empty log message ***
File size: 6.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): 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/////////////////////////////////////////////////////////////////////////////
54const TString inpath = "/home/rootdata/BlindPixel/";
55const Int_t pedrun = 20491;
56const Int_t calrun1 = 20494;
57const Int_t calrun2 = 20496;
58
59void 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 // Now setup the tasks and for the calibration:
113 // ---------------------------------------------------
114 //
115 MJCalibration calloop;
116 calloop.SetColor(color);
117
118 //
119 // If you want only the most necessary plots, choose:
120 // calloop.SetDataCheck();
121 //
122 // For everything, you ever dreamed of, choose:
123 // calloop.SetFullDisplay();
124
125 //
126 // If you want to calibrate the times as well, choose:
127 //
128 // calloop.SetRelTimeCalibration();
129 calloop.SetInput(&cruns);
130 calloop.SetDisplay(display);
131 calloop.SetQECam(qecam);
132 calloop.SetBadPixels(pedloop.GetBadPixels());
133 if (!calloop.Process(pedloop.GetPedestalCam()))
134 return;
135
136}
137
138MCalibrationCam::PulserColor_t FindColor(MDirIter* run)
139{
140
141 MCalibrationCam::PulserColor_t col = MCalibrationCam::kNONE;
142
143 TString filenames;
144
145 while (!(filenames=run->Next()).IsNull())
146 {
147
148 filenames.ToLower();
149
150 if (filenames.Contains("green"))
151 if (col == MCalibrationCam::kNONE)
152 {
153 cout << "Found colour: Green in " << filenames << endl;
154 col = MCalibrationCam::kGREEN;
155 }
156 else if (col != MCalibrationCam::kGREEN)
157 {
158 cout << "Different colour found in " << filenames << "... abort" << endl;
159 return MCalibrationCam::kNONE;
160 }
161
162 if (filenames.Contains("blue"))
163 if (col == MCalibrationCam::kNONE)
164 {
165 cout << "Found colour: Blue in " << filenames << endl;
166 col = MCalibrationCam::kBLUE;
167 }
168 else if (col != MCalibrationCam::kBLUE)
169 {
170 cout << "Different colour found in " << filenames << "... abort" << endl;
171 return MCalibrationCam::kNONE;
172 }
173
174 if (filenames.Contains("uv"))
175 if (col == MCalibrationCam::kNONE)
176 {
177 cout << "Found colour: Uv in " << filenames << endl;
178 col = MCalibrationCam::kUV;
179 }
180 else if (col != MCalibrationCam::kUV)
181 {
182 cout << "Different colour found in " << filenames << "... abort" << endl;
183 return MCalibrationCam::kNONE;
184 }
185
186 if (filenames.Contains("ct1"))
187 if (col == MCalibrationCam::kNONE)
188 {
189 cout << "Found colour: Ct1 in " << filenames << endl;
190 col = MCalibrationCam::kCT1;
191 }
192 else if (col != MCalibrationCam::kCT1)
193 {
194 cout << "Different colour found in " << filenames << "... abort" << endl;
195 return MCalibrationCam::kNONE;
196 }
197
198 }
199
200
201
202 if (col == MCalibrationCam::kNONE)
203 cout << "No colour found in filenames of runs: " << ((MRunIter*)run)->GetRunsAsString()
204 << "... abort" << endl;
205
206 return col;
207}
Note: See TracBrowser for help on using the repository browser.