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