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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, 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::ESRecordsToProductResolverIndices 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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 25 of file SiStripDetVOffPrinter.cc.

Constructor & Destructor Documentation

◆ SiStripDetVOffPrinter()

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

Definition at line 51 of file SiStripDetVOffPrinter.cc.

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

52  : m_connectionPool(),
53  m_condDb(iConfig.getParameter<std::string>("conditionDatabase")),
54  m_tagName(iConfig.getParameter<std::string>("tagName")),
55  m_startTime(iConfig.getParameter<std::string>("startTime")),
56  m_endTime(iConfig.getParameter<std::string>("endTime")),
57  m_output(iConfig.getParameter<std::string>("output")) {
60 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void setParameters(const edm::ParameterSet &connectionPset)
cond::persistency::ConnectionPool m_connectionPool

◆ ~SiStripDetVOffPrinter()

SiStripDetVOffPrinter::~SiStripDetVOffPrinter ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 64 of file SiStripDetVOffPrinter.cc.

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, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_condDb, m_connectionPool, m_endTime, m_output, m_startTime, m_tagName, jetsAK4_Puppi_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().

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

◆ endJob()

void SiStripDetVOffPrinter::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 222 of file SiStripDetVOffPrinter.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

222 {}

◆ fillDescriptions()

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

Definition at line 203 of file SiStripDetVOffPrinter.cc.

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

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

Member Data Documentation

◆ detidMap

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

Definition at line 48 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 45 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 46 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_condDb

std::string SiStripDetVOffPrinter::m_condDb
private

Definition at line 35 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_connectionPool

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

Definition at line 34 of file SiStripDetVOffPrinter.cc.

Referenced by analyze(), and SiStripDetVOffPrinter().

◆ m_endTime

std::string SiStripDetVOffPrinter::m_endTime
private

Definition at line 40 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_output

std::string SiStripDetVOffPrinter::m_output
private

Definition at line 42 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_startTime

std::string SiStripDetVOffPrinter::m_startTime
private

Definition at line 39 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().

◆ m_tagName

std::string SiStripDetVOffPrinter::m_tagName
private

Definition at line 36 of file SiStripDetVOffPrinter.cc.

Referenced by analyze().