CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PFClient Class Reference

#include <PFClient.h>

Inheritance diagram for PFClient:
edm::EDAnalyzer

List of all members.

Public Member Functions

 PFClient (const edm::ParameterSet &parameterSet)

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
void beginJob ()
void createEfficiencyPlots (std::string &folder, std::string &name)
void createResolutionPlots (std::string &folder, std::string &name)
void doEfficiency ()
void doSummaries ()
void endJob ()
void endRun (edm::Run const &run, edm::EventSetup const &eSetup)
void getHistogramParameters (MonitorElement *me_slice, double &avarage, double &rms, double &mean, double &sigma)

Private Attributes

DQMStoredqmStore_
std::vector< std::string > effHistogramNames_
bool efficiencyFlag_
std::vector< std::string > folderNames_
std::vector< std::string > histogramNames_

Detailed Description

Definition at line 12 of file PFClient.h.


Constructor & Destructor Documentation

PFClient::PFClient ( const edm::ParameterSet parameterSet)

Definition at line 16 of file PFClient.cc.

References effHistogramNames_, efficiencyFlag_, folderNames_, edm::ParameterSet::getParameter(), and histogramNames_.

{
  folderNames_ = parameterSet.getParameter< std::vector<std::string> >( "FolderNames" );
  histogramNames_  = parameterSet.getParameter< std::vector<std::string> >( "HistogramNames" );
  efficiencyFlag_ =  parameterSet.getParameter< bool> ("CreateEfficiencyPlots" );
  effHistogramNames_  = parameterSet.getParameter< std::vector<std::string> >( "HistogramNamesForEfficiencyPlots" );
}

Member Function Documentation

void PFClient::analyze ( edm::Event const &  ,
edm::EventSetup const &   
) [inline, private, virtual]

Implements edm::EDAnalyzer.

Definition at line 19 of file PFClient.h.

{;}
void PFClient::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 26 of file PFClient.cc.

References dqmStore_, and cppFunctionSkipper::operator.

void PFClient::createEfficiencyPlots ( std::string &  folder,
std::string &  name 
) [private]

Definition at line 158 of file PFClient.cc.

References DQMStore::book1D(), MonitorElement::DQM_KIND_TH1F, dqmStore_, postValidation_cfi::efficiency, DQMStore::get(), MonitorElement::getAxisTitle(), MonitorElement::getBinContent(), MonitorElement::getNbinsX(), MonitorElement::getTH1F(), MonitorElement::kind(), MonitorElement::Reset(), MonitorElement::setBinContent(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::xmin.

Referenced by doEfficiency().

                                                                       {     
  MonitorElement* me1 = dqmStore_->get(folder+"/"+name);
  MonitorElement* me2 = dqmStore_->get(folder+"/"+name+"ref_");
  if (!me1 || !me2) return;
  MonitorElement* me_eff;
  if ( (me1->kind() == MonitorElement::DQM_KIND_TH1F) &&
       (me1->kind() == MonitorElement::DQM_KIND_TH1F) ) {
    TH1* th1 = me1->getTH1F();
    size_t nbinx = me1->getNbinsX();
    
    float xmin = th1->GetXaxis()->GetXmin();
    float xmax = th1->GetXaxis()->GetXmax();
    std::string xtit = me1->getAxisTitle(1);
    std::string tit_new;
    tit_new = ";"+xtit+";Efficiency"; 

    dqmStore_->setCurrentFolder(folder);
    me_eff = dqmStore_->book1D("efficiency_"+name,tit_new, nbinx, xmin, xmax); 
                                 
    double  efficiency;
    me_eff->Reset();
    for (size_t ix = 1; ix < nbinx+1; ++ix) {
      float val1 = me1->getBinContent(ix);
      float val2 = me2->getBinContent(ix);
      if (val2 > 0.0) efficiency = val1/val2;
      else efficiency = 0;   
      me_eff->setBinContent(ix,efficiency);
    }
  }
}
void PFClient::createResolutionPlots ( std::string &  folder,
std::string &  name 
) [private]

Definition at line 77 of file PFClient.cc.

References PDRates::average, DQMStore::book1D(), MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, dqmStore_, DQMStore::get(), getHistogramParameters(), MonitorElement::getName(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), MonitorElement::getTH2F(), MonitorElement::kind(), timingPdfMaker::mean, DQMStore::removeElement(), MonitorElement::Reset(), plotscripts::rms(), MonitorElement::setBinContent(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, fw3dlego::xbins, SiStripMonitorClusterAlca_cfi::ymax, and SiStripMonitorClusterAlca_cfi::ymin.

Referenced by doSummaries().

                                                                       {     
  MonitorElement* me = dqmStore_->get(folder+"/"+name);
  if (!me) return;
  MonitorElement* me_average;
  MonitorElement* me_rms;
  MonitorElement* me_mean;
  MonitorElement* me_sigma;
  if ( (me->kind() == MonitorElement::DQM_KIND_TH2F) ||
       (me->kind() == MonitorElement::DQM_KIND_TH2S) ||
       (me->kind() == MonitorElement::DQM_KIND_TH2D) ) {
    TH2* th = me->getTH2F();
    size_t nbinx = me->getNbinsX();
    size_t nbiny = me->getNbinsY();
    
    float ymin = th->GetYaxis()->GetXmin();
    float ymax = th->GetYaxis()->GetXmax();
    std::string xtit = th->GetXaxis()->GetTitle();
    std::string ytit = th->GetYaxis()->GetTitle();
    float* xbins = new float[nbinx+1];
    for (size_t ix = 1; ix < nbinx+1; ++ix) {
       xbins[ix-1] = th->GetBinLowEdge(ix);
       if (ix == nbinx) xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
    }    

    std::string tit_new;
    dqmStore_->setCurrentFolder(folder);
    MonitorElement* me_slice = dqmStore_->book1D("PFlowSlice","PFlowSlice",nbiny,ymin,ymax); 
    
    tit_new = ";"+xtit+";Average_"+ytit; 
    me_average = dqmStore_->book1D("average_"+name,tit_new, nbinx, xbins); 
    tit_new = ";"+xtit+";RMS_"+ytit; 
    me_rms     = dqmStore_->book1D("rms_"+name,tit_new, nbinx, xbins); 
    tit_new = ";"+xtit+";Mean_"+ytit; 
    me_mean    = dqmStore_->book1D("mean_"+name,tit_new, nbinx, xbins); 
    tit_new = ";"+xtit+";Sigma_"+ytit;                           
    me_sigma   = dqmStore_->book1D("sigma_"+name,tit_new, nbinx, xbins); 
                                 
    double  average, rms, mean, sigma;
    for (size_t ix = 1; ix < nbinx+1; ++ix) {
      me_slice->Reset();
      for (size_t iy = 1; iy < nbiny+1; ++iy) {
        me_slice->setBinContent(iy,th->GetBinContent(ix,iy)); 
      }
      getHistogramParameters(me_slice, average, rms, mean, sigma);
      me_average->setBinContent(ix,average);
      me_rms->setBinContent(ix,rms);
      me_mean->setBinContent(ix,mean);
      me_sigma->setBinContent(ix,sigma);
    }
    if (me_slice) dqmStore_->removeElement(me_slice->getName());
    delete [] xbins;
  }
}
void PFClient::doEfficiency ( ) [private]

Definition at line 62 of file PFClient.cc.

References createEfficiencyPlots(), effHistogramNames_, folderNames_, getHLTPrescaleColumns::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endRun().

                            {
  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin();
                                    ifolder != folderNames_.end(); ifolder++) {
    std::string path  = "ParticleFlow/"+(*ifolder);

    for (std::vector<std::string>::const_iterator ihist = effHistogramNames_.begin();
         ihist != effHistogramNames_.end(); ihist++) {
      std::string hname = (*ihist);
      createEfficiencyPlots(path, hname);
    }
  }
}
void PFClient::doSummaries ( ) [private]

Definition at line 46 of file PFClient.cc.

References createResolutionPlots(), folderNames_, histogramNames_, getHLTPrescaleColumns::path, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endRun().

                           {

  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin();
                                    ifolder != folderNames_.end(); ifolder++) {
    std::string path  = "ParticleFlow/"+(*ifolder);

    for (std::vector<std::string>::const_iterator ihist = histogramNames_.begin();
       ihist != histogramNames_.end(); ihist++) {
      std::string hname = (*ihist); 
      createResolutionPlots(path, hname);
    }
  }
}
void PFClient::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file PFClient.cc.

                      {

}
void PFClient::endRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file PFClient.cc.

References doEfficiency(), doSummaries(), and efficiencyFlag_.

void PFClient::getHistogramParameters ( MonitorElement me_slice,
double &  avarage,
double &  rms,
double &  mean,
double &  sigma 
) [private]

Definition at line 133 of file PFClient.cc.

References MonitorElement::DQM_KIND_TH1F, MonitorElement::getMean(), MonitorElement::getRMS(), MonitorElement::getTH1F(), and MonitorElement::kind().

Referenced by createResolutionPlots().

                                                                                      {
  average = 0.0;
  rms     = 0.0;
  mean    = 0.0;
  sigma   = 0.0;

  if (!me_slice) return;
  if  (me_slice->kind() == MonitorElement::DQM_KIND_TH1F) {
    average = me_slice->getMean();
    rms     = me_slice->getRMS();  
    TH1F* th_slice = me_slice->getTH1F();
    if (th_slice && th_slice->GetEntries() > 0) {
      th_slice->Fit( "gaus","Q0");
      TF1* gaus = th_slice->GetFunction( "gaus" );
      if (gaus) {
        sigma = gaus->GetParameter(2);
        mean  = gaus->GetParameter(1);
      }
    }
  }
}

Member Data Documentation

Definition at line 35 of file PFClient.h.

Referenced by beginJob(), createEfficiencyPlots(), and createResolutionPlots().

std::vector<std::string> PFClient::effHistogramNames_ [private]

Definition at line 32 of file PFClient.h.

Referenced by doEfficiency(), and PFClient().

bool PFClient::efficiencyFlag_ [private]

Definition at line 33 of file PFClient.h.

Referenced by endRun(), and PFClient().

std::vector<std::string> PFClient::folderNames_ [private]

Definition at line 30 of file PFClient.h.

Referenced by doEfficiency(), doSummaries(), and PFClient().

std::vector<std::string> PFClient::histogramNames_ [private]

Definition at line 31 of file PFClient.h.

Referenced by doSummaries(), and PFClient().