File indexing completed on 2024-04-06 12:09:10
0001
0002 #include "DQM/TrackingMonitorClient/interface/TrackingActionExecutor.h"
0003
0004 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0005
0006 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0007
0008 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0009 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
0010 #include "DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h"
0011 #include "DQM/SiStripMonitorClient/interface/SiStripConfigWriter.h"
0012 #include "DQM/TrackingMonitorClient/interface/TrackingQualityChecker.h"
0013
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015
0016 #include <iomanip>
0017
0018
0019
0020 TrackingActionExecutor::TrackingActionExecutor(edm::ParameterSet const& ps) : pSet_(ps) {
0021 edm::LogInfo("TrackingActionExecutor") << " Creating TrackingActionExecutor "
0022 << "\n";
0023 qualityChecker_ = nullptr;
0024 configWriter_ = nullptr;
0025 }
0026
0027
0028
0029 TrackingActionExecutor::~TrackingActionExecutor() {
0030
0031 edm::LogInfo("TrackingActionExecutor") << " Deleting TrackingActionExecutor "
0032 << "\n";
0033 if (qualityChecker_)
0034 delete qualityChecker_;
0035 }
0036
0037
0038
0039
0040 void TrackingActionExecutor::createGlobalStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0041 if (!qualityChecker_)
0042 qualityChecker_ = new TrackingQualityChecker(pSet_);
0043 qualityChecker_->bookGlobalStatus(ibooker, igetter);
0044 }
0045
0046 void TrackingActionExecutor::createLSStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0047 if (!qualityChecker_)
0048 qualityChecker_ = new TrackingQualityChecker(pSet_);
0049 qualityChecker_->bookLSStatus(ibooker, igetter);
0050 }
0051
0052
0053
0054
0055 void TrackingActionExecutor::fillDummyGlobalStatus() { qualityChecker_->fillDummyGlobalStatus(); }
0056
0057 void TrackingActionExecutor::fillDummyLSStatus() { qualityChecker_->fillDummyLSStatus(); }
0058
0059
0060
0061
0062 void TrackingActionExecutor::fillGlobalStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0063 qualityChecker_->fillGlobalStatus(ibooker, igetter);
0064 }
0065
0066
0067
0068 void TrackingActionExecutor::fillStatusAtLumi(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0069 qualityChecker_->fillLSStatus(ibooker, igetter);
0070 }
0071
0072
0073
0074 void TrackingActionExecutor::createDummyShiftReport() {
0075
0076 std::ofstream report_file;
0077 report_file.open("tracking_shift_report.txt", std::ios::out);
0078 report_file << " Nothing to report!!" << std::endl;
0079 report_file.close();
0080 }
0081
0082
0083
0084 void TrackingActionExecutor::createShiftReport(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0085
0086
0087
0088 std::string localPath = std::string("DQM/TrackingMonitorClient/data/tracking_plot_layout.xml");
0089 SiStripLayoutParser layout_parser;
0090 layout_parser.getDocument(edm::FileInPath(localPath).fullPath());
0091
0092 std::map<std::string, std::vector<std::string> > layout_map;
0093 if (!layout_parser.getAllLayouts(layout_map))
0094 return;
0095
0096 std::ostringstream shift_summary;
0097 if (configWriter_)
0098 delete configWriter_;
0099 configWriter_ = new SiStripConfigWriter();
0100 configWriter_->init("ShiftReport");
0101
0102
0103 shift_summary << " Report Summary Content :" << std::endl;
0104 shift_summary << " =========================" << std::endl;
0105 configWriter_->createElement("ReportSummary");
0106
0107 shift_summary << std::endl;
0108 printShiftHistoParameters(ibooker, igetter, layout_map, shift_summary);
0109
0110 std::ofstream report_file;
0111 report_file.open("tracking_shift_report.txt", std::ios::out);
0112 report_file << shift_summary.str() << std::endl;
0113 report_file.close();
0114 configWriter_->write("tracking_shift_report.xml");
0115 delete configWriter_;
0116 configWriter_ = nullptr;
0117 }
0118
0119
0120
0121 void TrackingActionExecutor::printReportSummary(MonitorElement* me, std::ostringstream& str_val, std::string name) {
0122
0123 str_val << " " << name << " : ";
0124 std::string value;
0125 SiStripUtility::getMEValue(me, value);
0126 configWriter_->createChildElement("MonitorElement", name, "value", value);
0127 float fvalue = atof(value.c_str());
0128 if (fvalue == -1.0)
0129 str_val << " Dummy Value " << std::endl;
0130 else
0131 str_val << fvalue << std::endl;
0132 }
0133
0134
0135
0136 void TrackingActionExecutor::printShiftHistoParameters(DQMStore::IBooker& ibooker,
0137 DQMStore::IGetter& igetter,
0138 std::map<std::string, std::vector<std::string> >& layout_map,
0139 std::ostringstream& str_val) {
0140
0141 str_val << std::endl;
0142 for (std::map<std::string, std::vector<std::string> >::iterator it = layout_map.begin(); it != layout_map.end();
0143 it++) {
0144 std::string set_name = it->first;
0145 if (set_name.find("Summary") != std::string::npos)
0146 continue;
0147 configWriter_->createElement(set_name);
0148
0149 str_val << " " << set_name << " : " << std::endl;
0150 str_val << " ====================================" << std::endl;
0151
0152 str_val << std::setprecision(2);
0153 str_val << setiosflags(std::ios::fixed);
0154 for (std::vector<std::string>::iterator im = it->second.begin(); im != it->second.end(); im++) {
0155 std::string path_name = (*im);
0156 if (path_name.empty())
0157 continue;
0158 MonitorElement* me = igetter.get(path_name);
0159 std::ostringstream entry_str, mean_str, rms_str;
0160 entry_str << std::setprecision(2);
0161 entry_str << setiosflags(std::ios::fixed);
0162 mean_str << std::setprecision(2);
0163 mean_str << setiosflags(std::ios::fixed);
0164 rms_str << std::setprecision(2);
0165 rms_str << setiosflags(std::ios::fixed);
0166 entry_str << std::setw(7) << me->getEntries();
0167 mean_str << std::setw(7) << me->getMean();
0168 rms_str << std::setw(7) << me->getRMS();
0169 configWriter_->createChildElement(
0170 "MonitorElement", me->getName(), "entries", entry_str.str(), "mean", mean_str.str(), "rms", rms_str.str());
0171
0172 if (me)
0173 str_val << " " << me->getName() << " : entries = " << std::setw(7) << me->getEntries()
0174 << " mean = " << me->getMean() << " : rms = " << me->getRMS() << std::endl;
0175 }
0176 str_val << std::endl;
0177 }
0178 }