CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

DQMHistoryServiceBase Class Reference

#include <DQMHistoryServiceBase.h>

Inheritance diagram for DQMHistoryServiceBase:
GenericHistoryDQMService SiPixelHistoryDQMService SiStripHistoryDQMService

List of all members.

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)
virtual bool setDBValuesForUser (std::vector< MonitorElement * >::const_iterator iterMes, HDQMSummary::InputVector &values, std::string &quantity)

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.

                                                                                                          :
 iConfig_(iConfig),
 fSep("@")
{
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::DQMHistoryServiceBase]";
}
DQMHistoryServiceBase::~DQMHistoryServiceBase ( ) [virtual]

Definition at line 20 of file DQMHistoryServiceBase.cc.

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

Member Function Documentation

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

Definition at line 34 of file DQMHistoryServiceBase.cc.

References getRunNumber().

                                                             {
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::checkForCompatibility]";
  if(ss=="")
    return true;

  uint32_t previousRun=atoi(ss.substr(ss.find("Run ")+4).c_str());
  
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::checkForCompatibility] extracted string " << previousRun ;
  return previousRun<getRunNumber();
}
void DQMHistoryServiceBase::createSummary ( ) [protected, virtual]

Definition at line 45 of file DQMHistoryServiceBase.cc.

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

Referenced by getObj().

                                         {
    
  //LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB

  obj_=new HDQMSummary();

  obj_->setRunNr(getRunNumber());

  // DISCOVER SET OF HISTOGRAMS & QUANTITIES TO BE UPLOADED
  std::vector<std::string> userDBContent;
  typedef std::vector<edm::ParameterSet> VParameters;
  VParameters histoList = iConfig_.getParameter<VParameters>("histoList");
  VParameters::iterator ithistoList = histoList.begin();
  VParameters::iterator ithistoListEnd = histoList.end();
  
  for(; ithistoList != ithistoListEnd; ++ithistoList ) {    
    std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
    std::vector<std::string> Quantities = ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract"); 
    for (size_t i=0;i<Quantities.size();++i){
      
      if  ( Quantities[i] == "landau" )
        setDBLabelsForLandau(keyName, userDBContent);
      else if  ( Quantities[i] == "gauss" )
        setDBLabelsForGauss(keyName, userDBContent);
      else if  ( Quantities[i] == "stat" )
        setDBLabelsForStat(keyName, userDBContent);
      else 
        setDBLabelsForUser(keyName, userDBContent, Quantities[i]);
    }
  }
  obj_->setUserDBContent(userDBContent);
  
  std::stringstream ss;
  ss << "[DQMHistoryServiceBase::scanTreeAndFillSummary] QUANTITIES TO BE INSERTED IN DB :" << std::endl;  
  std::vector<std::string> userDBContentA = obj_->getUserDBContent();
  for (size_t i=0;i<userDBContentA.size();++i){
    ss << userDBContentA[i]<< std::endl;
  }
  edm::LogInfo("HDQMSummary") << ss.str();

  // OPEN DQM FILE
  openRequestedFile();
  const std::vector<MonitorElement*>& MEs = dqmStore_->getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));

  // FILL SUMMARY
  edm::LogInfo("HDQMSummary") << "\nSTARTING TO FILL OBJECT " << std::endl;
  ithistoList = histoList.begin();
  for(; ithistoList != ithistoListEnd; ++ithistoList ) {
    std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
    std::vector<std::string> Quantities = ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract"); 
    scanTreeAndFillSummary(MEs, obj_, keyName, Quantities);
  }
}
virtual void DQMHistoryServiceBase::getMetaDataString ( std::stringstream &  ss) [inline, virtual]

Definition at line 24 of file DQMHistoryServiceBase.h.

References getRunNumber().

{ss << "Run " << getRunNumber();};
virtual void DQMHistoryServiceBase::getObj ( HDQMSummary *&  obj) [inline, virtual]

Definition at line 28 of file DQMHistoryServiceBase.h.

References createSummary(), and obj_.

{createSummary(); obj=obj_;}
uint32_t DQMHistoryServiceBase::getRunNumber ( ) const [protected, virtual]

Definition at line 239 of file DQMHistoryServiceBase.cc.

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

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

                                                   {
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::getRunNumber] " << iConfig_.getParameter<uint32_t>("RunNb");
  return iConfig_.getParameter<uint32_t>("RunNb");
}
void DQMHistoryServiceBase::initialize ( ) [virtual]

Definition at line 24 of file DQMHistoryServiceBase.cc.

References fitME.

                                      {
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::initialize]";
  fitME = new HDQMfitUtilities();
}
void DQMHistoryServiceBase::openRequestedFile ( ) [protected, virtual]

Definition at line 99 of file DQMHistoryServiceBase.cc.

References dqmStore_, convertXMLtoSQLite_cfg::fileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), iConfig_, DQMStore::open(), and cppFunctionSkipper::operator.

Referenced by createSummary().

                                              { 

  dqmStore_ = edm::Service<DQMStore>().operator->(); 

  if( iConfig_.getParameter<bool>("accessDQMFile") ){
    
    std::string fileName = iConfig_.getUntrackedParameter<std::string>("FILE_NAME","");
    
    edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::openRequestedFile] Accessing root File" << fileName;

    dqmStore_->open(fileName, false); 
  } else {
    edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::openRequestedFile] Accessing dqmStore stream in Online Operation";
  }
}
virtual uint32_t DQMHistoryServiceBase::returnDetComponent ( const MonitorElement MEs) [inline, protected, virtual]

Reimplemented in SiPixelHistoryDQMService, SiStripHistoryDQMService, and GenericHistoryDQMService.

Definition at line 40 of file DQMHistoryServiceBase.h.

Referenced by scanTreeAndFillSummary().

{return 999999;}
void DQMHistoryServiceBase::scanTreeAndFillSummary ( const std::vector< MonitorElement * > &  MEs,
HDQMSummary summary,
std::string &  histoName,
std::vector< std::string > &  Quantities 
) [protected, virtual]

Definition at line 116 of file DQMHistoryServiceBase.cc.

References gather_cfg::cout, cond::rpcobgas::detid, alignCSCRings::e, edm::ParameterSet::getUntrackedParameter(), i, iConfig_, HDQMSummary::put(), returnDetComponent(), setDBLabelsForGauss(), setDBLabelsForLandau(), setDBLabelsForStat(), setDBLabelsForUser(), setDBValuesForGauss(), setDBValuesForLandau(), setDBValuesForStat(), setDBValuesForUser(), and makeHLTPrescaleTable::values.

Referenced by createSummary().

                                                                                                                                                                 {
  //
  // -- Scan full root file and fill module numbers and histograms
  //
  //-----------------------------------------------------------------------------------------------

  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::scanTreeAndFillSummary] keyName " << keyName;

  std::vector<MonitorElement*>::const_iterator iterMes = MEs.begin(); 
  std::vector<MonitorElement*>::const_iterator iterMesEnd = MEs.end(); 
  std::stringstream ss;

  // Use boost regex for more flexibility
  boost::regex re;
  try {
    re.assign(keyName);
  }
  catch( boost::regex_error& e ) {
    std::cout << "Error: " << keyName << " is not a valid regular expression: \""
              << e.what() << "\"" << std::endl;
    std::cout << "Skip search for matches" << std::endl;
    return;
  }
  for (; iterMes!=iterMesEnd; ++iterMes){
    // Name including path
    std::string me_name;
    if( iConfig_.getUntrackedParameter<bool>("useFullPath", false) ) {
      me_name = (*iterMes)->getFullname();
    }
    else {
      me_name = (*iterMes)->getName();
      // If the line does not start with a "^" add it
      if( me_name.find("^") != 0 ) {
        me_name = "^" + me_name;
      }
    }
    // regex_search has grep-like behaviour
    if( boost::regex_search(me_name, re) ) {

      HDQMSummary::InputVector values;
      std::vector<std::string> userDBContent;

      ss << "\nFound compatible ME " << me_name << " for key " << keyName << std::endl;

      for(size_t i=0;i<Quantities.size();++i) {

        if(Quantities[i]  == "landau"){
          setDBLabelsForLandau(keyName, userDBContent);
          setDBValuesForLandau(iterMes,values);
        }
        else if(Quantities[i]  == "gauss"){
          setDBLabelsForGauss(keyName, userDBContent);
          setDBValuesForGauss(iterMes,values);
        }
        else if(Quantities[i]  == "stat"){
          setDBLabelsForStat(keyName, userDBContent);
          setDBValuesForStat(iterMes,values);
        }
        else{
          setDBLabelsForUser(keyName, userDBContent,Quantities[i]);
          setDBValuesForUser(iterMes,values,Quantities[i]);
        }
      }
      uint32_t detid=returnDetComponent(*iterMes);

      ss << "detid " << detid << " \n";
      for(size_t i=0;i<values.size();++i)
        ss << "Quantity " << userDBContent[i] << " value " << values[i] << std::endl;
      
      summary->put(detid,values,userDBContent);
    }
  }
  edm::LogInfo("DQMHistoryServiceBase") <<  "[DQMHistoryServiceBase::scanTreeAndFillSummary] " << ss.str();
}   
bool DQMHistoryServiceBase::setDBLabelsForGauss ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
) [protected, virtual]

Definition at line 200 of file DQMHistoryServiceBase.cc.

References fSep.

Referenced by createSummary(), and scanTreeAndFillSummary().

                                                                                                      { 
  userDBContent.push_back(keyName+fSep+std::string("gaussMean"));
  userDBContent.push_back(keyName+fSep+std::string("gaussSigma"));
  userDBContent.push_back(keyName+fSep+std::string("gaussChi2NDF"));
  return true;
}       
bool DQMHistoryServiceBase::setDBLabelsForLandau ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
) [protected, virtual]

Definition at line 192 of file DQMHistoryServiceBase.cc.

References fSep.

Referenced by createSummary(), and scanTreeAndFillSummary().

                                                                                                       { 
  userDBContent.push_back(keyName+fSep+std::string("landauPeak"));
  userDBContent.push_back(keyName+fSep+std::string("landauPeakErr"));
  userDBContent.push_back(keyName+fSep+std::string("landauSFWHM"));
  userDBContent.push_back(keyName+fSep+std::string("landauChi2NDF"));
  return true;
}
bool DQMHistoryServiceBase::setDBLabelsForStat ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
) [protected, virtual]

Definition at line 206 of file DQMHistoryServiceBase.cc.

References fSep.

Referenced by createSummary(), and scanTreeAndFillSummary().

                                                                                                     { 
  userDBContent.push_back(keyName+fSep+std::string("entries"));
  userDBContent.push_back(keyName+fSep+std::string("mean"));
  userDBContent.push_back(keyName+fSep+std::string("rms"));
  return true;
}
virtual bool DQMHistoryServiceBase::setDBLabelsForUser ( std::string &  keyName,
std::vector< std::string > &  userDBContent 
) [inline, protected, virtual]

Definition at line 46 of file DQMHistoryServiceBase.h.

{return false;}
virtual bool DQMHistoryServiceBase::setDBLabelsForUser ( std::string &  keyName,
std::vector< std::string > &  userDBContent,
std::string &  quantity 
) [inline, protected, virtual]

Reimplemented in SiPixelHistoryDQMService, SiStripHistoryDQMService, and GenericHistoryDQMService.

Definition at line 45 of file DQMHistoryServiceBase.h.

References setDBLabelsForUser().

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

{return setDBLabelsForUser(keyName, userDBContent);}
bool DQMHistoryServiceBase::setDBValuesForGauss ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
) [protected, virtual]

Definition at line 223 of file DQMHistoryServiceBase.cc.

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

Referenced by scanTreeAndFillSummary().

                                                                                                                               {  
  fitME->doGaussFit(*iterMes);
  values.push_back( fitME->getGaussPar("mean")  );
  values.push_back( fitME->getGaussPar("sigma") );
  if (fitME->getFitnDof()!=0 ) values.push_back( fitME->getFitChi()/fitME->getFitnDof() );
  else                         values.push_back(-99.);
  return true;
}
bool DQMHistoryServiceBase::setDBValuesForLandau ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
) [protected, virtual]
bool DQMHistoryServiceBase::setDBValuesForStat ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
) [protected, virtual]

Definition at line 232 of file DQMHistoryServiceBase.cc.

Referenced by scanTreeAndFillSummary().

                                                                                                                              {  
  values.push_back( (*iterMes)->getEntries());
  values.push_back( (*iterMes)->getMean());
  values.push_back( (*iterMes)->getRMS());
  return true;
}
virtual bool DQMHistoryServiceBase::setDBValuesForUser ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values 
) [inline, protected, virtual]

Definition at line 52 of file DQMHistoryServiceBase.h.

{return false;}
virtual bool DQMHistoryServiceBase::setDBValuesForUser ( std::vector< MonitorElement * >::const_iterator  iterMes,
HDQMSummary::InputVector values,
std::string &  quantity 
) [inline, protected, virtual]
void DQMHistoryServiceBase::setSeparator ( std::string const &  in) [virtual]

Definition at line 29 of file DQMHistoryServiceBase.cc.

References fSep, and recoMuon::in.

                                                             {
  fSep = in;
  return;
}

Member Data Documentation

Definition at line 54 of file DQMHistoryServiceBase.h.

Referenced by createSummary(), and openRequestedFile().

Definition at line 57 of file DQMHistoryServiceBase.h.

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

std::string DQMHistoryServiceBase::fSep [protected]

Definition at line 56 of file DQMHistoryServiceBase.h.

Referenced by createSummary(), and getObj().