CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Provenance/interface/EventID.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_EventID_h
00002 #define DataFormats_Provenance_EventID_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     DataFormats/Provenance
00006 // Class  :     EventID
00007 //
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Mon Aug  8 15:13:14 EDT 2005
00019 //
00020 
00021 // system include files
00022 #include <iosfwd>
00023 
00024 // user include files
00025 #include "DataFormats/Provenance/interface/RunID.h"
00026 
00027 // forward declarations
00028 namespace edm {
00029 
00030    typedef unsigned int EventNumber_t;
00031    typedef unsigned int LuminosityBlockNumber_t;
00032 
00033 
00034   class EventID {
00035 
00036     public:
00037       EventID() : run_(0), luminosityBlock_(0), event_(0) {}
00038       EventID(RunNumber_t iRun, LuminosityBlockNumber_t iLumi, EventNumber_t iEvent) :
00039         run_(iRun), luminosityBlock_(iLumi), event_(iEvent) {}
00040 
00041       // ---------- const member functions ---------------------
00042       RunNumber_t run() const { return run_; }
00043       LuminosityBlockNumber_t luminosityBlock() const { return luminosityBlock_; }
00044       EventNumber_t event() const { return event_; }
00045 
00046       //moving from one EventID to another one
00047       EventID next(LuminosityBlockNumber_t const& lumi) const {
00048          if(event_ != maxEventNumber()) {
00049             return EventID(run_, lumi, event_ + 1);
00050          }
00051          return EventID(run_ + 1, lumi, 1);
00052       }
00053       EventID nextRun(LuminosityBlockNumber_t const& lumi) const {
00054          return EventID(run_ + 1, lumi, 0);
00055       }
00056       EventID nextRunFirstEvent(LuminosityBlockNumber_t const& lumi) const {
00057          return EventID(run_ + 1, lumi, 1);
00058       }
00059       EventID previousRunLastEvent(LuminosityBlockNumber_t const& lumi) const {
00060          if(run_ > 1) {
00061             return EventID(run_ - 1, lumi, maxEventNumber());
00062          }
00063          return EventID();
00064       }
00065 
00066       EventID previous(LuminosityBlockNumber_t const& lumi) const {
00067          if(event_ > 1) {
00068             return EventID(run_, lumi, event_-1);
00069          }
00070          if(run_ != 0) {
00071             return EventID(run_ - 1, lumi, maxEventNumber());
00072          }
00073          return EventID();
00074       }
00075 
00076       bool operator<(EventID const& iRHS) const {
00077         if (run_ < iRHS.run_) return true;
00078         if (run_ > iRHS.run_) return false;
00079         if (luminosityBlock_ < iRHS.luminosityBlock_) return true;
00080         if (luminosityBlock_ > iRHS.luminosityBlock_) return false;
00081         return (event_ < iRHS.event_);
00082       }
00083 
00084       bool operator>=(EventID const& iRHS) const {
00085          return !(*this < iRHS);
00086       }
00087 
00088       bool operator==(EventID const& iRHS) const {
00089          return !(*this < iRHS || iRHS < *this);
00090       }
00091 
00092       bool operator!=(EventID const& iRHS) const {
00093          return !(*this == iRHS);
00094       }
00095 
00096       bool operator<=(EventID const& iRHS) const {
00097          return (*this < iRHS || *this == iRHS);
00098       }
00099 
00100       bool operator>(EventID const& iRHS) const {
00101          return !(*this <= iRHS);
00102       }
00103 
00104       // ---------- static functions ---------------------------
00105 
00106       static EventNumber_t maxEventNumber() {
00107          return 0xFFFFFFFFU;
00108       }
00109 
00110       static EventID firstValidEvent() {
00111          return EventID(1, 1, 1);
00112       }
00113       // ---------- member functions ---------------------------
00114 
00115       void setLuminosityBlockNumber(LuminosityBlockNumber_t const& lb) {
00116         luminosityBlock_ = lb;
00117       }
00118    private:
00119       //EventID(EventID const&); // stop default
00120 
00121       //EventID const& operator=(EventID const&); // stop default
00122 
00123       // ---------- member data --------------------------------
00124       RunNumber_t run_;
00125       LuminosityBlockNumber_t luminosityBlock_;
00126       EventNumber_t event_;
00127   };
00128 
00129   std::ostream& operator<<(std::ostream& oStream, EventID const& iID);
00130 
00131   inline
00132   EventID const& min(EventID const& lh, EventID const& rh) {
00133     return (rh < lh ? rh : lh);
00134   }
00135 
00136   inline
00137   EventID const& max(EventID const& lh, EventID const& rh) {
00138     return (rh < lh ? lh : rh);
00139   }
00140 }
00141 #endif