CMS 3D CMS Logo

Public Member Functions | Protected Attributes

PFCandidateMonitor Class Reference

#include <PFCandidateMonitor.h>

Inheritance diagram for PFCandidateMonitor:
Benchmark

List of all members.

Public Member Functions

template<class T , class C >
void fill (const T &candidateCollection, const C &matchedCandCollection, float &minVal, float &maxVal)
 fill histograms with all particle
void fillOne (const reco::Candidate &cand)
 PFCandidateMonitor (float dRMax=0.3, bool matchCharge=true, Benchmark::Mode mode=Benchmark::DEFAULT)
void setDirectory (TDirectory *dir)
 set directory (to use in ROOT)
void setParameters (const edm::ParameterSet &parameterSet)
 set the parameters accessing them from ParameterSet
void setParameters (float dRMax, bool matchCharge, Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool refHistoFlag)
 set the parameters locally
void setup ()
 book histograms
void setup (const edm::ParameterSet &parameterSet)
 book histograms
virtual ~PFCandidateMonitor ()

Protected Attributes

CandidateBenchmark candBench_
bool createReferenceHistos_
float dRMax_
TH1F * eta_ref_
bool histogramBooked_
MatchCandidateBenchmark matchCandBench_
bool matchCharge_
TH1F * phi_ref_
TH1F * pt_ref_

Detailed Description

Definition at line 13 of file PFCandidateMonitor.h.


Constructor & Destructor Documentation

PFCandidateMonitor::PFCandidateMonitor ( float  dRMax = 0.3,
bool  matchCharge = true,
Benchmark::Mode  mode = Benchmark::DEFAULT 
)

Definition at line 15 of file PFCandidateMonitor.cc.

References createReferenceHistos_, eta_ref_, histogramBooked_, phi_ref_, pt_ref_, and Benchmark::setRange().

                                                                                         : 
  Benchmark(mode), 
  candBench_(mode), 
  matchCandBench_(mode), 
  dRMax_(dRMax), 
  matchCharge_(matchCharge) {
  
  setRange( 0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
  
  pt_ref_   = 0;
  eta_ref_  = 0;
  phi_ref_  = 0;
  
  createReferenceHistos_ = false;
  histogramBooked_ = false;
}  
PFCandidateMonitor::~PFCandidateMonitor ( ) [virtual]

Definition at line 34 of file PFCandidateMonitor.cc.

{}

Member Function Documentation

template<class T , class C >
void PFCandidateMonitor::fill ( const T candidateCollection,
const C &  matchedCandCollection,
float &  minVal,
float &  maxVal 
)

fill histograms with all particle

Definition at line 65 of file PFCandidateMonitor.h.

References candBench_, createReferenceHistos_, dRMax_, reco::Candidate::eta(), MatchCandidateBenchmark::fillOne(), CandidateBenchmark::fillOne(), fillOne(), i, Benchmark::isInRange(), match(), matchCandBench_, matchCharge_, reco::Candidate::phi(), reco::Candidate::pt(), and findQualityFiles::size.

Referenced by PFCandidateDQMAnalyzer::analyze().

                                                                                      {
  

  std::vector<int> matchIndices;
  PFB::match( candCollection, matchedCandCollection, matchIndices, 
              matchCharge_, dRMax_ );

  for (unsigned int i = 0; i < (candCollection).size(); i++) {
     const reco::Candidate& cand = candCollection[i];

    if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) continue;
    
    int iMatch = matchIndices[i];
    assert(iMatch< static_cast<int>(matchedCandCollection.size()));

    if( iMatch!=-1 ) {
      const reco::Candidate& matchedCand = matchedCandCollection[ iMatch ];
      if(!isInRange(matchedCand.pt(),matchedCand.eta(),matchedCand.phi() ) ) continue;
      float ptRes = (cand.pt() - matchedCand.pt())/matchedCand.pt();
      
      if (ptRes > maxVal) maxVal = ptRes;
      if (ptRes < minVal) minVal = ptRes;
 
      candBench_.fillOne(cand);
      matchCandBench_.fillOne(cand, matchedCand);
      if (createReferenceHistos_) fillOne(matchedCand);
    }
  }
}
void PFCandidateMonitor::fillOne ( const reco::Candidate cand)

Definition at line 136 of file PFCandidateMonitor.cc.

References createReferenceHistos_, reco::Candidate::eta(), eta_ref_, histogramBooked_, reco::Candidate::phi(), phi_ref_, reco::Candidate::pt(), and pt_ref_.

Referenced by fill().

                                                          {

  if (createReferenceHistos_ && histogramBooked_) {
 
    if (pt_ref_) pt_ref_->Fill(cand.pt());
    if (eta_ref_) eta_ref_->Fill(cand.eta() );
    if (phi_ref_) phi_ref_->Fill(cand.phi() );
  }
}
void PFCandidateMonitor::setDirectory ( TDirectory *  dir) [virtual]

set directory (to use in ROOT)

Reimplemented from Benchmark.

Definition at line 127 of file PFCandidateMonitor.cc.

References candBench_, matchCandBench_, and Benchmark::setDirectory().

void PFCandidateMonitor::setParameters ( const edm::ParameterSet parameterSet)

set the parameters accessing them from ParameterSet

Definition at line 39 of file PFCandidateMonitor.cc.

References candBench_, createReferenceHistos_, dRMax_, edm::ParameterSet::getParameter(), matchCandBench_, matchCharge_, Benchmark::mode_, Benchmark::setParameters(), and Benchmark::setRange().

                                                                            {

  dRMax_                 = parameterSet.getParameter<double>( "deltaRMax" );
  matchCharge_           = parameterSet.getParameter<bool>( "matchCharge" );
  mode_                  = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
  createReferenceHistos_ = parameterSet.getParameter<bool>( "CreateReferenceHistos" );

  
  setRange( parameterSet.getParameter<double>("ptMin"),
            parameterSet.getParameter<double>("ptMax"),
            parameterSet.getParameter<double>("etaMin"),
            parameterSet.getParameter<double>("etaMax"),
            parameterSet.getParameter<double>("phiMin"),
            parameterSet.getParameter<double>("phiMax") );

  candBench_.setParameters(mode_);
  matchCandBench_.setParameters(mode_);
}
void PFCandidateMonitor::setParameters ( float  dRMax,
bool  matchCharge,
Benchmark::Mode  mode,
float  ptmin,
float  ptmax,
float  etamin,
float  etamax,
float  phimin,
float  phimax,
bool  refHistoFlag 
)
void PFCandidateMonitor::setup ( void  )

book histograms

Definition at line 106 of file PFCandidateMonitor.cc.

References Benchmark::book1D(), candBench_, createReferenceHistos_, eta_ref_, histogramBooked_, Benchmark::PhaseSpace::m, Benchmark::PhaseSpace::M, matchCandBench_, Benchmark::PhaseSpace::n, phi_ref_, pt_ref_, MatchCandidateBenchmark::setup(), and CandidateBenchmark::setup().

Referenced by PFCandidateDQMAnalyzer::beginJob().

                               {
  candBench_.setup();
  matchCandBench_.setup();

  if (createReferenceHistos_ && !histogramBooked_) {
    PhaseSpace ptPS(100,0,100);
    PhaseSpace phiPS(360, -3.1416, 3.1416);
    PhaseSpace etaPS(100, -5,5);
    
    pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
    
    eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta", etaPS.n, etaPS.m, etaPS.M);
    
    phi_ref_ = book1D("phi_ref_", "phi_ref_;#phi", phiPS.n, phiPS.m, phiPS.M);

    histogramBooked_ = true;
  }
}
void PFCandidateMonitor::setup ( const edm::ParameterSet parameterSet)

book histograms

Definition at line 76 of file PFCandidateMonitor.cc.

References Benchmark::book1D(), candBench_, createReferenceHistos_, eta_ref_, edm::ParameterSet::getParameter(), histogramBooked_, matchCandBench_, phi_ref_, pt_ref_, MatchCandidateBenchmark::setup(), and CandidateBenchmark::setup().

                                                                   {
  candBench_.setup(parameterSet);
  matchCandBench_.setup(parameterSet);

  if (createReferenceHistos_ && !histogramBooked_) {
    edm::ParameterSet ptPS  = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
    edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
    edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
    if (ptPS.getParameter<bool>("switchOn")) {
      pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.getParameter<int32_t>("nBin"), 
                   ptPS.getParameter<double>("xMin"),
                   ptPS.getParameter<double>("xMax"));
    } 
    
    if (etaPS.getParameter<bool>("switchOn")) {
      eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta_ref_", etaPS.getParameter<int32_t>("nBin"), 
                    etaPS.getParameter<double>("xMin"),
                    etaPS.getParameter<double>("xMax"));
    }
    if (phiPS.getParameter<bool>("switchOn")) {
      phi_ref_ = book1D("phi_ref_", "phi_ref_;#phref_i", phiPS.getParameter<int32_t>("nBin"), 
                    phiPS.getParameter<double>("xMin"),
                    phiPS.getParameter<double>("xMax"));
    }
    histogramBooked_ = true;   
  }
}

Member Data Documentation

Definition at line 49 of file PFCandidateMonitor.h.

Referenced by fill(), setDirectory(), setParameters(), and setup().

Definition at line 58 of file PFCandidateMonitor.h.

Referenced by fill(), fillOne(), PFCandidateMonitor(), setParameters(), and setup().

float PFCandidateMonitor::dRMax_ [protected]

Definition at line 56 of file PFCandidateMonitor.h.

Referenced by fill(), and setParameters().

TH1F* PFCandidateMonitor::eta_ref_ [protected]

Definition at line 53 of file PFCandidateMonitor.h.

Referenced by fillOne(), PFCandidateMonitor(), and setup().

Definition at line 59 of file PFCandidateMonitor.h.

Referenced by fillOne(), PFCandidateMonitor(), and setup().

Definition at line 50 of file PFCandidateMonitor.h.

Referenced by fill(), setDirectory(), setParameters(), and setup().

Definition at line 57 of file PFCandidateMonitor.h.

Referenced by fill(), and setParameters().

TH1F* PFCandidateMonitor::phi_ref_ [protected]

Definition at line 54 of file PFCandidateMonitor.h.

Referenced by fillOne(), PFCandidateMonitor(), and setup().

TH1F* PFCandidateMonitor::pt_ref_ [protected]

Definition at line 52 of file PFCandidateMonitor.h.

Referenced by fillOne(), PFCandidateMonitor(), and setup().