Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:29

0001 #ifndef DataFormats_Provenance_EventID_h
0002 #define DataFormats_Provenance_EventID_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     DataFormats/Provenance
0006 // Class  :     EventID
0007 //
0008 /**\class edm::EventID
0009 
0010  Description: Holds run, lumi, and event numbers.
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Mon Aug  8 15:13:14 EDT 2005
0019 //
0020 
0021 // system include files
0022 #include <iosfwd>
0023 
0024 // user include files
0025 #include "DataFormats/Provenance/interface/RunID.h"
0026 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0027 
0028 // forward declarations
0029 namespace edm {
0030 
0031   class EventID {
0032   public:
0033     EventID() : run_(invalidRunNumber), luminosityBlock_(invalidLuminosityBlockNumber), event_(invalidEventNumber) {}
0034     EventID(RunNumber_t iRun, LuminosityBlockNumber_t iLumi, EventNumber_t iEvent)
0035         : run_(iRun), luminosityBlock_(iLumi), event_(iEvent) {}
0036 
0037     // ---------- const member functions ---------------------
0038     RunNumber_t run() const { return run_; }
0039     LuminosityBlockNumber_t luminosityBlock() const { return luminosityBlock_; }
0040     EventNumber_t event() const { return event_; }
0041 
0042     //moving from one EventID to another one
0043     EventID next(LuminosityBlockNumber_t const& lumi) const {
0044       if (event_ != maxEventNumber()) {
0045         return EventID(run_, lumi, event_ + 1);
0046       }
0047       return EventID(run_ + 1, lumi, 1);
0048     }
0049     EventID nextRun(LuminosityBlockNumber_t const& lumi) const { return EventID(run_ + 1, lumi, 0); }
0050     EventID nextRunFirstEvent(LuminosityBlockNumber_t const& lumi) const { return EventID(run_ + 1, lumi, 1); }
0051     EventID previousRunLastEvent(LuminosityBlockNumber_t const& lumi) const {
0052       if (run_ > 1) {
0053         return EventID(run_ - 1, lumi, maxEventNumber());
0054       }
0055       return EventID();
0056     }
0057 
0058     EventID previous(LuminosityBlockNumber_t const& lumi) const {
0059       if (event_ > 1) {
0060         return EventID(run_, lumi, event_ - 1);
0061       }
0062       if (run_ != 0) {
0063         return EventID(run_ - 1, lumi, maxEventNumber());
0064       }
0065       return EventID();
0066     }
0067 
0068     bool operator<(EventID const& iRHS) const {
0069       if (run_ < iRHS.run_)
0070         return true;
0071       if (run_ > iRHS.run_)
0072         return false;
0073       if (luminosityBlock_ < iRHS.luminosityBlock_)
0074         return true;
0075       if (luminosityBlock_ > iRHS.luminosityBlock_)
0076         return false;
0077       return (event_ < iRHS.event_);
0078     }
0079 
0080     bool operator>=(EventID const& iRHS) const { return !(*this < iRHS); }
0081 
0082     bool operator==(EventID const& iRHS) const { return !(*this < iRHS || iRHS < *this); }
0083 
0084     bool operator!=(EventID const& iRHS) const { return !(*this == iRHS); }
0085 
0086     bool operator<=(EventID const& iRHS) const { return (*this < iRHS || *this == iRHS); }
0087 
0088     bool operator>(EventID const& iRHS) const { return !(*this <= iRHS); }
0089 
0090     // ---------- static functions ---------------------------
0091 
0092     static RunNumber_t maxRunNumber() { return 0xFFFFFFFFU; }
0093 
0094     static LuminosityBlockNumber_t maxLuminosityBlockNumber() { return 0xFFFFFFFFU; }
0095 
0096     static EventNumber_t maxEventNumber() { return 0xFFFFFFFFFFFFFFFFULL; }
0097 
0098     static EventID firstValidEvent() { return EventID(1, 1, 1); }
0099     // ---------- member functions ---------------------------
0100 
0101     void setLuminosityBlockNumber(LuminosityBlockNumber_t const& lb) { luminosityBlock_ = lb; }
0102 
0103   private:
0104     //EventID(EventID const&); // stop default
0105 
0106     //EventID const& operator=(EventID const&); // stop default
0107 
0108     // ---------- member data --------------------------------
0109     RunNumber_t run_;
0110     LuminosityBlockNumber_t luminosityBlock_;
0111     EventNumber_t event_;
0112   };
0113 
0114   std::ostream& operator<<(std::ostream& oStream, EventID const& iID);
0115 
0116   inline EventID const& min(EventID const& lh, EventID const& rh) { return (rh < lh ? rh : lh); }
0117 
0118   inline EventID const& max(EventID const& lh, EventID const& rh) { return (rh < lh ? lh : rh); }
0119 }  // namespace edm
0120 #endif