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): Nicola Galante 12/2004 <mailto:nicola.galante@pi.infn.it>
|
---|
19 | ! Author(s): Thomas Bretz 12/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2004-2007
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MFTriggerPattern
|
---|
28 | //
|
---|
29 | // A Filter for testing the trigger performance using Trigger Pattern.
|
---|
30 | //
|
---|
31 | // For files before file version 5 the trigger pattern is set to 00000000.
|
---|
32 | //
|
---|
33 | // For more details see: MTriggerPattern
|
---|
34 | //
|
---|
35 | /////////////////////////////////////////////////////////////////////////////
|
---|
36 | #include "MFTriggerPattern.h"
|
---|
37 |
|
---|
38 | #include "MLog.h"
|
---|
39 | #include "MLogManip.h"
|
---|
40 |
|
---|
41 | #include "MParList.h"
|
---|
42 | #include "MTriggerPattern.h"
|
---|
43 |
|
---|
44 | ClassImp(MFTriggerPattern);
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | // --------------------------------------------------------------------------
|
---|
49 | //
|
---|
50 | // Default constructor. The default is to allow passing any trigger pattern.
|
---|
51 | //
|
---|
52 | MFTriggerPattern::MFTriggerPattern(const char *name, const char *title)
|
---|
53 | : fPattern(0), fMaskRequiredPrescaled(0), fMaskRequiredUnprescaled(0),
|
---|
54 | fMaskDeniedPrescaled(0), fMaskDeniedUnprescaled(0), fDefault(kTRUE)
|
---|
55 | {
|
---|
56 | fName = name ? name : "MFTriggerPattern";
|
---|
57 | fTitle = title ? title : "Filter on Trigger Pattern";
|
---|
58 | }
|
---|
59 |
|
---|
60 | // --------------------------------------------------------------------------
|
---|
61 | //
|
---|
62 | // Copy constructor
|
---|
63 | //
|
---|
64 | MFTriggerPattern::MFTriggerPattern(MFTriggerPattern &trigpatt)
|
---|
65 | : MFilter(trigpatt)
|
---|
66 | {
|
---|
67 | fMaskRequiredPrescaled = trigpatt.fMaskRequiredPrescaled;
|
---|
68 | fMaskRequiredUnprescaled = trigpatt.fMaskRequiredUnprescaled;
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | Int_t MFTriggerPattern::PreProcess(MParList *pList)
|
---|
75 | {
|
---|
76 | fPattern = (MTriggerPattern*)pList->FindObject("MTriggerPattern");
|
---|
77 | if (!fPattern)
|
---|
78 | {
|
---|
79 | *fLog << err << "MTriggerPattern not found... abort." << endl;
|
---|
80 | return kFALSE;
|
---|
81 | }
|
---|
82 |
|
---|
83 | return kTRUE;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | Int_t MFTriggerPattern::Process()
|
---|
89 | {
|
---|
90 | const Byte_t p = fPattern->GetPrescaled();
|
---|
91 | const Byte_t u = fPattern->GetUnprescaled();
|
---|
92 | if (p==0 && u==0)
|
---|
93 | {
|
---|
94 | fResult = fDefault;
|
---|
95 | return kTRUE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | fResult = kFALSE;
|
---|
99 |
|
---|
100 | // Check whether all the bits required are ON
|
---|
101 | if ( ((p & fMaskRequiredPrescaled) == fMaskRequiredPrescaled) &&
|
---|
102 | ((u & fMaskRequiredUnprescaled) == fMaskRequiredUnprescaled))
|
---|
103 | fResult = kTRUE;
|
---|
104 |
|
---|
105 | // Now overwrite the result if one of the bits is denied
|
---|
106 | if ( (p & fMaskDeniedPrescaled) || (u & fMaskDeniedUnprescaled) )
|
---|
107 | fResult = kFALSE;
|
---|
108 |
|
---|
109 | return kTRUE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | void MFTriggerPattern::RequireTriggerLvl1(Prescale_t prescaled)
|
---|
113 | {
|
---|
114 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kTriggerLvl1) : (fMaskRequiredUnprescaled |= MTriggerPattern::kTriggerLvl1);
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MFTriggerPattern::RequireTriggerLvl2(Prescale_t prescaled)
|
---|
118 | {
|
---|
119 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kTriggerLvl2) : (fMaskRequiredUnprescaled |= MTriggerPattern::kTriggerLvl2);
|
---|
120 | }
|
---|
121 |
|
---|
122 | void MFTriggerPattern::RequireCalibration(Prescale_t prescaled)
|
---|
123 | {
|
---|
124 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kCalibration) : (fMaskRequiredUnprescaled |= MTriggerPattern::kCalibration);
|
---|
125 | }
|
---|
126 |
|
---|
127 | void MFTriggerPattern::RequirePedestal(Prescale_t prescaled)
|
---|
128 | {
|
---|
129 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kPedestal) : (fMaskRequiredUnprescaled |= MTriggerPattern::kPedestal);
|
---|
130 | }
|
---|
131 |
|
---|
132 | void MFTriggerPattern::RequirePinDiode(Prescale_t prescaled)
|
---|
133 | {
|
---|
134 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kPinDiode) : (fMaskRequiredUnprescaled |= MTriggerPattern::kPinDiode);
|
---|
135 | }
|
---|
136 |
|
---|
137 | void MFTriggerPattern::RequireSumTrigger(Prescale_t prescaled)
|
---|
138 | {
|
---|
139 | prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kSumTrigger) : (fMaskRequiredUnprescaled |= MTriggerPattern::kSumTrigger);
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | void MFTriggerPattern::DenyTriggerLvl1(Prescale_t prescaled)
|
---|
144 | {
|
---|
145 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kTriggerLvl1) : (fMaskDeniedUnprescaled |= MTriggerPattern::kTriggerLvl1);
|
---|
146 | }
|
---|
147 |
|
---|
148 | void MFTriggerPattern::DenyTriggerLvl2(Prescale_t prescaled)
|
---|
149 | {
|
---|
150 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kTriggerLvl2) : (fMaskDeniedUnprescaled |= MTriggerPattern::kTriggerLvl2);
|
---|
151 | }
|
---|
152 |
|
---|
153 | void MFTriggerPattern::DenyCalibration(Prescale_t prescaled)
|
---|
154 | {
|
---|
155 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kCalibration) : (fMaskDeniedUnprescaled |= MTriggerPattern::kCalibration);
|
---|
156 | }
|
---|
157 |
|
---|
158 | void MFTriggerPattern::DenyPedestal(Prescale_t prescaled)
|
---|
159 | {
|
---|
160 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kPedestal) : (fMaskDeniedUnprescaled |= MTriggerPattern::kPedestal);
|
---|
161 | }
|
---|
162 |
|
---|
163 | void MFTriggerPattern::DenyPinDiode(Prescale_t prescaled)
|
---|
164 | {
|
---|
165 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kPinDiode) : (fMaskDeniedUnprescaled |= MTriggerPattern::kPinDiode);
|
---|
166 | }
|
---|
167 |
|
---|
168 | void MFTriggerPattern::DenySumTrigger(Prescale_t prescaled)
|
---|
169 | {
|
---|
170 | prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kSumTrigger) : (fMaskDeniedUnprescaled |= MTriggerPattern::kSumTrigger);
|
---|
171 | }
|
---|
172 |
|
---|
173 | // -------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Low level settings. USE THESE ONLY IF YOU ARE AN EXPERT!
|
---|
176 | //
|
---|
177 | // You can concatenate bits either by using MTriggerPatter:
|
---|
178 | // eg. MTriggerPattern::kTriggerLvl1 & MTiggerPattern::kTriggerLvl2
|
---|
179 | // of by hexadecimal values:
|
---|
180 | // eg. 0xab
|
---|
181 | //
|
---|
182 | // while 0xab can be decoded like:
|
---|
183 | //
|
---|
184 | // 8421 8421
|
---|
185 | // 0xa=10=8+2 0xb=11=8+2+1 --> 1010 1011
|
---|
186 | //
|
---|
187 | // or vice versa it is easy to get a hexadecimal number from a bit pattern,
|
---|
188 | // eg.
|
---|
189 | //
|
---|
190 | // 8421 8421
|
---|
191 | // 0101 1101 --> 4+1=5=0x5 8+4+1=13=0xd --> 0x5d
|
---|
192 | //
|
---|
193 | void MFTriggerPattern::SetMaskRequired(const Byte_t mask, Prescale_t prescaled)
|
---|
194 | {
|
---|
195 | prescaled==kPrescaled ? (fMaskRequiredPrescaled = mask) : (fMaskRequiredUnprescaled = mask);
|
---|
196 | }
|
---|
197 |
|
---|
198 | // -------------------------------------------------------------------------
|
---|
199 | //
|
---|
200 | // Low level settings. USE THESE ONLY IF YOU ARE AN EXPERT!
|
---|
201 | //
|
---|
202 | // You can concatenate bits either by using MTriggerPatter:
|
---|
203 | // eg. MTriggerPattern::kTriggerLvl1 & MTiggerPattern::kTriggerLvl2
|
---|
204 | // of by hexadecimal values:
|
---|
205 | // eg. 0xab
|
---|
206 | //
|
---|
207 | // while 0xab can be decoded like:
|
---|
208 | //
|
---|
209 | // 8421 8421
|
---|
210 | // 0xa=10=8+2 0xb=11=8+2+1 --> 1010 1011
|
---|
211 | //
|
---|
212 | // or vice versa it is easy to get a hexadecimal number from a bit pattern,
|
---|
213 | // eg.
|
---|
214 | //
|
---|
215 | // 8421 8421
|
---|
216 | // 0101 1101 --> 4+1=5=0x5 8+4+1=13=0xd --> 0x5d
|
---|
217 | //
|
---|
218 | void MFTriggerPattern::SetMaskDenied(const Byte_t mask, Prescale_t prescaled)
|
---|
219 | {
|
---|
220 | prescaled==kPrescaled ? (fMaskDeniedPrescaled = mask) : (fMaskDeniedUnprescaled = mask);
|
---|
221 | }
|
---|
222 |
|
---|
223 | // -------------------------------------------------------------------------
|
---|
224 | //
|
---|
225 | // Create the mask to allow a particular (un)prescaled trigger pattern.
|
---|
226 | //
|
---|
227 | // Possible arguments are (upper/lower case is ignored):
|
---|
228 | //
|
---|
229 | // "LT1" : Trigger Level 1 flag
|
---|
230 | // "CAL" : Calibration flag
|
---|
231 | // "LT2" : Trigger Level 2 flag
|
---|
232 | // "PED" : Pedestal flag
|
---|
233 | // "PIND" : Pin Diode flag
|
---|
234 | // "SUMT" : Sum Trigger flag
|
---|
235 | //
|
---|
236 | // concatenations of these strings are allowed and considered as
|
---|
237 | // a logic "and", while trigger pattern flags not considered are
|
---|
238 | // anyway allowed. To deny a particular trigger pattern use
|
---|
239 | // the method Deny
|
---|
240 | // Example: patt = "lt1 lt2" allows events with trigger pattern flags
|
---|
241 | // {LT1,CAL,LT2} but not events with flags {LT1,CAL}.
|
---|
242 | //
|
---|
243 | void MFTriggerPattern::Require(TString patt, Prescale_t prescaled)
|
---|
244 | {
|
---|
245 | if (patt.Contains("LT1", TString::kIgnoreCase))
|
---|
246 | RequireTriggerLvl1(prescaled);
|
---|
247 |
|
---|
248 | if (patt.Contains("LT2", TString::kIgnoreCase))
|
---|
249 | RequireTriggerLvl2(prescaled);
|
---|
250 |
|
---|
251 | if (patt.Contains("CAL", TString::kIgnoreCase))
|
---|
252 | RequireCalibration(prescaled);
|
---|
253 |
|
---|
254 | if (patt.Contains("PED", TString::kIgnoreCase))
|
---|
255 | RequirePedestal(prescaled);
|
---|
256 |
|
---|
257 | if (patt.Contains("PIND", TString::kIgnoreCase))
|
---|
258 | RequirePinDiode(prescaled);
|
---|
259 |
|
---|
260 | if (patt.Contains("SUMT", TString::kIgnoreCase))
|
---|
261 | RequireSumTrigger(prescaled);
|
---|
262 | }
|
---|
263 |
|
---|
264 | // -------------------------------------------------------------------------
|
---|
265 | //
|
---|
266 | // Create the mask to deny a particular (un)prescaled trigger pattern.
|
---|
267 | //
|
---|
268 | // This method is there because is not possible to deny trigger patterns
|
---|
269 | // using only the Require pattern. Possible arguments are (upper/lower
|
---|
270 | // case is ignored):
|
---|
271 | //
|
---|
272 | // "LT1" : Trigger Level 1 flag
|
---|
273 | // "CAL" : Calibration flag
|
---|
274 | // "LT2" : Trigger Level 2 flag
|
---|
275 | // "PED" : Pedestal flag
|
---|
276 | // "PIND" : Pin Diode flag
|
---|
277 | // "SUMT" : Sum Trigger flag
|
---|
278 | //
|
---|
279 | // concatenations of these strings are allowed and considered as
|
---|
280 | // a logic "and", while trigger pattern flags not considered are
|
---|
281 | // anyway allowed.
|
---|
282 | //
|
---|
283 | // Example: patt = "lt1 lt2" deny events with trigger pattern flags
|
---|
284 | // {LT1,CAL,LT2} but not events with flags {LT1,CAL}.
|
---|
285 | //
|
---|
286 | void MFTriggerPattern::Deny(TString patt, Prescale_t prescaled)
|
---|
287 | {
|
---|
288 | if (patt.Contains("LT1", TString::kIgnoreCase))
|
---|
289 | DenyTriggerLvl1(prescaled);
|
---|
290 |
|
---|
291 | if (patt.Contains("LT2", TString::kIgnoreCase))
|
---|
292 | DenyTriggerLvl2(prescaled);
|
---|
293 |
|
---|
294 | if (patt.Contains("CAL", TString::kIgnoreCase))
|
---|
295 | DenyCalibration(prescaled);
|
---|
296 |
|
---|
297 | if (patt.Contains("PED", TString::kIgnoreCase))
|
---|
298 | DenyPedestal(prescaled);
|
---|
299 |
|
---|
300 | if (patt.Contains("PIND", TString::kIgnoreCase))
|
---|
301 | DenyPinDiode(prescaled);
|
---|
302 |
|
---|
303 | if (patt.Contains("SUMT", TString::kIgnoreCase))
|
---|
304 | DenySumTrigger(prescaled);
|
---|
305 | }
|
---|
306 |
|
---|
307 | // --------------------------------------------------------------------------
|
---|
308 | //
|
---|
309 | Bool_t MFTriggerPattern::IsExpressionTrue() const
|
---|
310 | {
|
---|
311 | return fResult;
|
---|
312 | }
|
---|