source: trunk/Mars/macros/DAQDataCheck.C@ 11556

Last change on this file since 11556 was 4245, checked in by reyes, 21 years ago
*** empty log message ***
File size: 8.1 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): Raquel de los Reyes, 05/2004 <mailto:reyes@gae.ucm.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// This macro makes the check of the DAQ files (.raw files).
27//
28// The only argument to the macro is the directory with the night raw files
29// (ended with "/"). The macro sorts the entries in alphabetical order;
30// it then joins all the consecutive pedestal, calibration and data runs
31// and analyses all of them together. Data runs are taken consecutively
32// until it finds a run of other type (pedestal or calibration) or a data run
33// from another source. When a given source has no previous pedestal and/or
34// calibration runs, the macro takes the most recent ones.
35//
36// The analysis is done through the jobs classes MJPedestal and MJCalibration.
37//
38///////////////////////////////////////////////////////////////////////////
39void DataAnalysis(const Int_t prun1,const Int_t prun2,
40 const Int_t crun1,const Int_t crun2,
41 const Int_t drun1,const Int_t drun2,
42 const TString inpath,
43 const TString outdir)
44{
45
46 // Check if no pedestal runs has been detected
47 if(prun1==0)
48 {
49 cout << "No pedestal run(s)!!!"<< endl;
50 break;
51 }
52
53 gStyle->SetOptStat(1);
54 gStyle->SetOptFit();
55
56 MRunIter pruns;
57 MRunIter cruns;
58 MRunIter druns;
59 //
60 // Set the filter of MRunIter to .raw files
61 pruns.SetRawFile(kTRUE);
62 cruns.SetRawFile(kTRUE);
63 druns.SetRawFile(kTRUE);
64
65 //
66 // Check if you are analyzing more than one file
67 if(prun1==prun2)
68 pruns.AddRun(prun1,inpath);
69 else
70 pruns.AddRuns(prun1,prun2,inpath);
71 if(crun1==crun2)
72 cruns.AddRun(crun1,inpath);
73 else
74 cruns.AddRuns(crun1,crun2,inpath);
75 if(drun1==drun2)
76 druns.AddRun(drun1,inpath);
77 else
78 druns.AddRuns(drun1,drun2,inpath);
79
80 //
81 // Set up the source run-range
82 //
83 TRegexp type("_[A-Z]_");
84 TString source = "";
85 if(pruns.GetNumRuns()!=0)
86 source = pruns.Next();
87 source = source(source.Index(type)+3,source.Length());
88 source.Remove(source.Last('_'),source.Length());
89
90 TString title = outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps";
91
92 MStatusDisplay *d = new MStatusDisplay;
93 d->SetTitle(title);
94 d->SetLogStream(&gLog, kTRUE);
95
96 TObject::SetObjectStat(kTRUE);
97
98 //
99 // Choose the signal Extractor:
100 //
101 // MExtractFixedWindowPeakSearch extractor;
102 // MExtractSlidingWindow extractor;
103 MExtractFixedWindow extractor;
104
105 //
106 // Set Ranges or Windows
107 //
108 extractor.SetRange(3,14,3,14);
109 // extractor.SetWindows(8,8);
110
111 //
112 // Choose the arrival time Extractor:
113 //
114 // MExtractTimeHighestIntegral timeext;
115 MExtractTimeFastSpline timeext;
116 //
117 // Set Ranges or Windows
118 //
119 timeext.SetRange(2,12,4,14);
120
121 // ************************ GENERAL CONTAINERS *************************
122 MBadPixelsCam badcam;
123 MGeomCamMagic geomcam;
124 MGeomApply geomapl;
125 MCalibrationQECam qecam;
126
127 // **********************************************************************
128 // ***************************** PEDESTALS ******************************
129 // **********************************************************************
130 if(pruns.GetNumRuns()==0)
131 {
132 cout << "Warning, no entries found in pedestal run(s)!!!"<< endl;
133 break;
134 }
135
136 MJPedestal pedloop;
137 pedloop.SetExtractor(&extractor);
138 pedloop.SetInput(&pruns);
139 pedloop.SetDisplay(d);
140 pedloop.SetBadPixels(badcam);
141 //
142 // If you want to run the data-check on RAW DATA!!!, choose:
143 pedloop.SetDataCheck(kTRUE);
144
145 //
146 // Execute first analysis
147 //
148 cout << "*************************" << endl;
149 cout << "** COMPUTING PEDESTALS **" << endl;
150 cout << "*************************" << endl;
151 if (!pedloop.Process())
152 return;
153
154 //
155 // Save display into a postcript file
156 //
157 d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
158
159 // **********************************************************************
160 // ***************************** CALIBRATION ****************************
161 // **********************************************************************
162 if(cruns.GetNumRuns()==0)
163 {
164 cout << "Warning, no entries found in calibration run(s)!!!"<< endl;
165 break;
166 }
167
168 //
169 // Tell if you want to calibrate times:
170 //
171 static const Bool_t useTimes = kTRUE;
172
173 MJCalibration calloop;
174 //
175 // If you want to run the data-check on RAW DATA!!!, choose:
176 calloop.SetDataCheck();
177 //
178 // If you want to see the data-check plots only, choose:
179 calloop.SetDataCheckDisplay();
180
181 calloop.SetRelTimeCalibration(useTimes);
182 calloop.SetExtractor(&extractor);
183 calloop.SetTimeExtractor(&timeext);
184 calloop.SetInput(&cruns);
185 calloop.SetDisplay(d);
186 calloop.SetQECam(qecam);
187 calloop.SetBadPixels(pedloop.GetBadPixels());
188
189 //
190 // Execute first analysis
191 //
192 cout << "***************************" << endl;
193 cout << "** COMPUTING CALIBRATION **" << endl;
194 cout << "***************************" << endl;
195 if (!calloop.Process(pedloop.GetPedestalCam()))
196 return;
197
198 //
199 // Save display into a postcript file
200 //
201 d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
202
203
204}
205
206void DAQDataCheck(const TString directory="/remote/bigdown/data/Magic-DATA/Period014/rawdata/2004_02_17/",const TString outdir="./")
207{
208
209 MDirIter iter;
210 iter.AddDirectory(directory,"*.raw");
211
212 TString str=iter.Next();
213
214 TList list;
215 while(!str.IsNull())
216 {
217 list.Add(new TNamed(str,""));
218 str=iter.Next();
219 }
220 list.Sort();
221
222 TIter Next(&list);
223
224 TString fName="file.raw";
225
226 TRegexp run("_[0-9][0-9][0-9][0-9][0-9]_");
227 TRegexp type("_[A-Z]_");
228
229 Int_t pedrun1=0, pedrun2=0;
230 Int_t calrun1=0, calrun2=0;
231 Int_t datarun1=0, datarun2=0;
232
233 TString source="";
234
235 TObject o*;
236 o=Next();
237 fName = o->GetName(); // absolut path
238
239 while(!fName.IsNull())
240 {
241
242 source = fName(fName.Index(type)+3,fName.Length());
243 source.Remove(source.Last('_'),source.Length());
244
245 // Pedestal runs
246 if(fName.Contains("_P_"))
247 pedrun1=atoi(fName(fName.Index(run)+1,5).Data());
248 pedrun2=pedrun1;
249
250 while(fName.Contains("_P_")&&fName.Contains(source))
251 {
252 pedrun2=atoi(fName(fName.Index(run)+1,5).Data());
253 o=Next();
254 if(!o)
255 {
256 fName="";
257 break;
258 }
259 fName = o->GetName();
260 }
261
262 // Calibration runs
263 if(fName.Contains("_C_"))//||(!fName.Contains(source)))
264 calrun1=atoi(fName(fName.Index(run)+1,5).Data());
265// else
266// calrun1=0;
267 calrun2=calrun1;
268
269 while(fName.Contains("_C_")&&fName.Contains(source))
270 {
271 calrun2=atoi(fName(fName.Index(run)+1,5).Data());
272 o=Next();
273 if(!o)
274 {
275 fName = "";
276 break;
277 }
278 fName = o->GetName();
279 }
280
281 // Data runs
282 if(fName.Contains("_D_"))//||(!fName.Contains(source)))
283 datarun1=atoi(fName(fName.Index(run)+1,5).Data());
284 else
285 datarun1=0;
286 datarun2=datarun1;
287
288 while(fName.Contains("_D_")&&fName.Contains(source))
289 {
290 datarun2=atoi(fName(fName.Index(run)+1,5).Data());
291 o=Next();
292 if(!o)
293 {
294 fName = "";
295 break;
296 }
297 fName = o->GetName();
298 }
299
300// cout << pedrun1 << "\t"<<pedrun2 << endl;
301// cout << calrun1 << "\t"<<calrun2 << endl;
302// cout << datarun1 << "\t"<<datarun2 << endl;
303
304 DataAnalysis(pedrun1,pedrun2,calrun1,calrun2,datarun1,datarun2,directory,outdir);
305
306 cout << "----------------------------------------------" << endl;
307
308 }
309
310}
311
312
313
Note: See TracBrowser for help on using the repository browser.