CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
SiStripDetVOffPrinter Class Reference
Inheritance diagram for SiStripDetVOffPrinter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
 SiStripDetVOffPrinter (const edm::ParameterSet &iConfig)
 
 ~SiStripDetVOffPrinter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

std::map< uint32_t, std::vector< cond::Time_t > > detidMap
 
std::map< cond::Time_t, std::set< uint32_t > > iovMap_HVOff
 
std::map< cond::Time_t, std::set< uint32_t > > iovMap_LVOff
 
std::string m_condDb
 
cond::persistency::ConnectionPool m_connectionPool
 
std::string m_endTime
 
std::string m_output
 
std::string m_startTime
 
std::string m_tagName
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 26 of file SiStripDetVOffPrinter.cc.

Constructor & Destructor Documentation

◆ SiStripDetVOffPrinter()

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

◆ ~SiStripDetVOffPrinter()

SiStripDetVOffPrinter::~SiStripDetVOffPrinter ( )
override

Definition at line 63 of file SiStripDetVOffPrinter.cc.

63 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 65 of file SiStripDetVOffPrinter.cc.

65  {
66  // use start and end time from config file
67  boost::posix_time::ptime p_start, p_end;
68  p_start = boost::posix_time::time_from_string(m_startTime);
69  p_end = boost::posix_time::time_from_string(m_endTime);
70  cond::Time_t startIov = cond::time::from_boost(p_start);
71  cond::Time_t endIov = cond::time::from_boost(p_end);
72  if (startIov > endIov)
73  throw cms::Exception("endTime must be greater than startTime!");
74  edm::LogInfo("SiStripDetVOffPrinter") << "[SiStripDetVOffPrinter::" << __func__ << "] "
75  << "Set start time " << startIov << " ("
76  << boost::posix_time::to_simple_string(p_start) << ")"
77  << "\n ... Set end time " << endIov << " ("
78  << boost::posix_time::to_simple_string(p_end) << ")";
79 
80  // open db session
81  edm::LogInfo("SiStripDetVOffPrinter") << "[SiStripDetVOffPrinter::" << __func__ << "] "
82  << "Query the condition database " << m_condDb;
84  condDbSession.transaction().start(true);
85 
86  std::stringstream ss;
87  // list of times with new IOVs within the time range
88  std::vector<cond::Time_t> vTime;
89 
90  // query the database
91  edm::LogInfo("SiStripDetVOffPrinter") << "[SiStripDetVOffPrinter::" << __func__ << "] "
92  << "Reading IOVs from tag " << m_tagName;
93  cond::persistency::IOVProxy iovProxy = condDbSession.readIov(m_tagName); // load all?
94  auto iovs = iovProxy.selectAll();
95  auto iiov = iovs.find(startIov);
96  auto eiov = iovs.find(endIov);
97  int niov = 0;
98  while (iiov != iovs.end() && (*iiov).since <= (*eiov).since) {
99  // convert cond::Time_t to seconds since epoch
100  if ((*iiov).since < startIov) {
101  vTime.push_back(startIov);
102  } else {
103  vTime.push_back((*iiov).since);
104  }
105  auto payload = condDbSession.fetchPayload<SiStripDetVOff>((*iiov).payloadId);
106  // print IOVs summary
107  ss << boost::posix_time::to_simple_string(cond::time::to_boost((*iiov).since)) << " (" << (*iiov).since << ")"
108  << ", # HV Off=" << std::setw(6) << payload->getHVoffCounts() << ", # LV Off=" << std::setw(6)
109  << payload->getLVoffCounts() << std::endl;
110 
111  // list of detids with HV/LV Off
112  std::vector<uint32_t> detIds;
113  payload->getDetIds(detIds);
114  std::set<uint32_t> detIds_HVOff;
115  std::set<uint32_t> detIds_LVOff;
116  std::vector<uint32_t>::const_iterator it = detIds.begin();
117  for (; it != detIds.end(); ++it) {
118  if (payload->IsModuleHVOff(*it))
119  detIds_HVOff.insert(*it);
120  if (payload->IsModuleLVOff(*it))
121  detIds_LVOff.insert(*it);
122 
123  if (detidMap.find(*it) == detidMap.end()) {
124  std::vector<cond::Time_t> vec;
125  detidMap[*it] = vec;
126  }
127 
128  // for each module concerned by the IOV, add the time in an history vector
129  detidMap[*it].push_back(vTime.back());
130  }
131 
132  // fill list of channels Off at a given time
133  iovMap_HVOff[vTime.back()] = detIds_HVOff;
134  iovMap_LVOff[vTime.back()] = detIds_LVOff;
135 
136  /*std::vector<uint32_t>::const_iterator it = detIds.begin();
137  for( ; it!=detIds.end(); ++it ) {
138  std::cout << *it << std::endl;
139  }*/
140 
141  ++iiov;
142  ++niov;
143  }
144  vTime.push_back(endIov); // used to compute last IOV duration
145 
146  edm::LogInfo("SiStripDetVOffPrinter") << "[SiStripDetVOffPrinter::" << __func__ << "] "
147  << "Read " << niov << " IOVs from tag " << m_tagName
148  << " corresponding to the specified time interval.\n"
149  << ss.str();
150 
151  // Create a map of IOVs time_duration
152  std::map<cond::Time_t, boost::posix_time::time_duration> mIOVsDuration;
153  std::vector<cond::Time_t>::const_iterator itTime = ++vTime.begin();
154  std::vector<cond::Time_t>::const_iterator itPreviousTime = vTime.begin();
155  //std::vector< cond::Time_t >::const_iterator itLastTime = --vTime.end();
156  for (; itTime != vTime.end(); ++itTime) {
157  mIOVsDuration[*itPreviousTime] = cond::time::to_boost(*itTime) - cond::time::to_boost(*itPreviousTime);
158  itPreviousTime = itTime;
159  }
160  boost::posix_time::time_duration time_period =
161  cond::time::to_boost(*(--vTime.end())) - cond::time::to_boost(*(vTime.begin()));
162 
163  // debug
164  /*for( itTime=vTime.begin(); itTime!=itLastTime; ++itTime ) {
165  std::cout<<boost::posix_time::to_simple_string( cond::time::to_boost(*itTime) ) << " " <<boost::posix_time::to_simple_string(mIOVsDuration[ *itTime ])<<std::endl;
166  }*/
167 
168  // Print summary per module
169  edm::LogInfo("SiStripDetVOffPrinter") << "[SiStripDetVOffPrinter::" << __func__ << "] " << detidMap.size()
170  << " modules were Off at some point during the time interval";
171  ss.str("");
172 
173  // Loop over detIds
174  std::map<uint32_t, std::vector<cond::Time_t> >::const_iterator itMap = detidMap.begin();
175  for (; itMap != detidMap.end(); ++itMap) {
176  std::vector<cond::Time_t> vecTime = itMap->second;
177 
178  boost::posix_time::time_duration cumul_time_HVOff(0, 0, 0, 0);
179  boost::posix_time::time_duration cumul_time_LVOff(0, 0, 0, 0);
180  // Loop over IOVs
181  std::vector<cond::Time_t>::const_iterator itTime = vecTime.begin();
182  for (; itTime != vecTime.end(); ++itTime) {
183  if (iovMap_HVOff[*itTime].find(itMap->first) != iovMap_HVOff[*itTime].end())
184  cumul_time_HVOff += mIOVsDuration[*itTime];
185  if (iovMap_LVOff[*itTime].find(itMap->first) != iovMap_LVOff[*itTime].end())
186  cumul_time_LVOff += mIOVsDuration[*itTime];
187  }
188  ss << "detId " << itMap->first << " #IOVs: " << vecTime.size() << " HVOff: " << cumul_time_HVOff << " "
189  << cumul_time_HVOff.total_milliseconds() * 100.0 / time_period.total_milliseconds() << "% "
190  << " LVOff: " << cumul_time_LVOff << " "
191  << cumul_time_LVOff.total_milliseconds() * 100.0 / time_period.total_milliseconds() << "%" << std::endl;
192  }
193 
194  condDbSession.transaction().commit();
195 
196  if (!m_output.empty()) {
197  std::ofstream fout;
198  fout.open(m_output);
199  fout << ss.str();
200  fout.close();
201  }
202 }

References cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::createSession(), detidMap, Exception, cond::persistency::Session::fetchPayload(), spr::find(), cond::persistency::IOVArray::find(), groupFilesInBlocks::fout, cond::time::from_boost(), iovMap_HVOff, iovMap_LVOff, m_condDb, m_connectionPool, m_endTime, m_output, m_startTime, m_tagName, jets_cff::payload, cond::persistency::Session::readIov(), cond::persistency::IOVProxy::selectAll(), contentValuesCheck::ss, cond::persistency::Transaction::start(), cond::time::to_boost(), and cond::persistency::Session::transaction().

◆ endJob()

void SiStripDetVOffPrinter::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 223 of file SiStripDetVOffPrinter.cc.

223 {}

Referenced by o2olib.O2ORunMgr::executeJob().

◆ fillDescriptions()

void SiStripDetVOffPrinter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 204 of file SiStripDetVOffPrinter.cc.

204  {
206  desc.add<std::string>("conditionDatabase", "frontier://FrontierProd/CMS_CONDITIONS");
207  desc.add<std::string>("tagName", "SiStripDetVOff_1hourDelay_v1_Validation");
208  desc.add<std::string>("startTime", "2002-01-20 23:59:59.000");
209  desc.add<std::string>("endTime", "2002-01-20 23:59:59.000");
210  desc.add<std::string>("output", "PerModuleSummary.txt");
211  desc.add<std::string>("connect", "");
212 
213  edm::ParameterSetDescription descDBParameters;
214  descDBParameters.addUntracked<std::string>("authenticationPath", "");
215  descDBParameters.addUntracked<int>("authenticationSystem", 0);
216  descDBParameters.addUntracked<std::string>("security", "");
217  descDBParameters.addUntracked<int>("messageLevel", 0);
218 
219  desc.add<edm::ParameterSetDescription>("DBParameters", descDBParameters);
220  descriptions.add("siStripDetVOffPrinter", desc);
221 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ detidMap

std::map<uint32_t, std::vector<cond::Time_t> > SiStripDetVOffPrinter::detidMap
private

Definition at line 49 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ iovMap_HVOff

std::map<cond::Time_t, std::set<uint32_t> > SiStripDetVOffPrinter::iovMap_HVOff
private

Definition at line 46 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ iovMap_LVOff

std::map<cond::Time_t, std::set<uint32_t> > SiStripDetVOffPrinter::iovMap_LVOff
private

Definition at line 47 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_condDb

std::string SiStripDetVOffPrinter::m_condDb
private

Definition at line 36 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_connectionPool

cond::persistency::ConnectionPool SiStripDetVOffPrinter::m_connectionPool
private

Definition at line 35 of file SiStripDetVOffPrinter.cc.

Referenced by analyze(), and SiStripDetVOffPrinter().

◆ m_endTime

std::string SiStripDetVOffPrinter::m_endTime
private

Definition at line 41 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_output

std::string SiStripDetVOffPrinter::m_output
private

Definition at line 43 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_startTime

std::string SiStripDetVOffPrinter::m_startTime
private

Definition at line 40 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_tagName

std::string SiStripDetVOffPrinter::m_tagName
private

Definition at line 37 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

cond::time::to_boost
boost::posix_time::ptime to_boost(Time_t iValue)
Definition: TimeConversions.h:39
SiStripDetVOffPrinter::m_startTime
std::string m_startTime
Definition: SiStripDetVOffPrinter.cc:40
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SiStripDetVOffPrinter::detidMap
std::map< uint32_t, std::vector< cond::Time_t > > detidMap
Definition: SiStripDetVOffPrinter.cc:49
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:174
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:181
SiStripDetVOffPrinter::m_connectionPool
cond::persistency::ConnectionPool m_connectionPool
Definition: SiStripDetVOffPrinter.cc:35
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
cond::persistency::IOVArray::find
Iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:101
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiStripDetVOffPrinter::m_output
std::string m_output
Definition: SiStripDetVOffPrinter.cc:43
jets_cff.payload
payload
Definition: jets_cff.py:32
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ParameterSet
Definition: ParameterSet.h:47
cond::time::from_boost
Time_t from_boost(boost::posix_time::ptime bt)
Definition: TimeConversions.h:43
cond::persistency::Session
Definition: Session.h:63
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
groupFilesInBlocks.fout
fout
Definition: groupFilesInBlocks.py:162
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
SiStripDetVOff
Definition: SiStripDetVOff.h:31
cond::persistency::ConnectionPool::setParameters
void setParameters(const edm::ParameterSet &connectionPset)
Definition: ConnectionPool.cc:43
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:129
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripDetVOffPrinter::iovMap_HVOff
std::map< cond::Time_t, std::set< uint32_t > > iovMap_HVOff
Definition: SiStripDetVOffPrinter.cc:46
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripDetVOffPrinter::m_endTime
std::string m_endTime
Definition: SiStripDetVOffPrinter.cc:41
SiStripDetVOffPrinter::m_condDb
std::string m_condDb
Definition: SiStripDetVOffPrinter.cc:36
SiStripDetVOffPrinter::m_tagName
std::string m_tagName
Definition: SiStripDetVOffPrinter.cc:37
SiStripDetVOffPrinter::iovMap_LVOff
std::map< cond::Time_t, std::set< uint32_t > > iovMap_LVOff
Definition: SiStripDetVOffPrinter.cc:47