49 std::map<uint32_t, std::vector<cond::Time_t> >
detidMap;
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);
72 if (startIov > endIov)
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) <<
")";
81 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 82 <<
"Query the condition database " <<
m_condDb;
88 std::vector<cond::Time_t> vTime;
91 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 94 auto iiov = iovProxy.
find(startIov);
95 auto eiov = iovProxy.
find(endIov);
97 while (iiov != iovProxy.
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) {
117 if (
payload->IsModuleHVOff(*it))
118 detIds_HVOff.insert(*it);
119 if (
payload->IsModuleLVOff(*it))
120 detIds_LVOff.insert(*it);
123 std::vector<cond::Time_t> vec;
128 detidMap[*it].push_back(vTime.back());
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)
IOVProxy readIov(const std::string &tag, bool full=false)
#define DEFINE_FWK_MODULE(type)
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
Iterator find(cond::Time_t time)
Session createSession(const std::string &connectionString, bool writeCapable=false)
~SiStripDetVOffPrinter() override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Time_t from_boost(boost::posix_time::ptime bt)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::posix_time::ptime to_boost(Time_t iValue)