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