CMS 3D CMS Logo

SiStripActionExecutor.cc
Go to the documentation of this file.
3 
5 
7 
11 
13 
14 #include <fstream>
15 #include <iomanip>
16 #include <iostream>
17 #include <sstream>
18 
20  edm::LogInfo("SiStripActionExecutor") << " Creating SiStripActionExecutor "
21  << "\n";
22 }
23 
25  edm::LogInfo("SiStripActionExecutor") << " Deleting SiStripActionExecutor "
26  << "\n";
27 }
28 
30  if (!summaryCreator_) {
31  summaryCreator_ = std::make_unique<SiStripSummaryCreator>();
32  }
33  auto const fpath = pSet_.getUntrackedParameter<std::string>(
34  "SummaryConfigPath", "DQM/SiStripMonitorClient/data/sistrip_monitorelement_config.xml");
35  return summaryCreator_->readConfiguration(fpath);
36 }
37 
38 //
39 // -- Read Configuration File
40 //
42  tkMapCreator_ = std::make_unique<SiStripTrackerMapCreator>(eSetup);
43  return tkMapCreator_.get() != nullptr;
44 }
45 //
46 // -- Create and Fill Summary Monitor Elements
47 //
49  if (!summaryCreator_)
50  return;
51 
52  dqm_store.cd();
53  std::string dname = "SiStrip/MechanicalView";
54  if (dqm_store.dirExists(dname)) {
55  dqm_store.cd(dname);
56  summaryCreator_->createSummary(dqm_store);
57  }
58 }
59 //
60 // -- Create and Fill Summary Monitor Elements
61 //
63  if (!summaryCreator_)
64  return;
65 
66  dqm_store.cd();
67  std::string dname = "MechanicalView";
68  if (SiStripUtility::goToDir(dqm_store, dname)) {
69  summaryCreator_->createSummary(dqm_store);
70  }
71  dqm_store.cd();
72 }
73 //
74 // -- create tracker map
75 //
77  DQMStore& dqm_store,
78  std::string& map_type,
79  edm::EventSetup const& eSetup) {
80  if (tkMapCreator_)
81  tkMapCreator_->create(tkmapPset, dqm_store, map_type, eSetup);
82 }
83 //
84 // -- create tracker map for offline
85 //
87  DQMStore& dqm_store,
88  std::string& map_type,
89  edm::EventSetup const& eSetup) {
90  if (tkMapCreator_)
91  tkMapCreator_->createForOffline(tkmapPset, dqm_store, map_type, eSetup);
92 }
93 //
94 // -- create root file with detId info from tracker maps
95 //
96 void SiStripActionExecutor::createTkInfoFile(std::vector<std::string> map_names,
97  TTree* tkinfo_tree,
98  DQMStore& dqm_store) {
99  if (!tkMapCreator_)
100  return;
101 
102  tkMapCreator_->createInfoFile(map_names, tkinfo_tree, dqm_store);
103 }
104 //
105 // -- Create Status Monitor Elements
106 //
108  if (qualityChecker_.get() == nullptr) {
109  qualityChecker_ = std::make_unique<SiStripQualityChecker>(pSet_);
110  }
111  qualityChecker_->bookStatus(dqm_store);
112 }
113 
115 
117  edm::ESHandle<SiStripDetCabling> const& detcabling,
118  edm::EventSetup const& eSetup) {
119  qualityChecker_->fillStatus(dqm_store, detcabling, eSetup);
120 }
121 
122 void SiStripActionExecutor::fillStatusAtLumi(DQMStore& dqm_store) { qualityChecker_->fillStatusAtLumi(dqm_store); }
123 
125  std::ofstream report_file;
126  report_file.open("sistrip_shift_report.txt", std::ios::out);
127  report_file << " Nothing to report!!" << std::endl;
128  report_file.close();
129 }
130 
132  // Read layout configuration
133  std::string const localPath{"DQM/SiStripMonitorClient/data/sistrip_plot_layout.xml"};
134  SiStripLayoutParser layout_parser;
135  layout_parser.getDocument(edm::FileInPath(localPath).fullPath());
136 
137  std::map<std::string, std::vector<std::string>> layout_map;
138  if (!layout_parser.getAllLayouts(layout_map))
139  return;
140 
141  std::ostringstream shift_summary;
142  configWriter_ = std::make_unique<SiStripConfigWriter>();
143  configWriter_->init("ShiftReport");
144 
145  // Print Report Summary Content
146  shift_summary << " Report Summary Content :\n"
147  << " =========================" << std::endl;
148  configWriter_->createElement("ReportSummary");
149 
150  MonitorElement* me{nullptr};
151  std::string report_path;
152  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TECB";
153  me = dqm_store.get(report_path);
154  printReportSummary(me, shift_summary, "TECB");
155 
156  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TECF";
157  me = dqm_store.get(report_path);
158  printReportSummary(me, shift_summary, "TECF");
159 
160  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TIB";
161  me = dqm_store.get(report_path);
162  printReportSummary(me, shift_summary, "TIB");
163 
164  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TIDB";
165  me = dqm_store.get(report_path);
166  printReportSummary(me, shift_summary, "TIDB");
167 
168  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TIDF";
169  me = dqm_store.get(report_path);
170  printReportSummary(me, shift_summary, "TIDF");
171 
172  report_path = "SiStrip/EventInfo/reportSummaryContents/SiStrip_DetFraction_TOB";
173  me = dqm_store.get(report_path);
174  printReportSummary(me, shift_summary, "TOB");
175 
176  shift_summary << std::endl;
177  printShiftHistoParameters(dqm_store, layout_map, shift_summary);
178 
179  std::ofstream report_file;
180  report_file.open("sistrip_shift_report.txt", std::ios::out);
181  report_file << shift_summary.str() << std::endl;
182  report_file.close();
183  configWriter_->write("sistrip_shift_report.xml");
184  configWriter_.reset();
185 }
186 
188  str_val << " " << name << " : ";
191  configWriter_->createChildElement("MonitorElement", name, "value", value);
192  float fvalue = atof(value.c_str());
193  if (fvalue == -1.0)
194  str_val << " Dummy Value " << std::endl;
195  else
196  str_val << fvalue << std::endl;
197 }
198 
200  std::map<std::string, std::vector<std::string>> const& layout_map,
201  std::ostringstream& str_val) {
202  str_val << std::endl;
203  for (auto const& [set_name, path_names] : layout_map) {
204  if (set_name.find("Summary") != std::string::npos)
205  continue;
206  configWriter_->createElement(set_name);
207 
208  str_val << " " << set_name << " : " << std::endl;
209  str_val << " ====================================" << std::endl;
210 
211  str_val << std::setprecision(2);
212  str_val << setiosflags(std::ios::fixed);
213  for (auto const& path_name : path_names) {
214  if (path_name.empty())
215  continue;
216  MonitorElement* me = dqm_store.get(path_name);
217  std::ostringstream entry_str, mean_str, rms_str;
218  entry_str << std::setprecision(2);
219  entry_str << setiosflags(std::ios::fixed);
220  mean_str << std::setprecision(2);
221  mean_str << setiosflags(std::ios::fixed);
222  rms_str << std::setprecision(2);
223  rms_str << setiosflags(std::ios::fixed);
224  entry_str << std::setw(7) << me->getEntries();
225  mean_str << std::setw(7) << me->getMean();
226  rms_str << std::setw(7) << me->getRMS();
227  configWriter_->createChildElement(
228  "MonitorElement", me->getName(), "entries", entry_str.str(), "mean", mean_str.str(), "rms", rms_str.str());
229 
230  if (me)
231  str_val << " " << me->getName() << " : entries = " << std::setw(7) << me->getEntries()
232  << " mean = " << me->getMean() << " : rms = " << me->getRMS() << '\n';
233  }
234  str_val << std::endl;
235  }
236 }
237 
238 //
239 // -- Print List of Modules with QTest warning or Error
240 //
241 void SiStripActionExecutor::printFaultyModuleList(DQMStore& dqm_store, std::ostringstream& str_val) {
242  dqm_store.cd();
243 
244  std::string mdir = "MechanicalView";
245  if (!SiStripUtility::goToDir(dqm_store, mdir))
246  return;
247  std::string mechanicalview_dir = dqm_store.pwd();
248 
249  std::vector<std::string> subdet_folder;
250  subdet_folder.push_back("TIB");
251  subdet_folder.push_back("TOB");
252  subdet_folder.push_back("TEC/MINUS");
253  subdet_folder.push_back("TEC/PLUS");
254  subdet_folder.push_back("TID/MINUS");
255  subdet_folder.push_back("TID/PLUS");
256 
257  int nDetsTotal = 0;
258  int nDetsWithErrorTotal = 0;
259  for (auto const& sd : subdet_folder) {
260  std::string dname = mechanicalview_dir + "/" + sd;
261  if (!dqm_store.dirExists(dname))
262  continue;
263  str_val << "============\n" << sd << '\n' << "============\n" << std::endl;
264 
265  dqm_store.cd(dname);
266  std::vector<std::string> module_folders;
267  SiStripUtility::getModuleFolderList(dqm_store, module_folders);
268  int nDets = module_folders.size();
269  dqm_store.cd();
270 
271  int nDetsWithError = 0;
272  std::string bad_module_folder = dname + "/" + "BadModuleList";
273  if (dqm_store.dirExists(bad_module_folder)) {
274  auto const meVec = dqm_store.getContents(bad_module_folder);
275  for (auto me : meVec) {
276  nDetsWithError++;
277  uint16_t flag = me->getIntValue();
278  std::string message;
280  str_val << me->getName() << " flag : " << me->getIntValue() << " " << message << std::endl;
281  }
282  }
283  str_val << "---------------------------------------------------------------"
284  "-----\n"
285  << " Detectors : Total " << nDets << " with Error " << nDetsWithError << '\n'
286  << "---------------------------------------------------------------"
287  "-----\n";
288  nDetsTotal += nDets;
289  nDetsWithErrorTotal += nDetsWithError;
290  }
291  dqm_store.cd();
292  str_val << "--------------------------------------------------------------------\n"
293  << " Total Number of Connected Detectors : " << nDetsTotal << '\n'
294  << " Total Number of Detectors with Error : " << nDetsWithErrorTotal << '\n'
295  << "--------------------------------------------------------------------" << std::endl;
296 }
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
SiStripActionExecutor.h
dqm::implementation::IGetter::getContents
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
MessageLogger.h
SiStripFolderOrganizer.h
SiStripUtility::getModuleFolderList
static void getModuleFolderList(DQMStore &dqm_store, std::vector< std::string > &m_ids)
Definition: SiStripUtility.cc:187
SiStripActionExecutor::fillStatusAtLumi
void fillStatusAtLumi(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:122
SiStripActionExecutor::summaryCreator_
std::unique_ptr< SiStripSummaryCreator > summaryCreator_
Definition: SiStripActionExecutor.h:67
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
SiStripActionExecutor::SiStripActionExecutor
SiStripActionExecutor(edm::ParameterSet const &ps)
Definition: SiStripActionExecutor.cc:19
SiStripActionExecutor::createTkInfoFile
void createTkInfoFile(std::vector< std::string > tkhmap_names, TTree *tkinfo_tree, DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:96
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor::createSummaryOffline
void createSummaryOffline(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:62
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripActionExecutor::printFaultyModuleList
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
Definition: SiStripActionExecutor.cc:241
SiStripActionExecutor::printReportSummary
void printReportSummary(MonitorElement *me, std::ostringstream &str_val, std::string name)
Definition: SiStripActionExecutor.cc:187
SiStripActionExecutor::fillStatus
void fillStatus(DQMStore &dqm_store, edm::ESHandle< SiStripDetCabling > const &fedcabling, edm::EventSetup const &eSetup)
Definition: SiStripActionExecutor.cc:116
postprocess-scan-build.report_file
report_file
Definition: postprocess-scan-build.py:19
SiStripUtility.h
edm::FileInPath
Definition: FileInPath.h:64
SiStripDetCabling.h
SiStripActionExecutor::~SiStripActionExecutor
virtual ~SiStripActionExecutor()
Definition: SiStripActionExecutor.cc:24
dqm::legacy::DQMStore
Definition: DQMStore.h:727
SiStripLayoutParser
Definition: SiStripLayoutParser.h:16
SiStripUtility::getBadModuleStatus
static void getBadModuleStatus(uint16_t flag, std::string &message)
Definition: SiStripUtility.cc:343
edm::ESHandle< SiStripDetCabling >
SiStripUtility::getMEValue
static void getMEValue(MonitorElement const *me, std::string &val)
Definition: SiStripUtility.cc:239
SiStripActionExecutor::createShiftReport
void createShiftReport(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:131
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripLayoutParser.h
dqm::implementation::DQMStore::pwd
std::string pwd() override
Definition: DQMStore.h:567
SiStripActionExecutor::configWriter_
std::unique_ptr< SiStripConfigWriter > configWriter_
Definition: SiStripActionExecutor.h:70
SiStripActionExecutor::createOfflineTkMap
void createOfflineTkMap(const edm::ParameterSet &tkmapPset, DQMStore &dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
Definition: SiStripActionExecutor.cc:86
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripActionExecutor::printShiftHistoParameters
void printShiftHistoParameters(DQMStore &dqm_store, std::map< std::string, std::vector< std::string >> const &layout_map, std::ostringstream &str_val)
Definition: SiStripActionExecutor.cc:199
SiStripActionExecutor::createStatus
void createStatus(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:107
SiStripUtility::goToDir
static bool goToDir(DQMStore &dqm_store, std::string const &name)
Definition: SiStripUtility.cc:252
SiStripLayoutParser::getAllLayouts
bool getAllLayouts(std::map< std::string, std::vector< std::string > > &me_names)
Definition: SiStripLayoutParser.cc:20
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:57
SiStripActionExecutor::readTkMapConfiguration
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
Definition: SiStripActionExecutor.cc:41
SiStripActionExecutor::createTkMap
void createTkMap(const edm::ParameterSet &tkmapPset, DQMStore &dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
Definition: SiStripActionExecutor.cc:76
SiStripActionExecutor::tkMapCreator_
std::unique_ptr< SiStripTrackerMapCreator > tkMapCreator_
Definition: SiStripActionExecutor.h:68
SiStripActionExecutor::createDummyShiftReport
void createDummyShiftReport()
Definition: SiStripActionExecutor.cc:124
SiStripActionExecutor::pSet_
const edm::ParameterSet pSet_
Definition: SiStripActionExecutor.h:72
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiStripActionExecutor::fillDummyStatus
void fillDummyStatus()
Definition: SiStripActionExecutor.cc:114
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
SiStripActionExecutor::readConfiguration
bool readConfiguration()
Definition: SiStripActionExecutor.cc:29
RefreshWebPage.dname
dname
Definition: RefreshWebPage.py:56
sd
double sd
Definition: CascadeWrapper.h:113
SiStripActionExecutor::createSummary
void createSummary(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:48
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
genParticles_cff.map
map
Definition: genParticles_cff.py:11
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
StripSubdetector.h
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:708
dqm::implementation::DQMStore::cd
void cd() override
Definition: DQMStore.h:564
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
SiStripLayoutParser::getDocument
void getDocument(std::string filepath)
Definition: SiStripLayoutParser.cc:13
SiStripActionExecutor::qualityChecker_
std::unique_ptr< SiStripQualityChecker > qualityChecker_
Definition: SiStripActionExecutor.h:69