CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DQMOffline/PFTau/src/CandidateBenchmark.cc

Go to the documentation of this file.
00001 #include "DQMOffline/PFTau/interface/CandidateBenchmark.h"
00002 
00003 #include "DataFormats/Candidate/interface/Candidate.h"
00004 
00005 
00006 #include <TROOT.h>
00007 #include <TFile.h>
00008 #include <TH1.h>
00009 #include <TH2.h>
00010 
00011 
00012 using namespace std;
00013 
00014 
00015 CandidateBenchmark::CandidateBenchmark(Mode mode) : Benchmark(mode) {
00016   pt_     = 0; 
00017   eta_    = 0; 
00018   phi_    = 0; 
00019   charge_ = 0;
00020   pdgId_  = 0;
00021 
00022   histogramBooked_ = false;
00023  
00024 }
00025 
00026 CandidateBenchmark::~CandidateBenchmark() {}
00027 
00028 
00029 void CandidateBenchmark::setup() {
00030 
00031   if (!histogramBooked_) {
00032     PhaseSpace ptPS(100,0,100);
00033     PhaseSpace phiPS(360, -3.1416, 3.1416);
00034     PhaseSpace etaPS(100, -5,5);
00035     switch(mode_) {
00036     case DQMOFFLINE:
00037     default:
00038       ptPS = PhaseSpace(50, 0, 100);
00039       phiPS.n = 50;
00040       etaPS.n = 20;
00041       break;
00042     }
00043     
00044     pt_ = book1D("pt_", "pt_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
00045     
00046     eta_ = book1D("eta_", "eta_;#eta", etaPS.n, etaPS.m, etaPS.M);
00047     
00048     phi_ = book1D("phi_", "phi_;#phi", phiPS.n, phiPS.m, phiPS.M);
00049 
00050     charge_ = book1D("charge_", "charge_;charge", 3,-1.5,1.5);
00051 
00052     histogramBooked_ = true;
00053   }
00054 }
00055 
00056 void CandidateBenchmark::setup(const edm::ParameterSet& parameterSet) {
00057   if (!histogramBooked_)  {
00058     edm::ParameterSet ptPS  = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
00059     edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
00060     edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
00061     edm::ParameterSet chPS = parameterSet.getParameter<edm::ParameterSet>("ChargeHistoParameter");
00062     
00063     if (ptPS.getParameter<bool>("switchOn")) {
00064       pt_ = book1D("pt_", "pt_;p_{T} (GeV)", ptPS.getParameter<int32_t>("nBin"), 
00065                    ptPS.getParameter<double>("xMin"),
00066                    ptPS.getParameter<double>("xMax"));
00067     } 
00068     
00069     if (etaPS.getParameter<bool>("switchOn")) {
00070       eta_ = book1D("eta_", "eta_;#eta", etaPS.getParameter<int32_t>("nBin"), 
00071                     etaPS.getParameter<double>("xMin"),
00072                     etaPS.getParameter<double>("xMax"));
00073     }
00074     if (phiPS.getParameter<bool>("switchOn")) {
00075       phi_ = book1D("phi_", "phi_;#phi", phiPS.getParameter<int32_t>("nBin"), 
00076                     phiPS.getParameter<double>("xMin"),
00077                     phiPS.getParameter<double>("xMax"));
00078     }
00079     if (chPS.getParameter<bool>("switchOn")) {
00080       charge_ = book1D("charge_","charge_;charge",chPS.getParameter<int32_t>("nBin"),
00081                        chPS.getParameter<double>("xMin"),
00082                        chPS.getParameter<double>("xMax"));
00083     }   
00084     histogramBooked_ = true;
00085   }
00086 }
00087 
00088 void CandidateBenchmark::fillOne(const reco::Candidate& cand) {
00089 
00090   if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) return;
00091 
00092   if (histogramBooked_) {
00093     if (pt_) pt_->Fill( cand.pt() );
00094     if (eta_) eta_->Fill( cand.eta() );
00095     if (phi_) phi_->Fill( cand.phi() );
00096     if (charge_) charge_->Fill( cand.charge() );
00097   }
00098 }