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

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