Belle II Software  release-08-01-10
TrgBit.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef TRGBIT_h
9 #define TRGBIT_h
10 
11 #include <string>
12 #include <framework/dataobjects/EventMetaData.h>
13 #include <mdst/dataobjects/TRGSummary.h>
14 #include <trg/gdl/TrgBitInput.h>
15 
16 const int N_INPUT_ARRAY = 5;
17 const int N_OUTPUT_ARRAY = 5;
18 const int N_PSNM_ARRAY = 10;
19 const int N_BITS_RESERVED = 200;
20 
21 namespace Belle2 {
28  class TrgBit {
29 
30  public:
31 
33  TrgBit();
34 
36  virtual ~TrgBit();
37 
38  public:
39 
40 #include <trg/gdl/TrgBitOutput.h>
41 
42  public:
45 
46  public:
48  InputBitPattern() : _pattern{} {}; //TODO is it good default?
49 
51  virtual ~InputBitPattern() {};
52 
53  public:
54 
56  void set(unsigned pattern, unsigned wordPosition);
57 
59  bool isFired(unsigned bit) const;
60 
61  public:// Operators
64 
66  int operator [](unsigned);
67 
68  private:
69 
71  unsigned _pattern[6];
72 
73  };
74 
77 
78  public:
80  OutputBitPattern() : _pattern{} {}; //TODO is it good default?
81 
83  virtual ~OutputBitPattern() {};
84 
85  public:
86 
88  void set(unsigned pattern, unsigned wordPosition);
89 
91  bool isFired(unsigned bit) const;
92 
93  public:// Operators
94 
97 
99  int operator [](unsigned);
100 
101  private:
102 
104  unsigned _pattern[6];
105 
106  };
107 
108  private:
109 
110  unsigned _exp;
111  unsigned _run;
112 
113  // configuration numbers
114  unsigned nconf_psnm;
115  unsigned nconf_ftdl;
116  unsigned nconf_input;
117 
118  // number of using bits
119  unsigned n_input;
120  unsigned n_output;
121 
122  // Whether hit information is filled or not.
123  // This is true when TRGSummary class is available.
124  bool _isFiredFilled;
125 
126  public:// Selectors
127 
129  std::string version(void) const;
130 
132  unsigned preScaleValue(output A) const;
133  unsigned preScaleValue(unsigned i) const;
134 
136  void printPreScaleValues(void) const;
138  void printConf(void) const;
139 
141  bool isFired(output bitname) const;
143  bool isFired(const char* bitname) const;
145  bool isFired(input bitname) const;
146  bool isFiredInput(unsigned ith_bit) const;
147  bool isFiredInput(input bitname) const;
148  bool isFiredInput(const char* bitname) const;
149  bool isFiredFtdl(unsigned ith_bit) const;
150  bool isFiredFtdl(output bitname) const;
151  bool isFiredFtdl(const char* bitname) const;
152  bool isFiredPsnm(unsigned ith_bit) const;
153  bool isFiredPsnm(output bitname) const;
154  bool isFiredPsnm(const char* bitname) const;
155 
157  unsigned getNumOfInputs(void) {return n_input;}
158  unsigned getNumOfOutputs(void) {return n_output;}
159 
161  unsigned getOutputBitNum(const char* bitname) const;
162  unsigned getOutputBitNum(output a) {return _outputMap[nconf_ftdl][a];}
163 
165  unsigned getInputBitNum(const char* bitname) const;
166  unsigned getInputBitNum(input a) {return _inputMap[nconf_input][a];}
167 
171  int getBitNum(const char* bitname) const;
172 
174  bool isFiredFilled(void) {return _isFiredFilled;}
175 
177  bool isUsed(input a) const;
178  bool isUsed(output a) const;
179  bool isUsed(const char* bitname) const;
180 
182  const char* getInputBitName(unsigned ith_bit) const;
183  const char* getOutputBitName(unsigned ith_bit) const;
184 
187 
189  std::vector<unsigned> getInputVector(void) {return _itdVector;}
190  std::vector<unsigned> getFtdlVector(void) {return _ftdVector;}
191  std::vector<unsigned> getPsnmVector(void) {return _psnVector;}
192 
193  public:
194 
196  std::string versionFTDL(void) const;
197 
198  private:// Modifiers
199 
200  // Set configuration version from exp, run number
201  // Valid only for physics run, not for cosmic.
202  void mapNumber(unsigned exp, unsigned run);
203 
204  private:
205 
206  static const std::string _ftdlVersion[2];
207  static const unsigned _inputMap[N_INPUT_ARRAY][N_BITS_RESERVED];
208  static const unsigned _outputMap[N_OUTPUT_ARRAY][N_BITS_RESERVED];
209  static const unsigned _psnmValues[N_PSNM_ARRAY][N_BITS_RESERVED];
210  static const char* _inputBitNames[N_BITS_RESERVED];
211  static const char* _outputBitNames[N_BITS_RESERVED];
212 
213  TRGSummary::ETimingType timtype;
214 
215  InputBitPattern _input;
216  OutputBitPattern _ftdl;
217  OutputBitPattern _psnm;
218 
220  std::vector<unsigned> _itdVector;
221  std::vector<unsigned> _ftdVector;
222  std::vector<unsigned> _psnVector;
223 
224  };
225 
227 }
228 
229 #endif
ETimingType
types of trigger timing source defined in b2tt firmware
Definition: TRGSummary.h:43
Input bit pattern class.
Definition: TrgBit.h:44
int operator[](unsigned)
Bit.
Definition: TrgBit.cc:215
virtual ~InputBitPattern()
Destructor.
Definition: TrgBit.h:51
bool isFired(unsigned bit) const
get fired or not
Definition: TrgBit.cc:199
unsigned _pattern[6]
hit pattern
Definition: TrgBit.h:71
void set(unsigned pattern, unsigned wordPosition)
reads/sets a bit.
Definition: TrgBit.cc:187
int operator==(InputBitPattern &)
Comparison.
InputBitPattern()
Constructor.
Definition: TrgBit.h:48
Output bit pattern class.
Definition: TrgBit.h:76
int operator[](unsigned)
Bit.
Definition: TrgBit.cc:226
int operator==(OutputBitPattern &)
Comparison.
bool isFired(unsigned bit) const
get fired or not
Definition: TrgBit.cc:207
OutputBitPattern()
Constructor.
Definition: TrgBit.h:80
unsigned _pattern[6]
hit pattern
Definition: TrgBit.h:104
virtual ~OutputBitPattern()
Destructor.
Definition: TrgBit.h:83
void set(unsigned pattern, unsigned wordPosition)
reads/sets a bit.
Definition: TrgBit.cc:193
A general interface to get a trigger response.
Definition: TrgBit.h:28
const char * getInputBitName(unsigned ith_bit) const
returns bit name
Definition: TrgBit.cc:237
std::vector< unsigned > _itdVector
hit information in vector
Definition: TrgBit.h:220
bool isFired(output bitname) const
returns true if the psnm bit is fired.
Definition: TrgBit.cc:102
bool isFiredFilled(void)
Whether hit information is available or not.
Definition: TrgBit.h:174
bool isUsed(input a) const
Whether the bit exists for the run.
Definition: TrgBit.cc:311
std::string version(void) const
returns TrgBit version;
Definition: TrgBit.cc:15
unsigned getNumOfInputs(void)
return number of used bits
Definition: TrgBit.h:157
std::string versionFTDL(void) const
returns FTDL version;
Definition: TrgBit.cc:21
std::vector< unsigned > getInputVector(void)
return hit information in vector
Definition: TrgBit.h:189
int getBitNum(const char *bitname) const
returns bit number for the exprun, if >=0 it is input_bitnum if <0 it is -output_bitnum-1
Definition: TrgBit.cc:278
unsigned getOutputBitNum(const char *bitname) const
returns bit number
Definition: TrgBit.cc:300
virtual ~TrgBit()
Destructor.
Definition: TrgBit.cc:65
unsigned getInputBitNum(const char *bitname) const
returns bit number
Definition: TrgBit.cc:289
void printConf(void) const
print configuration values
Definition: TrgBit.cc:271
unsigned preScaleValue(output A) const
returns pre-scale value.
Definition: TrgBit.cc:174
TrgBit()
Constructor.
Definition: TrgBit.cc:26
void printPreScaleValues(void) const
print prescale values
Definition: TrgBit.cc:257
TRGSummary::ETimingType getTimingSource(void) const
returns timing source
Definition: TrgBit.cc:168
Abstract base class for different kinds of events.