CMS 3D CMS Logo

EncodedEventId.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_EncodedEventId_H
2 #define SimDataFormats_EncodedEventId_H 1
3 
4 #include <TMath.h>
5 #include <ostream>
6 #include <cstdint>
7 
12 public:
16  explicit EncodedEventId(uint32_t id);
18  EncodedEventId(int bunchX, int event) {
19  id_ = TMath::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()() { 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
EncodedEventId::operator()
uint32_t operator()()
Definition: EncodedEventId.h:31
EncodedEventId::eventMask_
static const unsigned int eventMask_
Definition: EncodedEventId.h:46
EncodedEventId::operator!=
int operator!=(const EncodedEventId &id) const
inequality
Definition: EncodedEventId.h:37
EncodedEventId::bunchXStartBit_
static const unsigned int bunchXStartBit_
Definition: EncodedEventId.h:42
EncodedEventId::eventStartBit_
static const unsigned int eventStartBit_
Definition: EncodedEventId.h:43
EncodedEventId::operator==
int operator==(const EncodedEventId &id) const
equality
Definition: EncodedEventId.h:35
EncodedEventId
Definition: EncodedEventId.h:11
Abs
T Abs(T a)
Definition: MathUtil.h:49
EncodedEventId::id_
uint32_t id_
Definition: EncodedEventId.h:49
EncodedEventId::event
int event() const
get the contents of the subdetector field (should be protected?)
Definition: EncodedEventId.h:30
createfilelist.int
int
Definition: createfilelist.py:10
EncodedEventId::operator<
int operator<(const EncodedEventId &id) const
comparison
Definition: EncodedEventId.h:39
EncodedEventId::EncodedEventId
EncodedEventId(int bunchX, int event)
Create an id, filling the bunch crossing and event infomrations.
Definition: EncodedEventId.h:18
EncodedEventId::bunchXMask_
static const unsigned int bunchXMask_
Definition: EncodedEventId.h:44
EncodedEventId::bunchNegMask_
static const unsigned int bunchNegMask_
Definition: EncodedEventId.h:45
EncodedEventId::EncodedEventId
EncodedEventId()
Create an empty or null id (also for persistence)
Definition: EncodedEventId.cc:3
event
Definition: event.py:1
EncodedEventId::bunchCrossing
int bunchCrossing() const
get the detector field from this detid
Definition: EncodedEventId.h:25
EncodedEventId::rawId
uint32_t rawId() const
get the raw id
Definition: EncodedEventId.h:33