CMS 3D CMS Logo

ReclusterJets.cc
Go to the documentation of this file.
1 #include <memory>
2 
5 #include "fastjet/tools/Pruner.hh"
6 
7 using namespace std;
8 
9 //using namespace std;
10 using namespace fastjet;
11 
12 namespace heppy {
13 
14  ReclusterJets::ReclusterJets(const std::vector<LorentzVector> &objects, double ktpower, double rparam)
15  : ktpower_(ktpower), rparam_(rparam) {
16  // define jet inputs
17  fjInputs_.clear();
18  int index = 0;
19  for (const LorentzVector &o : objects) {
20  fastjet::PseudoJet j(o.Px(), o.Py(), o.Pz(), o.E());
21  j.set_user_index(index);
22  index++; // in case we want to know which piece ended where
23  fjInputs_.push_back(j);
24  }
25 
26  // choose a jet definition
27  fastjet::JetDefinition jet_def;
28 
29  // prepare jet def
30  if (ktpower_ == 1.0) {
31  jet_def = JetDefinition(kt_algorithm, rparam_);
32  } else if (ktpower_ == 0.0) {
33  jet_def = JetDefinition(cambridge_algorithm, rparam_);
34  } else if (ktpower_ == -1.0) {
35  jet_def = JetDefinition(antikt_algorithm, rparam_);
36  } else {
37  throw cms::Exception("InvalidArgument", "Unsupported ktpower value");
38  }
39 
40  // print out some infos
41  // cout << "Clustering with " << jet_def.description() << endl;
43  // define jet clustering sequence
44  fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(fjInputs_, jet_def);
45  }
46 
47  std::vector<math::XYZTLorentzVector> ReclusterJets::makeP4s(const std::vector<fastjet::PseudoJet> &jets) {
48  std::vector<math::XYZTLorentzVector> JetObjectsAll;
49  for (const fastjet::PseudoJet &pj : jets) {
50  JetObjectsAll.push_back(LorentzVector(pj.px(), pj.py(), pj.pz(), pj.e()));
51  }
52  return JetObjectsAll;
53  }
54  std::vector<math::XYZTLorentzVector> ReclusterJets::getGrouping(double ptMin) {
55  // recluster jet
56  inclusiveJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(ptMin));
57  // return
58  return makeP4s(inclusiveJets_);
59  }
60 
61  std::vector<math::XYZTLorentzVector> ReclusterJets::getGroupingExclusive(double dcut) {
62  // recluster jet
63  exclusiveJets_ = fastjet::sorted_by_pt(fjClusterSeq_->exclusive_jets(dcut));
64  // return
65  return makeP4s(exclusiveJets_);
66  }
67 
68  std::vector<math::XYZTLorentzVector> ReclusterJets::getGroupingExclusive(int njets) {
69  // recluster jet
70  exclusiveJets_ = fastjet::sorted_by_pt(fjClusterSeq_->exclusive_jets(njets));
71  // return
72  return makeP4s(exclusiveJets_);
73  }
74 
76  // cluster everything first
77  exclusiveJets_ = fastjet::sorted_by_pt(fjClusterSeq_->exclusive_jets(1));
78  // get pruned exclusive
79  return getPrunedSubjetExclusive(0, zcut, rcutFactor);
80  }
81 
83  double zcut,
84  double rcutFactor) {
85  if (isubjet >= exclusiveJets_.size()) {
86  throw cms::Exception("InvalidArgument", "getPrunedSubjetExclusive called for non-existing exclusive subjet");
87  }
88  return getPruned(exclusiveJets_[isubjet], zcut, rcutFactor);
89  }
91  double zcut,
92  double rcutFactor) {
93  if (isubjet >= inclusiveJets_.size()) {
94  throw cms::Exception("InvalidArgument", "getPrunedSubjetInclusive called for non-existing inclusive subjet");
95  }
96  return getPruned(inclusiveJets_[isubjet], zcut, rcutFactor);
97  }
98 
99  math::XYZTLorentzVector ReclusterJets::getPruned(const fastjet::PseudoJet &jet, double zcut, double rcutFactor) {
100  // create pruner
101  fastjet::Pruner pruner(fastjet::cambridge_algorithm, zcut, rcutFactor);
102  // Prune the jet
103  fastjet::PseudoJet pruned_jet = pruner(jet);
104  return LorentzVector(pruned_jet.px(), pruned_jet.py(), pruned_jet.pz(), pruned_jet.e());
105  }
106 
107 } // namespace heppy
heppy::ReclusterJets::LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: ReclusterJets.h:21
fastjet
Definition: BackgroundEstimator.h:8
objects
Definition: __init__.py:1
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
HLT_2018_cff.zcut
zcut
Definition: HLT_2018_cff.py:7345
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
heppy::ReclusterJets::fjInputs_
std::vector< fastjet::PseudoJet > fjInputs_
Definition: ReclusterJets.h:51
heppy::ReclusterJets::getGrouping
std::vector< LorentzVector > getGrouping(double ptMin=0.0)
get grouping (inclusive jets)
Definition: ReclusterJets.cc:54
ReclusterJets.h
heppy::ReclusterJets::exclusiveJets_
std::vector< fastjet::PseudoJet > exclusiveJets_
Definition: ReclusterJets.h:60
heppy::ReclusterJets::fjClusterSeq_
ClusterSequencePtr fjClusterSeq_
Definition: ReclusterJets.h:58
heppy
TAKEN FROM http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/Utilities/src/PdfWeig...
Definition: AlphaT.h:16
fwrapper::jet_def
JetDefinition jet_def
Definition: fastjetfortran_madfks.cc:44
heppy::ReclusterJets::inclusiveJets_
std::vector< fastjet::PseudoJet > inclusiveJets_
Definition: ReclusterJets.h:59
heppy::ReclusterJets::rparam_
double rparam_
Definition: ReclusterJets.h:54
heppy::ReclusterJets::getPruned
LorentzVector getPruned(double zcut, double rcutFactor)
get pruned 4-vector
Definition: ReclusterJets.cc:75
std
Definition: JetResolutionObject.h:76
BTaggingMonitoring_cff.njets
njets
Definition: BTaggingMonitoring_cff.py:10
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:246
heppy::ReclusterJets::getGroupingExclusive
std::vector< LorentzVector > getGroupingExclusive(int njets)
get grouping (exclusive jets, until n are left)
Definition: ReclusterJets.cc:68
Exception.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
heppy::ReclusterJets::makeP4s
std::vector< LorentzVector > makeP4s(const std::vector< fastjet::PseudoJet > &jets)
Definition: ReclusterJets.cc:47
heppy::ReclusterJets::getPrunedSubjetExclusive
LorentzVector getPrunedSubjetExclusive(unsigned int isubjet, double zcut, double rcutFactor)
get pruned 4-vector for a given subject (must be called after getGroupingExclusive)
Definition: ReclusterJets.cc:82
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
heppy::ReclusterJets::ktpower_
double ktpower_
Definition: ReclusterJets.h:53
heppy::ReclusterJets::getPrunedSubjetInclusive
LorentzVector getPrunedSubjetInclusive(unsigned int isubjet, double zcut, double rcutFactor)
get pruned 4-vector for a given subject (must be called after getGroupingInclusive)
Definition: ReclusterJets.cc:90