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

Last change on this file since 5954 was 5903, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 9.5 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)
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 fResult = kFALSE;
89
90 const Byte_t p = fPattern->GetPrescaled();
91 const Byte_t u = fPattern->GetUnprescaled();
92
93 // Check whether all the bits required are ON
94 if ( ((p & fMaskRequiredPrescaled) == fMaskRequiredPrescaled) &&
95 ((u & fMaskRequiredUnprescaled) == fMaskRequiredUnprescaled))
96 fResult = kTRUE;
97
98 // Now overwrite the result if one of the bits is denied
99 if ( (p & fMaskDeniedPrescaled) || (u & fMaskDeniedUnprescaled) )
100 fResult = kFALSE;
101
102 return kTRUE;
103}
104
105void MFTriggerPattern::RequireTriggerLvl1(Prescale_t prescaled)
106{
107 prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kTriggerLvl1) : (fMaskRequiredUnprescaled |= MTriggerPattern::kTriggerLvl1);
108}
109
110void MFTriggerPattern::RequireTriggerLvl2(Prescale_t prescaled)
111{
112 prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kTriggerLvl2) : (fMaskRequiredUnprescaled |= MTriggerPattern::kTriggerLvl2);
113}
114
115void MFTriggerPattern::RequireCalibration(Prescale_t prescaled)
116{
117 prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kCalibration) : (fMaskRequiredUnprescaled |= MTriggerPattern::kCalibration);
118}
119
120void MFTriggerPattern::RequirePedestal(Prescale_t prescaled)
121{
122 prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kPedestal) : (fMaskRequiredUnprescaled |= MTriggerPattern::kPedestal);
123}
124
125void MFTriggerPattern::RequirePinDiode(Prescale_t prescaled)
126{
127 prescaled==kPrescaled ? (fMaskRequiredPrescaled |= MTriggerPattern::kPinDiode) : (fMaskRequiredUnprescaled |= MTriggerPattern::kPinDiode);
128}
129
130
131void MFTriggerPattern::DenyTriggerLvl1(Prescale_t prescaled)
132{
133 prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kTriggerLvl1) : (fMaskDeniedUnprescaled |= MTriggerPattern::kTriggerLvl1);
134}
135
136void MFTriggerPattern::DenyTriggerLvl2(Prescale_t prescaled)
137{
138 prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kTriggerLvl2) : (fMaskDeniedUnprescaled |= MTriggerPattern::kTriggerLvl2);
139}
140
141void MFTriggerPattern::DenyCalibration(Prescale_t prescaled)
142{
143 prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kCalibration) : (fMaskDeniedUnprescaled |= MTriggerPattern::kCalibration);
144}
145
146void MFTriggerPattern::DenyPedestal(Prescale_t prescaled)
147{
148 prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kPedestal) : (fMaskDeniedUnprescaled |= MTriggerPattern::kPedestal);
149}
150
151void MFTriggerPattern::DenyPinDiode(Prescale_t prescaled)
152{
153 prescaled==kPrescaled ? (fMaskDeniedPrescaled |= MTriggerPattern::kPinDiode) : (fMaskDeniedUnprescaled |= MTriggerPattern::kPinDiode);
154}
155
156// -------------------------------------------------------------------------
157//
158// Low level settings. USE THESE ONLY IF YOU ARE AN EXPERT!
159//
160// You can concatenate bits either by using MTriggerPatter:
161// eg. MTriggerPattern::kTriggerLvl1 & MTiggerPattern::kTriggerLvl2
162// of by hexadecimal values:
163// eg. 0xab
164//
165// while 0xab can be decoded like:
166//
167// 8421 8421
168// 0xa=10=8+2 0xb=11=8+2+1 --> 1010 1011
169//
170// or vice versa it is easy to get a hexadecimal number from a bit pattern,
171// eg.
172//
173// 8421 8421
174// 0101 1101 --> 4+1=5=0x5 8+4+1=13=0xd --> 0x5d
175//
176void MFTriggerPattern::SetMaskRequired(const Byte_t mask, Prescale_t prescaled)
177{
178 prescaled==kPrescaled ? (fMaskRequiredPrescaled = mask) : (fMaskRequiredUnprescaled = mask);
179}
180
181// -------------------------------------------------------------------------
182//
183// Low level settings. USE THESE ONLY IF YOU ARE AN EXPERT!
184//
185// You can concatenate bits either by using MTriggerPatter:
186// eg. MTriggerPattern::kTriggerLvl1 & MTiggerPattern::kTriggerLvl2
187// of by hexadecimal values:
188// eg. 0xab
189//
190// while 0xab can be decoded like:
191//
192// 8421 8421
193// 0xa=10=8+2 0xb=11=8+2+1 --> 1010 1011
194//
195// or vice versa it is easy to get a hexadecimal number from a bit pattern,
196// eg.
197//
198// 8421 8421
199// 0101 1101 --> 4+1=5=0x5 8+4+1=13=0xd --> 0x5d
200//
201void MFTriggerPattern::SetMaskDenied(const Byte_t mask, Prescale_t prescaled)
202{
203 prescaled==kPrescaled ? (fMaskDeniedPrescaled = mask) : (fMaskDeniedUnprescaled = mask);
204}
205
206// -------------------------------------------------------------------------
207//
208// Create the mask to allow a particular (un)prescaled trigger pattern.
209//
210// Possible arguments are (upper/lower case is ignored):
211//
212// "LT1" : Trigger Level 1 flag
213// "CAL" : Calibration flag
214// "LT2" : Trigger Level 2 flag
215// "PED" : Pedestal flag
216// "PIND" : Pin Diode flag
217//
218// concatenations of these strings are allowed and considered as
219// a logic "and", while trigger pattern flags not considered are
220// anyway allowed. To deny a particular trigger pattern use
221// the method Deny
222// Example: patt = "lt1 lt2" allows events with trigger pattern flags
223// {LT1,CAL,LT2} but not events with flags {LT1,CAL}.
224//
225void MFTriggerPattern::Require(TString patt, Prescale_t prescaled)
226{
227 if (patt.Contains("LT1", TString::kIgnoreCase))
228 RequireTriggerLvl1(prescaled);
229
230 if (patt.Contains("LT2", TString::kIgnoreCase))
231 RequireTriggerLvl2(prescaled);
232
233 if (patt.Contains("CAL", TString::kIgnoreCase))
234 RequireCalibration(prescaled);
235
236 if (patt.Contains("PED", TString::kIgnoreCase))
237 RequirePedestal(prescaled);
238
239 if (patt.Contains("PIND", TString::kIgnoreCase))
240 RequirePinDiode(prescaled);
241}
242
243// -------------------------------------------------------------------------
244//
245// Create the mask to deny a particular (un)prescaled trigger pattern.
246//
247// This method is there because is not possible to deny trigger patterns
248// using only the Require pattern. Possible arguments are (upper/lower
249// case is ignored):
250//
251// "LT1" : Trigger Level 1 flag
252// "CAL" : Calibration flag
253// "LT2" : Trigger Level 2 flag
254// "PED" : Pedestal flag
255// "PIND" : Pin Diode flag
256//
257// concatenations of these strings are allowed and considered as
258// a logic "and", while trigger pattern flags not considered are
259// anyway allowed.
260//
261// Example: patt = "lt1 lt2" deny events with trigger pattern flags
262// {LT1,CAL,LT2} but not events with flags {LT1,CAL}.
263//
264void MFTriggerPattern::Deny(TString patt, Prescale_t prescaled)
265{
266 if (patt.Contains("LT1", TString::kIgnoreCase))
267 DenyTriggerLvl1(prescaled);
268
269 if (patt.Contains("LT2", TString::kIgnoreCase))
270 DenyTriggerLvl2(prescaled);
271
272 if (patt.Contains("CAL", TString::kIgnoreCase))
273 DenyCalibration(prescaled);
274
275 if (patt.Contains("PED", TString::kIgnoreCase))
276 DenyPedestal(prescaled);
277
278 if (patt.Contains("PIND", TString::kIgnoreCase))
279 DenyPinDiode(prescaled);
280}
281
282// --------------------------------------------------------------------------
283//
284Bool_t MFTriggerPattern::IsExpressionTrue() const
285{
286 return fResult;
287}
Note: See TracBrowser for help on using the repository browser.