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 tillTimeForIOV (Time_t since, unsigned int iovSize, TimeType timeType)
 
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)
 
std::string transactionIdForLumiTime (Time_t time, unsigned int iovSize, const std::string &secretKey)
 
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 97 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().

97  {
98  switch (timetype) {
99  case RUNNUMBER:
100  return time.eventID().run();
101  case LUMIID: {
102  edm::LuminosityBlockID lum(time.eventID().run(), time.luminosityBlockNumber());
103  return lum.value();
104  }
105  case TIMESTAMP:
106  return time.time().value();
107  default:
108  return 0;
109  }
110  }
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 113 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().

113  {
114  switch (timetype) {
115  case RUNNUMBER:
116  // last lumi and event of this run
118  case LUMIID: {
119  // the same lumiblock
121  return edm::IOVSyncValue(edm::EventID(l.run(), l.luminosityBlock(), edm::EventID::maxEventNumber()));
122  }
123  case TIMESTAMP:
124  // next event ?
126  default:
128  }
129  }
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 131 of file Time.cc.

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

131  {
132  switch (timetype) {
133  case RUNNUMBER:
134  // last event of this run
135  return edm::IOVSyncValue(
137  case LUMIID:
138  // the same lumiblock
139  return edm::IOVSyncValue(
140  edm::EventID(time.eventID().run(), time.luminosityBlockNumber(), edm::EventID::maxEventNumber()));
141  case TIMESTAMP:
142  // same lumiblock
143  return edm::IOVSyncValue(
144  edm::EventID(time.eventID().run(), time.luminosityBlockNumber(), edm::EventID::maxEventNumber()));
145  default:
147  }
148  }
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(), tillTimeForIOV(), 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 68 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().

68  {
69  if (tp == TIMESTAMP)
70  return SINCE_TIME_GROUP_SIZE;
71  if (tp == LUMIID)
72  return SINCE_LUMI_GROUP_SIZE;
73  if (tp == HASH)
74  return SINCE_HASH_GROUP_SIZE;
75  return SINCE_RUN_GROUP_SIZE;
76  }
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::tillTimeForIOV ( Time_t  since,
unsigned int  iovSize,
TimeType  timeType 
)

Definition at line 54 of file Time.cc.

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

Referenced by CondDBESSource::setIntervalFor().

54  {
55  if (since == time::MAX_VAL)
56  return time::MAX_VAL;
57  if (timeType != (TimeType)TIMESTAMP) {
58  return since + iovSize - 1;
59  } else {
60  auto unpackedTime = unpack(since);
61  unpackedTime.first = unpackedTime.first + iovSize;
62  return tillTimeFromNextSince(pack(unpackedTime), timeType);
63  }
64  }
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
TimeType
Definition: Time.h:19
static constexpr TimeType TIMESTAMP
Definition: Time.h:35
Time_t tillTimeFromNextSince(Time_t nextSince, TimeType timeType)
Definition: Time.cc:34
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
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(), cond::persistency::IOVArray::Iterator::operator*(), and tillTimeForIOV().

34  {
35  if (nextSince == time::MAX_VAL)
36  return time::MAX_VAL;
37  if (timeType != (TimeType)TIMESTAMP) {
38  return nextSince - 1;
39  } else {
40  auto 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())
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 79 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().

79  {
80  switch (timetype) {
81  case RUNNUMBER:
82  return edm::IOVSyncValue(edm::EventID(time,
83  startOrStop ? 0 : edm::EventID::maxEventNumber(),
84  startOrStop ? 0 : edm::EventID::maxEventNumber()));
85  case LUMIID: {
87  return edm::IOVSyncValue(
88  edm::EventID(l.run(), l.luminosityBlock(), startOrStop ? 0 : edm::EventID::maxEventNumber()));
89  }
90  case TIMESTAMP:
91  return edm::IOVSyncValue(edm::Timestamp(time));
92  default:
94  }
95  }
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
std::string cond::time::transactionIdForLumiTime ( Time_t  time,
unsigned int  iovSize,
const std::string &  secretKey 
)

Definition at line 150 of file Time.cc.

References gpuClustering::id, lumiTime(), hltrates_dqm_sourceclient-live_cfg::offset, and unpack().

Referenced by cond::service::OnlineDBOutputService::preLoadIov(), and CondDBESSource::setIntervalFor().

150  {
151  auto unpackedTime = cond::time::unpack(time);
152  unsigned int offset = 1 + iovSize;
153  cond::Time_t id = 0;
154  if (unpackedTime.second < offset) {
155  id = lumiTime(unpackedTime.first, 1);
156  } else {
157  unsigned int res = (unpackedTime.second - offset) % iovSize;
158  id = lumiTime(unpackedTime.first, unpackedTime.second - res);
159  }
160  std::stringstream transId;
161  transId << id;
162  if (!secretKey.empty()) {
163  transId << "_" << secretKey;
164  }
165  return transId.str();
166  }
uint16_t *__restrict__ id
unsigned long long Time_t
Definition: Time.h:14
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:66
cond::UnpackedTime unpack(cond::Time_t iValue)
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.