CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/CondCore/DBCommon/src/ConvertIOVSyncValue.cc

Go to the documentation of this file.
00001 #include "CondCore/DBCommon/interface/ConvertIOVSyncValue.h"
00002 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00003 
00004 
00005 namespace cond {
00006 
00007   edm::IOVSyncValue toIOVSyncValue(cond::Time_t time, cond::TimeType timetype, bool startOrStop) {
00008     switch (timetype) {
00009     case cond::runnumber :
00010       return edm::IOVSyncValue( edm::EventID(time, 
00011                                              startOrStop ? 0 : edm::EventID::maxEventNumber(),
00012                                              startOrStop ? 0 : edm::EventID::maxEventNumber()) 
00013                                 );
00014     case cond::lumiid :
00015       {
00016         edm::LuminosityBlockID l(time);
00017         return edm::IOVSyncValue(edm::EventID(l.run(),  
00018                                               l.luminosityBlock(), 
00019                                               startOrStop ? 0 : edm::EventID::maxEventNumber())
00020                                  );
00021       }
00022     case cond::timestamp :
00023       return edm::IOVSyncValue( edm::Timestamp(time));
00024     default:
00025       return  edm::IOVSyncValue::invalidIOVSyncValue();
00026     }
00027   }
00028   
00029   cond::Time_t fromIOVSyncValue(edm::IOVSyncValue const & time, cond::TimeType timetype) {
00030     switch (timetype) {
00031     case cond::runnumber :
00032       return time.eventID().run();
00033     case cond::lumiid : 
00034       {
00035         edm::LuminosityBlockID lum(time.eventID().run(), time.luminosityBlockNumber());
00036         return lum.value();
00037       }
00038     case cond::timestamp :
00039       return time.time().value();
00040     default:
00041       return 0;
00042     }
00043   }
00044 
00045   // the minimal maximum-time an IOV can extend to
00046   edm::IOVSyncValue limitedIOVSyncValue(cond::Time_t time, cond::TimeType timetype) {
00047     switch (timetype) {
00048     case cond::runnumber :
00049       // last lumi and event of this run
00050       return edm::IOVSyncValue( edm::EventID(time, 
00051                                              edm::EventID::maxEventNumber(),
00052                                              edm::EventID::maxEventNumber()) 
00053                                 );
00054   case cond::lumiid : 
00055       {
00056         // the same lumiblock
00057         edm::LuminosityBlockID l(time);
00058         return edm::IOVSyncValue(edm::EventID(l.run(), 
00059                                               l.luminosityBlock(), 
00060                                               edm::EventID::maxEventNumber())
00061                                  );
00062       }
00063     case cond::timestamp :
00064       // next event ?
00065       return edm::IOVSyncValue::invalidIOVSyncValue();
00066     default:
00067       return  edm::IOVSyncValue::invalidIOVSyncValue();
00068     }
00069   }
00070   
00071   edm::IOVSyncValue limitedIOVSyncValue(edm::IOVSyncValue const & time, cond::TimeType timetype) {
00072     switch (timetype) {
00073     case cond::runnumber :
00074       // last event of this run
00075       return edm::IOVSyncValue(edm::EventID(time.eventID().run(),
00076                                             edm::EventID::maxEventNumber(), 
00077                                             edm::EventID::maxEventNumber()) 
00078                                );
00079     case cond::lumiid :
00080       // the same lumiblock
00081       return edm::IOVSyncValue(edm::EventID(time.eventID().run(), 
00082                                             time.luminosityBlockNumber(), 
00083                                             edm::EventID::maxEventNumber())
00084                                );
00085     case cond::timestamp :
00086       // same lumiblock
00087       return edm::IOVSyncValue(edm::EventID(time.eventID().run(), 
00088                                             time.luminosityBlockNumber(), 
00089                                             edm::EventID::maxEventNumber())
00090                                );       
00091     default:
00092       return  edm::IOVSyncValue::invalidIOVSyncValue();
00093     }
00094   }
00095   
00096 }
00097 
00098