CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ticl::TracksterLinkingbySuperClusteringMustache Class Reference

#include <TracksterLinkingbySuperClusteringMustache.h>

Inheritance diagram for ticl::TracksterLinkingbySuperClusteringMustache:
ticl::TracksterLinkingAlgoBase

Public Member Functions

void initialize (const HGCalDDDConstants *hgcons, const hgcal::RecHitTools rhtools, const edm::ESHandle< MagneticField > bfieldH, const edm::ESHandle< Propagator > propH) override
 
void linkTracksters (const Inputs &input, std::vector< Trackster > &resultTracksters, std::vector< std::vector< unsigned int >> &linkedResultTracksters, std::vector< std::vector< unsigned int >> &linkedTracksterIdToInputTracksterId) override
 
virtual void setEvent (edm::Event &iEvent, edm::EventSetup const &iEventSetup) override
 
 TracksterLinkingbySuperClusteringMustache (const edm::ParameterSet &ps, edm::ConsumesCollector iC, cms::Ort::ONNXRuntime const *onnxRuntime=nullptr)
 
 ~TracksterLinkingbySuperClusteringMustache () override
 
- Public Member Functions inherited from ticl::TracksterLinkingAlgoBase
 TracksterLinkingAlgoBase (const edm::ParameterSet &conf, edm::ConsumesCollector, cms::Ort::ONNXRuntime const *onnxRuntime=nullptr)
 
virtual ~TracksterLinkingAlgoBase ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &iDesc)
 
- Static Public Member Functions inherited from ticl::TracksterLinkingAlgoBase
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Member Functions

bool trackstersPassesPIDCut (const Trackster &ts) const
 

Private Attributes

float candidateEnergyThreshold_
 
edm::ESGetToken< EcalMustacheSCParameters, EcalMustacheSCParametersRcdecalMustacheSCParametersToken_
 
edm::ESGetToken< EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcdecalSCDynamicDPhiParametersToken_
 
bool filterByTracksterPID_
 
const EcalMustacheSCParametersmustacheSCParams_
 
float PIDThreshold_
 
const EcalSCDynamicDPhiParametersscDynamicDPhiParams_
 
float seedThresholdPt_
 
std::vector< int > tracksterPIDCategoriesToFilter_
 

Additional Inherited Members

- Protected Attributes inherited from ticl::TracksterLinkingAlgoBase
int algo_verbosity_
 
cms::Ort::ONNXRuntime const * onnxRuntime_
 

Detailed Description

Definition at line 29 of file TracksterLinkingbySuperClusteringMustache.h.

Constructor & Destructor Documentation

◆ TracksterLinkingbySuperClusteringMustache()

TracksterLinkingbySuperClusteringMustache::TracksterLinkingbySuperClusteringMustache ( const edm::ParameterSet ps,
edm::ConsumesCollector  iC,
cms::Ort::ONNXRuntime const *  onnxRuntime = nullptr 
)

Definition at line 17 of file TracksterLinkingbySuperClusteringMustache.cc.

19  : TracksterLinkingAlgoBase(ps, iC, onnxRuntime),
22  seedThresholdPt_(ps.getParameter<double>("seedThresholdPt")),
23  candidateEnergyThreshold_(ps.getParameter<double>("candidateEnergyThreshold")),
24  filterByTracksterPID_(ps.getParameter<bool>("filterByTracksterPID")),
25  tracksterPIDCategoriesToFilter_(ps.getParameter<std::vector<int>>("tracksterPIDCategoriesToFilter")),
26  PIDThreshold_(ps.getParameter<double>("PIDThreshold")) {}
edm::ESGetToken< EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcd > ecalSCDynamicDPhiParametersToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< EcalMustacheSCParameters, EcalMustacheSCParametersRcd > ecalMustacheSCParametersToken_
TracksterLinkingAlgoBase(const edm::ParameterSet &conf, edm::ConsumesCollector, cms::Ort::ONNXRuntime const *onnxRuntime=nullptr)

◆ ~TracksterLinkingbySuperClusteringMustache()

ticl::TracksterLinkingbySuperClusteringMustache::~TracksterLinkingbySuperClusteringMustache ( )
inlineoverride

Definition at line 34 of file TracksterLinkingbySuperClusteringMustache.h.

34 {}

Member Function Documentation

◆ fillPSetDescription()

void TracksterLinkingbySuperClusteringMustache::fillPSetDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 124 of file TracksterLinkingbySuperClusteringMustache.cc.

References submitPVResolutionJobs::desc, ticl::Trackster::electron, ticl::TracksterLinkingAlgoBase::fillPSetDescription(), and ticl::Trackster::photon.

124  {
125  TracksterLinkingAlgoBase::fillPSetDescription(desc); // adds algo_verbosity
126  desc.add<double>("seedThresholdPt", 1.)
127  ->setComment("Minimum transverse energy of trackster to be considered as seed of a supercluster");
128  desc.add<double>("candidateEnergyThreshold", 0.15)
129  ->setComment("Minimum energy of trackster to be considered as candidate for superclustering");
130  desc.add<bool>("filterByTracksterPID", true)->setComment("Filter tracksters before superclustering by PID score");
131  desc.add<std::vector<int>>(
132  "tracksterPIDCategoriesToFilter",
133  {static_cast<int>(Trackster::ParticleType::photon), static_cast<int>(Trackster::ParticleType::electron)})
134  ->setComment("List of PID particle types (ticl::Trackster::ParticleType enum) to consider for PID filtering");
135  desc.add<double>("PIDThreshold", 0.8)->setComment("PID score threshold");
136 }
static void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ initialize()

void TracksterLinkingbySuperClusteringMustache::initialize ( const HGCalDDDConstants hgcons,
const hgcal::RecHitTools  rhtools,
const edm::ESHandle< MagneticField bfieldH,
const edm::ESHandle< Propagator propH 
)
overridevirtual

Implements ticl::TracksterLinkingAlgoBase.

Definition at line 28 of file TracksterLinkingbySuperClusteringMustache.cc.

31  {}

◆ linkTracksters()

void TracksterLinkingbySuperClusteringMustache::linkTracksters ( const Inputs input,
std::vector< Trackster > &  resultTracksters,
std::vector< std::vector< unsigned int >> &  outputSuperclusters,
std::vector< std::vector< unsigned int >> &  linkedTracksterIdToInputTracksterId 
)
overridevirtual

resultTracksters : superclusters as tracksters (ie merging of tracksters that have been superclustered together) outputSuperclusters : same as linkedTracksterIdToInputTracksterId. Probably should use only one of the two. linkedTracksterIdToInputTracksterId : maps indices from resultTracksters back into input tracksters. resultTracksters[i] has seed input.tracksters[linkedTracksterIdToInputTracksterId[i][0]], linked with tracksters input.tracksters[linkedTracksterIdToInputTracksterId[i][1..N]]

Implements ticl::TracksterLinkingAlgoBase.

Definition at line 55 of file TracksterLinkingbySuperClusteringMustache.cc.

References ticl::Trackster::barycenter(), candidateEnergyThreshold_, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, reco::MustacheKernel::inDynamicDPhiWindow(), reco::MustacheKernel::inMustache(), input, mustacheSCParams_, ticl::Trackster::raw_energy(), ticl::Trackster::raw_pt(), scDynamicDPhiParams_, seedThresholdPt_, and trackstersPassesPIDCut().

59  {
60  // For now we use all input tracksters for superclustering. At some point there might be a filter here for EM tracksters (electromagnetic identification with DNN ?)
61  auto const& inputTracksters = input.tracksters;
62  const unsigned int tracksterCount = inputTracksters.size();
63 
64  /* Sorting tracksters by decreasing order of pT (out-of-place sort).
65  inputTracksters[trackstersIndicesPt[0]], ..., inputTracksters[trackstersIndicesPt[N]] makes a list of tracksters sorted by decreasing pT
66  Indices into this pT sorted collection will have the suffix _pt. Thus inputTracksters[index] and inputTracksters[trackstersIndicesPt[index_pt]] are correct
67  */
68  std::vector<unsigned int> trackstersIndicesPt(inputTracksters.size());
69  std::iota(trackstersIndicesPt.begin(), trackstersIndicesPt.end(), 0);
70  std::stable_sort(
71  trackstersIndicesPt.begin(), trackstersIndicesPt.end(), [&inputTracksters](unsigned int i1, unsigned int i2) {
72  return inputTracksters[i1].raw_pt() > inputTracksters[i2].raw_pt();
73  });
74 
75  std::vector<bool> tracksterMask_pt(tracksterCount, false); // Mask for already superclustered tracksters
76  // We also mask tracksters that don't pass the PID cut
77  for (unsigned int ts_idx_pt = 0; ts_idx_pt < tracksterCount; ts_idx_pt++) {
78  tracksterMask_pt[ts_idx_pt] = !trackstersPassesPIDCut(inputTracksters[trackstersIndicesPt[ts_idx_pt]]);
79  }
80 
81  for (unsigned int ts_seed_idx_pt = 0; ts_seed_idx_pt < tracksterCount; ts_seed_idx_pt++) {
82  Trackster const& ts_seed = inputTracksters[trackstersIndicesPt[ts_seed_idx_pt]];
83  if (ts_seed.raw_pt() <= seedThresholdPt_)
84  break; // Look only at seed tracksters passing threshold, take advantage of pt sorting for fast exit
85  if (tracksterMask_pt[ts_seed_idx_pt])
86  continue; // Trackster does not pass PID cut
87 
88  outputSuperclusters.emplace_back(std::initializer_list<unsigned int>{trackstersIndicesPt[ts_seed_idx_pt]});
89  resultTracksters.emplace_back(inputTracksters[trackstersIndicesPt[ts_seed_idx_pt]]);
90  linkedTracksterIdToInputTracksterId.emplace_back(
91  std::initializer_list<unsigned int>{trackstersIndicesPt[ts_seed_idx_pt]});
92 
93  for (unsigned int ts_cand_idx_pt = ts_seed_idx_pt + 1; ts_cand_idx_pt < tracksterCount; ts_cand_idx_pt++) {
94  if (tracksterMask_pt[ts_cand_idx_pt])
95  continue; // Trackster is either already superclustered or did not pass PID cut
96 
97  Trackster const& ts_cand = inputTracksters[trackstersIndicesPt[ts_cand_idx_pt]];
98 
99  if (ts_cand.raw_energy() <= candidateEnergyThreshold_)
100  continue;
101 
103  ts_seed.barycenter().eta(),
104  ts_seed.barycenter().phi(),
105  ts_cand.raw_energy(),
106  ts_cand.barycenter().eta(),
107  ts_cand.barycenter().phi());
108 
110  ts_seed.barycenter().eta(),
111  ts_seed.barycenter().phi(),
112  ts_cand.raw_energy(),
113  ts_cand.barycenter().eta(),
114  ts_cand.barycenter().phi())) {
115  outputSuperclusters.back().push_back(trackstersIndicesPt[ts_cand_idx_pt]);
116  resultTracksters.back().mergeTracksters(ts_cand);
117  linkedTracksterIdToInputTracksterId.back().push_back(trackstersIndicesPt[ts_cand_idx_pt]);
118  tracksterMask_pt[ts_cand_idx_pt] = true;
119  }
120  }
121  }
122 }
const float raw_pt() const
Definition: Trackster.h:156
const Vector & barycenter() const
Definition: Trackster.h:159
bool inMustache(const EcalMustacheSCParameters *params, const float maxEta, const float maxPhi, const float ClustE, const float ClusEta, const float ClusPhi)
Definition: Mustache.cc:8
static std::string const input
Definition: EdmProvDump.cc:50
const float raw_energy() const
Definition: Trackster.h:154
bool inDynamicDPhiWindow(const EcalSCDynamicDPhiParameters *params, const float seedEta, const float seedPhi, const float ClustE, const float ClusEta, const float clusPhi)
Definition: Mustache.cc:64

◆ setEvent()

void TracksterLinkingbySuperClusteringMustache::setEvent ( edm::Event iEvent,
edm::EventSetup const &  iEventSetup 
)
overridevirtual

Reimplemented from ticl::TracksterLinkingAlgoBase.

Definition at line 33 of file TracksterLinkingbySuperClusteringMustache.cc.

References ecalMustacheSCParametersToken_, ecalSCDynamicDPhiParametersToken_, edm::EventSetup::getData(), mustacheSCParams_, and scDynamicDPhiParams_.

33  {
34  mustacheSCParams_ = &iEventSetup.getData(ecalMustacheSCParametersToken_);
36 }
edm::ESGetToken< EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcd > ecalSCDynamicDPhiParametersToken_
edm::ESGetToken< EcalMustacheSCParameters, EcalMustacheSCParametersRcd > ecalMustacheSCParametersToken_

◆ trackstersPassesPIDCut()

bool TracksterLinkingbySuperClusteringMustache::trackstersPassesPIDCut ( const Trackster ts) const
private

Member Data Documentation

◆ candidateEnergyThreshold_

float ticl::TracksterLinkingbySuperClusteringMustache::candidateEnergyThreshold_
private

Definition at line 57 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by linkTracksters().

◆ ecalMustacheSCParametersToken_

edm::ESGetToken<EcalMustacheSCParameters, EcalMustacheSCParametersRcd> ticl::TracksterLinkingbySuperClusteringMustache::ecalMustacheSCParametersToken_
private

Definition at line 51 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by setEvent().

◆ ecalSCDynamicDPhiParametersToken_

edm::ESGetToken<EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcd> ticl::TracksterLinkingbySuperClusteringMustache::ecalSCDynamicDPhiParametersToken_
private

Definition at line 52 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by setEvent().

◆ filterByTracksterPID_

bool ticl::TracksterLinkingbySuperClusteringMustache::filterByTracksterPID_
private

Definition at line 58 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by trackstersPassesPIDCut().

◆ mustacheSCParams_

const EcalMustacheSCParameters* ticl::TracksterLinkingbySuperClusteringMustache::mustacheSCParams_
private

Definition at line 53 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by linkTracksters(), and setEvent().

◆ PIDThreshold_

float ticl::TracksterLinkingbySuperClusteringMustache::PIDThreshold_
private

Definition at line 60 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by trackstersPassesPIDCut().

◆ scDynamicDPhiParams_

const EcalSCDynamicDPhiParameters* ticl::TracksterLinkingbySuperClusteringMustache::scDynamicDPhiParams_
private

Definition at line 54 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by linkTracksters(), and setEvent().

◆ seedThresholdPt_

float ticl::TracksterLinkingbySuperClusteringMustache::seedThresholdPt_
private

Definition at line 56 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by linkTracksters().

◆ tracksterPIDCategoriesToFilter_

std::vector<int> ticl::TracksterLinkingbySuperClusteringMustache::tracksterPIDCategoriesToFilter_
private

Definition at line 59 of file TracksterLinkingbySuperClusteringMustache.h.

Referenced by trackstersPassesPIDCut().