48 std::map<uint32_t, std::vector<cond::Time_t> >
detidMap;
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")) {
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);
71 if (startIov > endIov)
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) <<
")";
80 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 81 <<
"Query the condition database " <<
m_condDb;
87 std::vector<cond::Time_t> vTime;
90 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 94 auto iiov = iovs.
find(startIov);
95 auto eiov = iovs.find(endIov);
97 while (iiov != iovs.end() && (*iiov).since <= (*eiov).since) {
99 if ((*iiov).since < startIov) {
100 vTime.push_back(startIov);
102 vTime.push_back((*iiov).since);
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;
111 std::vector<uint32_t> 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) {
118 detIds_HVOff.insert(*
it);
120 detIds_LVOff.insert(*
it);
123 std::vector<cond::Time_t> vec;
143 vTime.push_back(endIov);
145 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 146 <<
"Read " << niov <<
" IOVs from tag " <<
m_tagName 147 <<
" corresponding to the specified time interval.\n" 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();
155 for (; itTime != vTime.end(); ++itTime) {
157 itPreviousTime = itTime;
159 boost::posix_time::time_duration time_period =
168 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " <<
detidMap.size()
169 <<
" modules were Off at some point during the time interval";
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;
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);
180 std::vector<cond::Time_t>::const_iterator itTime = vecTime.begin();
181 for (; itTime != vecTime.end(); ++itTime) {
183 cumul_time_HVOff += mIOVsDuration[*itTime];
185 cumul_time_LVOff += mIOVsDuration[*itTime];
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;
205 desc.add<
std::string>(
"conditionDatabase",
"frontier://FrontierProd/CMS_CONDITIONS");
206 desc.add<
std::string>(
"tagName",
"SiStripDetVOff_1hourDelay_v1_Validation");
214 descDBParameters.addUntracked<
int>(
"authenticationSystem", 0);
215 descDBParameters.addUntracked<
std::string>(
"security",
"");
216 descDBParameters.addUntracked<
int>(
"messageLevel", 0);
219 descriptions.
add(
"siStripDetVOffPrinter",
desc);
std::map< cond::Time_t, std::set< uint32_t > > iovMap_LVOff
T getParameter(std::string const &) const
std::map< uint32_t, std::vector< cond::Time_t > > detidMap
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
SiStripDetVOffPrinter(const edm::ParameterSet &iConfig)
void start(bool readOnly=true)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Transaction & transaction()
void setParameters(const edm::ParameterSet &connectionPset)
unsigned long long Time_t
std::map< cond::Time_t, std::set< uint32_t > > iovMap_HVOff
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
cond::persistency::ConnectionPool m_connectionPool
Session createSession(const std::string &connectionString, bool writeCapable=false)
~SiStripDetVOffPrinter() override
#define DEFINE_FWK_MODULE(type)
Iterator find(cond::Time_t time) const
Time_t from_boost(boost::posix_time::ptime bt)
IOVProxy readIov(const std::string &tag)
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::posix_time::ptime to_boost(Time_t iValue)