CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuGMTCand.h
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
9 //
10 // $Date: 2007/03/23 18:52:17 $
11 // $Revision: 1.4 $
12 //
13 // Author :
14 // H. Sakulin HEPHY Vienna
15 // N. Neumeister CERN EP
16 //
17 // Migrated to CMSSW:
18 // I. Mikulec
19 //
20 //--------------------------------------------------
21 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
22 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
23 
24 //---------------
25 // C++ Headers --
26 //---------------
27 #include <string>
28 
29 //----------------------
30 // Base Class Headers --
31 //----------------------
32 
33 //------------------------------------
34 // Collaborating Class Declarations --
35 //------------------------------------
36 
37 
38 // ---------------------
39 // -- Class Interface --
40 // ---------------------
41 
42 class L1MuGMTCand {
43 
44  public:
45 
47  L1MuGMTCand();
48 
50  L1MuGMTCand(unsigned data, int bx=0);
51 
53  L1MuGMTCand(const L1MuGMTCand&);
54 
56  virtual ~L1MuGMTCand();
57 
59  void reset();
60 
61  //
62  // Getters
63  //
64 
66  bool empty() const { return readDataField( PT_START, PT_LENGTH) == 0; }
67 
69  unsigned getDataWord() const { return m_dataWord; }
70 
72  std::string name() const { return m_name; }
73 
75  unsigned int phiIndex() const { return readDataField( PHI_START, PHI_LENGTH); }
76 
78  unsigned int ptIndex() const { return readDataField( PT_START, PT_LENGTH); }
79 
81 
95  unsigned int quality() const { return readDataField( QUAL_START, QUAL_LENGTH); }
96 
98  bool useInSingleMuonTrigger() const { return quality() >= 4; };
99 
101  bool useInDiMuonTrigger() const { return (quality() >= 3) && (quality() !=4); };
102 
104  bool isMatchedCand() const { return quality() == 7; }
105 
107  bool isHaloCand() const { return quality() == 1; }
108 
110  unsigned int etaIndex() const { return readDataField( ETA_START, ETA_LENGTH); }
111 
113  unsigned sysign() const { return readDataField( SYSIGN_START, SYSIGN_LENGTH); }
114 
116  bool isol() const { return readDataField( ISO_START, ISO_LENGTH) == 1; }
117 
119  bool mip() const { return readDataField( MIP_START, MIP_LENGTH) == 1; }
120 
122  int bx() const { return m_bx; }
123 
126  float phiValue() const;
127 
130  float etaValue() const;
131 
134  float ptValue() const;
135 
137  int charge() const { return (readDataField( SYSIGN_START, SYSIGN_LENGTH) & 1 ) == 0 ? 1: -1; }
138 
140  bool charge_valid() const {
142  return (sysign == 0 || sysign == 1 );
143  }
144 
146  bool isSyncWord() const { return readDataField( SYSIGN_START, SYSIGN_LENGTH) == 3; }
147 
151 
153  void setPhiPacked(unsigned phi) { writeDataField( PHI_START, PHI_LENGTH, phi); }
154 
156  void setPtPacked(unsigned pt) { writeDataField( PT_START, PT_LENGTH, pt); }
157 
159  void setQuality(unsigned quality) { writeDataField( QUAL_START, QUAL_LENGTH, quality); }
160 
162  void setEtaPacked(unsigned eta) { writeDataField( ETA_START, ETA_LENGTH, eta); }
163 
165  void setIsolation(bool isol) { writeDataField( ISO_START, ISO_LENGTH, isol?1:0); }
166 
168  void setMIP(bool mip) { writeDataField( MIP_START, MIP_LENGTH, mip?1:0); }
169 
172 
174  void setBx(int bx) { m_bx = bx; }
175 
177 
179  void setPhiValue(float phiVal) {m_phiValue = phiVal;}
180 
182  void setPtValue(float ptVal) {m_ptValue = ptVal;}
183 
185  void setEtaValue(float etaVal) {m_etaValue = etaVal;}
186 
187  //
188  // Other
189  //
190 
191  unsigned int linearizedPt(float lsbValue, unsigned maxScale) const { return 0; }
192 
193  unsigned int etaRegionIndex() const { return etaIndex(); }
194 
195  unsigned int phiRegionIndex() const { return phiIndex(); }
196 
198  bool operator==(const L1MuGMTCand&) const;
199 
201  bool operator!=(const L1MuGMTCand&) const;
202 
204  void print() const;
205 
207  friend std::ostream& operator<<(std::ostream&, const L1MuGMTCand&);
208 
209  protected:
210 
211  protected:
212  inline unsigned readDataField(unsigned start, unsigned count) const;
213  inline void writeDataField(unsigned start, unsigned count, unsigned value);
214 
215  std::string m_name;
216  int m_bx; // in here only for technical reasons in simulation
217  unsigned m_dataWord; // muon data word (26 bits) :
218 
219  float m_phiValue;
220  float m_etaValue;
221  float m_ptValue;
222  static const float m_invalidValue;
223 
224 
225  // definition of the bit fields
226  enum { PHI_START=0}; enum { PHI_LENGTH = 8}; // Bits 0:7 phi (8 bits)
227  enum { PT_START=8}; enum { PT_LENGTH = 5}; // Bits 8:12 pt (5 bits)
228  enum { QUAL_START=13}; enum { QUAL_LENGTH = 3}; // Bits 13:15 quality (3 bits)
229  enum { ETA_START=16}; enum { ETA_LENGTH = 6}; // Bits 16:21 eta (6 bits)
230  enum { ISO_START=22}; enum { ISO_LENGTH = 1}; // Bit 22 Isolation
231  enum { MIP_START=23}; enum { MIP_LENGTH = 1}; // Bit 23 MIP
232  enum { SYSIGN_START=24}; enum { SYSIGN_LENGTH = 2}; // Bit 24:25 Charge/Syncword
233 };
234 
235 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
236  unsigned mask = ( (1 << count) - 1 ) << start;
237  return (m_dataWord & mask) >> start;
238 }
239 
240 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
241  unsigned mask = ( (1 << count) - 1 ) << start;
242  m_dataWord &= ~mask; // clear
243  m_dataWord |= (value << start) & mask ;
244 }
245 
246 
247 #endif
float etaValue() const
Definition: L1MuGMTCand.cc:116
void setPtPacked(unsigned pt)
set packed pt-code of muon candidate
Definition: L1MuGMTCand.h:156
float phiValue() const
Definition: L1MuGMTCand.cc:102
bool useInSingleMuonTrigger() const
interpretation of quality code: is the candidate to be used in a single muon trigger ...
Definition: L1MuGMTCand.h:98
void writeDataField(unsigned start, unsigned count, unsigned value)
Definition: L1MuGMTCand.h:240
void setMIP(bool mip)
set min ionizing bit for muon candidate
Definition: L1MuGMTCand.h:168
bool useInDiMuonTrigger() const
interpretation of quality code: is the candidate to be used in a di-muon trigger ?
Definition: L1MuGMTCand.h:101
std::string name() const
get name of object
Definition: L1MuGMTCand.h:72
unsigned int phiIndex() const
get phi-code
Definition: L1MuGMTCand.h:75
void reset()
reset muon candidate
Definition: L1MuGMTCand.cc:89
bool operator!=(const L1MuGMTCand &) const
unequal operator
Definition: L1MuGMTCand.cc:155
unsigned int etaIndex() const
get eta-code
Definition: L1MuGMTCand.h:110
unsigned readDataField(unsigned start, unsigned count) const
Definition: L1MuGMTCand.h:235
float m_ptValue
Definition: L1MuGMTCand.h:221
unsigned int phiRegionIndex() const
Definition: L1MuGMTCand.h:195
T eta() const
friend std::ostream & operator<<(std::ostream &, const L1MuGMTCand &)
output stream operator
bool isol() const
get isolation
Definition: L1MuGMTCand.h:116
L1MuGMTCand()
constructor
Definition: L1MuGMTCand.cc:51
bool isHaloCand() const
interpretation of quality code: is the candidate a beam halo muon ?
Definition: L1MuGMTCand.h:107
float m_etaValue
Definition: L1MuGMTCand.h:220
unsigned getDataWord() const
get muon data word
Definition: L1MuGMTCand.h:69
float m_phiValue
Definition: L1MuGMTCand.h:219
bool empty() const
is it an empty muon candidate?
Definition: L1MuGMTCand.h:66
static const float m_invalidValue
Definition: L1MuGMTCand.h:222
int bx() const
get bunch crossing identifier
Definition: L1MuGMTCand.h:122
void setPhiValue(float phiVal)
Setters for physical values.
Definition: L1MuGMTCand.h:179
std::string m_name
Definition: L1MuGMTCand.h:215
bool charge_valid() const
is the charge valid ?
Definition: L1MuGMTCand.h:140
void setBx(int bx)
set bunch crossing identifier
Definition: L1MuGMTCand.h:174
bool mip() const
get mip
Definition: L1MuGMTCand.h:119
unsigned m_dataWord
Definition: L1MuGMTCand.h:217
void setChargePacked(unsigned ch)
set packed charge/synchronization word of muon candidate (0=POS, 1=NEG, 2=UNDEF, 3=SYNC) ...
Definition: L1MuGMTCand.h:171
unsigned int linearizedPt(float lsbValue, unsigned maxScale) const
Definition: L1MuGMTCand.h:191
bool isSyncWord() const
is the candidate a sync word
Definition: L1MuGMTCand.h:146
unsigned sysign() const
get charge/synchronization word (0=POS, 1=NEG, 2=UNDEF, 3=SYNC)
Definition: L1MuGMTCand.h:113
float ptValue() const
Definition: L1MuGMTCand.cc:130
unsigned int etaRegionIndex() const
Definition: L1MuGMTCand.h:193
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:95
void setQuality(unsigned quality)
set quality of muon candidate
Definition: L1MuGMTCand.h:159
bool isMatchedCand() const
interpretation of quality code: is the candidate a matched candidate ?
Definition: L1MuGMTCand.h:104
void setEtaPacked(unsigned eta)
set packed eta-code of muon candidate
Definition: L1MuGMTCand.h:162
void setEtaValue(float etaVal)
Set Eta Value (need to set type, first)
Definition: L1MuGMTCand.h:185
bool operator==(const L1MuGMTCand &) const
equal operator
Definition: L1MuGMTCand.cc:143
void setPtValue(float ptVal)
Set Pt Value.
Definition: L1MuGMTCand.h:182
virtual ~L1MuGMTCand()
destructor
Definition: L1MuGMTCand.cc:75
unsigned int ptIndex() const
get pt-code
Definition: L1MuGMTCand.h:78
void setPhiPacked(unsigned phi)
set packed phi-code of muon candidate
Definition: L1MuGMTCand.h:153
void print() const
print parameters of muon candidate
Definition: L1MuGMTCand.cc:167
void setIsolation(bool isol)
set isolation of muon candidate
Definition: L1MuGMTCand.h:165
Definition: DDAxes.h:10
int charge() const
get charge (+1 -1)
Definition: L1MuGMTCand.h:137