CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SiStripSummaryCreator Class Reference

#include <SiStripSummaryCreator.h>

Public Types

typedef dqm::harvesting::DQMStore DQMStore
 
typedef
dqm::harvesting::MonitorElement 
MonitorElement
 

Public Member Functions

void createSummary (DQMStore &dqm_store)
 
void fillLayout (DQMStore &dqm_store)
 
int getFrequency () const
 
bool readConfiguration (std::string const &file_path)
 
void setSummaryMENames (std::map< std::string, std::string > &me_names)
 
 SiStripSummaryCreator ()
 
virtual ~SiStripSummaryCreator ()
 

Private Member Functions

void fillGrandSummaryHistos (DQMStore &dqm_store)
 
void fillHistos (int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
 
void fillSummaryHistos (DQMStore &dqm_store)
 
MonitorElementgetSummaryME (DQMStore &dqm_store, std::string &name, std::string htype)
 

Private Attributes

int summaryFrequency_ {-1}
 
std::map< std::string,
std::string > 
summaryMEs_
 

Detailed Description

Definition at line 12 of file SiStripSummaryCreator.h.

Member Typedef Documentation

Definition at line 15 of file SiStripSummaryCreator.h.

Definition at line 14 of file SiStripSummaryCreator.h.

Constructor & Destructor Documentation

SiStripSummaryCreator::SiStripSummaryCreator ( )

Definition at line 9 of file SiStripSummaryCreator.cc.

9  {
10  edm::LogInfo("SiStripSummaryCreator") << " Creating SiStripSummaryCreator "
11  << "\n";
12 }
Log< level::Info, false > LogInfo
SiStripSummaryCreator::~SiStripSummaryCreator ( )
virtual

Definition at line 14 of file SiStripSummaryCreator.cc.

14  {
15  edm::LogInfo("SiStripSummaryCreator") << " Deleting SiStripSummaryCreator "
16  << "\n";
17 }
Log< level::Info, false > LogInfo

Member Function Documentation

void SiStripSummaryCreator::createSummary ( DQMStore dqm_store)

Definition at line 45 of file SiStripSummaryCreator.cc.

References dqm::implementation::DQMStore::cd(), fillGrandSummaryHistos(), fillSummaryHistos(), dqm::implementation::IGetter::getSubdirs(), dqm::implementation::DQMStore::goUp(), dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, compareTotals::subdirs, and summaryMEs_.

45  {
46  if (summaryMEs_.empty())
47  return;
48  std::string currDir = dqm_store.pwd();
49  std::vector<std::string> subdirs = dqm_store.getSubdirs();
50  int nmod = 0;
51  for (std::vector<std::string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
52  if ((*it).find("module_") == std::string::npos)
53  continue;
54  nmod++;
55  }
56  if (nmod > 0) {
57  fillSummaryHistos(dqm_store);
58  } else {
59  for (std::vector<std::string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
60  dqm_store.cd(*it);
61  createSummary(dqm_store);
62  dqm_store.goUp();
63  }
64  fillGrandSummaryHistos(dqm_store);
65  }
66 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
std::string pwd() override
Definition: DQMStore.h:567
void fillSummaryHistos(DQMStore &dqm_store)
std::map< std::string, std::string > summaryMEs_
void fillGrandSummaryHistos(DQMStore &dqm_store)
void createSummary(DQMStore &dqm_store)
void SiStripSummaryCreator::fillGrandSummaryHistos ( DQMStore dqm_store)
private

Definition at line 117 of file SiStripSummaryCreator.cc.

References dqm::implementation::DQMStore::cd(), relmon_rootfiles_spy::contents, compare_using_db::dir_name, fillHistos(), dqm::implementation::IGetter::getContents(), dqm::impl::MonitorElement::getName(), dqm::impl::MonitorElement::getNbinsX(), dqm::implementation::IGetter::getSubdirs(), getSummaryME(), dqm::implementation::DQMStore::goUp(), isum, hlt_dqm_clientPB-live_cfg::me, mergeVDriftHistosByStation::name, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, compareTotals::subdirs, and summaryMEs_.

Referenced by createSummary().

117  {
118  std::map<std::string, MonitorElement*> MEMap;
119  std::string currDir = dqm_store.pwd();
120  std::string dir_name = currDir.substr(currDir.find_last_of('/') + 1);
121  if ((dir_name.find("SiStrip") == 0) || (dir_name.find("Collector") == 0) || (dir_name.find("MechanicalView") == 0) ||
122  (dir_name.find("FU") == 0))
123  return;
124  std::vector<std::string> subdirs = dqm_store.getSubdirs();
125  if (subdirs.empty())
126  return;
127  ;
128  for (std::map<std::string, std::string>::const_iterator isum = summaryMEs_.begin(); isum != summaryMEs_.end();
129  isum++) {
130  std::string name, summary_name;
131  name = isum->first;
132  if (isum->second == "sum" || isum->second == "sum")
133  summary_name = "Summary_" + isum->first;
134  else
135  summary_name = "Summary_Mean" + isum->first;
136  std::string htype = isum->second;
137  int ibinStep = 0;
138  for (std::vector<std::string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
139  dqm_store.cd(*it);
140  std::vector<MonitorElement*> contents = dqm_store.getContents(dqm_store.pwd());
141  dqm_store.goUp();
142  for (std::vector<MonitorElement*>::const_iterator im = contents.begin(); im != contents.end(); im++) {
143  MonitorElement* me_i = (*im);
144  if (!me_i)
145  continue;
146  std::string name_i = me_i->getName();
147  if (name_i.find((summary_name)) != std::string::npos) {
148  std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name);
150  if (iPos == MEMap.end()) {
151  if (htype == "sum" || htype == "Sum") {
152  me = getSummaryME(dqm_store, name, htype);
153  } else {
154  me = getSummaryME(dqm_store, name, "bin-by-bin");
155  }
156  MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
157  } else
158  me = iPos->second;
159  if (htype == "sum" || htype == "Sum") {
160  fillHistos(0, ibinStep, htype, me_i, me);
161  } else {
162  fillHistos(0, ibinStep, "bin-by-bin", me_i, me);
163  }
164  ibinStep += me_i->getNbinsX();
165  break;
166  }
167  }
168  }
169  }
170 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
const std::string & getName() const
get name of ME
std::string pwd() override
Definition: DQMStore.h:567
double isum
virtual int getNbinsX() const
get # of bins in X-axis
std::map< std::string, std::string > summaryMEs_
void fillHistos(int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
MonitorElement * getSummaryME(DQMStore &dqm_store, std::string &name, std::string htype)
void SiStripSummaryCreator::fillHistos ( int  ival,
int  istep,
std::string  htype,
MonitorElement me_src,
MonitorElement me 
)
private

Definition at line 282 of file SiStripSummaryCreator.cc.

References dqm::impl::MonitorElement::Fill(), dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getEntries(), dqm::impl::MonitorElement::getMean(), dqm::impl::MonitorElement::getName(), dqm::impl::MonitorElement::getNbinsX(), dqm::legacy::MonitorElement::getTH1(), dqm::legacy::MonitorElement::getTH1F(), dqm::legacy::MonitorElement::getTH2F(), isotrackApplyRegressor::k, dqm::impl::MonitorElement::kind(), mergeVDriftHistosByStation::name, hlt_dqm_clientPB-live_cfg::nbins, dqm::impl::MonitorElement::setBinContent(), AlCaHLTBitMon_QueryRunRegistry::string, MonitorElementData::TH1F, MonitorElementData::TH2F, and hgcalPerformanceValidation::val.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

283  {
284  if (me->getTH1()) {
285  TH1F* hist1 = nullptr;
286  TH2F* hist2 = nullptr;
287  if (me->kind() == MonitorElement::Kind::TH1F)
288  hist1 = me->getTH1F();
289  if (me->kind() == MonitorElement::Kind::TH2F)
290  hist2 = me->getTH2F();
291 
292  int nbins = me_src->getNbinsX();
293  const std::string& name = me_src->getName();
294  if (htype == "mean" || htype == "Mean") {
295  if (hist2 && name.find("NoisyStrips") != std::string::npos) {
296  float bad = 0.0;
297  float entries = me_src->getEntries();
298  if (entries > 0.0) {
299  float binEntry = entries / nbins;
300  for (int k = 1; k < nbins + 1; k++) {
301  float noisy = me_src->getBinContent(k, 3) + me_src->getBinContent(k, 5);
302  float dead = me_src->getBinContent(k, 2) + me_src->getBinContent(k, 4);
303  if (noisy >= binEntry * 0.5 || dead >= binEntry * 0.5)
304  bad++;
305  }
306  bad = bad * 100.0 / nbins;
307  me->Fill(ival, bad);
308  }
309  } else
310  me->Fill(ival, me_src->getMean());
311  } else if (htype == "bin-by-bin" || htype == "Bin-by-Bin") {
312  for (int k = 1; k < nbins + 1; k++) {
313  me->setBinContent(istep + k, me_src->getBinContent(k));
314  }
315  } else if (htype == "sum" || htype == "Sum") {
316  if (hist1) {
317  for (int k = 1; k < nbins + 1; k++) {
318  float val = me_src->getBinContent(k) + me->getBinContent(k);
319  me->setBinContent(k, val);
320  }
321  }
322  }
323  }
324 }
virtual TH2F * getTH2F() const
virtual TH1F * getTH1F() const
Kind kind() const
Get the type of the monitor element.
const std::string & getName() const
get name of ME
void Fill(long long x)
virtual int getNbinsX() const
get # of bins in X-axis
virtual double getEntries() const
get # of entries
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual TH1 * getTH1() const
void SiStripSummaryCreator::fillLayout ( DQMStore dqm_store)
void SiStripSummaryCreator::fillSummaryHistos ( DQMStore dqm_store)
private

Definition at line 70 of file SiStripSummaryCreator.cc.

References dqm::implementation::DQMStore::cd(), relmon_rootfiles_spy::contents, fillHistos(), dqm::implementation::IGetter::getContents(), dqm::impl::MonitorElement::getName(), dqm::impl::MonitorElement::getNbinsX(), dqm::implementation::IGetter::getSubdirs(), getSummaryME(), dqm::implementation::DQMStore::goUp(), isum, hlt_dqm_clientPB-live_cfg::me, mergeVDriftHistosByStation::name, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, compareTotals::subdirs, and summaryMEs_.

Referenced by createSummary().

70  {
71  std::string currDir = dqm_store.pwd();
72  std::map<std::string, MonitorElement*> MEMap;
73  std::vector<std::string> subdirs = dqm_store.getSubdirs();
74  if (subdirs.empty())
75  return;
76 
77  for (std::map<std::string, std::string>::const_iterator isum = summaryMEs_.begin(); isum != summaryMEs_.end();
78  isum++) {
79  std::string name = isum->first;
80  int iBinStep = 0;
81  int ndet = 0;
82  std::string htype = isum->second;
83  for (std::vector<std::string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
84  if ((*it).find("module_") == std::string::npos)
85  continue;
86  dqm_store.cd(*it);
87  ndet++;
88  std::vector<MonitorElement*> contents = dqm_store.getContents(dqm_store.pwd());
89  dqm_store.goUp();
90  for (std::vector<MonitorElement*>::const_iterator im = contents.begin(); im != contents.end(); im++) {
91  MonitorElement* me_i = (*im);
92  if (!me_i)
93  continue;
94  std::string name_i = me_i->getName();
95  if (name_i.find(name) == std::string::npos)
96  continue;
97  std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name);
99  // Get the Summary ME
100  if (iPos == MEMap.end()) {
101  me = getSummaryME(dqm_store, name, htype);
102  MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
103  } else
104  me = iPos->second;
105  // Fill it now
106  fillHistos(ndet, iBinStep, htype, me_i, me);
107  iBinStep += me_i->getNbinsX();
108  break;
109  }
110  }
111  }
112 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
const std::string & getName() const
get name of ME
std::string pwd() override
Definition: DQMStore.h:567
double isum
virtual int getNbinsX() const
get # of bins in X-axis
std::map< std::string, std::string > summaryMEs_
void fillHistos(int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
MonitorElement * getSummaryME(DQMStore &dqm_store, std::string &name, std::string htype)
int SiStripSummaryCreator::getFrequency ( ) const
inline

Definition at line 25 of file SiStripSummaryCreator.h.

References summaryFrequency_.

SiStripSummaryCreator::MonitorElement * SiStripSummaryCreator::getSummaryME ( DQMStore dqm_store,
std::string &  name,
std::string  htype 
)
private

Definition at line 172 of file SiStripSummaryCreator.cc.

References newFWLiteAna::bin, dqm::implementation::IBooker::book1D(), dqm::implementation::DQMStore::cd(), relmon_rootfiles_spy::contents, RefreshWebPage::dname, dqm::implementation::IGetter::getContents(), dqm::impl::MonitorElement::getName(), dqm::implementation::IGetter::getSubdirs(), dqm::legacy::MonitorElement::getTH1(), dqm::legacy::MonitorElement::getTH1F(), dqm::implementation::DQMStore::goUp(), gpuVertexFinder::hist, dqm::impl::MonitorElement::kind(), label, hlt_dqm_clientPB-live_cfg::me, mergeVDriftHistosByStation::name, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, compareTotals::subdirs, getPayloadData::tags, MonitorElementData::TH1F, MonitorElementData::TH2F, and MonitorElementData::TPROFILE.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

174  {
175  MonitorElement* me = nullptr;
176  std::string currDir = dqm_store.pwd();
177  std::string sum_name, tag_name;
178 
179  std::string dname = currDir.substr(currDir.find_last_of('/') + 1);
180  if (dname.find('_') != std::string::npos)
181  dname.insert(dname.find('_'), "_");
182  if (htype == "sum" && htype == "Sum") {
183  sum_name = "Summary" + name + "__" + dname;
184  tag_name = "Summary" + name;
185  } else {
186  sum_name = "Summary_Mean" + name + "__" + dname;
187  tag_name = "Summary_Mean" + name;
188  }
189  // If already booked
190  std::vector<MonitorElement*> contents = dqm_store.getContents(currDir);
191  for (std::vector<MonitorElement*>::const_iterator im = contents.begin(); im != contents.end(); im++) {
192  MonitorElement* me = (*im);
193  if (!me)
194  continue;
195  std::string me_name = me->getName();
196  if (me_name.find(sum_name) == 0) {
199  TH1* hist1 = me->getTH1();
200  if (hist1) {
201  hist1->Reset();
202  return me;
203  }
204  }
205  }
206  }
207  std::map<int, std::string> tags;
208  if (!me) {
209  int nBins = 0;
210  std::vector<std::string> subdirs = dqm_store.getSubdirs();
211  // set # of bins of the histogram
212  if (htype == "mean" || htype == "Mean") {
213  nBins = subdirs.size();
214  me = dqm_store.book1D(sum_name, sum_name, nBins, 0.5, nBins + 0.5);
215  int ibin = 0;
216  for (auto const& subdir : subdirs) {
217  std::string subdir_name = subdir.substr(subdir.find_last_of('/') + 1);
218  ++ibin;
219  tags.emplace(ibin, subdir_name);
220  }
221  } else if (htype == "bin-by-bin" || htype == "Bin-by-Bin") {
222  for (auto const& subdir : subdirs) {
223  dqm_store.cd(subdir);
224  std::string subdir_name = subdir.substr(subdir.find_last_of('/') + 1);
225  auto const& s_contents = dqm_store.getContents(dqm_store.pwd());
226  for (auto const* s_me : s_contents) {
227  if (!s_me)
228  continue;
229  std::string s_me_name = s_me->getName();
230  if (s_me_name.find(name) == 0 || s_me_name.find(tag_name) == 0) {
231  int ibin = s_me->getNbinsX();
232  nBins += ibin;
233  tags.emplace(nBins - ibin / 2, subdir_name);
234  break;
235  }
236  }
237  dqm_store.goUp();
238  }
239  me = dqm_store.book1D(sum_name, sum_name, nBins, 0.5, nBins + 0.5);
240  } else if (htype == "sum" || htype == "Sum") {
241  for (auto const& subdir : subdirs) {
242  dqm_store.cd(subdir);
243  auto const& s_contents = dqm_store.getContents(dqm_store.pwd());
244  dqm_store.goUp();
245  for (auto* s_me : s_contents) {
246  if (!s_me)
247  continue;
248  std::string s_me_name = s_me->getName();
249  if (s_me_name.find(name) == std::string::npos)
250  continue;
251  if (s_me->kind() == MonitorElement::Kind::TH1F) {
252  TH1F* hist1 = s_me->getTH1F();
253  if (hist1) {
254  nBins = s_me->getNbinsX();
255  me = dqm_store.book1D(
256  sum_name, sum_name, nBins, hist1->GetXaxis()->GetXmin(), hist1->GetXaxis()->GetXmax());
257  break;
258  }
259  }
260  }
261  }
262  }
263  }
264  // Set the axis title
265  if (me && me->kind() == MonitorElement::Kind::TH1F && (htype != "sum" || htype != "Sum")) {
266  TH1F* hist = me->getTH1F();
267  if (hist) {
268  if (name.find("NoisyStrips") != std::string::npos)
269  hist->GetYaxis()->SetTitle("Noisy Strips (%)");
270  else
271  hist->GetYaxis()->SetTitle(name.c_str());
272 
273  for (auto const& [bin, label] : tags) {
274  hist->GetXaxis()->SetBinLabel(bin, label.c_str());
275  }
276  hist->LabelsOption("uv");
277  }
278  }
279  return me;
280 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
virtual TH1F * getTH1F() const
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
Kind kind() const
Get the type of the monitor element.
const std::string & getName() const
get name of ME
std::string pwd() override
Definition: DQMStore.h:567
char const * label
__shared__ Hist hist
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual TH1 * getTH1() const
bool SiStripSummaryCreator::readConfiguration ( std::string const &  file_path)

Definition at line 19 of file SiStripSummaryCreator.cc.

References gather_cfg::cout, contentValuesFiles::fullPath, SiStripConfigParser::getDocument(), SiStripConfigParser::getFrequencyForSummary(), SiStripConfigParser::getMENamesForSummary(), summaryFrequency_, and summaryMEs_.

19  {
20  summaryMEs_.clear();
21  SiStripConfigParser config_parser;
22  config_parser.getDocument(edm::FileInPath(file_path).fullPath());
23  if (!config_parser.getFrequencyForSummary(summaryFrequency_)) {
24  std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
25  summaryFrequency_ = -1;
26  return false;
27  }
28  if (!config_parser.getMENamesForSummary(summaryMEs_)) {
29  std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
30  return false;
31  }
32  return true;
33 }
bool getFrequencyForSummary(int &u_freq)
void getDocument(std::string filepath)
std::map< std::string, std::string > summaryMEs_
bool getMENamesForSummary(std::map< std::string, std::string > &me_names)
tuple cout
Definition: gather_cfg.py:144
void SiStripSummaryCreator::setSummaryMENames ( std::map< std::string, std::string > &  me_names)

Definition at line 35 of file SiStripSummaryCreator.cc.

References isum, and summaryMEs_.

35  {
36  summaryMEs_.clear();
37  for (std::map<std::string, std::string>::const_iterator isum = me_names.begin(); isum != me_names.end(); isum++) {
38  summaryMEs_.insert(std::pair<std::string, std::string>(isum->first, isum->second));
39  }
40 }
double isum
std::map< std::string, std::string > summaryMEs_

Member Data Documentation

int SiStripSummaryCreator::summaryFrequency_ {-1}
private

Definition at line 35 of file SiStripSummaryCreator.h.

Referenced by getFrequency(), and readConfiguration().

std::map<std::string, std::string> SiStripSummaryCreator::summaryMEs_
private