CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQMOffline/PFTau/interface/PFJetMonitor.h

Go to the documentation of this file.
00001 #ifndef DQMOffline_PFTau_PFJetMonitor_h
00002 #define DQMOffline_PFTau_PFJetMonitor_h
00003 
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "DQMOffline/PFTau/interface/Benchmark.h"
00006 #include "DQMOffline/PFTau/interface/CandidateBenchmark.h"
00007 #include "DQMOffline/PFTau/interface/MatchCandidateBenchmark.h"
00008 
00009 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00010 
00011 #include <vector>
00012 class PFJetMonitor : public Benchmark {
00013 
00014  public:
00015 
00016   
00017   PFJetMonitor( float dRMax = 0.3, bool matchCharge = true, 
00018                 Benchmark::Mode mode=Benchmark::DEFAULT); 
00019   
00020   virtual ~PFJetMonitor();
00021   
00023   void setParameters(float dRMax, bool matchCharge, 
00024                      Benchmark::Mode mode,float ptmin, 
00025                      float ptmax, float etamin, float etamax, 
00026                      float phimin, float phimax, bool fracHistoFlag=true);
00027 
00029   void setParameters( const edm::ParameterSet& parameterSet);
00030   
00032   void setDirectory(TDirectory* dir);
00033 
00035   void setup();
00036   
00038   void setup(const edm::ParameterSet & parameterSet);
00039 
00041   template< class T, class C>
00042   void fill(const T& jetCollection,
00043             const C& matchedJetCollection, float& minVal, float& maxVal);
00044 
00045   void fillOne(const reco::Jet& jet,
00046                const reco::Jet& matchedJet);
00047 
00048  protected:
00049   CandidateBenchmark      candBench_;
00050   MatchCandidateBenchmark matchCandBench_;
00051 
00052   TH2F*  delta_frac_VS_frac_muon_;
00053   TH2F*  delta_frac_VS_frac_photon_;
00054   TH2F*  delta_frac_VS_frac_electron_;
00055   TH2F*  delta_frac_VS_frac_charged_hadron_;
00056   TH2F*  delta_frac_VS_frac_neutral_hadron_;
00057 
00058   float dRMax_;
00059   bool  matchCharge_;
00060   bool  createPFractionHistos_;
00061   bool  histogramBooked_;
00062 
00063 };
00064 
00065 #include "DQMOffline/PFTau/interface/Matchers.h"
00066 template< class T, class C>
00067 void PFJetMonitor::fill(const T& jetCollection,
00068                         const C& matchedJetCollection, float& minVal, float& maxVal) {
00069   
00070 
00071   std::vector<int> matchIndices;
00072   PFB::match( jetCollection, matchedJetCollection, matchIndices, 
00073               matchCharge_, dRMax_ );
00074 
00075   for (unsigned int i = 0; i < (jetCollection).size(); i++) {
00076     const reco::Jet& jet = jetCollection[i];
00077 
00078     if( !isInRange(jet.pt(), jet.eta(), jet.phi() ) ) continue;
00079     
00080     int iMatch = matchIndices[i];
00081     assert(iMatch< static_cast<int>(matchedJetCollection.size()));
00082 
00083     if( iMatch!=-1 ) {
00084       const reco::Candidate& matchedJet = matchedJetCollection[ iMatch ];
00085       if(!isInRange(matchedJet.pt(),matchedJet.eta(),matchedJet.phi() ) ) continue;
00086       float ptRes = (jet.pt() - matchedJet.pt())/matchedJet.pt();
00087       
00088       if (ptRes > maxVal) maxVal = ptRes;
00089       if (ptRes < minVal) minVal = ptRes;
00090  
00091       candBench_.fillOne(jet);
00092       matchCandBench_.fillOne(jet, matchedJetCollection[ iMatch ]);
00093       if (createPFractionHistos_ && histogramBooked_) fillOne(jet, matchedJetCollection[ iMatch ]);
00094     }
00095   }
00096 }
00097 #endif