source: trunk/Mars/mtrigger/MTriggerPattern.cc@ 18310

Last change on this file since 18310 was 9325, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 7.3 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:nicola.galante@pi.infn.it>
20!
21! Copyright: MAGIC Software Development, 2004-2007
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MTriggerPattern
28//
29// A container to store the decoded trigger pattern.
30//
31// The idea is, that this container will never change the meaning of its
32// variables, while the trigger pattern itself could.
33//
34// If new 'features' are necessary the decoding (MTriggerPatternDecode)
35// must be changed to correctly decode the pattern into the existing
36// MTriggerPattern. If new information is decoded you may have to
37// add new variables to this container. Don't forget to increase the
38// class version number (ClassDef) and document your change HERE.
39//
40// For files before file version 5 the trigger pattern is set to 00000000.
41//
42// --------------------------------------------------------------------------
43//
44// Here an explanation about the meaning of the Trigger Pattern.
45// The trigger pattern is a 16-BIT number where are stored informations
46// about which thriggers have been shot on each event. Every bit
47// correspond to a prticular kind of trigger (Pedestal, Calibration,
48// LT1, LT2, PIN Diode...) but the whole trigger pattern number
49// is divided into two parts (from left to right):
50//
51// 1) The first concerns unprescaled triggers.
52// 2) The second concerns prescaled triggers.
53//
54// The prescaler is a devicee installed AFTER the LT2. It collects
55// all kind of triggers and can prescale each trigger by a different
56// prescaling factor. This means that we can set the prescaler to
57// accept every LT2 trigger but only 1% of calibration triggers.
58// Therefore LT2 prescaling factor will be set to 1, while CAL prescaling
59// factor will be set to 100. If after the prescaler at least one trigger
60// survives, then the event is considered "TRIGGERED" and aquired by the DAQ.
61//
62// The current BIT meaning is:
63//
64// BIT(0): prescaled LT1
65// BIT(1): prescaled Calibration Trigger
66// BIT(2): prescaled LT2
67// BIT(3): prescaled Pedestal Trigger
68// BIT(4): prescaled Pin Diode
69// BIT(5): prescaled Sum Trigger
70// BIT(6): unused
71// BIT(7): unused
72// BIT(8): unprescaled LT1
73// BIT(9): unprescaled Calibration Trigger
74// BIT(10): unprescaled LT2
75// BIT(11): unprescaled Pedestal Trigger
76// BIT(12): unprescaled Pin Diode
77// BIT(13): unprescaled Sum Trigger
78// BIT(14): unused
79// BIT(15): unused
80//
81// Why are we saving both prescaled and unprescaled triggers?
82// Which should I look at? Let's give an example:
83//
84// BIT # 15-14-13-12-11-10- 9- 8- 7- 6- 5- 4- 3- 2- 1- 0
85//
86// event #1: 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1
87// event #2: 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1
88//
89// In both cases you have both CAL and LT1 trigger, but in first
90// event calibration trigger is prescaled and in second event no
91// trigger is prescaled. Imagine you are looking for calibration events.
92// If you look at the prescale bits you are sure that events with CAL
93// flag are calibration events (event #2) but you can miss other
94// real calibration events (event #1). If you are lucky that
95// the related prescaling factor is 1 you won't have this problem,
96// otherway you will have it.
97//
98// To select events by the trigger pattern you should use MFTriggerPattern
99// filter. This filter uses Require- and Deny- methods to select your
100// trigger pattern. Require- methods requires that your trigger bit is ON,
101// otherway the event is kicked out. Deny- methods requires that your
102// trigger bit is OFF, otherway your event is kicked out. Other bits not
103// selected by your Require- or Deny- call are ignored. Let's give an
104// example. You want to select all events that have both LT1 and LT2
105// trigger but which are not calibration neither Pin Diode events. You
106// should look at unprescaled bits to be sure about which were the initial
107// triggers. Then you can implement in your macro something like:
108//
109// MFTriggerPattern ftrigpatt;
110// ftrigpatt.RequireTriggerLvl1(MFTriggerPattern::kUnPrescaled);
111// ftrigpatt.RequireTriggerLvl2(MFTriggerPattern::kUnPrescaled);
112// ftrigpatt.DenyCalibration(MFTriggerPattern::kUnPrescaled);
113// ftrigpatt.DenyPinDiode(MFTriggerPattern::kUnPrescaled);
114//
115// Then you use in your tasklist as a usual MF filter. In this
116// example Pedestal trigger flag is ignored. Consider that by default
117// MFTriggerPattern::kUnPrescaled is set for Require- and Deny- methods.
118//
119// WARNING: please use MTriggerPatternDecode task to read the trigger pattern
120// of the event and to fill MTriggerPattern container. If you use your
121// private stuff to read MRawEvtHeader.fTriggerPattern[0] (data member
122// where the trigger pattern is stored) you must invert all the bits of
123// your number. Current hardware, infact, writes the trigger pattern bit-inverted.
124//
125//
126// For further informations contact:
127//
128// Nicola Galante nicola.galante@pi.infn.it
129// Riccardo Paoletti riccardo.paoletti@pi.infn.it
130// Antonio Stamerra antonio.stamerra@pi.infn.it
131//
132/////////////////////////////////////////////////////////////////////////////
133#include "MTriggerPattern.h"
134
135#include "MLog.h"
136#include "MLogManip.h"
137
138ClassImp(MTriggerPattern);
139
140using namespace std;
141
142// --------------------------------------------------------------------------
143//
144// Default constructor
145//
146MTriggerPattern::MTriggerPattern(const char *name, const char *title)
147 : fPrescaled(0), fUnprescaled(0)
148{
149 fName = name ? name : "MTriggerPattern";
150 fTitle = title ? title : "Container for decoded trigger pattern";
151}
152
153void MTriggerPattern::Copy(TObject &obj) const
154{
155 static_cast<MTriggerPattern&>(obj).fPrescaled=fPrescaled;
156 static_cast<MTriggerPattern&>(obj).fUnprescaled=fUnprescaled;
157}
158
159void MTriggerPattern::Print(Option_t *) const
160{
161 *fLog << all;
162 *fLog << "Trigger Pattern (un/prescaled): ";
163
164 if (fUnprescaled&kPedestal)
165 *fLog << "P";
166 if (fUnprescaled&kCalibration)
167 *fLog << "C";
168 if (fUnprescaled&kTriggerLvl1)
169 *fLog << "1";
170 if (fUnprescaled&kTriggerLvl2)
171 *fLog << "2";
172 if (fUnprescaled&kSumTrigger)
173 *fLog << "S";
174 if (fUnprescaled&kPinDiode)
175 *fLog << "-";
176 *fLog << "/";
177 if (fPrescaled&kPedestal)
178 *fLog << "P";
179 if (fPrescaled&kCalibration)
180 *fLog << "C";
181 if (fPrescaled&kTriggerLvl1)
182 *fLog << "1";
183 if (fPrescaled&kTriggerLvl2)
184 *fLog << "2";
185 if (fPrescaled&kSumTrigger)
186 *fLog << "S";
187 if (fPrescaled&kPinDiode)
188 *fLog << "-";
189 *fLog << endl;
190}
Note: See TracBrowser for help on using the repository browser.