CMS 3D CMS Logo

BeamSpotOnlinePopConSourceHandler.cc
Go to the documentation of this file.
5 
6 #include <chrono>
7 #include <memory>
8 
10  : m_debug(pset.getUntrackedParameter<bool>("debug", false)),
11  m_name(pset.getUntrackedParameter<std::string>("name", "BeamSpotOnlineSourceHandler")),
12  m_maxAge(pset.getUntrackedParameter<unsigned int>("maxAge", 86400)),
13  m_runNumber(pset.getUntrackedParameter<unsigned int>("runNumber", 1)),
14  m_sourcePayloadTag(pset.getUntrackedParameter<std::string>("sourcePayloadTag", "")) {}
15 
17 
18 bool checkPayloadAge(const BeamSpotOnlineObjects& payload, unsigned int maxAge) {
19  long creationTimeInSeconds = payload.GetCreationTime() >> 32;
20  auto timeNow = std::chrono::system_clock::now();
21  auto nowSinceEpoch = std::chrono::duration_cast<std::chrono::seconds>(timeNow.time_since_epoch()).count();
22  long age = nowSinceEpoch - creationTimeInSeconds;
23  return age < maxAge;
24 }
25 
26 std::unique_ptr<BeamSpotOnlineObjects> makeDummyPayload() {
27  // implement here
28  std::unique_ptr<BeamSpotOnlineObjects> ret;
29  ret = std::make_unique<BeamSpotOnlineObjects>();
30  auto timeNow = std::chrono::system_clock::now();
31  auto nowSinceEpoch = std::chrono::duration_cast<std::chrono::seconds>(timeNow.time_since_epoch()).count();
32  ret->SetCreationTime(nowSinceEpoch << 32);
33  return ret;
34 }
35 
37  bool addNewPayload = false;
38  if (!tagInfo().size) {
39  edm::LogInfo(m_name) << "New tag " << tagInfo().name << "; from " << m_name << "::getNewObjects";
40  addNewPayload = true;
41  } else {
42  edm::LogInfo(m_name) << "got info for tag " << tagInfo().name << ", last object valid since "
43  << tagInfo().lastInterval.since << "; from " << m_name << "::getNewObjects";
45  addNewPayload = true;
46  }
47  }
48 
49  if (addNewPayload) {
50  if (!m_sourcePayloadTag.empty()) {
51  edm::LogInfo(m_name) << "Reading target payload from tag " << m_sourcePayloadTag;
52  auto session = dbSession();
53  session.transaction().start(true);
54  auto lastIov = session.readIov(m_sourcePayloadTag).getLast();
55  m_payload = session.fetchPayload<BeamSpotOnlineObjects>(lastIov.payloadId);
56  session.transaction().commit();
57  } else {
59  }
60 
62  m_to_transfer.push_back(std::make_pair(m_payload.get(), targetTime));
63 
64  edm::LogInfo(m_name) << "Payload added with IOV since " << targetTime;
65  } else {
66  edm::LogInfo(m_name) << "Nothing to do, last payload satisfies maximum age requirement.";
67  }
68 }
69 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
makeDummyPayload
std::unique_ptr< BeamSpotOnlineObjects > makeDummyPayload()
Definition: BeamSpotOnlinePopConSourceHandler.cc:26
electrons_cff.bool
bool
Definition: electrons_cff.py:366
BeamSpotOnlinePopConSourceHandler::m_runNumber
unsigned int m_runNumber
Definition: BeamSpotOnlinePopConSourceHandler.h:21
popcon::PopConSourceHandler< BeamSpotOnlineObjects >::m_to_transfer
OldContainer m_to_transfer
Definition: PopConSourceHandler.h:162
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
popcon::PopConSourceHandler< BeamSpotOnlineObjects >::dbSession
cond::persistency::Session & dbSession() const
Definition: PopConSourceHandler.h:144
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
BeamSpotOnlinePopConSourceHandler::getNewObjects
void getNewObjects() override
Definition: BeamSpotOnlinePopConSourceHandler.cc:36
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
BeamSpotOnlinePopConSourceHandler::m_sourcePayloadTag
std::string m_sourcePayloadTag
Definition: BeamSpotOnlinePopConSourceHandler.h:22
cond::TagInfo_t::name
std::string name
Definition: Types.h:72
BeamSpotOnlinePopConSourceHandler::m_payload
std::unique_ptr< BeamSpotOnlineObjects > m_payload
Definition: BeamSpotOnlinePopConSourceHandler.h:23
checkPayloadAge
bool checkPayloadAge(const BeamSpotOnlineObjects &payload, unsigned int maxAge)
Definition: BeamSpotOnlinePopConSourceHandler.cc:18
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
jets_cff.payload
payload
Definition: jets_cff.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
BeamSpotOnlinePopConSourceHandler::~BeamSpotOnlinePopConSourceHandler
~BeamSpotOnlinePopConSourceHandler() override
Definition: BeamSpotOnlinePopConSourceHandler.cc:16
popcon::PopConSourceHandler< BeamSpotOnlineObjects >::tagInfo
cond::TagInfo_t const & tagInfo() const
Definition: PopConSourceHandler.h:78
cond::Iov_t::since
Time_t since
Definition: Types.h:53
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
createfilelist.int
int
Definition: createfilelist.py:10
BeamSpotOnlinePopConSourceHandler.h
cond::time::lumiTime
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:54
BeamSpotOnlinePopConSourceHandler::id
std::string id() const override
Definition: BeamSpotOnlinePopConSourceHandler.cc:70
BeamSpotOnlinePopConSourceHandler::m_maxAge
unsigned int m_maxAge
Definition: BeamSpotOnlinePopConSourceHandler.h:20
cond::TagInfo_t::lastInterval
Iov_t lastInterval
Definition: Types.h:73
BeamSpotOnlinePopConSourceHandler::BeamSpotOnlinePopConSourceHandler
BeamSpotOnlinePopConSourceHandler(const edm::ParameterSet &pset)
Definition: BeamSpotOnlinePopConSourceHandler.cc:9
std
Definition: JetResolutionObject.h:76
BeamSpotOnlineObjects
Definition: BeamSpotOnlineObjects.h:25
popcon::PopConSourceHandler< BeamSpotOnlineObjects >::lastPayload
Ref lastPayload() const
Definition: PopConSourceHandler.h:81
BeamSpotOnlinePopConSourceHandler::m_name
std::string m_name
Definition: BeamSpotOnlinePopConSourceHandler.h:19
TimeConversions.h
ParameterSet.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443