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

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