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

Last change on this file since 6364 was 6362, checked in by gaug, 21 years ago
*** empty log message ***
File size: 13.9 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 extractor = new MExtractTimeAndChargeDigitalFilter();
189 extractor->SetRange(0,14,3,14);
190 break;
191 case 35:
192 extractor = new MExtractTimeAndChargeDigitalFilterPeakSearch();
193 extractor->SetRange(0,20,3,14);
194 break;
195 default:
196 gLog << "No valid extractor flag chosen, cannot run..." << flag << endl;
197 return NULL;
198 break;
199 }
200
201 //
202 // Set Ranges or Windows
203 //
204 switch (flag)
205 {
206 // MExtractFixedWindow:
207 case 1:
208 extractor->SetRange(4,7,6,9);
209 break;
210 case 2:
211 extractor->SetRange(4,7,6,11);
212 break;
213 case 3:
214 extractor->SetRange(4,9,6,11);
215 break;
216 case 4:
217 extractor->SetRange(4,11,6,13);
218 break;
219 case 5:
220 extractor->SetRange(3,16,5,14);
221 break;
222 // MExtractFixedWindowSpline:
223 case 6:
224 extractor->SetRange(4,8,6,10);
225 break;
226 case 7:
227 extractor->SetRange(4,8,5,11);
228 break;
229 case 8:
230 extractor->SetRange(4,10,5,11);
231 break;
232 case 9:
233 extractor->SetRange(3,11,5,13);
234 break;
235 case 10:
236 extractor->SetRange(3,17,4,14);
237 break;
238 // MExtractFixedWindowPeakSearch:
239 case 11:
240 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(2,2,2);
241 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(0);
242 break;
243 case 12:
244 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,4,2);
245 break;
246 case 13:
247 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,6,4);
248 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(0);
249 break;
250 case 14:
251 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(6,6,4);
252 break;
253 case 15:
254 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(8,8,4);
255 break;
256 case 16:
257 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(14,10,4);
258 ((MExtractFixedWindowPeakSearch*)extractor)->SetOffsetFromWindow(2);
259 break;
260 // MExtractTimeAndChargeSlidingWindow
261 case 17:
262 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(2,2);
263 break;
264 case 18:
265 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,4);
266 break;
267 case 19:
268 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,6);
269 break;
270 case 20:
271 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(6,6);
272 break;
273 case 21:
274 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(8,8);
275 break;
276 case 22:
277 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(14,10);
278 break;
279 // MExtractTimeAndChargeSpline
280 case 23:
281 ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kAmplitude);
282 extractor->SetRange(0,13,2,13);
283 extractor->SetName(Form("%s_Amplitude",extractor->GetName()));
284 break;
285 case 24:
286 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(0.5);
287 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(0.5);
288 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,0.5));
289 break;
290 case 25:
291 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(0.5);
292 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(1.5);
293 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,1.5));
294 break;
295 case 26:
296 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(1.0);
297 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(3.0);
298 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,2.5));
299 break;
300 case 27:
301 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTimeHiGain(1.5);
302 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTimeHiGain(4.5);
303 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),1.5,4.5));
304 break;
305 // MExtractTimeAndChargeDigitalFilter
306 case 28:
307 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights.dat");
308 break;
309 case 29:
310 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4.dat");
311 break;
312 case 30:
313 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights_logaintest.dat");
314 break;
315 case 31:
316 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4_logaintest.dat");
317 break;
318 case 32:
319 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
320 break;
321 case 33:
322 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV_logaintest.dat");
323 break;
324 case 34:
325 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/MC_weights.dat");
326 break;
327 case 35:
328 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
329 break;
330 default:
331 gLog << "No valid extractor flag chosen, cannot run..." << endl;
332 return NULL;
333 break;
334 }
335
336 //
337 // Set the names of the extractors:
338 //
339 switch (flag)
340 {
341 case 1:
342 case 2:
343 case 3:
344 case 4:
345 case 5:
346 case 6:
347 case 7:
348 case 8:
349 case 9:
350 case 10:
351 break;
352 case 11:
353 case 12:
354 case 13:
355 case 14:
356 case 15:
357 case 16:
358 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
359 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetHiGainWindowSize(),
360 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetLoGainWindowSize()));
361 break;
362 case 17:
363 case 18:
364 case 19:
365 case 20:
366 case 21:
367 case 22:
368 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
369 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeHiGain(),
370 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeLoGain()));
371 break;
372 case 23:
373 case 24:
374 case 25:
375 case 26:
376 case 27:
377 break;
378 case 28:
379 case 29:
380 case 30:
381 case 31:
382 case 32:
383 case 33:
384 case 34:
385 case 35:
386 extractor->SetName(Form("%s_Weights_%s",extractor->GetName(),
387 gSystem->BaseName(((MExtractTimeAndChargeDigitalFilter*)extractor)->GetNameWeightsFile())));
388 break;
389 default:
390 gLog << "No valid extractor flag chosen, cannot run..." << endl;
391 return NULL;
392 break;
393 }
394
395 extractor->SetName(Form("%s_Range_%02d_%02d_%02d_%02d",extractor->GetName(),
396 (Int_t)extractor->GetHiGainFirst(),
397 (Int_t)extractor->GetHiGainLast(),
398 (Int_t)extractor->GetLoGainFirst(),
399 (Int_t)extractor->GetLoGainLast()));
400
401 gLog << "Extractor: " << flag << " with name: " << extractor->GetName() << endl;
402
403 return extractor;
404
405}
Note: See TracBrowser for help on using the repository browser.