Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:10

0001 #ifndef DataFormats_FWLite_IOVSyncValue_h
0002 #define DataFormats_FWLite_IOVSyncValue_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWLite
0006 // Class  :     IOVSyncValue
0007 //
0008 /**\class IOVSyncValue IOVSyncValue.h DataFormats/Framework/interface/IOVSyncValue.h
0009 
0010  Description: Provides the information needed to synchronize the EventSetup IOV with an Event
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Wed Aug  3 18:35:24 EDT 2005
0019 //
0020 
0021 // system include files
0022 #include <functional>
0023 
0024 // user include files
0025 #include "DataFormats/Provenance/interface/EventID.h"
0026 #include "DataFormats/Provenance/interface/Timestamp.h"
0027 
0028 // forward declarations
0029 
0030 namespace fwlite {
0031   class IOVSyncValue {
0032   public:
0033     IOVSyncValue();
0034     //virtual ~IOVSyncValue();
0035     explicit IOVSyncValue(const edm::EventID& iID);
0036     explicit IOVSyncValue(const edm::Timestamp& iTime);
0037     IOVSyncValue(const edm::EventID& iID, const edm::Timestamp& iTime);
0038 
0039     // ---------- const member functions ---------------------
0040     const edm::EventID& eventID() const { return eventID_; }
0041     edm::LuminosityBlockNumber_t luminosityBlockNumber() const { return eventID_.luminosityBlock(); }
0042     const edm::Timestamp& time() const { return time_; }
0043 
0044     bool operator==(const IOVSyncValue& iRHS) const { return doOp<std::equal_to>(iRHS); }
0045     bool operator!=(const IOVSyncValue& iRHS) const { return doOp<std::not_equal_to>(iRHS); }
0046 
0047     bool operator<(const IOVSyncValue& iRHS) const { return doOp<std::less>(iRHS); }
0048     bool operator<=(const IOVSyncValue& iRHS) const { return doOp<std::less_equal>(iRHS); }
0049     bool operator>(const IOVSyncValue& iRHS) const { return doOp<std::greater>(iRHS); }
0050     bool operator>=(const IOVSyncValue& iRHS) const { return doOp<std::greater_equal>(iRHS); }
0051 
0052     // ---------- static member functions --------------------
0053     static const IOVSyncValue& invalidIOVSyncValue();
0054     static const IOVSyncValue& endOfTime();
0055     static const IOVSyncValue& beginOfTime();
0056 
0057     // ---------- member functions ---------------------------
0058 
0059   private:
0060     //IOVSyncValue(const IOVSyncValue&); // stop default
0061 
0062     //const IOVSyncValue& operator=(const IOVSyncValue&); // stop default
0063     template <template <typename> class Op>
0064     bool doOp(const IOVSyncValue& iRHS) const {
0065       bool returnValue = false;
0066       if (haveID_ && iRHS.haveID_) {
0067         if (luminosityBlockNumber() == 0 || iRHS.luminosityBlockNumber() == 0 ||
0068             luminosityBlockNumber() == iRHS.luminosityBlockNumber()) {
0069           Op<edm::EventID> op;
0070           returnValue = op(eventID_, iRHS.eventID_);
0071         } else {
0072           if (iRHS.eventID_.run() == eventID_.run()) {
0073             Op<edm::LuminosityBlockNumber_t> op;
0074             returnValue = op(luminosityBlockNumber(), iRHS.luminosityBlockNumber());
0075           } else {
0076             Op<edm::RunNumber_t> op;
0077             returnValue = op(eventID_.run(), iRHS.eventID_.run());
0078           }
0079         }
0080 
0081       } else if (haveTime_ && iRHS.haveTime_) {
0082         Op<edm::Timestamp> op;
0083         returnValue = op(time_, iRHS.time_);
0084       } else {
0085         //error
0086       }
0087       return returnValue;
0088     }
0089 
0090     // ---------- member data --------------------------------
0091     edm::EventID eventID_;
0092     edm::Timestamp time_;
0093     bool haveID_;
0094     bool haveTime_;
0095   };
0096 
0097 }  // namespace fwlite
0098 
0099 #endif