File indexing completed on 2024-04-06 12:04:10
0001 #ifndef DataFormats_FWLite_IOVSyncValue_h
0002 #define DataFormats_FWLite_IOVSyncValue_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <functional>
0023
0024
0025 #include "DataFormats/Provenance/interface/EventID.h"
0026 #include "DataFormats/Provenance/interface/Timestamp.h"
0027
0028
0029
0030 namespace fwlite {
0031 class IOVSyncValue {
0032 public:
0033 IOVSyncValue();
0034
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
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
0053 static const IOVSyncValue& invalidIOVSyncValue();
0054 static const IOVSyncValue& endOfTime();
0055 static const IOVSyncValue& beginOfTime();
0056
0057
0058
0059 private:
0060
0061
0062
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
0086 }
0087 return returnValue;
0088 }
0089
0090
0091 edm::EventID eventID_;
0092 edm::Timestamp time_;
0093 bool haveID_;
0094 bool haveTime_;
0095 };
0096
0097 }
0098
0099 #endif