CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes

Benchmark Class Reference

abstract base class More...

#include <Benchmark.h>

Inheritance diagram for Benchmark:
CandidateBenchmark MatchCandidateBenchmark MatchMETBenchmark METBenchmark PFCandidateBenchmark PFCandidateManager PFCandidateMonitor PFJetMonitor PFMETMonitor

List of all members.

Classes

class  PhaseSpace

Public Types

enum  Mode { DEFAULT, DQMOFFLINE, VALIDATION }

Public Member Functions

 Benchmark (Mode mode=DEFAULT)
bool isInRange (float pt, float eta, float phi) const
virtual void setDirectory (TDirectory *dir)
void setParameters (Mode mode)
void setRange (float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
void write ()
 write to the TFile, in plain ROOT mode. No need to call this function in DQM mode
virtual ~Benchmark ()

Static Public Attributes

static DQMStoreDQM_ = 0

Protected Member Functions

TH1F * book1D (const char *histname, const char *title, int nbins, float xmin, float xmax)
 book a 1D histogram, either with DQM or plain root.
TH2F * book2D (const char *histname, const char *title, int nbinsx, float *xbins, int nbinsy, float ymin, float ymax)
 book a 2D histogram, either with DQM or plain root.
TH2F * book2D (const char *histname, const char *title, int nbinsx, float xmin, float xmax, int nbinsy, float ymin, float ymax)
 book a 2D histogram, either with DQM or plain root.

Protected Attributes

TDirectory * dir_
float etaMax_
float etaMin_
Mode mode_
float phiMax_
float phiMin_
float ptMax_
float ptMin_

Detailed Description

abstract base class

Definition at line 20 of file Benchmark.h.


Member Enumeration Documentation

Enumerator:
DEFAULT 
DQMOFFLINE 
VALIDATION 

Definition at line 33 of file Benchmark.h.


Constructor & Destructor Documentation

Benchmark::Benchmark ( Mode  mode = DEFAULT) [inline]

Definition at line 41 of file Benchmark.h.

                                 : 
    dir_(0), mode_(mode), 
    ptMin_(0), ptMax_(10e10), 
    etaMin_(-10), etaMax_(10), 
    phiMin_(-10), phiMax_(10) {}
Benchmark::~Benchmark ( ) [virtual]

Definition at line 15 of file Benchmark.cc.

                      {

}

Member Function Documentation

TH1F * Benchmark::book1D ( const char *  histname,
const char *  title,
int  nbins,
float  xmin,
float  xmax 
) [protected]

book a 1D histogram, either with DQM or plain root.

Definition at line 25 of file Benchmark.cc.

References gather_cfg::cout, sistrip::dir_, and estimatePileup::hist.

Referenced by PFMETMonitor::setup(), CandidateBenchmark::setup(), and PFCandidateMonitor::setup().

                                                           {
  // DQM_ has to be initialized in a child analyzer.
  if(DQM_) {
    edm::LogInfo("Benchmark") << " Benchmark::book1D " << "booking "<<histname;
    return DQM_->book1D(histname,title,nbins,xmin, xmax)->getTH1F();
  }
  else if(dir_){
    TDirectory *oldpwd = gDirectory; 
    dir_->cd();
    TH1F *hist =  new TH1F(histname, title, nbins, xmin, xmax);
    cout<<"booking (ROOT mode) "<<histname<<" in "<<dir_->GetName()<<endl;
    oldpwd->cd();
    return hist;
  }
  else assert(0);
}
TH2F * Benchmark::book2D ( const char *  histname,
const char *  title,
int  nbinsx,
float *  xbins,
int  nbinsy,
float  ymin,
float  ymax 
) [protected]

book a 2D histogram, either with DQM or plain root.

Definition at line 62 of file Benchmark.cc.

References gather_cfg::cout, sistrip::dir_, estimatePileup::hist, and i.

                                                             {
  if(DQM_) {
    edm::LogInfo("Benchmark") << " Benchmark::book2D " << " booked "<<histname;
    
    // need to build the y bin array manually, due to a missing 
    // function in DQMStore
    vector<float> ybins( nbinsy+1 );
    double binsize = (ymax - ymin) / nbinsy;
    for(int i=0; i<=nbinsy; ++i) {
      ybins[i] = ymin + i*binsize;
    } 
    
    return DQM_->book2D(histname,title,nbinsx, xbins, nbinsy, &ybins[0])->getTH2F();
  }
  else if(dir_) {
    TDirectory *oldpwd = gDirectory; 
    dir_->cd();

    // need to convert the float bin array into a double bin array,
    // because the DQMStore functions take floats, while the ROOT functions
    // take double. 
    vector<double> xbinsd(nbinsx+1); 
    for(int i=0; i<=nbinsx; ++i) {
      xbinsd[i] = xbins[i];
    }

    TH2F *hist = new TH2F(histname, title, nbinsx, &xbinsd[0], nbinsy, ymin, ymax);
    cout<<"booked (ROOT mode) "<<histname<<" in "<<dir_->GetName()<<endl;
    oldpwd->cd();
    return hist;
  }
  else assert(0);
}
TH2F * Benchmark::book2D ( const char *  histname,
const char *  title,
int  nbinsx,
float  xmin,
float  xmax,
int  nbinsy,
float  ymin,
float  ymax 
) [protected]

book a 2D histogram, either with DQM or plain root.

Definition at line 43 of file Benchmark.cc.

References gather_cfg::cout, sistrip::dir_, and estimatePileup::hist.

Referenced by PFMETMonitor::setup(), MatchCandidateBenchmark::setup(), and PFJetMonitor::setup().

                                                             {
  // DQM_ has to be initialized in a child analyzer.
  if(DQM_) {
    edm::LogInfo("Benchmark") << " Benchmark::book2D "<<"booked "<<histname;
    return DQM_->book2D(histname,title,nbinsx,xmin, xmax, nbinsy, ymin, ymax)->getTH2F();
  }
  else if(dir_) {
    TDirectory *oldpwd = gDirectory; 
    dir_->cd();
    TH2F *hist = new TH2F(histname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
    cout<<"booked (ROOT mode) "<<histname<<" in "<<dir_->GetName()<<endl;
    oldpwd->cd();
    return hist;
  }
  else assert(0);
}
bool Benchmark::isInRange ( float  pt,
float  eta,
float  phi 
) const [inline]

Definition at line 58 of file Benchmark.h.

References etaMin_, phiMax_, phiMin_, and ptMin_.

Referenced by PFCandidateManager::fill(), PFCandidateMonitor::fill(), PFJetMonitor::fill(), CandidateBenchmark::fillOne(), MatchCandidateBenchmark::fillOne(), and PFMETMonitor::fillOne().

                                                       {
    return pt>ptMin_ && pt<ptMax_ && eta>etaMin_ && eta<etaMax_ && phi>phiMin_ && phi<phiMax_ ? true : false; 
  }
void Benchmark::setDirectory ( TDirectory *  dir) [virtual]
void Benchmark::setParameters ( Mode  mode) [inline]
void Benchmark::setRange ( float  ptMin,
float  ptMax,
float  etaMin,
float  etaMax,
float  phiMin,
float  phiMax 
) [inline]
void Benchmark::write ( void  )

write to the TFile, in plain ROOT mode. No need to call this function in DQM mode

Definition at line 99 of file Benchmark.cc.

References sistrip::dir_.

Referenced by PFRootEventManager::write().

                      {
  //COLIN not sure about the root mode 
  if( dir_ )
    dir_->Write();

  //COLIN remove old bullshit:
//   if ( ame.size() != 0 && file_)
//     cout<<"saving histograms in "<<fileName<<endl;
//     file_->Write(fileName.c_str());
}

Member Data Documentation

TDirectory* Benchmark::dir_ [protected]

Definition at line 84 of file Benchmark.h.

DQMStore * Benchmark::DQM_ = 0 [static]
float Benchmark::etaMax_ [protected]

Definition at line 91 of file Benchmark.h.

Referenced by setRange().

float Benchmark::etaMin_ [protected]

Definition at line 90 of file Benchmark.h.

Referenced by isInRange(), and setRange().

Mode Benchmark::mode_ [protected]
float Benchmark::phiMax_ [protected]

Definition at line 93 of file Benchmark.h.

Referenced by isInRange(), and setRange().

float Benchmark::phiMin_ [protected]

Definition at line 92 of file Benchmark.h.

Referenced by isInRange(), and setRange().

float Benchmark::ptMax_ [protected]

Definition at line 89 of file Benchmark.h.

Referenced by setRange().

float Benchmark::ptMin_ [protected]

Definition at line 88 of file Benchmark.h.

Referenced by isInRange(), and setRange().