File indexing completed on 2023-03-17 10:53:23
0001 #ifndef DPGanalysis_SiStripTools_TinyEvent_H
0002 #define DPGanalysis_SiStripTools_TinyEvent_H
0003
0004 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0005 #include <vector>
0006
0007 namespace edm {
0008 class Event;
0009 }
0010
0011
0012
0013 struct TinyEvent {
0014 TinyEvent() : _event(0), _orbit(0), _bx(0) {}
0015
0016 explicit TinyEvent(const edm::EventNumber_t event, const int orbit, const int bx)
0017 : _event(event), _orbit(orbit < 0 ? 0 : orbit), _bx(bx < 0 ? 0 : bx) {}
0018
0019 explicit TinyEvent(const edm::EventNumber_t event, const unsigned int orbit, const int bx)
0020 : _event(event), _orbit(orbit), _bx(bx < 0 ? 0 : bx) {}
0021
0022 TinyEvent(const TinyEvent& se) : _event(se._event), _orbit(se._orbit), _bx(se._bx) {}
0023
0024 TinyEvent(const edm::Event& event);
0025 TinyEvent(const edm::EventAuxiliary& eaux);
0026
0027 TinyEvent& operator=(const TinyEvent& se) {
0028 if (this != &se) {
0029 _event = se._event;
0030 _orbit = se._orbit;
0031 _bx = se._bx;
0032 }
0033
0034 return *this;
0035 }
0036
0037 int operator<(const TinyEvent& other) const { return _event < other._event; }
0038
0039 int operator==(const TinyEvent& other) const {
0040 return (_event == other._event) && (_orbit == other._orbit) && (_bx == other._bx);
0041 }
0042
0043 int isNextOf(const TinyEvent& se) const { return (se._event > 0) && ((se._event + 1) == _event); }
0044
0045 long long absoluteBX() const { return (long long)_orbit * 3564 + _bx; }
0046
0047 long long absoluteBXinCycle(const int bx0) const { return (absoluteBX() - bx0); }
0048
0049 long long deltaBX(const TinyEvent& se) const {
0050 int sign = 1;
0051 if (se._event > _event)
0052 sign = -1;
0053
0054 long long dorb = (int)(_orbit) - (int)(se._orbit);
0055 return (dorb * 3564 + (int)_bx - (int)se._bx) * sign;
0056 }
0057
0058 long long deltaBXinCycle(const TinyEvent& se, const int bx0) const {
0059 long long dbx = deltaBX(se);
0060
0061 return dbx + (69 + se.absoluteBX() - bx0 % 70) % 70;
0062 }
0063
0064 edm::EventNumber_t _event;
0065 unsigned int _orbit;
0066 unsigned int _bx;
0067 };
0068
0069 typedef std::vector<TinyEvent> TinyEventCollection;
0070
0071 #endif