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

Last change on this file since 5574 was 5531, 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(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
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(6,6,4);
239 break;
240 case 14:
241 ((MExtractFixedWindowPeakSearch*)extractor)->SetWindows(4,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(6,6);
258 break;
259 case 20:
260 ((MExtractTimeAndChargeSlidingWindow*)extractor)->SetWindowSize(4,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)->SetRiseTime(1.5);
271 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(4.5);
272 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),1.5,4.5));
273 break;
274 case 24:
275 ((MExtractTimeAndChargeSpline*)extractor)->SetRiseTime(0.5);
276 ((MExtractTimeAndChargeSpline*)extractor)->SetFallTime(2.5);
277 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,2.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(0.5);
287 extractor->SetName(Form("%s_Rise-and-Fall-Time_%2.1f_%2.1f",extractor->GetName(),0.5,0.5));
288 break;
289 case 27:
290 ((MExtractTimeAndChargeSpline*)extractor)->SetChargeType(MExtractTimeAndChargeSpline::kAmplitude);
291 extractor->SetRange(0,10,4,11);
292 break;
293 // MExtractTimeAndChargeDigitalFilter
294 case 28:
295 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights.dat");
296 break;
297 case 29:
298 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4.dat");
299 break;
300 case 30:
301 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights_logaintest.dat");
302 break;
303 case 31:
304 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/cosmics_weights4_logaintest.dat");
305 break;
306 case 32:
307 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV.dat");
308 break;
309 case 33:
310 ((MExtractTimeAndChargeDigitalFilter*)extractor)->SetNameWeightsFile("msignal/calibration_weights_UV_logaintest.dat");
311 break;
312 default:
313 gLog << "No valid extractor flag chosen, cannot run..." << endl;
314 return NULL;
315 break;
316 }
317
318 //
319 // Set the names of the extractors:
320 //
321 switch (flag)
322 {
323 case 1:
324 case 2:
325 case 3:
326 case 4:
327 case 5:
328 case 6:
329 case 7:
330 case 8:
331 case 9:
332 case 10:
333 break;
334 case 11:
335 case 12:
336 case 13:
337 case 14:
338 case 15:
339 case 16:
340 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
341 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetHiGainWindowSize(),
342 (Int_t)((MExtractFixedWindowPeakSearch*)extractor)->GetLoGainWindowSize()));
343 break;
344 case 17:
345 case 18:
346 case 19:
347 case 20:
348 case 21:
349 case 22:
350 extractor->SetName(Form("%s_Windows_%02d_%02d",extractor->GetName(),
351 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeHiGain(),
352 (Int_t)((MExtractTimeAndChargeSlidingWindow*)extractor)->GetWindowSizeLoGain()));
353 break;
354 case 23:
355 case 24:
356 case 25:
357 case 26:
358 break;
359 case 27:
360 extractor->SetName(Form("%s_Amplitude",extractor->GetName()));
361 break;
362 case 28:
363 case 29:
364 case 30:
365 case 31:
366 case 32:
367 case 33:
368 case 34:
369 case 35:
370 extractor->SetName(Form("%s_Weights_%s",extractor->GetName(),
371 gSystem->BaseName(((MExtractTimeAndChargeDigitalFilter*)extractor)->GetNameWeightsFile())));
372 break;
373 default:
374 gLog << "No valid extractor flag chosen, cannot run..." << endl;
375 return NULL;
376 break;
377 }
378
379 extractor->SetName(Form("%s_Range_%02d_%02d_%02d_%02d",extractor->GetName(),
380 (Int_t)extractor->GetHiGainFirst(),
381 (Int_t)extractor->GetHiGainLast(),
382 (Int_t)extractor->GetLoGainFirst(),
383 (Int_t)extractor->GetLoGainLast()));
384
385 gLog << "Extractor: " << flag << " with name: " << extractor->GetName() << endl;
386
387 return extractor;
388
389}
Note: See TracBrowser for help on using the repository browser.