CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DPGAnalysis/SiStripTools/interface/TinyEvent.h

Go to the documentation of this file.
00001 #ifndef DPGanalysis_SiStripTools_TinyEvent_H
00002 #define DPGanalysis_SiStripTools_TinyEvent_H
00003 
00004 #include <vector>
00005 
00006 namespace edm {
00007   class Event;
00008   class EventAuxiliary;
00009 }
00010 
00011 //class EventIdWithBX;
00012 
00013 struct TinyEvent {
00014 
00015   TinyEvent():_event(0), _orbit(0), _bx(0) { }
00016 
00017   explicit TinyEvent(const unsigned int event,const int orbit,const int bx):
00018     _event(event), _orbit(orbit<0 ? 0 : orbit ), _bx(bx<0 ? 0 : bx) { }
00019 
00020   explicit TinyEvent(const unsigned int event,const unsigned int orbit,const int bx):
00021     _event(event), _orbit(orbit), _bx(bx<0 ? 0 : bx) { }
00022 
00023   TinyEvent(const TinyEvent& se):
00024     _event(se._event), _orbit(se._orbit), _bx(se._bx) { }
00025 
00026   TinyEvent(const edm::Event& event);
00027   TinyEvent(const edm::EventAuxiliary& eaux);
00028 
00029   TinyEvent& operator=(const TinyEvent& se) {
00030 
00031     if(this != &se) {
00032       _event = se._event;
00033       _orbit = se._orbit;
00034       _bx = se._bx;
00035     }
00036     
00037     return *this;
00038 
00039   }
00040 
00041   int operator<(const TinyEvent& other) const { 
00042     return _event < other._event;
00043   }
00044 
00045   int operator==(const TinyEvent& other) const { 
00046     return (_event == other._event) &&
00047       (_orbit == other._orbit) &&
00048       (_bx == other._bx) ;
00049   }
00050 
00051   int isNextOf(const TinyEvent& se) const {
00052 
00053     return (se._event>0) && ((se._event + 1) == _event);
00054 
00055   }
00056 
00057   long long absoluteBX() const {
00058 
00059     return (long long)_orbit * 3564 + _bx;
00060 
00061   }
00062 
00063   long long absoluteBXinCycle(const int bx0) const {
00064 
00065     return (absoluteBX()-bx0);
00066 
00067   }
00068 
00069   long long deltaBX(const TinyEvent& se) const {
00070 
00071     int sign = 1;
00072     if(se._event > _event) sign = -1;
00073       
00074     long long dorb = (int)(_orbit) - (int)(se._orbit);
00075     return (dorb*3564 + (int)_bx - (int)se._bx) * sign;
00076 
00077   }
00078 
00079   long long deltaBXinCycle(const TinyEvent& se, const int bx0) const {
00080 
00081     long long dbx = deltaBX(se);
00082 
00083     return dbx+(69 + se.absoluteBX() -bx0%70 )%70; // I could use: dbx+(69+se.absoluteBXinCycle(bx0))%70
00084 
00085   }
00086 
00087   unsigned int _event;
00088   unsigned int _orbit;
00089   unsigned int _bx;
00090 
00091 };
00092 
00093 typedef std::vector<TinyEvent> TinyEventCollection;
00094 
00095 #endif // DPGanalysis_SiStripTools_TinyEvent_H