CMS 3D CMS Logo

TracksterLinkingbyFastJet.cc
Go to the documentation of this file.
2 #include "fastjet/ClusterSequence.hh"
5 
6 using namespace ticl;
7 
9  const Inputs& input,
10  std::vector<Trackster>& resultTracksters,
11  std::vector<std::vector<unsigned int>>& linkedResultTracksters,
12  std::vector<std::vector<unsigned int>>& linkedTracksterIdToInputTracksterId) {
13  // Create jets of tracksters using FastJet
14  std::vector<fastjet::PseudoJet> fjInputs;
15  for (size_t i = 0; i < input.tracksters.size(); ++i) {
16  // Convert Trackster information to PseudoJet
17  fastjet::PseudoJet pj(input.tracksters[i].barycenter().x(),
18  input.tracksters[i].barycenter().y(),
19  input.tracksters[i].barycenter().z(),
20  input.tracksters[i].raw_energy());
21  pj.set_user_index(i);
22  fjInputs.push_back(pj);
23  }
24 
25  // Cluster tracksters into jets using FastJet
26  fastjet::ClusterSequence sequence(fjInputs, fastjet::JetDefinition(algorithm_, radius_));
27  auto jets = fastjet::sorted_by_pt(sequence.inclusive_jets(0));
28  linkedTracksterIdToInputTracksterId.resize(jets.size());
29  // Link tracksters based on which ones are components of the same jet
30  for (unsigned int i = 0; i < jets.size(); ++i) {
31  const auto& jet = jets[i];
32 
33  std::vector<unsigned int> linkedTracksters;
34  Trackster outTrackster;
35  if (!jet.constituents().empty()) {
36  // Check if a trackster is a component of the current jet
37  for (const auto& constituent : jet.constituents()) {
38  auto tracksterIndex = constituent.user_index();
39  linkedTracksterIdToInputTracksterId[i].push_back(tracksterIndex);
40  outTrackster.mergeTracksters(input.tracksters[tracksterIndex]);
41  }
42  linkedTracksters.push_back(resultTracksters.size());
43  resultTracksters.push_back(outTrackster);
44  // Store the linked tracksters
45  linkedResultTracksters.push_back(linkedTracksters);
46  }
47  }
48 }
static std::string const input
Definition: EdmProvDump.cc:50
void mergeTracksters(const Trackster &other)
Definition: Trackster.h:81
void linkTracksters(const Inputs &input, std::vector< Trackster > &resultTracksters, std::vector< std::vector< unsigned int >> &linkedResultTracksters, std::vector< std::vector< unsigned int >> &linkedTracksterIdToInputTracksterId) override
Definition: Common.h:10