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

Last change on this file since 4101 was 4069, checked in by gaug, 21 years ago
*** empty log message ***
File size: 6.4 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// Last, a third loop is performed over the calibration file again in order to
54// "calibrate" it and test the resulting outcome.
55//
56/////////////////////////////////////////////////////////////////////////////
57static const TString outpath = "./";
58static const TString inpath = "./";
59//static const TString inpath = "/home/rootdata/Calib/";
60//
61// Tell if you want to calibrate times:
62//
63static const Bool_t useTimes = kTRUE;
64//
65// the default pedestal run for the calibration
66//
67static const Int_t pedrun = 13426;
68//
69// the default start calibration run
70//
71static const Int_t calrun1 = 16744;
72//
73// the default last calibration run (if 0, only one run is taken, otherwise consecutive runs
74// between calrun1 and calrun2)
75//
76static const Int_t calrun2 = 0;
77
78void calibration(const Int_t prun=pedrun, const Int_t crun1=calrun1, const Int_t crun2=calrun2)
79{
80
81
82 //
83 // Choose the signal Extractor:
84 //
85 // MExtractFixedWindowPeakSearch extractor;
86 // MExtractSlidingWindow extractor;
87 MExtractFixedWindow extractor;
88
89 //
90 // Set Ranges or Windows
91 //
92 extractor.SetRange(3,14,3,14);
93 // extractor.SetWindows(8,8);
94
95 //
96 // Choose the arrival time Extractor:
97 //
98 // MExtractTimeHighestIntegral timeext;
99 MExtractTimeFastSpline timeext;
100 //
101 // Set Ranges or Windows
102 //
103 timeext.SetRange(2,12,4,14);
104
105 MRunIter pruns;
106 MRunIter cruns;
107
108 pruns.AddRun(prun,inpath);
109
110 if (crun2==0)
111 cruns.AddRun(crun1,inpath);
112 else
113 cruns.AddRuns(crun1,crun2,inpath);
114
115 gStyle->SetOptStat(1);
116 gStyle->SetOptFit();
117
118 MStatusDisplay *display = new MStatusDisplay;
119 display->SetUpdateTime(3000);
120 display->Resize(850,700);
121
122 /************************************/
123 /* FIRST LOOP: PEDESTAL COMPUTATION */
124 /************************************/
125
126 MCalibrationQECam qecam;
127 MBadPixelsCam badcam;
128 MGeomCamMagic geomcam;
129 MGeomApply geomapl;
130 //
131 // If you want to exclude pixels from the beginning, read
132 // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
133 //
134// badcam.AsciiRead("badpixels.dat");
135
136 MJPedestal pedloop;
137 pedloop.SetExtractor(&extractor);
138 pedloop.SetInput(&pruns);
139 pedloop.SetOutputPath(outpath.Data());
140 pedloop.SetDisplay(display);
141 pedloop.SetBadPixels(badcam);
142
143 if (!pedloop.Process())
144 return;
145
146 /****************************************/
147 /* SECOND LOOP: CALIBRATION COMPUTATION */
148 /****************************************/
149
150 MJCalibration calloop;
151
152 //
153 // If you want to run the data-check on RAW DATA!!!, choose:
154 // calloop.SetDataCheck();
155 //
156 // If you want to see the data-check plots only, choose:
157 // calloop.SetDataCheckDisplay();
158 //
159 // For everything, you have ever dreamed of, choose:
160 // calloop.SetFullDisplay();
161
162 //
163 // If you want to calibrate the times as well, choose:
164 //
165 calloop.SetRelTimeCalibration(useTimes);
166 calloop.SetExtractor(&extractor);
167 calloop.SetTimeExtractor(&timeext);
168 calloop.SetInput(&cruns);
169 calloop.SetOutputPath(outpath.Data());
170 calloop.SetDisplay(display);
171 calloop.SetQECam(qecam);
172 calloop.SetBadPixels(pedloop.GetBadPixels());
173
174// TObject::SetObjectStat(kTRUE);
175
176 calloop.Process(pedloop.GetPedestalCam());
177
178// gObjectTable->Print();
179
180 /********************************************************************/
181 /* THIRD LOOP: APPLY CALIBRATION TO THE CALIBRATION FILES FOR TESTS */
182 /********************************************************************/
183
184 MJExtractCalibTest testloop;
185
186 testloop.SetExtractor(&extractor);
187 testloop.SetTimeExtractor(&timeext);
188 testloop.SetInput(&cruns);
189 testloop.SetOutputPath(outpath);
190 testloop.SetDisplay(display);
191 testloop.SetBadPixels(calloop.GetBadPixels());
192 testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam());
193 if (useTimes)
194 testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam());
195
196 //
197 // List of useful containers:
198 //
199/*
200 MPedestalCam &pedcam = pedloop.GetPedestalCam();
201 MCalibrationChargeCam &chargecam = calloop.GetCalibrationCam();
202 MCalibrationQECam &qecam = calloop.GetCalibrationCam();
203 MBadPixelsCam &badcam = calloop.GetBadPixels();
204 MHCalibrationTestCam &testcam = testloop.GetTestCam();
205 MHCalibrationTestTimeCam &testtime = testloop.GetTestTimeCam();
206*/
207}
208
209
Note: See TracBrowser for help on using the repository browser.