test
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 //
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 // ---------------------
37 // -- Class Interface --
38 // ---------------------
39 
40 class L1MuGMTCand {
41 
42  public:
43 
45  L1MuGMTCand();
46 
48  L1MuGMTCand(unsigned data, int bx=0);
49 
51  L1MuGMTCand(const L1MuGMTCand&);
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 
151  void setPhiPacked(unsigned phi) { writeDataField( PHI_START, PHI_LENGTH, phi); }
152 
154  void setPtPacked(unsigned pt) { writeDataField( PT_START, PT_LENGTH, pt); }
155 
157  void setQuality(unsigned quality) { writeDataField( QUAL_START, QUAL_LENGTH, quality); }
158 
160  void setEtaPacked(unsigned eta) { writeDataField( ETA_START, ETA_LENGTH, eta); }
161 
163  void setIsolation(bool isol) { writeDataField( ISO_START, ISO_LENGTH, isol?1:0); }
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 
209  protected:
210  inline unsigned readDataField(unsigned start, unsigned count) const;
211  inline void writeDataField(unsigned start, unsigned count, unsigned value);
212 
214  int m_bx; // in here only for technical reasons in simulation
215  unsigned m_dataWord; // muon data word (26 bits) :
216 
217  float m_phiValue;
218  float m_etaValue;
219  float m_ptValue;
220  static const float m_invalidValue;
221 
222 
223  // definition of the bit fields
224  enum { PHI_START=0}; enum { PHI_LENGTH = 8}; // Bits 0:7 phi (8 bits)
225  enum { PT_START=8}; enum { PT_LENGTH = 5}; // Bits 8:12 pt (5 bits)
226  enum { QUAL_START=13}; enum { QUAL_LENGTH = 3}; // Bits 13:15 quality (3 bits)
227  enum { ETA_START=16}; enum { ETA_LENGTH = 6}; // Bits 16:21 eta (6 bits)
228  enum { ISO_START=22}; enum { ISO_LENGTH = 1}; // Bit 22 Isolation
229  enum { MIP_START=23}; enum { MIP_LENGTH = 1}; // Bit 23 MIP
230  enum { SYSIGN_START=24}; enum { SYSIGN_LENGTH = 2}; // Bit 24:25 Charge/Syncword
231 };
232 
233 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
234  unsigned mask = ( (1 << count) - 1 ) << start;
235  return (m_dataWord & mask) >> start;
236 }
237 
238 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
239  unsigned mask = ( (1 << count) - 1 ) << start;
240  m_dataWord &= ~mask; // clear
241  m_dataWord |= (value << start) & mask ;
242 }
243 
244 
245 #endif
float etaValue() const
Definition: L1MuGMTCand.cc:114
void setPtPacked(unsigned pt)
set packed pt-code of muon candidate
Definition: L1MuGMTCand.h:154
float phiValue() const
Definition: L1MuGMTCand.cc:100
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
bool useInSingleMuonTrigger() const
interpretation of quality code: is the candidate to be used in a single muon trigger ...
Definition: L1MuGMTCand.h:96
void writeDataField(unsigned start, unsigned count, unsigned value)
Definition: L1MuGMTCand.h:238
void setMIP(bool mip)
set min ionizing bit for muon candidate
Definition: L1MuGMTCand.h:166
bool useInDiMuonTrigger() const
interpretation of quality code: is the candidate to be used in a di-muon trigger ?
Definition: L1MuGMTCand.h:99
std::string name() const
get name of object
Definition: L1MuGMTCand.h:70
unsigned int phiIndex() const
get phi-code
Definition: L1MuGMTCand.h:73
void reset()
reset muon candidate
Definition: L1MuGMTCand.cc:87
bool operator!=(const L1MuGMTCand &) const
unequal operator
Definition: L1MuGMTCand.cc:153
unsigned int etaIndex() const
get eta-code
Definition: L1MuGMTCand.h:108
unsigned readDataField(unsigned start, unsigned count) const
Definition: L1MuGMTCand.h:233
float m_ptValue
Definition: L1MuGMTCand.h:219
unsigned int phiRegionIndex() const
Definition: L1MuGMTCand.h:193
friend std::ostream & operator<<(std::ostream &, const L1MuGMTCand &)
output stream operator
bool isol() const
get isolation
Definition: L1MuGMTCand.h:114
L1MuGMTCand()
constructor
Definition: L1MuGMTCand.cc:49
bool isHaloCand() const
interpretation of quality code: is the candidate a beam halo muon ?
Definition: L1MuGMTCand.h:105
float m_etaValue
Definition: L1MuGMTCand.h:218
unsigned getDataWord() const
get muon data word
Definition: L1MuGMTCand.h:67
float m_phiValue
Definition: L1MuGMTCand.h:217
bool empty() const
is it an empty muon candidate?
Definition: L1MuGMTCand.h:64
static const float m_invalidValue
Definition: L1MuGMTCand.h:220
int bx() const
get bunch crossing identifier
Definition: L1MuGMTCand.h:120
void setPhiValue(float phiVal)
Setters for physical values.
Definition: L1MuGMTCand.h:177
std::string m_name
Definition: L1MuGMTCand.h:213
bool charge_valid() const
is the charge valid ?
Definition: L1MuGMTCand.h:138
void setBx(int bx)
set bunch crossing identifier
Definition: L1MuGMTCand.h:172
bool mip() const
get mip
Definition: L1MuGMTCand.h:117
unsigned m_dataWord
Definition: L1MuGMTCand.h:215
void setChargePacked(unsigned ch)
set packed charge/synchronization word of muon candidate (0=POS, 1=NEG, 2=UNDEF, 3=SYNC) ...
Definition: L1MuGMTCand.h:169
unsigned int linearizedPt(float lsbValue, unsigned maxScale) const
Definition: L1MuGMTCand.h:189
bool isSyncWord() const
is the candidate a sync word
Definition: L1MuGMTCand.h:144
unsigned sysign() const
get charge/synchronization word (0=POS, 1=NEG, 2=UNDEF, 3=SYNC)
Definition: L1MuGMTCand.h:111
float ptValue() const
Definition: L1MuGMTCand.cc:128
unsigned int etaRegionIndex() const
Definition: L1MuGMTCand.h:191
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:93
void setQuality(unsigned quality)
set quality of muon candidate
Definition: L1MuGMTCand.h:157
bool isMatchedCand() const
interpretation of quality code: is the candidate a matched candidate ?
Definition: L1MuGMTCand.h:102
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
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool operator==(const L1MuGMTCand &) const
equal operator
Definition: L1MuGMTCand.cc:141
void setPtValue(float ptVal)
Set Pt Value.
Definition: L1MuGMTCand.h:180
virtual ~L1MuGMTCand()
destructor
Definition: L1MuGMTCand.cc:73
unsigned int ptIndex() const
get pt-code
Definition: L1MuGMTCand.h:76
void setPhiPacked(unsigned phi)
set packed phi-code of muon candidate
Definition: L1MuGMTCand.h:151
void print() const
print parameters of muon candidate
Definition: L1MuGMTCand.cc:165
void setIsolation(bool isol)
set isolation of muon candidate
Definition: L1MuGMTCand.h:163
int charge() const
get charge (+1 -1)
Definition: L1MuGMTCand.h:135