CMS 3D CMS Logo

SiStripDQMHistoryHelper.cc
Go to the documentation of this file.
2 #include <boost/regex.hpp>
3 
5 
6 void SiStripDQMHistoryHelper::scanTreeAndFillSummary(const std::vector<MonitorElement*>& MEs, HDQMSummary* summary, const std::string& keyName, const std::vector<std::string>& Quantities) const
7 {
8  //
9  // -- Scan full root file and fill module numbers and histograms
10  //
11  //-----------------------------------------------------------------------------------------------
12 
13  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::scanTreeAndFillSummary] keyName " << keyName;
14 
15  std::stringstream ss;
16 
17  // Use boost regex for more flexibility
18  boost::regex re;
19  try {
20  re.assign(keyName);
21  } catch ( boost::regex_error& e ) {
22  std::cout << "Error: " << keyName << " is not a valid regular expression: \""
23  << e.what() << "\"" << std::endl;
24  std::cout << "Skip search for matches" << std::endl;
25  return;
26  }
27  for ( const MonitorElement* me : MEs ) {
28  // Name including path
29  std::string me_name;
30  if ( m_useFullPath ) {
31  me_name = me->getFullname();
32  } else {
33  me_name = me->getName();
34  // If the line does not start with a "^" add it
35  if( me_name.find("^") != 0 ) {
36  me_name = "^" + me_name;
37  }
38  }
39  // regex_search has grep-like behaviour
40  if ( boost::regex_search(me_name, re) ) {
41 
43  std::vector<std::string> userDBContent;
44 
45  ss << "\nFound compatible ME " << me_name << " for key " << keyName << std::endl;
46 
47  for ( const std::string& quant : Quantities ) {
48  if ( quant == "landau" ) {
49  setDBLabelsForLandau(keyName, userDBContent);
50  setDBValuesForLandau(me, values);
51  } else if ( quant == "gauss" ) {
52  setDBLabelsForGauss(keyName, userDBContent);
53  setDBValuesForGauss(me, values);
54  } else if ( quant == "stat" ) {
55  setDBLabelsForStat(keyName, userDBContent);
56  setDBValuesForStat(me, values);
57  } else {
58  setDBLabelsForUser(keyName, userDBContent, quant);
59  setDBValuesForUser(me, values, quant);
60  }
61  }
62  uint32_t detid = returnDetComponent(me);
63 
64  ss << "detid " << detid << " \n";
65  for ( size_t i = 0; i < values.size(); ++i )
66  ss << "Quantity " << userDBContent[i] << " value " << values[i] << std::endl;
67 
68  summary->put(detid, values, userDBContent);
69  }
70  }
71  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::scanTreeAndFillSummary] " << ss.str();
72 }
73 
74 bool SiStripDQMHistoryHelper::setDBLabelsForLandau(const std::string& keyName, std::vector<std::string>& userDBContent) const
75 {
76  userDBContent.push_back(keyName+sep()+std::string("landauPeak"));
77  userDBContent.push_back(keyName+sep()+std::string("landauPeakErr"));
78  userDBContent.push_back(keyName+sep()+std::string("landauSFWHM"));
79  userDBContent.push_back(keyName+sep()+std::string("landauChi2NDF"));
80  return true;
81 }
82 
83 bool SiStripDQMHistoryHelper::setDBLabelsForGauss(const std::string& keyName, std::vector<std::string>& userDBContent) const
84 {
85  userDBContent.push_back(keyName+sep()+std::string("gaussMean"));
86  userDBContent.push_back(keyName+sep()+std::string("gaussSigma"));
87  userDBContent.push_back(keyName+sep()+std::string("gaussChi2NDF"));
88  return true;
89 }
90 
91 bool SiStripDQMHistoryHelper::setDBLabelsForStat(const std::string& keyName, std::vector<std::string>& userDBContent) const
92 {
93  userDBContent.push_back(keyName+sep()+std::string("entries"));
94  userDBContent.push_back(keyName+sep()+std::string("mean"));
95  userDBContent.push_back(keyName+sep()+std::string("rms"));
96  return true;
97 }
98 
100 {
101  m_fitME.doLanGaussFit(const_cast<MonitorElement*>(me));
102  values.push_back( m_fitME.getLanGaussPar("mpv") );
103  values.push_back( m_fitME.getLanGaussParErr("mpv") );
104  values.push_back( m_fitME.getLanGaussConv("fwhm") );
105  if (m_fitME.getFitnDof()!=0 ) values.push_back( m_fitME.getFitChi()/m_fitME.getFitnDof() );
106  else values.push_back(-99.);
107  return true;
108 }
109 
111 {
112  m_fitME.doGaussFit(const_cast<MonitorElement*>(me));
113  values.push_back( m_fitME.getGaussPar("mean") );
114  values.push_back( m_fitME.getGaussPar("sigma") );
115  if (m_fitME.getFitnDof()!=0 ) values.push_back( m_fitME.getFitChi()/m_fitME.getFitnDof() );
116  else values.push_back(-99.);
117  return true;
118 }
119 
121 {
122  values.push_back( me->getEntries());
123  values.push_back( me->getMean());
124  values.push_back( me->getRMS());
125  return true;
126 }
double getLanGaussParErr(std::string s)
bool put(const uint32_t &detID, InputVector &input, std::vector< std::string > &userContent)
Definition: HDQMSummary.cc:26
virtual bool setDBLabelsForUser(const std::string &keyName, std::vector< std::string > &userDBContent, const std::string &quantity) const
virtual bool setDBValuesForStat(const MonitorElement *me, HDQMSummary::InputVector &values) const
double doGaussFit(MonitorElement *ME)
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double getLanGaussConv(std::string s)
virtual bool setDBLabelsForStat(const std::string &keyName, std::vector< std::string > &userDBContent) const
std::vector< float > InputVector
Definition: HDQMSummary.h:62
virtual bool setDBLabelsForLandau(const std::string &keyName, std::vector< std::string > &userDBContent) const
virtual bool setDBValuesForGauss(const MonitorElement *me, HDQMSummary::InputVector &values) const
virtual void scanTreeAndFillSummary(const std::vector< MonitorElement * > &MEs, HDQMSummary *summary, const std::string &histoName, const std::vector< std::string > &Quantities) const
virtual uint32_t returnDetComponent(const MonitorElement *ME) const =0
double getLanGaussPar(std::string s)
double getGaussPar(std::string s)
double getEntries() const
get # of entries
quant
Definition: HTMonitor.h:44
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual bool setDBValuesForUser(const MonitorElement *me, HDQMSummary::InputVector &values, const std::string &quantity) const
virtual bool setDBLabelsForGauss(const std::string &keyName, std::vector< std::string > &userDBContent) const
virtual bool setDBValuesForLandau(const MonitorElement *me, HDQMSummary::InputVector &values) const
double doLanGaussFit(MonitorElement *ME)