CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EncodedEventId.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_EncodedEventId_H
2 #define SimDataFormats_EncodedEventId_H 1
3 
4 #include <cmath>
5 #include <ostream>
6 #include <cstdint>
7 
12 public:
16  explicit EncodedEventId(uint32_t id);
18  EncodedEventId(int bunchX, int event) {
19  id_ = std::abs(bunchX) << bunchXStartBit_ | event;
20  if (bunchX < 0)
21  id_ = id_ | bunchNegMask_;
22  }
23 
25  int bunchCrossing() const {
26  int bcr = int((id_ >> bunchXStartBit_) & 0x7FFF);
27  return id_ & bunchNegMask_ ? -bcr : bcr;
28  }
30  int event() const { return int(id_ & 0xFFFF); }
31  uint32_t operator()() const { return id_; }
33  uint32_t rawId() const { return id_; }
35  int operator==(const EncodedEventId& id) const { return id_ == id.id_; }
37  int operator!=(const EncodedEventId& id) const { return id_ != id.id_; }
39  int operator<(const EncodedEventId& id) const { return id_ < id.id_; }
40 
41 private:
42  static const unsigned int bunchXStartBit_ = 16;
43  static const unsigned int eventStartBit_ = 0;
44  static const unsigned int bunchXMask_ = 0x10;
45  static const unsigned int bunchNegMask_ = 0x80000000;
46  static const unsigned int eventMask_ = 0x10;
47 
48 protected:
49  uint32_t id_;
50 };
51 #endif
static const unsigned int eventMask_
int event() const
get the contents of the subdetector field (should be protected?)
static const unsigned int bunchXMask_
static const unsigned int bunchXStartBit_
EncodedEventId(int bunchX, int event)
Create an id, filling the bunch crossing and event infomrations.
EncodedEventId()
Create an empty or null id (also for persistence)
uint32_t operator()() const
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int operator!=(const EncodedEventId &id) const
inequality
uint32_t rawId() const
get the raw id
static const unsigned int eventStartBit_
int operator<(const EncodedEventId &id) const
comparison
static const unsigned int bunchNegMask_
int operator==(const EncodedEventId &id) const
equality