CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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 const std::pair< const
char *, TimeType
s_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 25 of file Time.h.

Definition at line 23 of file Time.h.

Enumeration Type Documentation

Enumerator
INVALID 
RUNNUMBER 
TIMESTAMP 
LUMIID 
HASH 
USERID 

Definition at line 28 of file Time.h.

Function Documentation

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

Definition at line 52 of file TimeConversions.h.

References itsNanoseconds(), edmStreamStallGrapher::t, getDQMSummary::td, and time0.

Referenced by 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 edmStreamStallGrapher::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(), ConfigFiles::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:106
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:106
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().

Referenced by cond::UpdateStamp::stamp().

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 edmStreamStallGrapher::t.

Referenced by FillInfoPopConSourceHandler::getNewObjects(), cond::IOVElementProxy::set(), 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
Time_t cond::time::tillTimeFromNextSince ( Time_t  nextSince,
TimeType  timeType 
)

Definition at line 33 of file Time.cc.

References 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  }
TimeType
Definition: Time.h:21
cond::Time_t Time_t
Definition: Time.h:17
cond::UnpackedTime UnpackedTime
Definition: Time.h:23
TimeType cond::time::timeTypeFromName ( const std::string &  name)

Definition at line 24 of file Time.cc.

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

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

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  }
int i
Definition: DBlmapReader.cc:9
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, and s_timeTypeMap.

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

Definition at line 45 of file TimeConversions.h.

References kLowMask(), seconds(), and time0.

Referenced by SiStripDetVOffBuilder::getCoralTime(), FillInfoPopConSourceHandler::getNewObjects(), FillInfo::print(), and popcon::SiStripDetVOffHandler::setUserTextLog().

45  {
46  return time0 +
47  boost::posix_time::seconds( iValue >> 32) +
48  nanoseconds(kLowMask & iValue);
49  }
double seconds()
const boost::posix_time::ptime time0
const Time_t kLowMask(0xFFFFFFFF)
boost::date_time::subsecond_duration< boost::posix_time::time_duration, 1000000000 > nanoseconds
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(), ConfigFiles::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:106
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 FillInfoPopConSourceHandler::getNewObjects(), cond::IOVElementProxy::set(), 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

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_GROUP_SIZE = 1000
static

Definition at line 35 of file Time.h.

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

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(), RunInfoRead::readData(), and to_boost().