CMS 3D CMS Logo

TrackingActionExecutor.cc
Go to the documentation of this file.
1 
3 
5 
7 
13 
15 
16 
17 #include <iomanip>
18 //
19 // -- Constructor
20 //
22  edm::LogInfo("TrackingActionExecutor") << " Creating TrackingActionExecutor " << "\n" ;
23  qualityChecker_ = nullptr;
24  configWriter_ = nullptr;
25 }
26 //
27 // -- Destructor
28 //
30  // std::cout << "[TrackingActionExecutor::~TrackingActionExecutor] .. starting" << std::endl;
31  edm::LogInfo("TrackingActionExecutor") << " Deleting TrackingActionExecutor " << "\n" ;
32  if (qualityChecker_) delete qualityChecker_;
33 }
34 
35 //
36 // -- Create Status Monitor Elements
37 //
40  qualityChecker_->bookGlobalStatus(ibooker,igetter);
41 }
42 
45  qualityChecker_->bookLSStatus(ibooker,igetter);
46 }
47 
48 //
49 // -- Fill Dummy Status
50 //
53 }
54 
57 }
58 
59 //
60 // -- Fill Status
61 //
63  qualityChecker_->fillGlobalStatus(ibooker,igetter);
64 }
65 //
66 // -- Fill Lumi Status
67 //
69  qualityChecker_->fillLSStatus(ibooker,igetter);
70 }
71 //
72 // --
73 //
75  // std::cout << "[TrackingActionExecutor::createDummyShiftReport]" << std::endl;
76  std::ofstream report_file;
77  report_file.open("tracking_shift_report.txt", std::ios::out);
78  report_file << " Nothing to report!!" << std::endl;
79  report_file.close();
80 }
81 //
82 // -- Create Shift Report
83 //
85 
86  // std::cout << "[TrackingActionExecutor::createShiftReport]" << std::endl;
87 
88  // Read layout configuration
89  std::string localPath = std::string("DQM/TrackingMonitorClient/data/tracking_plot_layout.xml");
90  SiStripLayoutParser layout_parser;
91  layout_parser.getDocument(edm::FileInPath(localPath).fullPath());
92 
93  std::map<std::string, std::vector<std::string> > layout_map;
94  if (!layout_parser.getAllLayouts(layout_map)) return;
95 
96 
97  std::ostringstream shift_summary;
98  if (configWriter_) delete configWriter_;
100  configWriter_->init("ShiftReport");
101 
102 
103  // Print Report Summary Content
104  shift_summary << " Report Summary Content :" << std::endl;
105  shift_summary << " =========================" << std::endl;
106  configWriter_->createElement("ReportSummary");
107 
108  shift_summary << std::endl;
109  printShiftHistoParameters(ibooker,igetter, layout_map, shift_summary);
110 
111  std::ofstream report_file;
112  report_file.open("tracking_shift_report.txt", std::ios::out);
113  report_file << shift_summary.str() << std::endl;
114  report_file.close();
115  configWriter_->write("tracking_shift_report.xml");
116  delete configWriter_;
117  configWriter_ = nullptr;
118 }
119 //
120 // -- Print Report Summary
121 //
123  std::ostringstream& str_val, std::string name) {
124 
125  // std::cout << "[TrackingActionExecutor::printReportSummary]" << std::endl;
126  str_val <<" " << name << " : ";
128  SiStripUtility::getMEValue(me, value);
129  configWriter_->createChildElement("MonitorElement", name, "value", value);
130  float fvalue = atof(value.c_str());
131  if (fvalue == -1.0) str_val <<" Dummy Value "<<std::endl;
132  else str_val << fvalue << std::endl;
133 }
134 //
135 // -- Print Shift Histogram Properties
136 //
137 void TrackingActionExecutor::printShiftHistoParameters(DQMStore::IBooker & ibooker, DQMStore::IGetter & igetter, std::map<std::string, std::vector<std::string> >& layout_map, std::ostringstream& str_val) {
138 
139  // std::cout << "[TrackingActionExecutor::printShiftHistoParameters]" << std::endl;
140  str_val << std::endl;
141  for (std::map<std::string, std::vector< std::string > >::iterator it = layout_map.begin() ; it != layout_map.end(); it++) {
142  std::string set_name = it->first;
143  if (set_name.find("Summary") != std::string::npos) continue;
144  configWriter_->createElement(set_name);
145 
146  str_val << " " << set_name << " : " << std::endl;
147  str_val << " ===================================="<< std::endl;
148 
149  str_val << std::setprecision(2);
150  str_val << setiosflags(std::ios::fixed);
151  for (std::vector<std::string>::iterator im = it->second.begin();
152  im != it->second.end(); im++) {
153  std::string path_name = (*im);
154  if (path_name.empty()) continue;
155  MonitorElement* me = igetter.get(path_name);
156  std::ostringstream entry_str, mean_str, rms_str;
157  entry_str << std::setprecision(2);
158  entry_str << setiosflags(std::ios::fixed);
159  mean_str << std::setprecision(2);
160  mean_str << setiosflags(std::ios::fixed);
161  rms_str << std::setprecision(2);
162  rms_str << setiosflags(std::ios::fixed);
163  entry_str << std::setw(7) << me->getEntries();
164  mean_str << std::setw(7) << me->getMean();
165  rms_str << std::setw(7) << me->getRMS();
166  configWriter_->createChildElement("MonitorElement", me->getName(),
167  "entries",entry_str.str(),"mean",mean_str.str(),"rms",rms_str.str());
168 
169  if (me) str_val << " "<< me->getName() <<" : entries = "<< std::setw(7)
170  << me->getEntries() << " mean = "<< me->getMean()
171  <<" : rms = "<< me->getRMS()<< std::endl;
172  }
173  str_val << std::endl;
174  }
175 }
void createChildElement(std::string tag, std::string name)
void fillGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
static void getMEValue(MonitorElement *me, std::string &val)
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
void fillStatusAtLumi(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
void createLSStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
const std::string & getName() const
get name of ME
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
TrackingQualityChecker * qualityChecker_
void createShiftReport(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void createElement(std::string tag)
TrackingActionExecutor(edm::ParameterSet const &ps)
bool init(std::string main)
Write XML file.
void fillGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void printShiftHistoParameters(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::map< std::string, std::vector< std::string > > &layout_map, std::ostringstream &str_val)
void fillLSStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
double getEntries() const
get # of entries
void bookLSStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void bookGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
SiStripConfigWriter * configWriter_
void write(std::string fname)
void createGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void printReportSummary(MonitorElement *me, std::ostringstream &str_val, std::string name)
bool getAllLayouts(std::map< std::string, std::vector< std::string > > &me_names)