51 std::map<uint32_t, std::vector<cond::Time_t> >
detidMap;
72 boost::posix_time::ptime p_start, p_end;
73 p_start = boost::posix_time::time_from_string(
m_startTime);
74 p_end = boost::posix_time::time_from_string(
m_endTime);
77 if (startIov > endIov)
79 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 80 <<
"Set start time " << startIov <<
" (" 81 << boost::posix_time::to_simple_string(p_start) <<
")" 82 <<
"\n ... Set end time " << endIov <<
" (" 83 << boost::posix_time::to_simple_string(p_end) <<
")";
86 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 87 <<
"Query the condition database " <<
m_condDb;
93 std::vector<cond::Time_t> vTime;
96 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 99 auto iiov = iovProxy.
find(startIov);
100 auto eiov = iovProxy.
find(endIov);
102 while (iiov != iovProxy.
end() && (*iiov).since <= (*eiov).since) {
104 if ((*iiov).since < startIov) {
105 vTime.push_back(startIov);
107 vTime.push_back((*iiov).since);
111 ss << boost::posix_time::to_simple_string(
cond::time::to_boost((*iiov).since)) <<
" (" << (*iiov).since <<
")" 112 <<
", # HV Off=" << std::setw(6) <<
payload->getHVoffCounts() <<
", # LV Off=" << std::setw(6)
113 <<
payload->getLVoffCounts() << std::endl;
116 std::vector<uint32_t> detIds;
118 std::set<uint32_t> detIds_HVOff;
119 std::set<uint32_t> detIds_LVOff;
120 std::vector<uint32_t>::const_iterator it = detIds.begin();
121 for (; it != detIds.end(); ++it) {
122 if (
payload->IsModuleHVOff(*it))
123 detIds_HVOff.insert(*it);
124 if (
payload->IsModuleLVOff(*it))
125 detIds_LVOff.insert(*it);
128 std::vector<cond::Time_t> vec;
133 detidMap[*it].push_back(vTime.back());
148 vTime.push_back(endIov);
150 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " 151 <<
"Read " << niov <<
" IOVs from tag " << m_tagName
152 <<
" corresponding to the specified time interval.\n" 156 std::map<cond::Time_t, boost::posix_time::time_duration> mIOVsDuration;
157 std::vector<cond::Time_t>::const_iterator itTime = ++vTime.begin();
158 std::vector<cond::Time_t>::const_iterator itPreviousTime = vTime.begin();
160 for (; itTime != vTime.end(); ++itTime) {
162 itPreviousTime = itTime;
164 boost::posix_time::time_duration time_period =
173 edm::LogInfo(
"SiStripDetVOffPrinter") <<
"[SiStripDetVOffPrinter::" << __func__ <<
"] " <<
detidMap.size()
174 <<
" modules were Off at some point during the time interval";
178 std::map<uint32_t, std::vector<cond::Time_t> >::const_iterator itMap =
detidMap.begin();
179 for (; itMap !=
detidMap.end(); ++itMap) {
180 std::vector<cond::Time_t> vecTime = itMap->second;
182 boost::posix_time::time_duration cumul_time_HVOff(0, 0, 0, 0);
183 boost::posix_time::time_duration cumul_time_LVOff(0, 0, 0, 0);
185 std::vector<cond::Time_t>::const_iterator itTime = vecTime.begin();
186 for (; itTime != vecTime.end(); ++itTime) {
188 cumul_time_HVOff += mIOVsDuration[*itTime];
190 cumul_time_LVOff += mIOVsDuration[*itTime];
192 ss <<
"detId " << itMap->first <<
" #IOVs: " << vecTime.size() <<
" HVOff: " << cumul_time_HVOff <<
" " 193 << cumul_time_HVOff.total_milliseconds() * 100.0 / time_period.total_milliseconds() <<
"% " 194 <<
" LVOff: " << cumul_time_LVOff <<
" " 195 << cumul_time_LVOff.total_milliseconds() * 100.0 / time_period.total_milliseconds() <<
"%" << std::endl;
210 desc.
add<
std::string>(
"conditionDatabase",
"frontier://FrontierProd/CMS_CONDITIONS");
211 desc.
add<
std::string>(
"tagName",
"SiStripDetVOff_1hourDelay_v1_Validation");
219 descDBParameters.addUntracked<
int>(
"authenticationSystem", 0);
220 descDBParameters.addUntracked<
std::string>(
"security",
"");
221 descDBParameters.addUntracked<
int>(
"messageLevel", 0);
224 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)
edm::Service< SiStripDetInfoFileReader > detidReader
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::posix_time::ptime to_boost(Time_t iValue)