CMS 3D CMS Logo

PFJetMonitor.h
Go to the documentation of this file.
1 #ifndef DQMOffline_PFTau_PFJetMonitor_h
2 #define DQMOffline_PFTau_PFJetMonitor_h
3 
8 
10 
11 #include <vector>
12 #include <numeric> // std::iota
13 #include <algorithm> // std::sort
14 
15 #include <TH1.h> //needed by the deltaR->Fill() call
16 
17 class PFJetMonitor : public Benchmark {
18 public:
20 
21  ~PFJetMonitor() override;
22 
25 
27  void setDirectory(TDirectory *dir) override;
28 
30  void setup(DQMStore::IBooker &b);
32 
34  template <class T, class C>
35  void fill(const T &candidateCollection,
36  const C &matchedCandCollection,
37  float &minVal,
38  float &maxVal,
39  float &jetpT,
41 
42  void fillOne(const reco::Jet &jet, const reco::Jet &matchedJet);
43 
44 protected:
47 
53 
54  TH1F *deltaR_;
55  float dRMax_;
60 };
61 
63 
64 template <class T, class C>
66  const C &matchedJetCollection,
67  float &minVal,
68  float &maxVal,
69  float &jetpT,
71  std::vector<int> matchIndices;
72  PFB::match(jetCollection, matchedJetCollection, matchIndices, matchCharge_, dRMax_);
73  // now matchIndices[i] stores the j-th closest matched jet
74 
75  std::vector<uint32_t> sorted_pt_indices(jetCollection.size());
76  std::iota(std::begin(sorted_pt_indices), std::end(sorted_pt_indices), 0);
77  // Sort the vector of indices using the pt() as ordering variable
78  std::sort(std::begin(sorted_pt_indices), std::end(sorted_pt_indices), [&](uint32_t i, uint32_t j) {
79  return jetCollection[i].pt() < jetCollection[j].pt();
80  });
81  for (uint32_t i = 0; i < sorted_pt_indices.size(); ++i) {
82  // If we want only the 2 pt-leading jets, now that they are orderd, simply
83  // check if the index is either in the first or second location of the
84  // sorted indices: if not, bail out.
85  if (onlyTwoJets_ && i > 1)
86  break;
87 
88  const reco::Jet &jet = jetCollection[i];
89 
90  if (!isInRange(jet.pt(), jet.eta(), jet.phi()))
91  continue;
92 
93  int iMatch = matchIndices[i];
94  assert(iMatch < static_cast<int>(matchedJetCollection.size()));
95 
96  if (iMatch != -1) {
97  const reco::Jet &matchedJet = matchedJetCollection[iMatch];
98  if (!isInRange(matchedJet.pt(), matchedJet.eta(), matchedJet.phi()))
99  continue;
100 
101  float ptRes = (jet.pt() - matchedJet.pt()) / matchedJet.pt();
102 
103  jetpT = jet.pt();
104  if (ptRes > maxVal)
105  maxVal = ptRes;
106  if (ptRes < minVal)
107  minVal = ptRes;
108 
109  candBench_.fillOne(jet); // fill pt eta phi and charge histos for MATCHED candidate jet
110  matchCandBench_.fillOne(jet, matchedJet, parameterSet); // fill delta_x_VS_y histos for matched couple
112  fillOne(jet, matchedJet); // book and fill delta_frac_VS_frac histos for matched couple
113  }
114 
115  for (unsigned j = 0; j < matchedJetCollection.size(); ++j) // for DeltaR spectrum
116  if (deltaR_)
117  deltaR_->Fill(reco::deltaR(jetCollection[i], matchedJetCollection[j]));
118  } // end loop on jetCollection
119 }
120 #endif
Benchmark
abstract base class
Definition: Benchmark.h:19
PFJetMonitor::delta_frac_VS_frac_neutral_hadron_
TH2F * delta_frac_VS_frac_neutral_hadron_
Definition: PFJetMonitor.h:52
mps_fire.i
i
Definition: mps_fire.py:428
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
Benchmark::isInRange
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
PFB::match
void match(const C &candCollection, const M &matchedCandCollection, std::vector< int > &matchIndices, bool matchCharge=false, float dRMax=-1)
Definition: Matchers.h:17
Matchers.h
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
cms::cuda::assert
assert(be >=bs)
BasicJetCollection.h
PFJetMonitor::histogramBooked_
bool histogramBooked_
Definition: PFJetMonitor.h:59
PFJetMonitor::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: PFJetMonitor.cc:119
CandidateBenchmark
To plot Candidate quantities.
Definition: CandidateBenchmark.h:10
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
MatchCandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
Definition: MatchCandidateBenchmark.cc:228
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
PFJetMonitor::dRMax_
float dRMax_
Definition: PFJetMonitor.h:55
pfCandidateManager_cfi.matchCharge
matchCharge
Definition: pfCandidateManager_cfi.py:15
PFJetMonitor::createPFractionHistos_
bool createPFractionHistos_
Definition: PFJetMonitor.h:58
PFJetMonitor::matchCharge_
bool matchCharge_
Definition: PFJetMonitor.h:57
mps_fire.end
end
Definition: mps_fire.py:242
MatchCandidateBenchmark
To plot Candidate quantities.
Definition: MatchCandidateBenchmark.h:13
CandidateBenchmark.h
MatchCandidateBenchmark.h
PFJetMonitor::fill
void fill(const T &candidateCollection, const C &matchedCandCollection, float &minVal, float &maxVal, float &jetpT, const edm::ParameterSet &parameterSet)
fill histograms with all particle
Definition: PFJetMonitor.h:65
PFJetMonitor::delta_frac_VS_frac_muon_
TH2F * delta_frac_VS_frac_muon_
Definition: PFJetMonitor.h:48
PFJetMonitor::setParameters
void setParameters(const edm::ParameterSet &parameterSet)
set the parameters accessing them from ParameterSet
Definition: PFJetMonitor.cc:39
jetfilter_cfi.jetCollection
jetCollection
Definition: jetfilter_cfi.py:4
b
double b
Definition: hdecay.h:118
Benchmark.h
PFJetMonitor::delta_frac_VS_frac_photon_
TH2F * delta_frac_VS_frac_photon_
Definition: PFJetMonitor.h:49
PFJetMonitor::setDirectory
void setDirectory(TDirectory *dir) override
set directory (to use in ROOT)
Definition: PFJetMonitor.cc:157
edm::ParameterSet
Definition: ParameterSet.h:47
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
Benchmark::Mode
Mode
Definition: Benchmark.h:32
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
PFJetMonitor
Definition: PFJetMonitor.h:17
PFJetMonitor::~PFJetMonitor
~PFJetMonitor() override
Definition: PFJetMonitor.cc:34
PFJetMonitor::candBench_
CandidateBenchmark candBench_
Definition: PFJetMonitor.h:45
CandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
Definition: CandidateBenchmark.cc:90
metBenchmark_cfi.dRMax
dRMax
Definition: metBenchmark_cfi.py:18
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
PFJetMonitor::fillOne
void fillOne(const reco::Jet &jet, const reco::Jet &matchedJet)
Definition: PFJetMonitor.cc:167
gen::C
C
Definition: PomwigHadronizer.cc:78
T
long double T
Definition: Basic3DVectorLD.h:48
metsig::jet
Definition: SignAlgoResolutions.h:47
PFJetMonitor::deltaR_
TH1F * deltaR_
Definition: PFJetMonitor.h:54
Benchmark::DEFAULT
Definition: Benchmark.h:32
PFJetMonitor::matchCandBench_
MatchCandidateBenchmark matchCandBench_
Definition: PFJetMonitor.h:46
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
dqm::implementation::IBooker
Definition: DQMStore.h:43
PFJetMonitor::onlyTwoJets_
bool onlyTwoJets_
Definition: PFJetMonitor.h:56
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFJetMonitor::delta_frac_VS_frac_charged_hadron_
TH2F * delta_frac_VS_frac_charged_hadron_
Definition: PFJetMonitor.h:51
PFJetMonitor::PFJetMonitor
PFJetMonitor(float dRMax=0.3, bool matchCharge=true, Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFJetMonitor.cc:15
PFJetMonitor::delta_frac_VS_frac_electron_
TH2F * delta_frac_VS_frac_electron_
Definition: PFJetMonitor.h:50
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23