CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiStripDetVOffHandler Class Reference
Inheritance diagram for SiStripDetVOffHandler:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
 SiStripDetVOffHandler (const edm::ParameterSet &iConfig)
 
 ~SiStripDetVOffHandler () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::string m_condDb
 
cond::persistency::ConnectionPool m_connectionPool
 
std::string m_localCondDbFile
 
std::string m_targetTag
 
int maxTimeBeforeNewIOV_
 
edm::Service< SiStripDetVOffBuildermodHVBuilder
 
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > newPayloads
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 14 of file SiStripDetVOffHandler.cc.

Constructor & Destructor Documentation

◆ SiStripDetVOffHandler()

SiStripDetVOffHandler::SiStripDetVOffHandler ( const edm::ParameterSet iConfig)
explicit

Definition at line 33 of file SiStripDetVOffHandler.cc.

34  : m_connectionPool(),
35  m_condDb(iConfig.getParameter<std::string>("conditionDatabase")),
36  m_localCondDbFile(iConfig.getParameter<std::string>("condDbFile")),
37  m_targetTag(iConfig.getParameter<std::string>("targetTag")),
38  maxTimeBeforeNewIOV_(iConfig.getUntrackedParameter<int>("maxTimeBeforeNewIOV", 24)) {
41  // get last IOV from local sqlite file if "conditionDatabase" is empty
42  if (m_condDb.empty())
44 }

References cond::persistency::ConnectionPool::configure(), edm::ParameterSet::getParameter(), m_condDb, m_connectionPool, m_localCondDbFile, and cond::persistency::ConnectionPool::setParameters().

◆ ~SiStripDetVOffHandler()

SiStripDetVOffHandler::~SiStripDetVOffHandler ( )
override

Definition at line 46 of file SiStripDetVOffHandler.cc.

46 {}

Member Function Documentation

◆ analyze()

void SiStripDetVOffHandler::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 48 of file SiStripDetVOffHandler.cc.

48  {
49  // get last payload from condDb
50  cond::Time_t lastIov = 0;
51  std::shared_ptr<SiStripDetVOff> lastPayload;
52 
53  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
54  << "Retrieve last IOV from " << m_condDb;
56  condDbSession.transaction().start(true);
57  if (m_condDb.find("sqlite") == 0 && (!condDbSession.existsDatabase())) {
58  // Source of last IOV is empty
59  edm::LogInfo("SiStripDetVOffHandler")
60  << "[SiStripDetVOffHandler::" << __func__ << "] "
61  << "No information can be retrieved from " << m_condDb << " because the file is empty.\n"
62  << "Will assume all HV/LV's are off.";
63  } else {
64  cond::persistency::IOVProxy iovProxy = condDbSession.readIov(m_targetTag);
65  cond::Hash lastPayloadHash = iovProxy.getLast().payloadId;
66  if (!lastPayloadHash.empty()) {
67  lastPayload = condDbSession.fetchPayload<SiStripDetVOff>(lastPayloadHash);
68  lastIov = iovProxy.getLast().since; // move to LastValidatedTime?
69  }
70  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
71  << " ... last IOV: " << lastIov << " , "
72  << "last Payload: " << lastPayloadHash;
73  }
74  condDbSession.transaction().commit();
75 
76  // build the object!
77  newPayloads.clear();
78  modHVBuilder->setLastSiStripDetVOff(lastPayload.get(), lastIov);
81  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
82  << "Finished building " << newPayloads.size() << " new payloads.";
83 
84  // write the payloads to sqlite file
85  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
86  << "Write new payloads to sqlite file " << m_localCondDbFile;
88  localFileSession.transaction().start(false);
89  if (lastPayload && newPayloads.size() == 1 && *newPayloads[0].first == *lastPayload) {
90  // if no HV/LV transition was found in this period
91  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
92  << "No HV/LV transition was found from PVSS query.";
93  bool forceNewIOV = true;
94  if (maxTimeBeforeNewIOV_ < 0)
95  forceNewIOV = false;
96  else {
97  auto deltaT = cond::time::to_boost(newPayloads[0].second) - cond::time::to_boost(lastIov);
98  forceNewIOV = deltaT > boost::posix_time::hours(maxTimeBeforeNewIOV_);
99  }
100  if (!forceNewIOV) {
101  newPayloads.erase(newPayloads.begin());
102  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
103  << " ... No payload transfered.";
104  } else {
105  edm::LogInfo("SiStripDetVOffHandler")
106  << "[SiStripDetVOffHandler::" << __func__ << "] "
107  << " ... The last IOV is too old. Will start a new IOV from " << newPayloads[0].second << "("
108  << boost::posix_time::to_simple_string(cond::time::to_boost(newPayloads[0].second))
109  << ") with the same payload.";
110  }
111  }
112 
114  if (localFileSession.existsDatabase() && localFileSession.existsIov(m_targetTag)) {
115  edm::LogWarning("SiStripDetVOffHandler")
116  << "[SiStripDetVOffHandler::" << __func__ << "] "
117  << "IOV of tag " << m_targetTag << " already exists in sqlite file " << m_localCondDbFile;
118  iovEditor = localFileSession.editIov(m_targetTag);
119  } else {
120  iovEditor = localFileSession.createIov<SiStripDetVOff>(m_targetTag, cond::timestamp);
121  iovEditor.setDescription("New IOV");
122  }
123  for (const auto& payload : newPayloads) {
124  cond::Hash thePayloadHash = localFileSession.storePayload<SiStripDetVOff>(*payload.first);
125  iovEditor.insert(payload.second, thePayloadHash);
126  }
127  iovEditor.flush();
128  localFileSession.transaction().commit();
129 
130  edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] " << newPayloads.size()
131  << " payloads written to sqlite file.";
132 }

References SiStripDetVOffBuilder::BuildDetVOffObj(), cond::persistency::Transaction::commit(), cond::persistency::Session::createIov(), cond::persistency::ConnectionPool::createSession(), cond::persistency::Session::editIov(), cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), cond::persistency::Session::fetchPayload(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVProxy::getLast(), SiStripDetVOffBuilder::getModulesVOff(), getRunInfo::hours, cond::persistency::IOVEditor::insert(), m_condDb, m_connectionPool, m_localCondDbFile, m_targetTag, maxTimeBeforeNewIOV_, modHVBuilder, newPayloads, jets_cff::payload, cond::Iov_t::payloadId, cond::persistency::Session::readIov(), edm::second(), cond::persistency::IOVEditor::setDescription(), SiStripDetVOffBuilder::setLastSiStripDetVOff(), cond::Iov_t::since, cond::persistency::Transaction::start(), cond::persistency::Session::storePayload(), cond::timestamp, cond::time::to_boost(), and cond::persistency::Session::transaction().

◆ endJob()

void SiStripDetVOffHandler::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 134 of file SiStripDetVOffHandler.cc.

134 {}

Referenced by o2olib.O2ORunMgr::executeJob().

Member Data Documentation

◆ m_condDb

std::string SiStripDetVOffHandler::m_condDb
private

Definition at line 23 of file SiStripDetVOffHandler.cc.

Referenced by analyze(), and SiStripDetVOffHandler().

◆ m_connectionPool

cond::persistency::ConnectionPool SiStripDetVOffHandler::m_connectionPool
private

Definition at line 22 of file SiStripDetVOffHandler.cc.

Referenced by analyze(), and SiStripDetVOffHandler().

◆ m_localCondDbFile

std::string SiStripDetVOffHandler::m_localCondDbFile
private

Definition at line 24 of file SiStripDetVOffHandler.cc.

Referenced by analyze(), and SiStripDetVOffHandler().

◆ m_targetTag

std::string SiStripDetVOffHandler::m_targetTag
private

Definition at line 25 of file SiStripDetVOffHandler.cc.

Referenced by analyze().

◆ maxTimeBeforeNewIOV_

int SiStripDetVOffHandler::maxTimeBeforeNewIOV_
private

Definition at line 27 of file SiStripDetVOffHandler.cc.

Referenced by analyze().

◆ modHVBuilder

edm::Service<SiStripDetVOffBuilder> SiStripDetVOffHandler::modHVBuilder
private

Definition at line 30 of file SiStripDetVOffHandler.cc.

Referenced by analyze().

◆ newPayloads

std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > SiStripDetVOffHandler::newPayloads
private

Definition at line 29 of file SiStripDetVOffHandler.cc.

Referenced by analyze().

cond::persistency::IOVEditor::insert
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:139
cond::persistency::IOVProxy::getLast
cond::Iov_t getLast()
Definition: IOVProxy.cc:386
cond::time::to_boost
boost::posix_time::ptime to_boost(Time_t iValue)
Definition: TimeConversions.h:39
cond::Hash
std::string Hash
Definition: Types.h:43
cond::persistency::Session::existsIov
bool existsIov(const std::string &tag)
Definition: Session.cc:77
SiStripDetVOffHandler::modHVBuilder
edm::Service< SiStripDetVOffBuilder > modHVBuilder
Definition: SiStripDetVOffHandler.cc:30
cond::persistency::IOVEditor
Definition: IOVEditor.h:28
edm::LogInfo
Definition: MessageLogger.h:254
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripDetVOffBuilder::setLastSiStripDetVOff
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
Definition: SiStripDetVOffBuilder.cc:502
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:158
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
cond::timestamp
Definition: Time.h:19
jets_cff.payload
payload
Definition: jets_cff.py:34
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::IOVEditor::setDescription
void setDescription(const std::string &description)
Definition: IOVEditor.cc:114
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
edm::LogWarning
Definition: MessageLogger.h:141
cond::persistency::Session::editIov
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
edm::ParameterSet
Definition: ParameterSet.h:36
cond::Iov_t::payloadId
Hash payloadId
Definition: Types.h:55
SiStripDetVOffBuilder::BuildDetVOffObj
void BuildDetVOffObj()
Definition: SiStripDetVOffBuilder.cc:96
cond::persistency::Session
Definition: Session.h:63
cond::Iov_t::since
Time_t since
Definition: Types.h:53
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
SiStripDetVOffHandler::m_condDb
std::string m_condDb
Definition: SiStripDetVOffHandler.cc:23
SiStripDetVOff
Definition: SiStripDetVOff.h:31
cond::persistency::ConnectionPool::setParameters
void setParameters(const edm::ParameterSet &connectionPset)
Definition: ConnectionPool.cc:39
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:125
SiStripDetVOffHandler::m_targetTag
std::string m_targetTag
Definition: SiStripDetVOffHandler.cc:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
cond::persistency::Session::storePayload
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
SiStripDetVOffHandler::m_connectionPool
cond::persistency::ConnectionPool m_connectionPool
Definition: SiStripDetVOffHandler.cc:22
cond::persistency::Session::existsDatabase
bool existsDatabase()
Definition: Session.cc:55
cond::persistency::Session::createIov
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
getRunInfo.hours
hours
Definition: getRunInfo.py:25
SiStripDetVOffHandler::newPayloads
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > newPayloads
Definition: SiStripDetVOffHandler.cc:29
SiStripDetVOffHandler::m_localCondDbFile
std::string m_localCondDbFile
Definition: SiStripDetVOffHandler.cc:24
SiStripDetVOffHandler::maxTimeBeforeNewIOV_
int maxTimeBeforeNewIOV_
Definition: SiStripDetVOffHandler.cc:27
cond::persistency::IOVEditor::flush
bool flush()
Definition: IOVEditor.cc:295
SiStripDetVOffBuilder::getModulesVOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
Definition: SiStripDetVOffBuilder.h:48