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

Last change on this file since 5602 was 5580, checked in by gaug, 20 years ago
*** empty log message ***
File size: 13.4 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(4,6,4) << endl;
57// 14: SetWindows(6,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(4,6) << endl;
65// 20: SetWindowSize(6,6) << endl;
66// 21: SetWindowSize(8,8) << endl;
67// 22: SetWindowSize(14,10) << endl;
68// MExtractTimeAndChargeSpline: << endl;
69// 23: SetChargeType(MExtractTimeAndChargeSpline::kAmplitude << endl;
70// SetRange(0,10,4,11) << endl;
71// 24: SetChargeType(MExtractTimeAndChargeSpline::kIntegral) and: << endl;
72// SetRange(0,18,2,14) and the following parameters: << endl;
73// SetRiseTime(0.5); SetFallTime(0.5) << endl;
74// 25: SetRiseTime(0.5); SetFallTime(1.5) << endl;
75// 26: SetRiseTime(0.5); SetFallTime(2.5) << endl;
76// 27: SetRiseTime(1.5); SetFallTime(4.5) << 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
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(4,7,6,9);
217 break;
218 case 7:
219 extractor->SetRange(4,7,5,10);
220 break;
221 case 8:
222 extractor->SetRange(3,8,5,10);
223 break;
224 case 9:
225 extractor->SetRange(2,9,4,11);
226 break;
227 case 10:
228 extractor->SetRange(0,13,4,13);
229 break;
230 // MExtractFixedWindowPeakSearch:
231 case 11:
232 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(2,2,2);
233 break;
234 case 12:
235 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,4,2);
236 break;
237 case 13:
238 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,6,4);
239 break;
240 case 14:
241 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(6,6,4);
242 break;
243 case 15:
244 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(8,8,4);
245 break;
246 case 16:
247 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(14,10,4);
248 break;
249 // MExtractTimeAndChargeSlidingWindow
250 case 17:
251 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(2,2);
252 break;
253 case 18:
254 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,4);
255 break;
256 case 19:
257 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,6);
258 break;
259 case 20:
260 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(6,6);
261 break;
262 case 21:
263 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(8,8);
264 break;
265 case 22:
266 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(14,10);
267 break;
268 // MExtractTimeAndChargeSpline
269 case 23:
270 ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kAmplitude);
271 extractor->SetRange(0,10,4,11);
272 extractor->SetName(Form("%s_Amplitude",extractor->GetName()));
273 break;
274 case 24:
275 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime(0.5);
276 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(0.5);
277 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,0.5));
278 break;
279 case 25:
280 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime(0.5);
281 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(1.5);
282 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,1.5));
283 break;
284 case 26:
285 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime(0.5);
286 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(2.5);
287 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,2.5));
288 break;
289 case 27:
290 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime(1.5);
291 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(4.5);
292 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),1.5,4.5));
293 break;
294 // MExtractTimeAndChargeDigitalFilter
295 case 28:
296 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights.dat");
297 break;
298 case 29:
299 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4.dat");
300 break;
301 case 30:
302 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights_logaintest.dat");
303 break;
304 case 31:
305 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4_logaintest.dat");
306 break;
307 case 32:
308 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
309 break;
310 case 33:
311 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV_logaintest.dat");
312 break;
313 default:
314 gLog << "No valid extractor flag chosen, cannot run..." << endl;
315 return NULL;
316 break;
317 }
318
319 //
320 // Set the names of the extractors:
321 //
322 switch (flag)
323 {
324 case 1:
325 case 2:
326 case 3:
327 case 4:
328 case 5:
329 case 6:
330 case 7:
331 case 8:
332 case 9:
333 case 10:
334 break;
335 case 11:
336 case 12:
337 case 13:
338 case 14:
339 case 15:
340 case 16:
341 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
342 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetHiGainWindowSize(),
343 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetLoGainWindowSize()));
344 break;
345 case 17:
346 case 18:
347 case 19:
348 case 20:
349 case 21:
350 case 22:
351 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
352 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeHiGain(),
353 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeLoGain()));
354 break;
355 case 23:
356 case 24:
357 case 25:
358 case 26:
359 case 27:
360 break;
361 case 28:
362 case 29:
363 case 30:
364 case 31:
365 case 32:
366 case 33:
367 case 34:
368 case 35:
369 extractor->SetName(Form("%s_Weights_%s",extractor->GetName(),
370 gSystem->BaseName(((MExtractTimeAndChargeDigitalFilter*)extractor)->GetNameWeightsFile())));
371 break;
372 default:
373 gLog << "No valid extractor flag chosen, cannot run..." << endl;
374 return NULL;
375 break;
376 }
377
378 extractor->SetName(Form("%s_Range_%02d_%02d_%02d_%02d",extractor->GetName(),
379 (Int_t)extractor->GetHiGainFirst(),
380 (Int_t)extractor->GetHiGainLast(),
381 (Int_t)extractor->GetLoGainFirst(),
382 (Int_t)extractor->GetLoGainLast()));
383
384 gLog << "Extractor: " << flag << " with name: " << extractor->GetName() << endl;
385
386 return extractor;
387
388}
Note: See TracBrowser for help on using the repository browser.