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

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