source: trunk/MagicSoft/Mars/mtrigger/MFTriggerPattern.cc@ 7106

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