CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/SimDataFormats/EncodedEventId/interface/EncodedEventId.h

Go to the documentation of this file.
00001 #ifndef SimDataFormats_EncodedEventId_H
00002 #define SimDataFormats_EncodedEventId_H 1
00003 
00004 #include <TMath.h>
00005 #include <boost/cstdint.hpp> //INCLUDECHECKER:SKIP
00006 #include <ostream>
00007 
00011 class EncodedEventId {
00012  public:
00014   EncodedEventId();
00016   explicit EncodedEventId(uint32_t id);
00018   EncodedEventId(int bunchX, int event){
00019     id_ = TMath::Abs(bunchX)<< bunchXStartBit_ |event ;
00020     if (bunchX<0) id_=id_ | bunchNegMask_;
00021   }
00022 
00024   int bunchCrossing() const { int bcr= int((id_ >> bunchXStartBit_) & 0x7FFF); return id_ & bunchNegMask_ ? -bcr : bcr; }
00026   int event() const { return int(id_ & 0xFFFF); }
00027   uint32_t operator()() { return id_; }
00029   uint32_t rawId() const { return id_; }
00031   int operator==(const EncodedEventId& id) const { return id_==id.id_; }
00033   int operator!=(const EncodedEventId& id) const { return id_!=id.id_; }
00035   int operator<(const EncodedEventId& id) const { return id_<id.id_; }
00036  private:
00037   static const unsigned int bunchXStartBit_ =  16;
00038   static const unsigned int eventStartBit_  =  0;
00039   static const unsigned int bunchXMask_ =   0x10;
00040   static const unsigned int bunchNegMask_ =  0x80000000;
00041   static const unsigned int eventMask_  =   0x10;
00042  protected:
00043   uint32_t id_;
00044 };
00045 #endif