CMS 3D CMS Logo

SubJetAlgorithm.cc
Go to the documentation of this file.
1 #include <memory>
2 
6 #include "fastjet/ClusterSequenceArea.hh"
7 
8 using namespace std;
9 using namespace edm;
10 
11 void SubJetAlgorithm::set_zcut(double z) { zcut_ = z; }
12 
13 void SubJetAlgorithm::set_rcut_factor(double r) { rcut_factor_ = r; }
14 
15 // Run the algorithm
16 // ------------------
17 void SubJetAlgorithm::run(const vector<fastjet::PseudoJet>& cell_particles, vector<CompoundPseudoJet>& hardjetsOutput) {
18  //for actual jet clustering, either the pruned or the original version is used.
19  //For the pruned version, a new jet definition using the PrunedRecombPlugin is required:
20  fastjet::FastPrunePlugin PRplugin(*fjJetDefinition_, *fjJetDefinition_, zcut_, rcut_factor_);
21  fastjet::JetDefinition pjetdef(&PRplugin);
22 
23  // cluster the jets with the jet definition jetDef:
24  // run algorithm
25  std::shared_ptr<fastjet::ClusterSequence> fjClusterSeq;
26  if (!doAreaFastjet_) {
27  fjClusterSeq = std::make_shared<fastjet::ClusterSequence>(cell_particles, pjetdef);
28  } else if (voronoiRfact_ <= 0) {
29  fjClusterSeq = std::shared_ptr<fastjet::ClusterSequence>(
30  new fastjet::ClusterSequenceActiveArea(cell_particles, pjetdef, *fjActiveArea_));
31  } else {
32  fjClusterSeq = std::shared_ptr<fastjet::ClusterSequence>(
33  new fastjet::ClusterSequenceVoronoiArea(cell_particles, pjetdef, fastjet::VoronoiAreaSpec(voronoiRfact_)));
34  }
35 
36  vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq->inclusive_jets(ptMin_);
37 
38  // These will store the indices of each subjet that
39  // are present in each jet
40  vector<vector<int> > indices(inclusiveJets.size());
41  // Loop over inclusive jets, attempt to find substructure
42  vector<fastjet::PseudoJet>::iterator jetIt = inclusiveJets.begin();
43  for (; jetIt != inclusiveJets.end(); ++jetIt) {
44  //decompose into requested number of subjets:
45  vector<fastjet::PseudoJet> subjets = fjClusterSeq->exclusive_subjets(*jetIt, nSubjets_);
46  //create the subjets objects to put into the "output" objects
47  vector<CompoundPseudoSubJet> subjetsOutput;
48  std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = subjets.begin(), itSubJet = itSubJetBegin,
49  itSubJetEnd = subjets.end();
50  for (; itSubJet != itSubJetEnd; ++itSubJet) {
51  // Get the transient subjet constituents from fastjet
52  vector<fastjet::PseudoJet> subjetFastjetConstituents = fjClusterSeq->constituents(*itSubJet);
53  // Get the indices of the constituents:
54  vector<int> constituents;
55  vector<fastjet::PseudoJet>::const_iterator fastSubIt = subjetFastjetConstituents.begin(),
56  transConstEnd = subjetFastjetConstituents.end();
57  for (; fastSubIt != transConstEnd; ++fastSubIt) {
58  if (fastSubIt->user_index() >= 0) {
59  constituents.push_back(fastSubIt->user_index());
60  }
61  }
62 
63  double subJetArea =
64  (doAreaFastjet_) ? dynamic_cast<fastjet::ClusterSequenceActiveArea&>(*fjClusterSeq).area(*itSubJet) : 0.0;
65 
66  // Make a CompoundPseudoSubJet object to hold this subjet and the indices of its constituents
67  subjetsOutput.push_back(CompoundPseudoSubJet(*itSubJet, subJetArea, constituents));
68  }
69 
70  double fatJetArea =
71  (doAreaFastjet_) ? dynamic_cast<fastjet::ClusterSequenceActiveArea&>(*fjClusterSeq).area(*jetIt) : 0.0;
72 
73  // Make a CompoundPseudoJet object to hold this hard jet, and the subjets that make it up
74  hardjetsOutput.push_back(CompoundPseudoJet(*jetIt, fatJetArea, subjetsOutput));
75  }
76 }
void set_rcut_factor(double r)
void set_zcut(double z)
CompoundPseudoJet holds an association of fastjet::PseudoJets that represent a "hard" top jet with su...
HLT enums.
void run(const std::vector< fastjet::PseudoJet > &cell_particles, std::vector< CompoundPseudoJet > &hardjetsOutput)
Find the ProtoJets from the collection of input Candidates.