Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:44

0001 #ifndef RecoParticleFlow_Benchmark_BenchmarkManager_h
0002 #define RecoParticleFlow_Benchmark_BenchmarkManager_h
0003 
0004 #include "DQMOffline/PFTau/interface/Benchmark.h"
0005 #include "DQMOffline/PFTau/interface/CandidateBenchmark.h"
0006 #include "DQMOffline/PFTau/interface/MatchCandidateBenchmark.h"
0007 #include "DQMOffline/PFTau/interface/PFCandidateBenchmark.h"
0008 
0009 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0010 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0011 
0012 #include <vector>
0013 
0014 /// \brief A benchmark managing several benchmarks
0015 ///
0016 /// The benchmarks are filled only for the PFCandidates matched to
0017 /// a candidate in the matching collection within the limits in delta R.
0018 /// The parameters for this benchmark are:
0019 /// - the maximum delta R for matching
0020 /// - the minimum pT of the reconstructed PFCandidate. Low pT PFCandidates have
0021 /// to be removed, as they lead to a lot of hits in the histograms with delta
0022 /// p_T just a bit larger than p_T_gen
0023 /// - a bool, specifying if the charge of the candidates should be used in the
0024 /// matching.
0025 /// - the benchmark mode, driving the size of the histograms.
0026 class PFCandidateManager : public Benchmark {
0027 public:
0028   PFCandidateManager(float dRMax = 0.3, bool matchCharge = true, Benchmark::Mode mode = Benchmark::DEFAULT)
0029       : Benchmark(mode),
0030         candBench_(mode),
0031         pfCandBench_(mode),
0032         matchCandBench_(mode),
0033         dRMax_(dRMax),
0034         matchCharge_(matchCharge) {}
0035 
0036   ~PFCandidateManager() override;
0037 
0038   /// set the benchmark parameters
0039   void setParameters(float dRMax = 0.3, bool matchCharge = true, Benchmark::Mode mode = Benchmark::DEFAULT);
0040 
0041   /// set directory (to use in ROOT)
0042   void setDirectory(TDirectory *dir) override;
0043 
0044   /// book histograms
0045   void setup(DQMStore::IBooker &b);
0046 
0047   /// fill histograms with all particle
0048   template <class C>
0049   void fill(const reco::PFCandidateCollection &candCollection, const C &matchedCandCollection);
0050 
0051 protected:
0052   CandidateBenchmark candBench_;
0053   PFCandidateBenchmark pfCandBench_;
0054   MatchCandidateBenchmark matchCandBench_;
0055 
0056   float dRMax_;
0057   bool matchCharge_;
0058 };
0059 
0060 #include "DQMOffline/PFTau/interface/Matchers.h"
0061 
0062 template <class C>
0063 void PFCandidateManager::fill(const reco::PFCandidateCollection &candCollection, const C &matchCandCollection) {
0064   std::vector<int> matchIndices;
0065   PFB::match(candCollection, matchCandCollection, matchIndices, matchCharge_, dRMax_);
0066 
0067   for (unsigned int i = 0; i < candCollection.size(); i++) {
0068     const reco::PFCandidate &cand = candCollection[i];
0069 
0070     if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
0071       continue;
0072 
0073     int iMatch = matchIndices[i];
0074 
0075     assert(iMatch < static_cast<int>(matchCandCollection.size()));
0076 
0077     // COLIN how to handle efficiency plots?
0078 
0079     // filling the histograms in CandidateBenchmark only in case
0080     // of a matching.
0081     if (iMatch != -1) {
0082       candBench_.fillOne(cand);
0083       pfCandBench_.fillOne(cand);
0084       matchCandBench_.fillOne(cand, matchCandCollection[iMatch]);
0085     }
0086   }
0087 }
0088 
0089 #endif