CMS 3D CMS Logo

Typedefs | Enumerations | Functions | Variables
cond::time Namespace Reference

Typedefs

typedef boost::date_time::subsecond_duration< boost::posix_time::time_duration, 1000000000 > nanoseconds
 
typedef cond::Time_t Time_t
 
typedef cond::TimeType TimeType
 
typedef cond::UnpackedTime UnpackedTime
 

Enumerations

enum  _timetype {
  INVALID =cond::invalid, RUNNUMBER =cond::runnumber, TIMESTAMP =cond::timestamp, LUMIID =cond::lumiid,
  HASH =cond::hash, USERID =cond::userid
}
 

Functions

Time_t from_boost (boost::posix_time::ptime bt)
 
Time_t from_timeval (::timeval stv)
 
Time_t fromIOVSyncValue (edm::IOVSyncValue const &time, TimeType timetype)
 
unsigned int itsNanoseconds (boost::posix_time::time_duration const &td)
 
const Time_t kLowMask (0xFFFFFFFF)
 
edm::IOVSyncValue limitedIOVSyncValue (Time_t time, TimeType timetype)
 
edm::IOVSyncValue limitedIOVSyncValue (edm::IOVSyncValue const &time, TimeType timetype)
 
const Time_t MAX_VAL (std::numeric_limits< Time_t >::max())
 
const Time_t MIN_VAL (0)
 
Time_t now ()
 
cond::Time_t pack (cond::UnpackedTime iValue)
 
const unsigned int SECONDS_PER_LUMI (23)
 
Time_t tillTimeFromNextSince (Time_t nextSince, TimeType timeType)
 
TimeType timeTypeFromName (const std::string &name)
 
std::string timeTypeName (TimeType type)
 
boost::posix_time::ptime to_boost (Time_t iValue)
 
inline::timeval to_timeval (Time_t iValue)
 
edm::IOVSyncValue toIOVSyncValue (cond::Time_t time, TimeType timetype, bool startOrStop)
 
cond::UnpackedTime unpack (cond::Time_t iValue)
 

Variables

static constexpr const char *const MAX_TIMESTAMP = "9999-12-31 23:59:59.000"
 
static const std::pair< const char *, TimeTypes_timeTypeMap []
 
static constexpr unsigned int SINCE_GROUP_SIZE = 1000
 
const boost::posix_time::ptime time0
 

Typedef Documentation

typedef boost::date_time::subsecond_duration<boost::posix_time::time_duration,1000000000> cond::time::nanoseconds

Definition at line 18 of file TimeConversions.h.

Definition at line 17 of file Time.h.

Definition at line 29 of file Time.h.

Definition at line 27 of file Time.h.

Enumeration Type Documentation

Function Documentation

Time_t cond::time::from_boost ( boost::posix_time::ptime  bt)
inline

Definition at line 52 of file TimeConversions.h.

References itsNanoseconds(), lumiQTWidget::t, and time0.

Referenced by SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffTrendPlotter::analyze(), cond::payloadInspector::TimeHistoryPlot< PayloadType, Y >::fill(), SiStripDetVOffBuilder::getCondTime(), and FillInfoPopConSourceHandler::getNewObjects().

52  {
53  boost::posix_time::time_duration td = bt - time0;
54  Time_t t = td.total_seconds();
55  return (t << 32) + itsNanoseconds(td);
56 
57  }
const boost::posix_time::ptime time0
unsigned int itsNanoseconds(boost::posix_time::time_duration const &td)
cond::Time_t Time_t
Definition: Time.h:17
Time_t cond::time::from_timeval ( ::timeval  stv)
inline

Definition at line 70 of file TimeConversions.h.

References lumiQTWidget::t.

Referenced by now().

70  {
71  Time_t t = stv.tv_sec;
72  return (t << 32) + 1000*stv.tv_usec;
73  }
cond::Time_t Time_t
Definition: Time.h:17
Time_t cond::time::fromIOVSyncValue ( edm::IOVSyncValue const &  time,
TimeType  timetype 
)

Definition at line 74 of file Time.cc.

References edm::IOVSyncValue::eventID(), LUMIID, edm::IOVSyncValue::luminosityBlockNumber(), edm::EventID::run(), RUNNUMBER, edm::IOVSyncValue::time(), TIMESTAMP, edm::LuminosityBlockID::value(), and edm::Timestamp::value().

Referenced by CondDBESSource::setIntervalFor().

74  {
75  switch (timetype) {
76  case RUNNUMBER :
77  return time.eventID().run();
78  case LUMIID :
79  {
80  edm::LuminosityBlockID lum(time.eventID().run(), time.luminosityBlockNumber());
81  return lum.value();
82  }
83  case TIMESTAMP :
84  return time.time().value();
85  default:
86  return 0;
87  }
88  }
boost::uint64_t value() const
unsigned int cond::time::itsNanoseconds ( boost::posix_time::time_duration const &  td)
inline

Definition at line 36 of file TimeConversions.h.

Referenced by from_boost().

36  {
37  return boost::posix_time::time_duration::num_fractional_digits() == 6 ?
38  1000*td.fractional_seconds() : td.fractional_seconds();
39  }
const Time_t cond::time::kLowMask ( 0xFFFFFFFF  )
edm::IOVSyncValue cond::time::limitedIOVSyncValue ( Time_t  time,
TimeType  timetype 
)

Definition at line 91 of file Time.cc.

References edm::IOVSyncValue::invalidIOVSyncValue(), checklumidiff::l, LUMIID, edm::LuminosityBlockID::luminosityBlock(), edm::EventID::maxEventNumber(), edm::LuminosityBlockID::run(), RUNNUMBER, and TIMESTAMP.

Referenced by CondDBESSource::setIntervalFor().

91  {
92  switch (timetype) {
93  case RUNNUMBER :
94  // last lumi and event of this run
98  );
99  case LUMIID :
100  {
101  // the same lumiblock
103  return edm::IOVSyncValue(edm::EventID(l.run(),
104  l.luminosityBlock(),
106  );
107  }
108  case TIMESTAMP :
109  // next event ?
111  default:
113  }
114  }
static EventNumber_t maxEventNumber()
Definition: EventID.h:111
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:92
edm::IOVSyncValue cond::time::limitedIOVSyncValue ( edm::IOVSyncValue const &  time,
TimeType  timetype 
)

Definition at line 116 of file Time.cc.

References edm::IOVSyncValue::eventID(), edm::IOVSyncValue::invalidIOVSyncValue(), LUMIID, edm::IOVSyncValue::luminosityBlockNumber(), edm::EventID::maxEventNumber(), edm::EventID::run(), RUNNUMBER, and TIMESTAMP.

116  {
117  switch (timetype) {
118  case RUNNUMBER :
119  // last event of this run
120  return edm::IOVSyncValue(edm::EventID(time.eventID().run(),
123  );
124  case LUMIID :
125  // the same lumiblock
126  return edm::IOVSyncValue(edm::EventID(time.eventID().run(),
127  time.luminosityBlockNumber(),
129  );
130  case TIMESTAMP :
131  // same lumiblock
132  return edm::IOVSyncValue(edm::EventID(time.eventID().run(),
133  time.luminosityBlockNumber(),
135  );
136  default:
138  }
139  }
static EventNumber_t maxEventNumber()
Definition: EventID.h:111
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:92
const Time_t cond::time::MAX_VAL ( std::numeric_limits< Time_t ::max())
const Time_t cond::time::MIN_VAL ( )
Time_t cond::time::now ( )
inline

Definition at line 75 of file TimeConversions.h.

References from_timeval().

75  {
76  ::timeval stv;
77  ::gettimeofday(&stv,0);
78  return from_timeval(stv);
79  }
Time_t from_timeval(::timeval stv)
cond::Time_t cond::time::pack ( cond::UnpackedTime  iValue)
inline

Definition at line 29 of file TimeConversions.h.

References lumiQTWidget::t.

Referenced by FillInfoPopConSourceHandler::getNewObjects(), and tillTimeFromNextSince().

29  {
30  Time_t t = iValue.first;
31  return (t<< 32) + iValue.second;
32  }
cond::Time_t Time_t
Definition: Time.h:17
const unsigned int cond::time::SECONDS_PER_LUMI ( 23  )
Time_t cond::time::tillTimeFromNextSince ( Time_t  nextSince,
TimeType  timeType 
)

Definition at line 33 of file Time.cc.

References createfilelist::int, pack(), TIMESTAMP, and unpack().

Referenced by cond::persistency::IOVProxy::Iterator::operator*().

33  {
34  if( timeType != (TimeType)TIMESTAMP ){
35  return nextSince - 1;
36  } else {
37  UnpackedTime unpackedTime = unpack( nextSince );
38  //number of seconds in nanoseconds (avoid multiply and divide by 1e09)
39  Time_t totalSecondsInNanoseconds = ((Time_t)unpackedTime.first)*1000000000;
40  //total number of nanoseconds
41  Time_t totalNanoseconds = totalSecondsInNanoseconds + ((Time_t)(unpackedTime.second));
42  //now decrementing of 1 nanosecond
43  totalNanoseconds--;
44  //now repacking (just change the value of the previous pair)
45  unpackedTime.first = (unsigned int) (totalNanoseconds/1000000000);
46  unpackedTime.second = (unsigned int)(totalNanoseconds - (Time_t)unpackedTime.first*1000000000);
47  return pack(unpackedTime);
48  }
49  }
def pack(high, low)
TimeType
Definition: Time.h:21
cond::Time_t Time_t
Definition: Time.h:17
cond::UnpackedTime UnpackedTime
Definition: Time.h:27
TimeType cond::time::timeTypeFromName ( const std::string &  name)

Definition at line 24 of file Time.cc.

References cond::findSpecs(), mps_fire::i, and cond::TimeTypeSpecs::type.

Referenced by cond::service::PoolDBOutputService::fillRecord(), cond::persistency::GetFromRow< cond::TimeType >::operator()(), cond::service::PoolDBOutputService::PoolDBOutputService(), and cond::payloadInspector::PlotBase::process().

24  {
25  for (auto const &i : s_timeTypeMap)
26  if (name.compare(i.first) == 0)
27  return i.second;
28  const cond::TimeTypeSpecs & theSpec = cond::findSpecs( name );
29  return theSpec.type;
30  //throwException( "TimeType \""+name+"\" is unknown.","timeTypeFromName");
31  }
static const std::pair< const char *, TimeType > s_timeTypeMap[]
Definition: Time.cc:14
TimeType type
Definition: Time.h:41
const TimeTypeSpecs & findSpecs(std::string const &name)
Definition: Time.cc:33
std::string cond::time::timeTypeName ( TimeType  type)

Definition at line 19 of file Time.cc.

References cond::invalid.

Referenced by cond::persistency::static_assert_is_same_decayed().

19  {
20  if( type==invalid ) return "";
21  return s_timeTypeMap[type].first;
22  }
type
Definition: HCALResponse.h:21
static const std::pair< const char *, TimeType > s_timeTypeMap[]
Definition: Time.cc:14
boost::posix_time::ptime cond::time::to_boost ( Time_t  iValue)
inline
inline ::timeval cond::time::to_timeval ( Time_t  iValue)

Definition at line 60 of file TimeConversions.h.

References kLowMask().

60  {
61  ::timeval stv;
62  // stv.tv_sec = static_cast<unsigned int>(iValue >> 32);
63  //stv.tv_usec = static_cast<unsigned int>(kLowMask & iValue);
64  stv.tv_sec = iValue >> 32;
65  stv.tv_usec = (kLowMask & iValue)/1000;
66  return stv;
67  }
const Time_t kLowMask(0xFFFFFFFF)
edm::IOVSyncValue cond::time::toIOVSyncValue ( cond::Time_t  time,
TimeType  timetype,
bool  startOrStop 
)

Definition at line 52 of file Time.cc.

References edm::IOVSyncValue::invalidIOVSyncValue(), checklumidiff::l, LUMIID, edm::LuminosityBlockID::luminosityBlock(), edm::EventID::maxEventNumber(), edm::LuminosityBlockID::run(), RUNNUMBER, and TIMESTAMP.

Referenced by CondDBESSource::setIntervalFor().

52  {
53  switch (timetype) {
54  case RUNNUMBER :
56  startOrStop ? 0 : edm::EventID::maxEventNumber(),
57  startOrStop ? 0 : edm::EventID::maxEventNumber())
58  );
59  case LUMIID :
60  {
62  return edm::IOVSyncValue(edm::EventID(l.run(),
63  l.luminosityBlock(),
64  startOrStop ? 0 : edm::EventID::maxEventNumber())
65  );
66  }
67  case TIMESTAMP :
69  default:
71  }
72  }
static EventNumber_t maxEventNumber()
Definition: EventID.h:111
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:92
cond::UnpackedTime cond::time::unpack ( cond::Time_t  iValue)
inline

Definition at line 25 of file TimeConversions.h.

References kLowMask().

Referenced by SiStripDetVOffTrendPlotter::analyze(), FillInfoPopConSourceHandler::getNewObjects(), and tillTimeFromNextSince().

25  {
26  return cond::UnpackedTime(iValue >> 32, kLowMask & iValue);
27  }
const Time_t kLowMask(0xFFFFFFFF)
std::pair< unsigned int, unsigned int > UnpackedTime
Definition: Time.h:17

Variable Documentation

constexpr const char* const cond::time::MAX_TIMESTAMP = "9999-12-31 23:59:59.000"
static

Definition at line 25 of file Time.h.

Referenced by CondDBESSource::CondDBESSource().

const std::pair<const char*, TimeType> cond::time::s_timeTypeMap[]
static
Initial value:
= { std::make_pair("Run", cond::runnumber),
std::make_pair("Time", cond::timestamp ),
std::make_pair("Lumi", cond::lumiid ),
std::make_pair("Hash", cond::hash ),
std::make_pair("User", cond::userid ) }

Definition at line 14 of file Time.cc.

constexpr unsigned int cond::time::SINCE_GROUP_SIZE = 1000
static

Definition at line 39 of file Time.h.

Referenced by cond::persistency::IOV::SINCE_GROUP::group().

const boost::posix_time::ptime cond::time::time0
Initial value:
=
boost::posix_time::from_time_t(0)

Definition at line 42 of file TimeConversions.h.

Referenced by from_boost(), and RunInfoRead::readData().