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
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
00035
00036 PFJetMonitor::~PFJetMonitor() {}
00037
00038
00039
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
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
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
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
00124
00125
00126 void PFJetMonitor::setDirectory(TDirectory* dir) {
00127 Benchmark::setDirectory(dir);
00128
00129 candBench_.setDirectory(dir);
00130 matchCandBench_.setDirectory(dir);
00131 }
00132
00133
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 del_frac_muon = -99.9;
00141 float del_frac_elec = -99.9;
00142 float del_frac_phot = -99.9;
00143 float del_frac_ch_had = -99.9;
00144 float del_frac_neu_had = -99.9;
00145
00146 int mult_muon = pfMatchedJet->muonMultiplicity();
00147 int mult_elec = pfMatchedJet->electronMultiplicity();
00148 int mult_phot = pfMatchedJet->photonMultiplicity();
00149 int mult_ch_had = pfMatchedJet->chargedHadronMultiplicity();
00150 int mult_neu_had = pfMatchedJet->neutralHadronMultiplicity();
00151
00152 if (mult_muon > 0) del_frac_muon = (pfJet->muonMultiplicity() - mult_muon)*1.0/mult_muon;
00153 if (mult_elec > 0) del_frac_elec = (pfJet->electronMultiplicity() - mult_elec)*1.0/mult_elec;
00154 if (mult_phot > 0) del_frac_phot = (pfJet->photonMultiplicity() - mult_phot)*1.0/mult_phot;
00155 if (mult_ch_had > 0) del_frac_ch_had = (pfJet->chargedHadronMultiplicity() - mult_ch_had)*1.0/mult_ch_had;
00156 if (mult_neu_had > 0) del_frac_neu_had = (pfJet->neutralHadronMultiplicity() - mult_neu_had)*1.0/mult_neu_had;
00157
00158 delta_frac_VS_frac_muon_->Fill(mult_muon, del_frac_muon);
00159 delta_frac_VS_frac_electron_->Fill(mult_elec, del_frac_elec);
00160 delta_frac_VS_frac_photon_->Fill(mult_phot, del_frac_phot);
00161 delta_frac_VS_frac_charged_hadron_->Fill(mult_ch_had, del_frac_ch_had);
00162 delta_frac_VS_frac_neutral_hadron_->Fill(mult_neu_had, del_frac_neu_had);
00163 }
00164 }
00165