CMS 3D CMS Logo

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

#include <SiStripSummaryCreator.h>

Public Member Functions

void createSummary (DQMStore *dqm_store)
 
void fillLayout (DQMStore *dqm_store)
 
int getFrequency ()
 
bool readConfiguration (std::string &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_
 
std::map< std::string,
std::string > 
summaryMEMap
 

Detailed Description

Definition at line 14 of file SiStripSummaryCreator.h.

Constructor & Destructor Documentation

SiStripSummaryCreator::SiStripSummaryCreator ( )

Definition at line 11 of file SiStripSummaryCreator.cc.

References summaryFrequency_, and summaryMEMap.

11  {
12  edm::LogInfo("SiStripSummaryCreator") <<
13  " Creating SiStripSummaryCreator " << "\n" ;
14  summaryMEMap.clear();
15  summaryFrequency_ = -1;
16 }
std::map< std::string, std::string > summaryMEMap
SiStripSummaryCreator::~SiStripSummaryCreator ( )
virtual

Definition at line 20 of file SiStripSummaryCreator.cc.

References summaryMEMap.

20  {
21  edm::LogInfo("SiStripSummaryCreator") <<
22  " Deleting SiStripSummaryCreator " << "\n" ;
23  summaryMEMap.clear();
24 }
std::map< std::string, std::string > summaryMEMap

Member Function Documentation

void SiStripSummaryCreator::createSummary ( DQMStore dqm_store)

Definition at line 57 of file SiStripSummaryCreator.cc.

References DQMStore::cd(), fillGrandSummaryHistos(), fillSummaryHistos(), DQMStore::getSubdirs(), DQMStore::goUp(), DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryMEMap.

Referenced by SiStripActionExecutor::createSummary(), and SiStripActionExecutor::createSummaryOffline().

57  {
58  if (summaryMEMap.size() == 0) return;
59  std::string currDir = dqm_store->pwd();
60  std::vector<std::string> subdirs = dqm_store->getSubdirs();
61  int nmod = 0;
62  for (std::vector<std::string>::const_iterator it = subdirs.begin();
63  it != subdirs.end(); it++) {
64  if ( (*it).find("module_") == std::string::npos) continue;
65  nmod++;
66  }
67  if (nmod > 0) {
68  fillSummaryHistos(dqm_store);
69  } else {
70  for (std::vector<std::string>::const_iterator it = subdirs.begin();
71  it != subdirs.end(); it++) {
72  dqm_store->cd(*it);
73  createSummary(dqm_store);
74  dqm_store->goUp();
75  }
76  fillGrandSummaryHistos(dqm_store);
77  }
78 }
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1699
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:684
void createSummary(DQMStore *dqm_store)
std::map< std::string, std::string > summaryMEMap
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:718
void fillSummaryHistos(DQMStore *dqm_store)
void fillGrandSummaryHistos(DQMStore *dqm_store)
const std::string & pwd(void) const
Definition: DQMStore.cc:679
void SiStripSummaryCreator::fillGrandSummaryHistos ( DQMStore dqm_store)
private

Definition at line 126 of file SiStripSummaryCreator.cc.

References DQMStore::cd(), relmon_rootfiles_spy::contents, compare_using_db::dir_name, fillHistos(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getNbinsX(), DQMStore::getSubdirs(), getSummaryME(), DQMStore::goUp(), isum, mergeVDriftHistosByStation::name, DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryMEMap.

Referenced by createSummary().

126  {
127  std::map<std::string, MonitorElement*> MEMap;
128  std::string currDir = dqm_store->pwd();
129  std::string dir_name = currDir.substr(currDir.find_last_of("/")+1);
130  if ((dir_name.find("SiStrip") == 0) ||
131  (dir_name.find("Collector") == 0) ||
132  (dir_name.find("MechanicalView") == 0) ||
133  (dir_name.find("FU") == 0) ) return;
134  std::vector<std::string> subdirs = dqm_store->getSubdirs();
135  if (subdirs.size() == 0) return;;
136  for (std::map<std::string,std::string>::const_iterator isum = summaryMEMap.begin();
137  isum != summaryMEMap.end(); isum++) {
138  std::string name, summary_name;
139  name = isum->first;
140  if (isum->second == "sum" || isum->second == "sum")
141  summary_name = "Summary_" + isum->first;
142  else
143  summary_name = "Summary_Mean" + isum->first;
144  std::string htype = isum->second;
145  int ibinStep =0;
146  for (std::vector<std::string>::const_iterator it = subdirs.begin();
147  it != subdirs.end(); it++) {
148  dqm_store->cd(*it);
149  std::vector<MonitorElement*> contents = dqm_store->getContents(dqm_store->pwd());
150  dqm_store->goUp();
151  for (std::vector<MonitorElement *>::const_iterator im = contents.begin();
152  im != contents.end(); im++) {
153  MonitorElement * me_i = (*im);
154  if (!me_i) continue;
155  std::string name_i = me_i->getName();
156  if (name_i.find((summary_name)) != std::string::npos) {
157 
158  std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name);
159  MonitorElement* me;
160  if (iPos == MEMap.end()) {
161  if (htype == "sum" || htype == "Sum") {
162  me = getSummaryME(dqm_store, name, htype);
163  } else {
164  me = getSummaryME(dqm_store, name, "bin-by-bin");
165  }
166  MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
167  } else me = iPos->second;
168  if (htype == "sum" || htype == "Sum") {
169  fillHistos(0, ibinStep, htype, me_i, me);
170  } else {
171  fillHistos(0, ibinStep,"bin-by-bin", me_i, me);
172  }
173  ibinStep += me_i->getNbinsX();
174  break;
175  }
176  }
177  }
178  }
179 }
const std::string & getName(void) const
get name of ME
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1699
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:684
double isum
std::map< std::string, std::string > summaryMEMap
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1777
MonitorElement * getSummaryME(DQMStore *dqm_store, std::string &name, std::string htype)
void fillHistos(int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
int getNbinsX(void) const
get # of bins in X-axis
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:718
const std::string & pwd(void) const
Definition: DQMStore.cc:679
void SiStripSummaryCreator::fillHistos ( int  ival,
int  istep,
std::string  htype,
MonitorElement me_src,
MonitorElement me 
)
private

Definition at line 298 of file SiStripSummaryCreator.cc.

References cond::ecalcond::bad(), MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2F, python.tagInventory::entries, MonitorElement::Fill(), MonitorElement::getBinContent(), MonitorElement::getEntries(), MonitorElement::getMean(), MonitorElement::getName(), MonitorElement::getNbinsX(), MonitorElement::getTH1(), MonitorElement::getTH1F(), MonitorElement::getTH2F(), relval_steps::k, MonitorElement::kind(), mergeVDriftHistosByStation::name, pileupCalc::nbins, MonitorElement::setBinContent(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

299  {
300 
301  if (me->getTH1()) {
302  // TProfile* prof = 0;
303  TH1F* hist1 = 0;
304  TH2F* hist2 = 0;
305  if (me->kind() == MonitorElement::DQM_KIND_TH1F) hist1 = me->getTH1F();
306  if (me->kind() == MonitorElement::DQM_KIND_TH2F) hist2 = me->getTH2F();
307  // if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) prof = me->getTProfile();
308 
309  int nbins = me_src->getNbinsX();
310  std::string name = me_src->getName();
311  if (htype == "mean" || htype == "Mean" ) {
312  if (hist2 && name.find("NoisyStrips") != std::string::npos) {
313  float bad = 0.0;
314  float entries = me_src->getEntries();
315  if (entries > 0.0) {
316  float binEntry = entries/nbins;
317  for (int k=1; k<nbins+1; k++) {
318  float noisy = me_src->getBinContent(k,3)+me_src->getBinContent(k,5);
319  float dead = me_src->getBinContent(k,2)+me_src->getBinContent(k,4);
320 // float good = me_src->getBinContent(k,1);
321  if (noisy >= binEntry*0.5 || dead >= binEntry*0.5) bad++;
322  }
323  bad = bad*100.0/nbins;
324  me->Fill(ival, bad);
325  }
326  } else me->Fill(ival, me_src->getMean());
327  } else if (htype == "bin-by-bin" || htype == "Bin-by-Bin") {
328  for (int k=1; k<nbins+1; k++) {
329  me->setBinContent(istep+k,me_src->getBinContent(k));
330  }
331  } else if (htype == "sum" || htype == "Sum") {
332  if ( hist1) {
333  for (int k=1; k<nbins+1; k++) {
334  float val = me_src->getBinContent(k) + me->getBinContent(k) ;
335  me->setBinContent(k,val);
336  }
337  }
338  }
339  }
340 }
const std::string & getName(void) const
get name of ME
void setBinContent(int binx, double content)
set content of bin (1-D)
double getEntries(void) const
get # of entries
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
void Fill(long long x)
int bad(Items const &cont)
TH1 * getTH1(void) const
Kind kind(void) const
Get the type of the monitor element.
TH1F * getTH1F(void) const
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
TH2F * getTH2F(void) const
void SiStripSummaryCreator::fillLayout ( DQMStore dqm_store)
void SiStripSummaryCreator::fillSummaryHistos ( DQMStore dqm_store)
private

Definition at line 82 of file SiStripSummaryCreator.cc.

References DQMStore::cd(), relmon_rootfiles_spy::contents, fillHistos(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getNbinsX(), DQMStore::getSubdirs(), getSummaryME(), DQMStore::goUp(), isum, mergeVDriftHistosByStation::name, DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryMEMap.

Referenced by createSummary().

82  {
83  std::string currDir = dqm_store->pwd();
84  std::map<std::string, MonitorElement*> MEMap;
85  std::vector<std::string> subdirs = dqm_store->getSubdirs();
86  if (subdirs.size() ==0) return;
87 
88 
89  for (std::map<std::string,std::string>::const_iterator isum = summaryMEMap.begin();
90  isum != summaryMEMap.end(); isum++) {
91  std::string name = isum->first;
92  int iBinStep = 0;
93  int ndet = 0;
94  std::string htype = isum->second;
95  for (std::vector<std::string>::const_iterator it = subdirs.begin();
96  it != subdirs.end(); it++) {
97  if ( (*it).find("module_") == std::string::npos) continue;
98  dqm_store->cd(*it);
99  ndet++;
100  std::vector<MonitorElement*> contents = dqm_store->getContents(dqm_store->pwd());
101  dqm_store->goUp();
102  for (std::vector<MonitorElement *>::const_iterator im = contents.begin();
103  im != contents.end(); im++) {
104  MonitorElement * me_i = (*im);
105  if (!me_i) continue;
106  std::string name_i = me_i->getName();
107  if (name_i.find(name) == std::string::npos) continue;
108  std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name);
109  MonitorElement* me;
110  // Get the Summary ME
111  if (iPos == MEMap.end()){
112  me = getSummaryME(dqm_store, name, htype);
113  MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
114  } else me = iPos->second;
115  // Fill it now
116  fillHistos(ndet, iBinStep, htype, me_i, me);
117  iBinStep += me_i->getNbinsX();
118  break;
119  }
120  }
121  }
122 }
const std::string & getName(void) const
get name of ME
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1699
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:684
double isum
std::map< std::string, std::string > summaryMEMap
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1777
MonitorElement * getSummaryME(DQMStore *dqm_store, std::string &name, std::string htype)
void fillHistos(int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
int getNbinsX(void) const
get # of bins in X-axis
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:718
const std::string & pwd(void) const
Definition: DQMStore.cc:679
int SiStripSummaryCreator::getFrequency ( )
inline

Definition at line 26 of file SiStripSummaryCreator.h.

References summaryFrequency_.

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

Definition at line 183 of file SiStripSummaryCreator.cc.

References DQMStore::book1D(), DQMStore::cd(), relmon_rootfiles_spy::contents, RefreshWebPage::dname, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getNbinsX(), DQMStore::getSubdirs(), MonitorElement::getTH1(), MonitorElement::getTH1F(), DQMStore::goUp(), estimatePileup::hist, MonitorElement::kind(), mergeVDriftHistosByStation::name, DQMStore::pwd(), AlCaHLTBitMon_QueryRunRegistry::string, and o2o::tags.

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

184  {
185  MonitorElement* me = 0;
186  std::string currDir = dqm_store->pwd();
187  std::string sum_name, tag_name;
188 
189  std::string dname = currDir.substr(currDir.find_last_of("/")+1);
190  if (dname.find("_") != std::string::npos) dname.insert(dname.find("_"),"_");
191  if (htype == "sum" && htype == "Sum") {
192  sum_name = "Summary" + name + "__" + dname;
193  tag_name = "Summary" + name;
194  } else {
195  sum_name = "Summary_Mean" + name + "__" + dname;
196  tag_name = "Summary_Mean" + name;
197  }
198  // If already booked
199  std::vector<MonitorElement*> contents = dqm_store->getContents(currDir);
200  for (std::vector<MonitorElement *>::const_iterator im = contents.begin();
201  im != contents.end(); im++) {
202  MonitorElement * me = (*im);
203  if (!me) continue;
204  std::string me_name = me->getName();
205  if (me_name.find(sum_name) == 0) {
206  if (me->kind() == MonitorElement::DQM_KIND_TH1F ||
209  TH1* hist1 = me->getTH1();
210  if (hist1) {
211  hist1->Reset();
212  return me;
213  }
214  }
215  }
216  }
217  std::map<int, std::string> tags;
218  if (!me) {
219  int nBins = 0;
220  std::vector<std::string> subdirs = dqm_store->getSubdirs();
221  // set # of bins of the histogram
222  if (htype == "mean" || htype == "Mean" ) {
223  nBins = subdirs.size();
224  me = dqm_store->book1D(sum_name,sum_name,nBins,0.5,nBins+0.5);
225  int ibin = 0;
226  for (std::vector<std::string>::const_iterator it = subdirs.begin();
227  it != subdirs.end(); it++) {
228  std::string subdir_name = (*it).substr((*it).find_last_of("/")+1);
229  ibin++;
230  tags.insert(std::pair<int,std::string>(ibin, (subdir_name)));
231  }
232  } else if (htype == "bin-by-bin" || htype == "Bin-by-Bin") {
233  for (std::vector<std::string>::const_iterator it = subdirs.begin();
234  it != subdirs.end(); it++) {
235  dqm_store->cd(*it);
236  std::string subdir_name = (*it).substr((*it).find_last_of("/")+1);
237  std::vector<MonitorElement*> s_contents = dqm_store->getContents(dqm_store->pwd());
238  for (std::vector<MonitorElement *>::const_iterator iv = s_contents.begin();
239  iv != s_contents.end(); iv++) {
240  MonitorElement* s_me = (*iv);
241  if (!s_me) continue;
242  std::string s_me_name = s_me->getName();
243  if (s_me_name.find(name) == 0 || s_me_name.find(tag_name) == 0) {
244  int ibin = s_me->getNbinsX();
245  nBins += ibin;
246  tags.insert(std::pair<int,std::string>(nBins-ibin/2, (subdir_name)));
247  break;
248  }
249  }
250  dqm_store->goUp();
251  }
252  me = dqm_store->book1D(sum_name,sum_name,nBins,0.5,nBins+0.5);
253  } else if (htype == "sum" || htype == "Sum") {
254  for (std::vector<std::string>::const_iterator it = subdirs.begin();
255  it != subdirs.end(); it++) {
256  dqm_store->cd(*it);
257  std::vector<MonitorElement*> s_contents = dqm_store->getContents(dqm_store->pwd());
258  dqm_store->goUp();
259  for (std::vector<MonitorElement *>::const_iterator iv = s_contents.begin();
260  iv != s_contents.end(); iv++) {
261  MonitorElement* s_me = (*iv);
262  if (!s_me) continue;
263  std::string s_me_name = s_me->getName();
264  if (s_me_name.find(name) == std::string::npos) continue;
265  if (s_me->kind() == MonitorElement::DQM_KIND_TH1F) {
266  TH1F* hist1 = s_me->getTH1F();
267  if (hist1) {
268  nBins = s_me->getNbinsX();
269  me = dqm_store->book1D(sum_name,sum_name,nBins,
270  hist1->GetXaxis()->GetXmin(),hist1->GetXaxis()->GetXmax());
271  break;
272  }
273  }
274  }
275  }
276  }
277  }
278  // Set the axis title
279  if (me && me->kind() == MonitorElement::DQM_KIND_TH1F
280  && (htype != "sum" || htype != "Sum")) {
281  TH1F* hist = me->getTH1F();
282  if (hist) {
283  if (name.find("NoisyStrips") != std::string::npos) hist->GetYaxis()->SetTitle("Noisy Strips (%)");
284  else hist->GetYaxis()->SetTitle(name.c_str());
285 
286  for (std::map<int,std::string>::const_iterator ic = tags.begin();
287  ic != tags.end(); ic++) {
288  hist->GetXaxis()->SetBinLabel(ic->first, (ic->second).c_str());
289  }
290  hist->LabelsOption("uv");
291  }
292  }
293  return me;
294 }
const std::string & getName(void) const
get name of ME
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1699
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:994
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:684
TH1 * getTH1(void) const
Kind kind(void) const
Get the type of the monitor element.
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1777
tuple tags
Definition: o2o.py:248
TH1F * getTH1F(void) const
int getNbinsX(void) const
get # of bins in X-axis
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:718
const std::string & pwd(void) const
Definition: DQMStore.cc:679
bool SiStripSummaryCreator::readConfiguration ( std::string &  file_path)

Definition at line 28 of file SiStripSummaryCreator.cc.

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

Referenced by SiStripActionExecutor::readConfiguration().

28  {
29  summaryMEMap.clear();
30  SiStripConfigParser config_parser;
31  config_parser.getDocument(edm::FileInPath(file_path).fullPath());
32  if (!config_parser.getFrequencyForSummary(summaryFrequency_)){
33  std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
34  summaryFrequency_ = -1;
35  return false;
36  }
37  if (!config_parser.getMENamesForSummary(summaryMEMap)) {
38  std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
39  return false;
40  }
41  return true;
42 }
bool getFrequencyForSummary(int &u_freq)
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
std::map< std::string, std::string > summaryMEMap
bool getMENamesForSummary(std::map< std::string, std::string > &me_names)
tuple cout
Definition: gather_cfg.py:121
void SiStripSummaryCreator::setSummaryMENames ( std::map< std::string, std::string > &  me_names)

Definition at line 46 of file SiStripSummaryCreator.cc.

References isum, and summaryMEMap.

46  {
47 
48  summaryMEMap.clear();
49  for (std::map<std::string,std::string>::const_iterator isum = me_names.begin();
50  isum != me_names.end(); isum++) {
51  summaryMEMap.insert(std::pair<std::string,std::string>(isum->first, isum->second));
52  }
53 }
double isum
std::map< std::string, std::string > summaryMEMap

Member Data Documentation

int SiStripSummaryCreator::summaryFrequency_
private

Definition at line 41 of file SiStripSummaryCreator.h.

Referenced by getFrequency(), readConfiguration(), and SiStripSummaryCreator().

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