CMS 3D CMS Logo

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

◆ DQMStore

Definition at line 15 of file SiStripSummaryCreator.h.

◆ MonitorElement

Definition at line 14 of file SiStripSummaryCreator.h.

Constructor & Destructor Documentation

◆ SiStripSummaryCreator()

SiStripSummaryCreator::SiStripSummaryCreator ( )

Definition at line 9 of file SiStripSummaryCreator.cc.

9  {
10  edm::LogInfo("SiStripSummaryCreator") << " Creating SiStripSummaryCreator "
11  << "\n";
12 }

◆ ~SiStripSummaryCreator()

SiStripSummaryCreator::~SiStripSummaryCreator ( )
virtual

Definition at line 14 of file SiStripSummaryCreator.cc.

14  {
15  edm::LogInfo("SiStripSummaryCreator") << " Deleting SiStripSummaryCreator "
16  << "\n";
17 }

Member Function Documentation

◆ createSummary()

void SiStripSummaryCreator::createSummary ( DQMStore dqm_store)

Definition at line 45 of file SiStripSummaryCreator.cc.

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 }

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

◆ fillGrandSummaryHistos()

void SiStripSummaryCreator::fillGrandSummaryHistos ( DQMStore dqm_store)
private

Definition at line 117 of file SiStripSummaryCreator.cc.

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 }

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, Skims_PA_cff::name, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryMEs_.

Referenced by createSummary().

◆ fillHistos()

void SiStripSummaryCreator::fillHistos ( int  ival,
int  istep,
std::string  htype,
MonitorElement me_src,
MonitorElement me 
)
private

Definition at line 282 of file SiStripSummaryCreator.cc.

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 }

References dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getEntries(), dqm::impl::MonitorElement::getMean(), dqm::impl::MonitorElement::getName(), dqm::impl::MonitorElement::getNbinsX(), dqmdumpme::k, hlt_dqm_clientPB-live_cfg::me, Skims_PA_cff::name, LaserClient_cfi::nbins, AlCaHLTBitMon_QueryRunRegistry::string, MonitorElementData::TH1F, MonitorElementData::TH2F, and heppy_batch::val.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

◆ fillLayout()

void SiStripSummaryCreator::fillLayout ( DQMStore dqm_store)

◆ fillSummaryHistos()

void SiStripSummaryCreator::fillSummaryHistos ( DQMStore dqm_store)
private

Definition at line 70 of file SiStripSummaryCreator.cc.

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 }

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, Skims_PA_cff::name, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryMEs_.

Referenced by createSummary().

◆ getFrequency()

int SiStripSummaryCreator::getFrequency ( ) const
inline

Definition at line 25 of file SiStripSummaryCreator.h.

25 { return summaryFrequency_; }

References summaryFrequency_.

◆ getSummaryME()

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

Definition at line 172 of file SiStripSummaryCreator.cc.

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) {
197  if (me->kind() == MonitorElement::Kind::TH1F || me->kind() == MonitorElement::Kind::TH2F ||
198  me->kind() == MonitorElement::Kind::TPROFILE) {
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 }

References newFWLiteAna::bin, dqm::implementation::IBooker::book1D(), dqm::implementation::DQMStore::cd(), relmon_rootfiles_spy::contents, RefreshWebPage::dname, dqm::implementation::IGetter::getContents(), dqm::implementation::IGetter::getSubdirs(), dqm::implementation::DQMStore::goUp(), compare::hist, label, hlt_dqm_clientPB-live_cfg::me, Skims_PA_cff::name, seedmultiplicitymonitor_newtracking_cfi::nBins, dqm::implementation::DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, triggerMatcherToHLTDebug_cfi::tags, MonitorElementData::TH1F, MonitorElementData::TH2F, and MonitorElementData::TPROFILE.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

◆ readConfiguration()

bool SiStripSummaryCreator::readConfiguration ( std::string const &  file_path)

Definition at line 19 of file SiStripSummaryCreator.cc.

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 }

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

◆ setSummaryMENames()

void SiStripSummaryCreator::setSummaryMENames ( std::map< std::string, std::string > &  me_names)

Definition at line 35 of file SiStripSummaryCreator.cc.

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 }

References isum, and summaryMEs_.

Member Data Documentation

◆ summaryFrequency_

int SiStripSummaryCreator::summaryFrequency_ {-1}
private

Definition at line 35 of file SiStripSummaryCreator.h.

Referenced by getFrequency(), and readConfiguration().

◆ summaryMEs_

std::map<std::string, std::string> SiStripSummaryCreator::summaryMEs_
private
SiStripSummaryCreator::fillSummaryHistos
void fillSummaryHistos(DQMStore &dqm_store)
Definition: SiStripSummaryCreator.cc:70
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
MonitorElementData::Kind::TH1F
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
SiStripSummaryCreator::summaryMEs_
std::map< std::string, std::string > summaryMEs_
Definition: SiStripSummaryCreator.h:34
MonitorElementData::Kind::TH2F
relmon_rootfiles_spy.contents
contents
Definition: relmon_rootfiles_spy.py:129
edm::FileInPath
Definition: FileInPath.h:64
compare.hist
hist
Definition: compare.py:376
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqm::impl::MonitorElement::getEntries
virtual double getEntries() const
get # of entries
Definition: MonitorElement.cc:628
SiStripConfigParser::getFrequencyForSummary
bool getFrequencyForSummary(int &u_freq)
Definition: SiStripConfigParser.cc:46
compare_using_db.dir_name
dir_name
Definition: compare_using_db.py:32
SiStripSummaryCreator::getSummaryME
MonitorElement * getSummaryME(DQMStore &dqm_store, std::string &name, std::string htype)
Definition: SiStripSummaryCreator.cc:172
SiStripConfigParser
Definition: SiStripConfigParser.h:19
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
SiStripSummaryCreator::summaryFrequency_
int summaryFrequency_
Definition: SiStripSummaryCreator.h:35
SiStripConfigParser::getDocument
void getDocument(std::string filepath)
Definition: SiStripConfigParser.cc:13
SiStripConfigParser::getMENamesForSummary
bool getMENamesForSummary(std::map< std::string, std::string > &me_names)
Definition: SiStripConfigParser.cc:27
heppy_batch.val
val
Definition: heppy_batch.py:351
isum
double isum
Definition: MuScleFitUtils.cc:77
SiStripSummaryCreator::fillHistos
void fillHistos(int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
Definition: SiStripSummaryCreator.cc:282
SiStripSummaryCreator::createSummary
void createSummary(DQMStore &dqm_store)
Definition: SiStripSummaryCreator.cc:45
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
SiStripSummaryCreator::fillGrandSummaryHistos
void fillGrandSummaryHistos(DQMStore &dqm_store)
Definition: SiStripSummaryCreator.cc:117
dqm::impl::MonitorElement::getName
const std::string & getName() const
get name of ME
Definition: MonitorElement.h:250
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::impl::MonitorElement::getMean
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:549
RefreshWebPage.dname
dname
Definition: RefreshWebPage.py:56
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
MonitorElementData::Kind::TPROFILE
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
label
const char * label
Definition: PFTauDecayModeTools.cc:11