CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DQMHistoryServiceBase Class Reference

#include <DQMHistoryServiceBase.h>

Inheritance diagram for DQMHistoryServiceBase:
GenericHistoryDQMService SiStripHistoryDQMService

Public Member Functions

virtual bool checkForCompatibility (std::string ss)
 
 DQMHistoryServiceBase (const edm::ParameterSet &, const edm::ActivityRegistry &)
 
virtual void getMetaDataString (std::stringstream &ss)
 
virtual void getObj (HDQMSummary *&obj)
 
virtual void initialize ()
 
virtual void setSeparator (std::string const &)
 
virtual ~DQMHistoryServiceBase ()
 

Protected Member Functions

virtual void createSummary ()
 
virtual uint32_t getRunNumber () const
 
virtual void openRequestedFile ()
 
virtual uint32_t returnDetComponent (const MonitorElement *MEs)
 
virtual void scanTreeAndFillSummary (const std::vector< MonitorElement * > &MEs, HDQMSummary *summary, std::string &histoName, std::vector< std::string > &Quantities)
 
virtual bool setDBLabelsForGauss (std::string &keyName, std::vector< std::string > &userDBContent)
 
virtual bool setDBLabelsForLandau (std::string &keyName, std::vector< std::string > &userDBContent)
 
virtual bool setDBLabelsForStat (std::string &keyName, std::vector< std::string > &userDBContent)
 
virtual bool setDBLabelsForUser (std::string &keyName, std::vector< std::string > &userDBContent, std::string &quantity)
 
virtual bool setDBLabelsForUser (std::string &keyName, std::vector< std::string > &userDBContent)
 
virtual bool setDBValuesForGauss (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
 
virtual bool setDBValuesForLandau (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
 
virtual bool setDBValuesForStat (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
 
virtual bool setDBValuesForUser (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values, std::string &quantity)
 
virtual bool setDBValuesForUser (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
 

Protected Attributes

DQMStoredqmStore_
 
HDQMfitUtilitiesfitME
 
std::string fSep
 
edm::ParameterSet iConfig_
 
HDQMSummaryobj_
 

Detailed Description

Definition at line 18 of file DQMHistoryServiceBase.h.

Constructor & Destructor Documentation

DQMHistoryServiceBase::DQMHistoryServiceBase ( const edm::ParameterSet iConfig,
const edm::ActivityRegistry aReg 
)

Definition at line 12 of file DQMHistoryServiceBase.cc.

12  :
13  iConfig_(iConfig),
14  fSep("@")
15 {
16  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::DQMHistoryServiceBase]";
17 }
edm::ParameterSet iConfig_
DQMHistoryServiceBase::~DQMHistoryServiceBase ( )
virtual

Definition at line 20 of file DQMHistoryServiceBase.cc.

20  {
21  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::~DQMHistoryServiceBase]";
22 }

Member Function Documentation

bool DQMHistoryServiceBase::checkForCompatibility ( std::string  ss)
virtual

Definition at line 34 of file DQMHistoryServiceBase.cc.

References getRunNumber().

Referenced by getMetaDataString().

34  {
35  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::checkForCompatibility]";
36  if(ss=="")
37  return true;
38 
39  uint32_t previousRun=atoi(ss.substr(ss.find("Run ")+4).c_str());
40 
41  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::checkForCompatibility] extracted string " << previousRun ;
42  return previousRun<getRunNumber();
43 }
virtual uint32_t getRunNumber() const
void DQMHistoryServiceBase::createSummary ( )
protectedvirtual

Definition at line 45 of file DQMHistoryServiceBase.cc.

References dqmStore_, DQMStore::getAllContents(), edm::ParameterSet::getParameter(), getRunNumber(), edm::ParameterSet::getUntrackedParameter(), HDQMSummary::getUserDBContent(), mps_fire::i, iConfig_, obj_, openRequestedFile(), scanTreeAndFillSummary(), setDBLabelsForGauss(), setDBLabelsForLandau(), setDBLabelsForStat(), setDBLabelsForUser(), HDQMSummary::setRunNr(), HDQMSummary::setUserDBContent(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getObj().

45  {
46 
47  //LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB
48 
49  obj_=new HDQMSummary();
50 
52 
53  // DISCOVER SET OF HISTOGRAMS & QUANTITIES TO BE UPLOADED
54  std::vector<std::string> userDBContent;
55  typedef std::vector<edm::ParameterSet> VParameters;
56  VParameters histoList = iConfig_.getParameter<VParameters>("histoList");
57  VParameters::iterator ithistoList = histoList.begin();
58  VParameters::iterator ithistoListEnd = histoList.end();
59 
60  for(; ithistoList != ithistoListEnd; ++ithistoList ) {
61  std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
62  std::vector<std::string> Quantities = ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract");
63  for (size_t i=0;i<Quantities.size();++i){
64 
65  if ( Quantities[i] == "landau" )
66  setDBLabelsForLandau(keyName, userDBContent);
67  else if ( Quantities[i] == "gauss" )
68  setDBLabelsForGauss(keyName, userDBContent);
69  else if ( Quantities[i] == "stat" )
70  setDBLabelsForStat(keyName, userDBContent);
71  else
72  setDBLabelsForUser(keyName, userDBContent, Quantities[i]);
73  }
74  }
75  obj_->setUserDBContent(userDBContent);
76 
77  std::stringstream ss;
78  ss << "[DQMHistoryServiceBase::scanTreeAndFillSummary] QUANTITIES TO BE INSERTED IN DB :" << std::endl;
79  std::vector<std::string> userDBContentA = obj_->getUserDBContent();
80  for (size_t i=0;i<userDBContentA.size();++i){
81  ss << userDBContentA[i]<< std::endl;
82  }
83  edm::LogInfo("HDQMSummary") << ss.str();
84 
85  // OPEN DQM FILE
87  const std::vector<MonitorElement*>& MEs = dqmStore_->getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));
88 
89  // FILL SUMMARY
90  edm::LogInfo("HDQMSummary") << "\nSTARTING TO FILL OBJECT " << std::endl;
91  ithistoList = histoList.begin();
92  for(; ithistoList != ithistoListEnd; ++ithistoList ) {
93  std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
94  std::vector<std::string> Quantities = ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract");
95  scanTreeAndFillSummary(MEs, obj_, keyName, Quantities);
96  }
97 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual uint32_t getRunNumber() const
void setRunNr(int inputRunNr)
Definition: HDQMSummary.h:112
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:2001
void setUserDBContent(const std::vector< std::string > &userDBContent)
Definition: HDQMSummary.h:111
virtual bool setDBLabelsForStat(std::string &keyName, std::vector< std::string > &userDBContent)
edm::ParameterSet iConfig_
virtual bool setDBLabelsForGauss(std::string &keyName, std::vector< std::string > &userDBContent)
virtual bool setDBLabelsForUser(std::string &keyName, std::vector< std::string > &userDBContent, std::string &quantity)
virtual bool setDBLabelsForLandau(std::string &keyName, std::vector< std::string > &userDBContent)
virtual void scanTreeAndFillSummary(const std::vector< MonitorElement * > &MEs, HDQMSummary *summary, std::string &histoName, std::vector< std::string > &Quantities)
std::vector< std::string > getUserDBContent() const
Definition: HDQMSummary.h:116
virtual void DQMHistoryServiceBase::getMetaDataString ( std::stringstream &  ss)
inlinevirtual

Definition at line 24 of file DQMHistoryServiceBase.h.

References checkForCompatibility(), getRunNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

24 {ss << "Run " << getRunNumber();};
virtual uint32_t getRunNumber() const
virtual void DQMHistoryServiceBase::getObj ( HDQMSummary *&  obj)
inlinevirtual
uint32_t DQMHistoryServiceBase::getRunNumber ( ) const
protectedvirtual

Definition at line 239 of file DQMHistoryServiceBase.cc.

References edm::ParameterSet::getParameter(), and iConfig_.

Referenced by checkForCompatibility(), createSummary(), getMetaDataString(), and getObj().

239  {
240  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::getRunNumber] " << iConfig_.getParameter<uint32_t>("RunNb");
241  return iConfig_.getParameter<uint32_t>("RunNb");
242 }
T getParameter(std::string const &) const
edm::ParameterSet iConfig_
void DQMHistoryServiceBase::initialize ( )
virtual

Definition at line 24 of file DQMHistoryServiceBase.cc.

References fitME.

Referenced by getObj().

24  {
25  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::initialize]";
26  fitME = new HDQMfitUtilities();
27 }
HDQMfitUtilities * fitME
void DQMHistoryServiceBase::openRequestedFile ( )
protectedvirtual

Definition at line 99 of file DQMHistoryServiceBase.cc.

References dqmStore_, MillePedeFileConverter_cfg::fileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), iConfig_, DQMStore::open(), Utilities::operator, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createSummary(), and getObj().

99  {
100 
102 
103  if( iConfig_.getParameter<bool>("accessDQMFile") ){
104 
106 
107  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::openRequestedFile] Accessing root File" << fileName;
108 
109  dqmStore_->open(fileName, false);
110  } else {
111  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::openRequestedFile] Accessing dqmStore stream in Online Operation";
112  }
113 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet iConfig_
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:3006
virtual uint32_t DQMHistoryServiceBase::returnDetComponent ( const MonitorElement MEs)
inlineprotectedvirtual
void DQMHistoryServiceBase::scanTreeAndFillSummary ( const std::vector< MonitorElement * > &  MEs,
HDQMSummary summary,
std::string &  histoName,
std::vector< std::string > &  Quantities 
)
protectedvirtual

Definition at line 116 of file DQMHistoryServiceBase.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, iConfig_, HDQMSummary::put(), returnDetComponent(), setDBLabelsForGauss(), setDBLabelsForLandau(), setDBLabelsForStat(), setDBLabelsForUser(), setDBValuesForGauss(), setDBValuesForLandau(), setDBValuesForStat(), setDBValuesForUser(), AlCaHLTBitMon_QueryRunRegistry::string, and MuonErrorMatrixValues_cff::values.

Referenced by createSummary(), and getObj().

116  {
117  //
118  // -- Scan full root file and fill module numbers and histograms
119  //
120  //-----------------------------------------------------------------------------------------------
121 
122  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::scanTreeAndFillSummary] keyName " << keyName;
123 
124  std::vector<MonitorElement*>::const_iterator iterMes = MEs.begin();
125  std::vector<MonitorElement*>::const_iterator iterMesEnd = MEs.end();
126  std::stringstream ss;
127 
128  // Use boost regex for more flexibility
129  boost::regex re;
130  try {
131  re.assign(keyName);
132  }
133  catch( boost::regex_error& e ) {
134  std::cout << "Error: " << keyName << " is not a valid regular expression: \""
135  << e.what() << "\"" << std::endl;
136  std::cout << "Skip search for matches" << std::endl;
137  return;
138  }
139  for (; iterMes!=iterMesEnd; ++iterMes){
140  // Name including path
141  std::string me_name;
142  if( iConfig_.getUntrackedParameter<bool>("useFullPath", false) ) {
143  me_name = (*iterMes)->getFullname();
144  }
145  else {
146  me_name = (*iterMes)->getName();
147  // If the line does not start with a "^" add it
148  if( me_name.find("^") != 0 ) {
149  me_name = "^" + me_name;
150  }
151  }
152  // regex_search has grep-like behaviour
153  if( boost::regex_search(me_name, re) ) {
154 
156  std::vector<std::string> userDBContent;
157 
158  ss << "\nFound compatible ME " << me_name << " for key " << keyName << std::endl;
159 
160  for(size_t i=0;i<Quantities.size();++i) {
161 
162  if(Quantities[i] == "landau"){
163  setDBLabelsForLandau(keyName, userDBContent);
164  setDBValuesForLandau(iterMes,values);
165  }
166  else if(Quantities[i] == "gauss"){
167  setDBLabelsForGauss(keyName, userDBContent);
168  setDBValuesForGauss(iterMes,values);
169  }
170  else if(Quantities[i] == "stat"){
171  setDBLabelsForStat(keyName, userDBContent);
172  setDBValuesForStat(iterMes,values);
173  }
174  else{
175  setDBLabelsForUser(keyName, userDBContent,Quantities[i]);
176  setDBValuesForUser(iterMes,values,Quantities[i]);
177  }
178  }
179  uint32_t detid=returnDetComponent(*iterMes);
180 
181  ss << "detid " << detid << " \n";
182  for(size_t i=0;i<values.size();++i)
183  ss << "Quantity " << userDBContent[i] << " value " << values[i] << std::endl;
184 
185  summary->put(detid,values,userDBContent);
186  }
187  }
188  edm::LogInfo("DQMHistoryServiceBase") << "[DQMHistoryServiceBase::scanTreeAndFillSummary] " << ss.str();
189 }
virtual bool setDBValuesForGauss(std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
T getUntrackedParameter(std::string const &, T const &) const
bool put(const uint32_t &detID, InputVector &input, std::vector< std::string > &userContent)
Definition: HDQMSummary.cc:26
virtual bool setDBValuesForUser(std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values, std::string &quantity)
std::vector< float > InputVector
Definition: HDQMSummary.h:62
virtual bool setDBLabelsForStat(std::string &keyName, std::vector< std::string > &userDBContent)
edm::ParameterSet iConfig_
virtual uint32_t returnDetComponent(const MonitorElement *MEs)
virtual bool setDBLabelsForGauss(std::string &keyName, std::vector< std::string > &userDBContent)
virtual bool setDBLabelsForUser(std::string &keyName, std::vector< std::string > &userDBContent, std::string &quantity)
virtual bool setDBLabelsForLandau(std::string &keyName, std::vector< std::string > &userDBContent)
virtual bool setDBValuesForLandau(std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
virtual bool setDBValuesForStat(std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values)
bool DQMHistoryServiceBase::setDBLabelsForGauss ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
)
protectedvirtual

Definition at line 200 of file DQMHistoryServiceBase.cc.

References fSep, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createSummary(), returnDetComponent(), and scanTreeAndFillSummary().

200  {
201  userDBContent.push_back(keyName+fSep+std::string("gaussMean"));
202  userDBContent.push_back(keyName+fSep+std::string("gaussSigma"));
203  userDBContent.push_back(keyName+fSep+std::string("gaussChi2NDF"));
204  return true;
205 }
bool DQMHistoryServiceBase::setDBLabelsForLandau ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
)
protectedvirtual

Definition at line 192 of file DQMHistoryServiceBase.cc.

References fSep, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createSummary(), returnDetComponent(), and scanTreeAndFillSummary().

192  {
193  userDBContent.push_back(keyName+fSep+std::string("landauPeak"));
194  userDBContent.push_back(keyName+fSep+std::string("landauPeakErr"));
195  userDBContent.push_back(keyName+fSep+std::string("landauSFWHM"));
196  userDBContent.push_back(keyName+fSep+std::string("landauChi2NDF"));
197  return true;
198 }
bool DQMHistoryServiceBase::setDBLabelsForStat ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
)
protectedvirtual

Definition at line 206 of file DQMHistoryServiceBase.cc.

References fSep, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createSummary(), returnDetComponent(), and scanTreeAndFillSummary().

206  {
207  userDBContent.push_back(keyName+fSep+std::string("entries"));
208  userDBContent.push_back(keyName+fSep+std::string("mean"));
209  userDBContent.push_back(keyName+fSep+std::string("rms"));
210  return true;
211 }
virtual bool DQMHistoryServiceBase::setDBLabelsForUser ( std::string &  keyName,
std::vector< std::string > &  userDBContent,
std::string &  quantity 
)
inlineprotectedvirtual

Reimplemented in SiStripHistoryDQMService, and GenericHistoryDQMService.

Definition at line 45 of file DQMHistoryServiceBase.h.

References setDBLabelsForUser().

Referenced by createSummary(), scanTreeAndFillSummary(), and setDBLabelsForUser().

45 {return setDBLabelsForUser(keyName, userDBContent);}
virtual bool setDBLabelsForUser(std::string &keyName, std::vector< std::string > &userDBContent, std::string &quantity)
virtual bool DQMHistoryServiceBase::setDBLabelsForUser ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
)
inlineprotectedvirtual
bool DQMHistoryServiceBase::setDBValuesForGauss ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
)
protectedvirtual

Definition at line 223 of file DQMHistoryServiceBase.cc.

References HDQMfitUtilities::doGaussFit(), fitME, HDQMfitUtilities::getFitChi(), HDQMfitUtilities::getFitnDof(), and HDQMfitUtilities::getGaussPar().

Referenced by scanTreeAndFillSummary(), and setDBLabelsForUser().

223  {
224  fitME->doGaussFit(*iterMes);
225  values.push_back( fitME->getGaussPar("mean") );
226  values.push_back( fitME->getGaussPar("sigma") );
227  if (fitME->getFitnDof()!=0 ) values.push_back( fitME->getFitChi()/fitME->getFitnDof() );
228  else values.push_back(-99.);
229  return true;
230 }
double doGaussFit(MonitorElement *ME)
HDQMfitUtilities * fitME
double getGaussPar(std::string s)
bool DQMHistoryServiceBase::setDBValuesForLandau ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
)
protectedvirtual

Definition at line 213 of file DQMHistoryServiceBase.cc.

References HDQMfitUtilities::doLanGaussFit(), fitME, HDQMfitUtilities::getFitChi(), HDQMfitUtilities::getFitnDof(), HDQMfitUtilities::getLanGaussConv(), HDQMfitUtilities::getLanGaussPar(), and HDQMfitUtilities::getLanGaussParErr().

Referenced by scanTreeAndFillSummary(), and setDBLabelsForUser().

213  {
214  fitME->doLanGaussFit(*iterMes);
215  values.push_back( fitME->getLanGaussPar("mpv") );
216  values.push_back( fitME->getLanGaussParErr("mpv") );
217  values.push_back( fitME->getLanGaussConv("fwhm") );
218  if (fitME->getFitnDof()!=0 ) values.push_back( fitME->getFitChi()/fitME->getFitnDof() );
219  else values.push_back(-99.);
220  return true;
221 }
double getLanGaussParErr(std::string s)
double getLanGaussConv(std::string s)
HDQMfitUtilities * fitME
double getLanGaussPar(std::string s)
double doLanGaussFit(MonitorElement *ME)
bool DQMHistoryServiceBase::setDBValuesForStat ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
)
protectedvirtual

Definition at line 232 of file DQMHistoryServiceBase.cc.

Referenced by scanTreeAndFillSummary(), and setDBLabelsForUser().

232  {
233  values.push_back( (*iterMes)->getEntries());
234  values.push_back( (*iterMes)->getMean());
235  values.push_back( (*iterMes)->getRMS());
236  return true;
237 }
virtual bool DQMHistoryServiceBase::setDBValuesForUser ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values,
std::string &  quantity 
)
inlineprotectedvirtual

Reimplemented in SiStripHistoryDQMService, and GenericHistoryDQMService.

Definition at line 51 of file DQMHistoryServiceBase.h.

References setDBValuesForUser().

Referenced by scanTreeAndFillSummary(), and setDBValuesForUser().

51 {return setDBValuesForUser(iterMes,values);}
virtual bool setDBValuesForUser(std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values, std::string &quantity)
virtual bool DQMHistoryServiceBase::setDBValuesForUser ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
)
inlineprotectedvirtual

Definition at line 52 of file DQMHistoryServiceBase.h.

52 {return false;}
void DQMHistoryServiceBase::setSeparator ( std::string const &  in)
virtual

Definition at line 29 of file DQMHistoryServiceBase.cc.

References fSep, and recoMuon::in.

Referenced by getObj().

29  {
30  fSep = in;
31  return;
32 }

Member Data Documentation

DQMStore* DQMHistoryServiceBase::dqmStore_
protected

Definition at line 54 of file DQMHistoryServiceBase.h.

Referenced by createSummary(), and openRequestedFile().

HDQMfitUtilities* DQMHistoryServiceBase::fitME
protected

Definition at line 57 of file DQMHistoryServiceBase.h.

Referenced by initialize(), setDBValuesForGauss(), and setDBValuesForLandau().

std::string DQMHistoryServiceBase::fSep
protected
edm::ParameterSet DQMHistoryServiceBase::iConfig_
protected
HDQMSummary* DQMHistoryServiceBase::obj_
protected

Definition at line 56 of file DQMHistoryServiceBase.h.

Referenced by createSummary(), and getObj().