CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQMOffline/PFTau/src/PFJetMonitor.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/PFJetMonitor.h"
00007 
00008 #include <TROOT.h>
00009 #include <TFile.h>
00010 #include <TH1.h>
00011 #include <TH2.h>
00012 //
00013 // -- Constructor
00014 //
00015 PFJetMonitor::PFJetMonitor( 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   delta_frac_VS_frac_muon_           = 0;
00025   delta_frac_VS_frac_photon_         = 0;
00026   delta_frac_VS_frac_electron_       = 0;
00027   delta_frac_VS_frac_charged_hadron_ = 0;
00028   delta_frac_VS_frac_neutral_hadron_ = 0;
00029   
00030   createPFractionHistos_ = false;
00031   histogramBooked_ = false;
00032 }
00033 //
00034 // -- Destructor
00035 //
00036 PFJetMonitor::~PFJetMonitor() {}
00037 
00038 //
00039 // -- Set Parameters accessing them from ParameterSet
00040 //
00041 void PFJetMonitor::setParameters( const edm::ParameterSet & parameterSet) {
00042 
00043   dRMax_                 = parameterSet.getParameter<double>( "deltaRMax" );
00044   matchCharge_           = parameterSet.getParameter<bool>( "matchCharge" );
00045   mode_                  = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
00046   createPFractionHistos_ = parameterSet.getParameter<bool>( "CreatePFractionHistos" );
00047 
00048   
00049   setRange( parameterSet.getParameter<double>("ptMin"),
00050             parameterSet.getParameter<double>("ptMax"),
00051             parameterSet.getParameter<double>("etaMin"),
00052             parameterSet.getParameter<double>("etaMax"),
00053             parameterSet.getParameter<double>("phiMin"),
00054             parameterSet.getParameter<double>("phiMax") );
00055 
00056   candBench_.setParameters(mode_);
00057   matchCandBench_.setParameters(mode_);
00058 }
00059 //
00060 // -- Set Parameters 
00061 //
00062 void PFJetMonitor::setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode,
00063                     float ptmin, float ptmax, float etamin, float etamax, 
00064                                  float phimin, float phimax, bool fracHistoFlag) {
00065   dRMax_                 = dRMax;
00066   matchCharge_           = matchCharge;
00067   mode_                  = mode;
00068   createPFractionHistos_ = fracHistoFlag;
00069   
00070   setRange( ptmin, ptmax, etamin, etamax, phimin, phimax );
00071 
00072   candBench_.setParameters(mode_);
00073   matchCandBench_.setParameters(mode_);
00074 
00075 }
00076 //
00077 // -- Create histograms accessing parameters from ParameterSet
00078 //
00079 void PFJetMonitor::setup(const edm::ParameterSet & parameterSet) {
00080   candBench_.setup(parameterSet);
00081   matchCandBench_.setup(parameterSet);
00082 
00083   if (createPFractionHistos_ && !histogramBooked_) {
00084     delta_frac_VS_frac_muon_ = book2D("delta_frac_VS_frac_muon_", 
00085  "#DeltaFraction_Vs_Fraction(muon)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00086     delta_frac_VS_frac_photon_ = book2D("delta_frac_VS_frac_photon_", 
00087  "#DeltaFraction_Vs_Fraction(photon)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00088     delta_frac_VS_frac_electron_ = book2D("delta_frac_VS_frac_electron_", 
00089  "#DeltaFraction_Vs_Fraction(electron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00090     delta_frac_VS_frac_charged_hadron_ = book2D("delta_frac_VS_frac_charged_hadron_", 
00091  "#DeltaFraction_Vs_Fraction(charged hadron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00092     delta_frac_VS_frac_neutral_hadron_ = book2D("delta_frac_VS_frac_neutral_hadron_", 
00093  "#DeltaFraction_Vs_Fraction(neutral hadron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00094   
00095     histogramBooked_ = true;
00096   }
00097 
00098 }
00099 //
00100 // -- Create histograms using local parameters
00101 //
00102 void PFJetMonitor::setup() {
00103   candBench_.setup();
00104   matchCandBench_.setup();
00105 
00106   if (createPFractionHistos_ && !histogramBooked_) {
00107     delta_frac_VS_frac_muon_ = book2D("delta_frac_VS_frac_muon_", 
00108  "#DeltaFraction_Vs_Fraction(muon)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00109     delta_frac_VS_frac_photon_ = book2D("delta_frac_VS_frac_photon_", 
00110  "#DeltaFraction_Vs_Fraction(photon)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00111     delta_frac_VS_frac_electron_ = book2D("delta_frac_VS_frac_electron_", 
00112  "#DeltaFraction_Vs_Fraction(electron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00113     delta_frac_VS_frac_charged_hadron_ = book2D("delta_frac_VS_frac_charged_hadron_", 
00114  "#DeltaFraction_Vs_Fraction(charged hadron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00115     delta_frac_VS_frac_neutral_hadron_ = book2D("delta_frac_VS_frac_neutral_hadron_", 
00116  "#DeltaFraction_Vs_Fraction(neutral hadron)", 100, 0.0, 1.0, 100, -1.0, 1.0);
00117 
00118     histogramBooked_ = true;
00119   }
00120 
00121 }
00122 //
00123 // -- Set directory to book histograms using ROOT
00124 //
00125 
00126 void PFJetMonitor::setDirectory(TDirectory* dir) {
00127   Benchmark::setDirectory(dir);
00128 
00129   candBench_.setDirectory(dir);
00130   matchCandBench_.setDirectory(dir);
00131 }
00132 //
00133 // -- fill histograms for a given Jet pair
00134 //
00135 void PFJetMonitor::fillOne(const reco::Jet& jet,
00136                         const reco::Jet& matchedJet) {
00137   const reco::PFJet* pfJet = dynamic_cast<const reco::PFJet*>(&jet);
00138   const reco::PFJet* pfMatchedJet = dynamic_cast<const reco::PFJet*>(&matchedJet);
00139   if (pfJet && pfMatchedJet && createPFractionHistos_) {
00140     float frac_muon = -99.9;
00141     float frac_elec = -99.9; 
00142     float frac_phot = -99.9;
00143     float frac_ch_had = -99.9;
00144     float frac_neu_had = -99.9;
00145  
00146     if (pfMatchedJet->muonMultiplicity() > 0) frac_muon = (pfJet->muonMultiplicity() - pfMatchedJet->muonMultiplicity())*1.0/pfMatchedJet->muonMultiplicity(); 
00147     if (pfMatchedJet->chargedHadronMultiplicity() > 0) frac_ch_had = (pfJet->chargedHadronMultiplicity() - pfMatchedJet->chargedHadronMultiplicity())*1.0/pfMatchedJet->chargedHadronMultiplicity(); 
00148     if (pfMatchedJet->neutralHadronMultiplicity() > 0) frac_neu_had = (pfJet->neutralHadronMultiplicity() - pfMatchedJet->neutralHadronMultiplicity())*1.0/pfMatchedJet->neutralHadronMultiplicity(); 
00149     if (pfMatchedJet->photonMultiplicity() > 0) frac_phot = (pfJet->photonMultiplicity() - pfMatchedJet->photonMultiplicity())*1.0/pfMatchedJet->photonMultiplicity(); 
00150     if (pfMatchedJet->electronMultiplicity() > 0) frac_elec = (pfJet->electronMultiplicity() - pfMatchedJet->electronMultiplicity())*1.0/pfMatchedJet->electronMultiplicity(); 
00151 
00152     delta_frac_VS_frac_muon_->Fill(frac_muon);
00153     delta_frac_VS_frac_electron_->Fill(frac_elec);
00154     delta_frac_VS_frac_photon_->Fill(frac_phot);
00155     delta_frac_VS_frac_charged_hadron_->Fill(frac_ch_had);
00156     delta_frac_VS_frac_neutral_hadron_->Fill(frac_neu_had);
00157   }
00158 }
00159