CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Typedefs | 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
 

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)
 
Time_t lumiTime (unsigned int run, unsigned int lumiId)
 
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 sinceGroupSize (TimeType tp)
 
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 TimeType HASH = cond::hash
 
static constexpr TimeType INVALID = cond::invalid
 
static constexpr TimeType LUMIID = cond::lumiid
 
static constexpr const char *const MAX_TIMESTAMP = "9999-12-31 23:59:59.000"
 
static constexpr TimeType RUNNUMBER = cond::runnumber
 
static const std::pair< const
char *, TimeType
s_timeTypeMap []
 
static constexpr unsigned int SINCE_HASH_GROUP_SIZE = SINCE_RUN_GROUP_SIZE
 
static constexpr unsigned int SINCE_LUMI_GROUP_SIZE = SINCE_RUN_GROUP_SIZE
 
static constexpr unsigned int SINCE_RUN_GROUP_SIZE = 1000
 
static constexpr unsigned long SINCE_TIME_GROUP_SIZE = 154618822656000
 
const boost::posix_time::ptime time0 = boost::posix_time::from_time_t(0)
 
static constexpr TimeType TIMESTAMP = cond::timestamp
 
static constexpr TimeType USERID = cond::userid
 

Typedef Documentation

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

Definition at line 16 of file TimeConversions.h.

Definition at line 18 of file Time.h.

Definition at line 30 of file Time.h.

Definition at line 28 of file Time.h.

Function Documentation

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

Definition at line 58 of file TimeConversions.h.

References submitPVValidationJobs::t.

Referenced by now().

58  {
59  Time_t t = stv.tv_sec;
60  return (t << 32) + 1000 * stv.tv_usec;
61  }
cond::Time_t Time_t
Definition: Time.h:18
Time_t cond::time::fromIOVSyncValue ( edm::IOVSyncValue const &  time,
TimeType  timetype 
)

Definition at line 85 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().

85  {
86  switch (timetype) {
87  case RUNNUMBER:
88  return time.eventID().run();
89  case LUMIID: {
90  edm::LuminosityBlockID lum(time.eventID().run(), time.luminosityBlockNumber());
91  return lum.value();
92  }
93  case TIMESTAMP:
94  return time.time().value();
95  default:
96  return 0;
97  }
98  }
static constexpr TimeType RUNNUMBER
Definition: Time.h:34
uint64_t value() const
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
static constexpr TimeType LUMIID
Definition: Time.h:36
unsigned int cond::time::itsNanoseconds ( boost::posix_time::time_duration const &  td)
inline

Definition at line 32 of file TimeConversions.h.

Referenced by from_boost().

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

Definition at line 101 of file Time.cc.

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

Referenced by CondDBESSource::setIntervalFor().

101  {
102  switch (timetype) {
103  case RUNNUMBER:
104  // last lumi and event of this run
106  case LUMIID: {
107  // the same lumiblock
109  return edm::IOVSyncValue(edm::EventID(l.run(), l.luminosityBlock(), edm::EventID::maxEventNumber()));
110  }
111  case TIMESTAMP:
112  // next event ?
114  default:
116  }
117  }
static constexpr TimeType RUNNUMBER
Definition: Time.h:34
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78
static constexpr TimeType LUMIID
Definition: Time.h:36
edm::IOVSyncValue cond::time::limitedIOVSyncValue ( edm::IOVSyncValue const &  time,
TimeType  timetype 
)

Definition at line 119 of file Time.cc.

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

119  {
120  switch (timetype) {
121  case RUNNUMBER:
122  // last event of this run
123  return edm::IOVSyncValue(
125  case LUMIID:
126  // the same lumiblock
127  return edm::IOVSyncValue(
128  edm::EventID(time.eventID().run(), time.luminosityBlockNumber(), edm::EventID::maxEventNumber()));
129  case TIMESTAMP:
130  // same lumiblock
131  return edm::IOVSyncValue(
132  edm::EventID(time.eventID().run(), time.luminosityBlockNumber(), edm::EventID::maxEventNumber()));
133  default:
135  }
136  }
static constexpr TimeType RUNNUMBER
Definition: Time.h:34
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78
static constexpr TimeType LUMIID
Definition: Time.h:36
Time_t cond::time::lumiTime ( unsigned int  run,
unsigned int  lumiId 
)
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 63 of file TimeConversions.h.

References from_timeval().

63  {
64  ::timeval stv;
65  ::gettimeofday(&stv, nullptr);
66  return from_timeval(stv);
67  }
Time_t from_timeval(::timeval stv)
cond::Time_t cond::time::pack ( cond::UnpackedTime  iValue)
inline

Definition at line 26 of file TimeConversions.h.

References submitPVValidationJobs::t.

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

26  {
27  Time_t t = iValue.first;
28  return (t << 32) + iValue.second;
29  }
cond::Time_t Time_t
Definition: Time.h:18
const unsigned int cond::time::SECONDS_PER_LUMI ( 23  )
Time_t cond::time::sinceGroupSize ( TimeType  tp)

Definition at line 56 of file Time.cc.

References HASH, LUMIID, SINCE_HASH_GROUP_SIZE, SINCE_LUMI_GROUP_SIZE, SINCE_RUN_GROUP_SIZE, SINCE_TIME_GROUP_SIZE, and TIMESTAMP.

Referenced by cond::persistency::IOVProxy::loadGroups().

56  {
57  if (tp == TIMESTAMP)
58  return SINCE_TIME_GROUP_SIZE;
59  if (tp == LUMIID)
60  return SINCE_LUMI_GROUP_SIZE;
61  if (tp == HASH)
62  return SINCE_HASH_GROUP_SIZE;
63  return SINCE_RUN_GROUP_SIZE;
64  }
static constexpr unsigned long SINCE_TIME_GROUP_SIZE
Definition: Time.h:47
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
static constexpr unsigned int SINCE_LUMI_GROUP_SIZE
Definition: Time.h:48
static constexpr unsigned int SINCE_HASH_GROUP_SIZE
Definition: Time.h:49
static constexpr TimeType HASH
Definition: Time.h:37
static constexpr unsigned int SINCE_RUN_GROUP_SIZE
Definition: Time.h:45
static constexpr TimeType LUMIID
Definition: Time.h:36
Time_t cond::time::tillTimeFromNextSince ( Time_t  nextSince,
TimeType  timeType 
)

Definition at line 34 of file Time.cc.

References MAX_VAL(), pack(), TIMESTAMP, and unpack().

Referenced by cond::persistency::IOVProxy::fetchSequence(), cond::persistency::IOVProxy::getInterval(), and cond::persistency::IOVArray::Iterator::operator*().

34  {
35  if (nextSince == time::MAX_VAL)
36  return time::MAX_VAL;
37  if (timeType != (TimeType)TIMESTAMP) {
38  return nextSince - 1;
39  } else {
40  UnpackedTime unpackedTime = unpack(nextSince);
41  //number of seconds in nanoseconds (avoid multiply and divide by 1e09)
42  Time_t totalSecondsInNanoseconds = ((Time_t)unpackedTime.first) * 1000000000;
43  //total number of nanoseconds
44  Time_t totalNanoseconds = totalSecondsInNanoseconds + ((Time_t)(unpackedTime.second));
45  //now decrementing of 1 nanosecond
46  totalNanoseconds--;
47  //now repacking (just change the value of the previous pair)
48  unpackedTime.first = (unsigned int)(totalNanoseconds / 1000000000);
49  unpackedTime.second = (unsigned int)(totalNanoseconds - (Time_t)unpackedTime.first * 1000000000);
50  return pack(unpackedTime);
51  }
52  }
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
TimeType
Definition: Time.h:19
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
cond::Time_t Time_t
Definition: Time.h:18
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
cond::UnpackedTime UnpackedTime
Definition: Time.h:28
TimeType cond::time::timeTypeFromName ( const std::string &  name)

Definition at line 25 of file Time.cc.

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

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

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

Definition at line 19 of file Time.cc.

References s_timeTypeMap.

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

19  {
20  if (type == invalid)
21  return "";
22  return s_timeTypeMap[type].first;
23  }
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 49 of file TimeConversions.h.

References kLowMask().

49  {
50  ::timeval stv;
51  // stv.tv_sec = static_cast<unsigned int>(iValue >> 32);
52  //stv.tv_usec = static_cast<unsigned int>(kLowMask & iValue);
53  stv.tv_sec = iValue >> 32;
54  stv.tv_usec = (kLowMask & iValue) / 1000;
55  return stv;
56  }
const Time_t kLowMask(0xFFFFFFFF)
edm::IOVSyncValue cond::time::toIOVSyncValue ( cond::Time_t  time,
TimeType  timetype,
bool  startOrStop 
)

Definition at line 67 of file Time.cc.

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

Referenced by CondDBESSource::setIntervalFor().

67  {
68  switch (timetype) {
69  case RUNNUMBER:
70  return edm::IOVSyncValue(edm::EventID(time,
71  startOrStop ? 0 : edm::EventID::maxEventNumber(),
72  startOrStop ? 0 : edm::EventID::maxEventNumber()));
73  case LUMIID: {
75  return edm::IOVSyncValue(
76  edm::EventID(l.run(), l.luminosityBlock(), startOrStop ? 0 : edm::EventID::maxEventNumber()));
77  }
78  case TIMESTAMP:
79  return edm::IOVSyncValue(edm::Timestamp(time));
80  default:
82  }
83  }
static constexpr TimeType RUNNUMBER
Definition: Time.h:34
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78
static constexpr TimeType LUMIID
Definition: Time.h:36
cond::UnpackedTime cond::time::unpack ( cond::Time_t  iValue)
inline

Variable Documentation

constexpr TimeType cond::time::HASH = cond::hash
static

Definition at line 37 of file Time.h.

Referenced by sinceGroupSize().

constexpr TimeType cond::time::INVALID = cond::invalid
static

Definition at line 33 of file Time.h.

constexpr TimeType cond::time::LUMIID = cond::lumiid
static

Definition at line 36 of file Time.h.

Referenced by fromIOVSyncValue(), limitedIOVSyncValue(), sinceGroupSize(), and toIOVSyncValue().

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

Definition at line 26 of file Time.h.

Referenced by CondDBESSource::CondDBESSource().

constexpr TimeType cond::time::RUNNUMBER = cond::runnumber
static

Definition at line 34 of file Time.h.

Referenced by fromIOVSyncValue(), limitedIOVSyncValue(), and toIOVSyncValue().

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.

Referenced by timeTypeFromName(), and timeTypeName().

constexpr unsigned int cond::time::SINCE_HASH_GROUP_SIZE = SINCE_RUN_GROUP_SIZE
static

Definition at line 49 of file Time.h.

Referenced by sinceGroupSize().

constexpr unsigned int cond::time::SINCE_LUMI_GROUP_SIZE = SINCE_RUN_GROUP_SIZE
static

Definition at line 48 of file Time.h.

Referenced by sinceGroupSize().

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

Definition at line 45 of file Time.h.

Referenced by sinceGroupSize().

constexpr unsigned long cond::time::SINCE_TIME_GROUP_SIZE = 154618822656000
static

Definition at line 47 of file Time.h.

Referenced by sinceGroupSize().

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

Definition at line 37 of file TimeConversions.h.

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

constexpr TimeType cond::time::TIMESTAMP = cond::timestamp
static
constexpr TimeType cond::time::USERID = cond::userid
static

Definition at line 38 of file Time.h.