source: trunk/MagicSoft/Mars/macros/getExtractor.C@ 6986

Last change on this file since 6986 was 6395, checked in by gaug, 20 years ago
*** empty log message ***
File size: 14.0 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/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// getExtractor.C
27//
28// This macro has to be included in another macro or code in order to be
29// used in the following way:
30//
31// #include "getExtractor.C"
32//
33// Later, inside the macro, you can initialize one of the signal extractors,
34// as specified in the TDAS-Extractor with the following meaning:
35//
36// Nr. Extractor Parameters
37//
38// MExtractFixedWindow:
39// with the following parameters, if 'maxbin' defines the mean position
40// of the High-Gain FADC slice carrying the pulse maximum:
41// 1: SetRange('maxbin'-1,'maxbin'+2,'maxbin'+0.5,'maxbin'+3.5)
42// 2: SetRange('maxbin'-1,'maxbin'+2,'maxbin'-0.5,'maxbin'+4.5)
43// 3: SetRange('maxbin'-2,'maxbin'+3,'maxbin'-0.5,'maxbin'+4.5)
44// 4: SetRange('maxbin'-3,'maxbin'+4,'maxbin'-1.5,'maxbin'+5.5)
45// 5: SetRange('maxbin'-5,'maxbin'+8,'maxbin'-1.5,'maxbin'+7.5)
46// MExtractFixedWindowSpline:
47// 6: SetRange('maxbin'-1.5,'maxbin'+2.5,'maxbin','maxbin'+4)
48// 7: SetRange('maxbin'-1.5,'maxbin'+2.5,'maxbin'-1,'maxbin'+5)
49// 8: SetRange('maxbin'-2.5,'maxbin'+3.5,'maxbin'-1,'maxbin'+5)
50// 9: SetRange('maxbin'-3.5,'maxbin'+4.5,'maxbin'-2,'maxbin'+6)
51// 10: SetRange('maxbin'-5.5,'maxbin'+8.5,'maxbin'-2,'maxbin'+8)
52// MExtractFixedWindowPeakSearch:
53// SetRange(0,18,2,14) and the following parameters:
54// 11: SetWindows(2,2,2)
55// 12: SetWindows(4,4,2)
56// 13: SetWindows(4,6,4)
57// 14: SetWindows(6,6,4)
58// 15: SetWindows(8,8,4)
59// 16: SetWindows(14,10,4)
60// MExtractTimeAndChargeSlidingWindow:
61// SetRange(0,18,2,14) and the following parameters:
62// 17: SetWindowSize(2,2)
63// 18: SetWindowSize(4,4)
64// 19: SetWindowSize(4,6)
65// 20: SetWindowSize(6,6)
66// 21: SetWindowSize(8,8)
67// 22: SetWindowSize(14,10)
68// MExtractTimeAndChargeSpline:
69// 23: SetChargeType(MExtractTimeAndChargeSpline::kAmplitude
70// SetRange(0,13,2,13)
71// 24: SetChargeType(MExtractTimeAndChargeSpline::kIntegral) and:
72// SetRange(0,18,2,14) and the following parameters:
73// SetRiseTime(0.5); SetFallTime(0.5)
74// 25: SetRiseTime(0.5); SetFallTime(1.5)
75// 26: SetRiseTime(1.0); SetFallTime(3.0)
76// 27: SetRiseTime(1.5); SetFallTime(4.5)
77// MExtractTimeAndChargeDigitalFilter
78// SetRange(0,18,2,14) and the following parameters:
79// 28: SetNameWeightsFile('msignal/cosmics_weights.dat')
80// 29: SetNameWeightsFile('msignal/cosmics_weights4.dat')
81// 30: SetNameWeightsFile('msignal/cosmics_weights_logain.dat')
82// 31: SetNameWeightsFile('msignal/cosmics_weights4_logain.dat')
83// 32: SetNameWeightsFile('msignal/calibration_weights_UV.dat')
84// 33: SetNameWeightsFile('msignal/calibration_weights_UV_logain.dat')
85// 34: SetNameWeightsFile('msignal/MC_weights.dat')
86// MExtractTimeAndChargeDigitalFilterPeakSearch
87// 35: SetNameWeightsFile('msignal/calibration_weights_UV.dat')
88//
89// The extractor will also carry a meaningful name, storing all information about its
90// initialization there.
91//
92//////////////////////////////////////////////////////////////////////////////////////////
93#include "MExtractor.h"
94#include "MExtractFixedWindowPeakSearch.h"
95#include "MExtractFixedWindow.h"
96#include "MExtractFixedWindowSpline.h"
97#include "MExtractTimeAndChargeDigitalFilter.h"
98#include "MExtractTimeAndChargeDigitalFilterPeakSearch.h"
99#include "MExtractTimeAndChargeSlidingWindow.h"
100#include "MExtractTimeAndChargeSpline.h"
101#include "MLog.h"
102
103#include <TSystem.h>
104#include <fstream>
105
106using namespace std;
107
108MExtractor *getExtractor(const UInt_t flag)
109{
110
111 MExtractor *extractor = NULL;
112
113 //
114 // Choose the signal Extractor:
115 //
116 // PURE CHARGE EXTRACTORS:
117 // MExtractFixedWindowPeakSearchs
118 // MExtractSlidingWindow
119 // MExtractFixedWindow
120 // MExtractFixedWindowSpline
121 // MExtractAmplitudeSpline
122 //
123 switch (flag)
124 {
125 case 1:
126 case 2:
127 case 3:
128 case 4:
129 case 5:
130 extractor = new MExtractFixedWindow();
131 break;
132 case 6:
133 case 7:
134 case 8:
135 case 9:
136 case 10:
137 extractor = new MExtractFixedWindowSpline();
138 break;
139 case 11:
140 case 12:
141 case 13:
142 case 14:
143 case 15:
144 case 16:
145 extractor = new MExtractFixedWindowPeakSearch();
146 extractor->SetRange(0,18,2,14);
147 break;
148 //
149 // PURE TIME EXTRACTORS:
150 // ATTENTION: If an extractor deriving from MExtractTimeAndCharge is
151 // used, you may want to use the timing calculated directly
152 // from there.
153 //
154 // MExtractTimeHighestIntegral
155 // MExtractTimeFastSpline
156 // MExtractTimeSpline
157 //
158 // COMBINED TIME AND CHARGE EXTRACTORS:
159 // MExtractTimeAndChargeDigitalFilter
160 // MExtractTimeAndChargeSpline
161 // MExtractTimeAndChargeSlidingWindow
162 //
163 case 17:
164 case 18:
165 case 19:
166 case 20:
167 case 21:
168 case 22:
169 extractor = new MExtractTimeAndChargeSlidingWindow();
170 extractor->SetRange(0,18,2,14);
171 break;
172 case 23:
173 case 24:
174 case 25:
175 case 26:
176 case 27:
177 extractor = new MExtractTimeAndChargeSpline();
178 ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kIntegral);
179 extractor->SetRange(0,18,2,14);
180 break;
181 case 28:
182 case 29:
183 case 30:
184 case 31:
185 case 32:
186 case 33:
187 case 34:
188 case 35:
189 extractor = new MExtractTimeAndChargeDigitalFilter();
190 extractor->SetRange(0,16,3,14);
191 break;
192 case 36:
193 extractor = new MExtractTimeAndChargeDigitalFilterPeakSearch();
194 extractor->SetRange(0,20,3,14);
195 break;
196 default:
197 gLog << "No valid extractor flag chosen, cannot run..." << flag << endl;
198 return NULL;
199 break;
200 }
201
202 //
203 // Set Ranges or Windows
204 //
205 switch (flag)
206 {
207 // MExtractFixedWindow:
208 case 1:
209 extractor->SetRange(4,7,6,9);
210 break;
211 case 2:
212 extractor->SetRange(4,7,6,11);
213 break;
214 case 3:
215 extractor->SetRange(4,9,6,11);
216 break;
217 case 4:
218 extractor->SetRange(4,11,6,13);
219 break;
220 case 5:
221 extractor->SetRange(3,16,5,14);
222 break;
223 // MExtractFixedWindowSpline:
224 case 6:
225 extractor->SetRange(4,8,6,10);
226 break;
227 case 7:
228 extractor->SetRange(4,8,5,11);
229 break;
230 case 8:
231 extractor->SetRange(4,10,5,11);
232 break;
233 case 9:
234 extractor->SetRange(3,11,5,13);
235 break;
236 case 10:
237 extractor->SetRange(3,17,4,14);
238 break;
239 // MExtractFixedWindowPeakSearch:
240 case 11:
241 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(2,2,2);
242 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(0);
243 break;
244 case 12:
245 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,4,2);
246 break;
247 case 13:
248 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,6,4);
249 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(0);
250 break;
251 case 14:
252 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(6,6,4);
253 break;
254 case 15:
255 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(8,8,4);
256 break;
257 case 16:
258 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(14,10,4);
259 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(2);
260 break;
261 // MExtractTimeAndChargeSlidingWindow
262 case 17:
263 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(2,2);
264 break;
265 case 18:
266 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,4);
267 break;
268 case 19:
269 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,6);
270 break;
271 case 20:
272 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(6,6);
273 break;
274 case 21:
275 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(8,8);
276 break;
277 case 22:
278 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(14,10);
279 break;
280 // MExtractTimeAndChargeSpline
281 case 23:
282 ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kAmplitude);
283 extractor->SetRange(0,13,2,13);
284 extractor->SetName(Form("%s_Amplitude",extractor->GetName()));
285 break;
286 case 24:
287 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(0.5);
288 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(0.5);
289 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,0.5));
290 break;
291 case 25:
292 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(0.5);
293 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(1.5);
294 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,1.5));
295 break;
296 case 26:
297 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(1.0);
298 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(3.0);
299 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),1.0,3.0));
300 break;
301 case 27:
302 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(1.5);
303 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(4.5);
304 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),1.5,4.5));
305 break;
306 // MExtractTimeAndChargeDigitalFilter
307 case 28:
308 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights.dat");
309 break;
310 case 29:
311 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4.dat");
312 break;
313 case 30:
314 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights_logaintest.dat");
315 break;
316 case 31:
317 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4_logaintest.dat");
318 break;
319 case 32:
320 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
321 break;
322 case 33:
323 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV_logaintest.dat");
324 break;
325 case 34:
326 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/MC_weights.dat");
327 break;
328 case 35:
329 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
330 break;
331 case 36:
332 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
333 break;
334 default:
335 gLog << "No valid extractor flag chosen, cannot run..." << endl;
336 return NULL;
337 break;
338 }
339
340 //
341 // Set the names of the extractors:
342 //
343 switch (flag)
344 {
345 case 1:
346 case 2:
347 case 3:
348 case 4:
349 case 5:
350 case 6:
351 case 7:
352 case 8:
353 case 9:
354 case 10:
355 break;
356 case 11:
357 case 12:
358 case 13:
359 case 14:
360 case 15:
361 case 16:
362 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
363 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetHiGainWindowSize(),
364 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetLoGainWindowSize()));
365 break;
366 case 17:
367 case 18:
368 case 19:
369 case 20:
370 case 21:
371 case 22:
372 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
373 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeHiGain(),
374 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeLoGain()));
375 break;
376 case 23:
377 case 24:
378 case 25:
379 case 26:
380 case 27:
381 break;
382 case 28:
383 case 29:
384 case 30:
385 case 31:
386 case 32:
387 case 33:
388 case 34:
389 case 35:
390 case 36:
391 extractor->SetName(Form("%s_Weights_%s",extractor->GetName(),
392 gSystem->BaseName(((MExtractTimeAndChargeDigitalFilter*)extractor)->GetNameWeightsFile())));
393 break;
394 default:
395 gLog << "No valid extractor flag chosen, cannot run..." << endl;
396 return NULL;
397 break;
398 }
399
400 extractor->SetName(Form("%s_Range_%02d_%02d_%02d_%02d",extractor->GetName(),
401 (Int_t)extractor->GetHiGainFirst(),
402 (Int_t)extractor->GetHiGainLast(),
403 (Int_t)extractor->GetLoGainFirst(),
404 (Int_t)extractor->GetLoGainLast()));
405
406 gLog << "Extractor: " << flag << " with name: " << extractor->GetName() << endl;
407
408 return extractor;
409
410}
Note: See TracBrowser for help on using the repository browser.