CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "DataFormats/JetReco/interface/Jet.h"
00002 #include "DataFormats/JetReco/interface/PFJet.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "DQMOffline/PFTau/interface/Matchers.h"
00005 
00006 #include "DQMOffline/PFTau/interface/PFCandidateMonitor.h"
00007 
00008 #include <TROOT.h>
00009 #include <TFile.h>
00010 #include <TH1.h>
00011 #include <TH2.h>
00012 //
00013 // -- Constructor
00014 //
00015 PFCandidateMonitor::PFCandidateMonitor( float dRMax, bool matchCharge, Benchmark::Mode mode) : 
00016   Benchmark(mode), 
00017   candBench_(mode), 
00018   matchCandBench_(mode), 
00019   dRMax_(dRMax), 
00020   matchCharge_(matchCharge) {
00021   
00022   setRange( 0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
00023   
00024   pt_ref_   = 0;
00025   eta_ref_  = 0;
00026   phi_ref_  = 0;
00027   
00028   createReferenceHistos_ = false;
00029   histogramBooked_ = false;
00030 }  
00031 //
00032 // -- Destructor
00033 //
00034 PFCandidateMonitor::~PFCandidateMonitor() {}
00035 
00036 //
00037 // -- Set Parameters accessing them from ParameterSet
00038 //
00039 void PFCandidateMonitor::setParameters( const edm::ParameterSet & parameterSet) {
00040 
00041   dRMax_                 = parameterSet.getParameter<double>( "deltaRMax" );
00042   matchCharge_           = parameterSet.getParameter<bool>( "matchCharge" );
00043   mode_                  = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
00044   createReferenceHistos_ = parameterSet.getParameter<bool>( "CreateReferenceHistos" );
00045 
00046   
00047   setRange( parameterSet.getParameter<double>("ptMin"),
00048             parameterSet.getParameter<double>("ptMax"),
00049             parameterSet.getParameter<double>("etaMin"),
00050             parameterSet.getParameter<double>("etaMax"),
00051             parameterSet.getParameter<double>("phiMin"),
00052             parameterSet.getParameter<double>("phiMax") );
00053 
00054   candBench_.setParameters(mode_);
00055   matchCandBench_.setParameters(mode_);
00056 }
00057 //
00058 // -- Set Parameters 
00059 //
00060 void PFCandidateMonitor::setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode,
00061                                  float ptmin, float ptmax, float etamin, float etamax, 
00062                                  float phimin, float phimax, bool refHistoFlag) {
00063   dRMax_                 = dRMax;
00064   matchCharge_           = matchCharge;
00065   mode_                  = mode;
00066   createReferenceHistos_ = refHistoFlag;
00067   
00068   setRange( ptmin, ptmax, etamin, etamax, phimin, phimax );
00069 
00070   candBench_.setParameters(mode_);
00071   matchCandBench_.setParameters(mode_);
00072 }
00073 //
00074 // -- Create histograms accessing parameters from ParameterSet
00075 //
00076 void PFCandidateMonitor::setup(const edm::ParameterSet & parameterSet) {
00077   candBench_.setup(parameterSet);
00078   matchCandBench_.setup(parameterSet);
00079 
00080   if (createReferenceHistos_ && !histogramBooked_) {
00081     edm::ParameterSet ptPS  = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
00082     edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
00083     edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
00084     if (ptPS.getParameter<bool>("switchOn")) {
00085       pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.getParameter<int32_t>("nBin"), 
00086                    ptPS.getParameter<double>("xMin"),
00087                    ptPS.getParameter<double>("xMax"));
00088     } 
00089     
00090     if (etaPS.getParameter<bool>("switchOn")) {
00091       eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta_ref_", etaPS.getParameter<int32_t>("nBin"), 
00092                     etaPS.getParameter<double>("xMin"),
00093                     etaPS.getParameter<double>("xMax"));
00094     }
00095     if (phiPS.getParameter<bool>("switchOn")) {
00096       phi_ref_ = book1D("phi_ref_", "phi_ref_;#phref_i", phiPS.getParameter<int32_t>("nBin"), 
00097                     phiPS.getParameter<double>("xMin"),
00098                     phiPS.getParameter<double>("xMax"));
00099     }
00100     histogramBooked_ = true;   
00101   }
00102 }
00103 //
00104 // -- Create histograms using local parameters
00105 //
00106 void PFCandidateMonitor::setup() {
00107   candBench_.setup();
00108   matchCandBench_.setup();
00109 
00110   if (createReferenceHistos_ && !histogramBooked_) {
00111     PhaseSpace ptPS(100,0,100);
00112     PhaseSpace phiPS(360, -3.1416, 3.1416);
00113     PhaseSpace etaPS(100, -5,5);
00114     
00115     pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
00116     
00117     eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta", etaPS.n, etaPS.m, etaPS.M);
00118     
00119     phi_ref_ = book1D("phi_ref_", "phi_ref_;#phi", phiPS.n, phiPS.m, phiPS.M);
00120 
00121     histogramBooked_ = true;
00122   }
00123 }
00124 //
00125 // -- Set directory to book histograms using ROOT
00126 //
00127 void PFCandidateMonitor::setDirectory(TDirectory* dir) {
00128   Benchmark::setDirectory(dir);
00129 
00130   candBench_.setDirectory(dir);
00131   matchCandBench_.setDirectory(dir);
00132 }
00133 //
00134 // -- fill histograms for a given Jet pair
00135 //
00136 void PFCandidateMonitor::fillOne(const reco::Candidate& cand) {
00137 
00138   if (createReferenceHistos_ && histogramBooked_) {
00139  
00140     if (pt_ref_) pt_ref_->Fill(cand.pt());
00141     if (eta_ref_) eta_ref_->Fill(cand.eta() );
00142     if (phi_ref_) phi_ref_->Fill(cand.phi() );
00143   }
00144 }
00145