CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef DQMOffline_PFTau_PFCandidateMonitor_h
00002 #define DQMOffline_PFTau_PFCandidateMonitor_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/Candidate/interface/CandidateFwd.h"
00010 #include "DataFormats/Candidate/interface/Candidate.h"
00011 
00012 #include <vector>
00013 class PFCandidateMonitor : public Benchmark {
00014 
00015  public:
00016 
00017   PFCandidateMonitor( float dRMax = 0.3,
00018                       bool matchCharge = true, 
00019                       Benchmark::Mode mode=Benchmark::DEFAULT); 
00020 
00021   virtual ~PFCandidateMonitor();
00022   
00024    void setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode,
00025                      float ptmin, float ptmax, float etamin, float etamax,
00026                      float phimin, float phimax, bool refHistoFlag);
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& candidateCollection,
00043             const C& matchedCandCollection, float& minVal, float& maxVal);
00044 
00045 
00046   void fillOne(const reco::Candidate& cand);
00047 
00048  protected:
00049   CandidateBenchmark      candBench_;
00050   MatchCandidateBenchmark matchCandBench_;
00051 
00052   TH1F*  pt_ref_;
00053   TH1F*  eta_ref_;
00054   TH1F*  phi_ref_;
00055 
00056   float dRMax_;
00057   bool  matchCharge_;
00058   bool  createReferenceHistos_;
00059   bool  histogramBooked_;
00060 
00061 };
00062 
00063 #include "DQMOffline/PFTau/interface/Matchers.h"
00064 template< class T, class C>
00065 void PFCandidateMonitor::fill(const T& candCollection,
00066                         const C& matchedCandCollection, float& minVal, float& maxVal) {
00067   
00068 
00069   std::vector<int> matchIndices;
00070   PFB::match( candCollection, matchedCandCollection, matchIndices, 
00071               matchCharge_, dRMax_ );
00072 
00073   for (unsigned int i = 0; i < (candCollection).size(); i++) {
00074      const reco::Candidate& cand = candCollection[i];
00075 
00076     if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) continue;
00077     
00078     int iMatch = matchIndices[i];
00079     assert(iMatch< static_cast<int>(matchedCandCollection.size()));
00080 
00081     if( iMatch!=-1 ) {
00082       const reco::Candidate& matchedCand = matchedCandCollection[ iMatch ];
00083       if(!isInRange(matchedCand.pt(),matchedCand.eta(),matchedCand.phi() ) ) continue;
00084       float ptRes = (cand.pt() - matchedCand.pt())/matchedCand.pt();
00085       
00086       if (ptRes > maxVal) maxVal = ptRes;
00087       if (ptRes < minVal) minVal = ptRes;
00088  
00089       candBench_.fillOne(cand);
00090       matchCandBench_.fillOne(cand, matchedCand);
00091       if (createReferenceHistos_) fillOne(matchedCand);
00092     }
00093   }
00094 }
00095 #endif