CMS 3D CMS Logo

L1MuGMTCand.h
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
9 //
10 //
11 // Author :
12 // H. Sakulin HEPHY Vienna
13 // N. Neumeister CERN EP
14 //
15 // Migrated to CMSSW:
16 // I. Mikulec
17 //
18 //--------------------------------------------------
19 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
20 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
21 
22 //---------------
23 // C++ Headers --
24 //---------------
25 #include <string>
26 
27 //----------------------
28 // Base Class Headers --
29 //----------------------
30 
31 //------------------------------------
32 // Collaborating Class Declarations --
33 //------------------------------------
34 
35 // ---------------------
36 // -- Class Interface --
37 // ---------------------
38 
39 class L1MuGMTCand {
40 public:
42  L1MuGMTCand();
43 
45  L1MuGMTCand(unsigned data, int bx = 0);
46 
48  L1MuGMTCand(const L1MuGMTCand&);
49 
51  L1MuGMTCand& operator=(const L1MuGMTCand&) = default;
52 
54  virtual ~L1MuGMTCand();
55 
57  void reset();
58 
59  //
60  // Getters
61  //
62 
64  bool empty() const { return readDataField(PT_START, PT_LENGTH) == 0; }
65 
67  unsigned getDataWord() const { return m_dataWord; }
68 
70  std::string name() const { return m_name; }
71 
73  unsigned int phiIndex() const { return readDataField(PHI_START, PHI_LENGTH); }
74 
76  unsigned int ptIndex() const { return readDataField(PT_START, PT_LENGTH); }
77 
79 
93  unsigned int quality() const { return readDataField(QUAL_START, QUAL_LENGTH); }
94 
96  bool useInSingleMuonTrigger() const { return quality() >= 4; };
97 
99  bool useInDiMuonTrigger() const { return (quality() >= 3) && (quality() != 4); };
100 
102  bool isMatchedCand() const { return quality() == 7; }
103 
105  bool isHaloCand() const { return quality() == 1; }
106 
108  unsigned int etaIndex() const { return readDataField(ETA_START, ETA_LENGTH); }
109 
111  unsigned sysign() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH); }
112 
114  bool isol() const { return readDataField(ISO_START, ISO_LENGTH) == 1; }
115 
117  bool mip() const { return readDataField(MIP_START, MIP_LENGTH) == 1; }
118 
120  int bx() const { return m_bx; }
121 
124  float phiValue() const;
125 
128  float etaValue() const;
129 
132  float ptValue() const;
133 
135  int charge() const { return (readDataField(SYSIGN_START, SYSIGN_LENGTH) & 1) == 0 ? 1 : -1; }
136 
138  bool charge_valid() const {
140  return (sysign == 0 || sysign == 1);
141  }
142 
144  bool isSyncWord() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH) == 3; }
145 
149 
152 
155 
158 
161 
164 
166  void setMIP(bool mip) { writeDataField(MIP_START, MIP_LENGTH, mip ? 1 : 0); }
167 
170 
172  void setBx(int bx) { m_bx = bx; }
173 
175 
177  void setPhiValue(float phiVal) { m_phiValue = phiVal; }
178 
180  void setPtValue(float ptVal) { m_ptValue = ptVal; }
181 
183  void setEtaValue(float etaVal) { m_etaValue = etaVal; }
184 
185  //
186  // Other
187  //
188 
189  unsigned int linearizedPt(float lsbValue, unsigned maxScale) const { return 0; }
190 
191  unsigned int etaRegionIndex() const { return etaIndex(); }
192 
193  unsigned int phiRegionIndex() const { return phiIndex(); }
194 
196  bool operator==(const L1MuGMTCand&) const;
197 
199  bool operator!=(const L1MuGMTCand&) const;
200 
202  void print() const;
203 
205  friend std::ostream& operator<<(std::ostream&, const L1MuGMTCand&);
206 
207 protected:
208 protected:
209  inline unsigned readDataField(unsigned start, unsigned count) const;
210  inline void writeDataField(unsigned start, unsigned count, unsigned value);
211 
213  int m_bx; // in here only for technical reasons in simulation
214  unsigned m_dataWord; // muon data word (26 bits) :
215 
216  float m_phiValue;
217  float m_etaValue;
218  float m_ptValue;
219  static const float m_invalidValue;
220 
221  // definition of the bit fields
222  enum { PHI_START = 0 };
223  enum { PHI_LENGTH = 8 }; // Bits 0:7 phi (8 bits)
224  enum { PT_START = 8 };
225  enum { PT_LENGTH = 5 }; // Bits 8:12 pt (5 bits)
226  enum { QUAL_START = 13 };
227  enum { QUAL_LENGTH = 3 }; // Bits 13:15 quality (3 bits)
228  enum { ETA_START = 16 };
229  enum { ETA_LENGTH = 6 }; // Bits 16:21 eta (6 bits)
230  enum { ISO_START = 22 };
231  enum { ISO_LENGTH = 1 }; // Bit 22 Isolation
232  enum { MIP_START = 23 };
233  enum { MIP_LENGTH = 1 }; // Bit 23 MIP
234  enum { SYSIGN_START = 24 };
235  enum { SYSIGN_LENGTH = 2 }; // Bit 24:25 Charge/Syncword
236 };
237 
238 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
239  unsigned mask = ((1 << count) - 1) << start;
240  return (m_dataWord & mask) >> start;
241 }
242 
243 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
244  unsigned mask = ((1 << count) - 1) << start;
245  m_dataWord &= ~mask; // clear
246  m_dataWord |= (value << start) & mask;
247 }
248 
249 #endif
Definition: start.py:1
void setPtPacked(unsigned pt)
set packed pt-code of muon candidate
Definition: L1MuGMTCand.h:154
bool isol() const
get isolation
Definition: L1MuGMTCand.h:114
void writeDataField(unsigned start, unsigned count, unsigned value)
Definition: L1MuGMTCand.h:243
void setMIP(bool mip)
set min ionizing bit for muon candidate
Definition: L1MuGMTCand.h:166
unsigned int etaRegionIndex() const
Definition: L1MuGMTCand.h:191
void print() const
print parameters of muon candidate
Definition: L1MuGMTCand.cc:144
unsigned int linearizedPt(float lsbValue, unsigned maxScale) const
Definition: L1MuGMTCand.h:189
bool useInSingleMuonTrigger() const
interpretation of quality code: is the candidate to be used in a single muon trigger ...
Definition: L1MuGMTCand.h:96
bool mip() const
get mip
Definition: L1MuGMTCand.h:117
void reset()
reset muon candidate
Definition: L1MuGMTCand.cc:81
unsigned int ptIndex() const
get pt-code
Definition: L1MuGMTCand.h:76
int bx() const
get bunch crossing identifier
Definition: L1MuGMTCand.h:120
float m_ptValue
Definition: L1MuGMTCand.h:218
unsigned int phiRegionIndex() const
Definition: L1MuGMTCand.h:193
friend std::ostream & operator<<(std::ostream &, const L1MuGMTCand &)
output stream operator
L1MuGMTCand()
constructor
Definition: L1MuGMTCand.cc:49
float m_etaValue
Definition: L1MuGMTCand.h:217
bool operator!=(const L1MuGMTCand &) const
unequal operator
Definition: L1MuGMTCand.cc:133
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:93
float m_phiValue
Definition: L1MuGMTCand.h:216
bool charge_valid() const
is the charge valid ?
Definition: L1MuGMTCand.h:138
static const float m_invalidValue
Definition: L1MuGMTCand.h:219
unsigned readDataField(unsigned start, unsigned count) const
Definition: L1MuGMTCand.h:238
void setPhiValue(float phiVal)
Setters for physical values.
Definition: L1MuGMTCand.h:177
std::string m_name
Definition: L1MuGMTCand.h:212
L1MuGMTCand & operator=(const L1MuGMTCand &)=default
assignment operator
unsigned int phiIndex() const
get phi-code
Definition: L1MuGMTCand.h:73
float etaValue() const
Definition: L1MuGMTCand.cc:102
void setBx(int bx)
set bunch crossing identifier
Definition: L1MuGMTCand.h:172
Definition: value.py:1
int charge() const
get charge (+1 -1)
Definition: L1MuGMTCand.h:135
float ptValue() const
Definition: L1MuGMTCand.cc:112
unsigned m_dataWord
Definition: L1MuGMTCand.h:214
bool empty() const
is it an empty muon candidate?
Definition: L1MuGMTCand.h:64
void setChargePacked(unsigned ch)
set packed charge/synchronization word of muon candidate (0=POS, 1=NEG, 2=UNDEF, 3=SYNC) ...
Definition: L1MuGMTCand.h:169
bool isHaloCand() const
interpretation of quality code: is the candidate a beam halo muon ?
Definition: L1MuGMTCand.h:105
unsigned sysign() const
get charge/synchronization word (0=POS, 1=NEG, 2=UNDEF, 3=SYNC)
Definition: L1MuGMTCand.h:111
void setQuality(unsigned quality)
set quality of muon candidate
Definition: L1MuGMTCand.h:157
bool useInDiMuonTrigger() const
interpretation of quality code: is the candidate to be used in a di-muon trigger ?
Definition: L1MuGMTCand.h:99
void setEtaPacked(unsigned eta)
set packed eta-code of muon candidate
Definition: L1MuGMTCand.h:160
void setEtaValue(float etaVal)
Set Eta Value (need to set type, first)
Definition: L1MuGMTCand.h:183
float phiValue() const
Definition: L1MuGMTCand.cc:92
std::string name() const
get name of object
Definition: L1MuGMTCand.h:70
bool isSyncWord() const
is the candidate a sync word
Definition: L1MuGMTCand.h:144
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
bool isMatchedCand() const
interpretation of quality code: is the candidate a matched candidate ?
Definition: L1MuGMTCand.h:102
unsigned getDataWord() const
get muon data word
Definition: L1MuGMTCand.h:67
unsigned int etaIndex() const
get eta-code
Definition: L1MuGMTCand.h:108
void setPtValue(float ptVal)
Set Pt Value.
Definition: L1MuGMTCand.h:180
virtual ~L1MuGMTCand()
destructor
Definition: L1MuGMTCand.cc:72
bool operator==(const L1MuGMTCand &) const
equal operator
Definition: L1MuGMTCand.cc:122
void setPhiPacked(unsigned phi)
set packed phi-code of muon candidate
Definition: L1MuGMTCand.h:151
void setIsolation(bool isol)
set isolation of muon candidate
Definition: L1MuGMTCand.h:163