CMS 3D CMS Logo

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

#include <TracksterLinkingbySkeletons.h>

Inheritance diagram for ticl::TracksterLinkingbySkeletons:
ticl::TracksterLinkingAlgoBase

Public Member Functions

bool areCompatible (const ticl::Trackster &myTrackster, const ticl::Trackster &otherTrackster, const std::array< ticl::Vector, 3 > &mySkeleton, const std::array< ticl::Vector, 3 > &otherSkeleton)
 
std::array< ticl::Vector, 3 > findSkeletonNodes (const ticl::Trackster &trackster, float lower_percentage, float upper_percentage, const std::vector< reco::CaloCluster > &layerClusters, const hgcal::RecHitTools &rhtools)
 
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
 
 TracksterLinkingbySkeletons (const edm::ParameterSet &conf, edm::ConsumesCollector iC, cms::Ort::ONNXRuntime const *onnxRuntime=nullptr)
 
 ~TracksterLinkingbySkeletons () override
 
- Public Member Functions inherited from ticl::TracksterLinkingAlgoBase
virtual void setEvent (edm::Event &iEvent, edm::EventSetup const &iEventSetup)
 
 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 Types

using Vector = ticl::Trackster::Vector
 

Private Member Functions

void buildLayers ()
 
void dumpLinksFound (std::vector< std::vector< unsigned >> &resultCollection, const char *label) const
 

Private Attributes

edm::ESHandle< MagneticFieldbfield_
 
std::vector< double > cylinder_radius_sqr_
 
float del_
 
float dot_prod_th_
 
std::unique_ptr< GeomDetfirstDisk_ [2]
 
const HGCalDDDConstantshgcons_
 
std::unique_ptr< GeomDetinterfaceDisk_ [2]
 
std::vector< double > max_distance_projective_sqr_
 
std::vector< double > max_distance_projective_sqr_closest_points_
 
std::vector< double > max_z_distance_closest_points_
 
std::vector< double > min_distance_z_
 
unsigned int min_num_lcs_
 
float min_trackster_energy_
 
float pca_quality_th_
 
edm::ESHandle< Propagatorpropagator_
 
hgcal::RecHitTools rhtools_
 
float timing_quality_threshold_
 

Additional Inherited Members

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

Detailed Description

Definition at line 24 of file TracksterLinkingbySkeletons.h.

Member Typedef Documentation

◆ Vector

Definition at line 69 of file TracksterLinkingbySkeletons.h.

Constructor & Destructor Documentation

◆ TracksterLinkingbySkeletons()

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

Definition at line 53 of file TracksterLinkingbySkeletons.cc.

56  : TracksterLinkingAlgoBase(conf, iC),
57  timing_quality_threshold_(conf.getParameter<double>("track_time_quality_threshold")),
58  del_(conf.getParameter<double>("wind")),
59  min_num_lcs_(conf.getParameter<unsigned int>("min_num_lcs")),
60  min_trackster_energy_(conf.getParameter<double>("min_trackster_energy")),
61  pca_quality_th_(conf.getParameter<double>("pca_quality_th")),
62  dot_prod_th_(conf.getParameter<double>("dot_prod_th")),
63  max_distance_projective_sqr_(conf.getParameter<std::vector<double>>("max_distance_projective_sqr")),
64  min_distance_z_(conf.getParameter<std::vector<double>>("min_distance_z")),
66  conf.getParameter<std::vector<double>>("max_distance_projective_sqr_closest_points")),
67  max_z_distance_closest_points_(conf.getParameter<std::vector<double>>("max_z_distance_closest_points")),
68  cylinder_radius_sqr_(conf.getParameter<std::vector<double>>("cylinder_radius_sqr"))
69 
70 {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< double > max_distance_projective_sqr_closest_points_
TracksterLinkingAlgoBase(const edm::ParameterSet &conf, edm::ConsumesCollector, cms::Ort::ONNXRuntime const *onnxRuntime=nullptr)

◆ ~TracksterLinkingbySkeletons()

ticl::TracksterLinkingbySkeletons::~TracksterLinkingbySkeletons ( )
inlineoverride

Definition at line 30 of file TracksterLinkingbySkeletons.h.

30 {}

Member Function Documentation

◆ areCompatible()

bool TracksterLinkingbySkeletons::areCompatible ( const ticl::Trackster myTrackster,
const ticl::Trackster otherTrackster,
const std::array< ticl::Vector, 3 > &  mySkeleton,
const std::array< ticl::Vector, 3 > &  otherSkeleton 
)

Definition at line 201 of file TracksterLinkingbySkeletons.cc.

References funct::abs(), cylinder_radius_sqr_, ztail::d, dot_prod_th_, hgcal::RecHitTools::getPositionLayer(), mps_fire::i, isInCylinder(), dqmiolumiharvest::j, hgcal::RecHitTools::lastLayerEE(), LogDebug, WZElectronSkims53X_cff::max, max_distance_projective_sqr_, max_distance_projective_sqr_closest_points_, max_z_distance_closest_points_, min_distance_z_, min_num_lcs_, min_trackster_energy_, pca_quality_th_, ticl::Trackster::raw_energy(), rhtools_, ticl::Trackster::vertices(), and beamSpotPI::Z.

Referenced by linkTracksters().

204  {
205  //do not start links from small/bad tracksters
206  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
207  if (!isGoodTrackster(myTrackster, mySkeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) {
208  LogDebug("TracksterLinkingbySkeletons") << "Inner Trackster with energy " << myTrackster.raw_energy() << " Num LCs "
209  << myTrackster.vertices().size() << " NOT GOOD " << std::endl;
210  return false;
211  } else {
212  LogDebug("TracksterLinkingbySkeletons") << "Inner Trackster wi energy " << myTrackster.raw_energy() << " Num LCs "
213  << myTrackster.vertices().size() << " IS GOOD " << std::endl;
214  float proj_distance = projective_distance(mySkeleton[1], otherSkeleton[1]);
215  auto isEE = mySkeleton[1].z() <= zVal_interface ? 0 : 1;
216  bool areAlignedInProjectiveSpace = proj_distance < max_distance_projective_sqr_[isEE];
217  LogDebug("TracksterLinkingbySkeletons")
218  << "\t Trying to compare with outer Trackster with energy " << otherTrackster.raw_energy() << " Num LCS "
219  << otherTrackster.vertices().size() << " Projective distance " << proj_distance << " areAlignedProjective "
220  << areAlignedInProjectiveSpace << " TH " << max_distance_projective_sqr_[isEE] << std::endl;
221  //check if otherTrackster is good
222  if (isGoodTrackster(otherTrackster, otherSkeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) {
223  // if both tracksters are good, then we can check the projective distance between the barycenters.
224  // if the barycenters are aligned, then we check that the two skeletons are aligned
225  if (areAlignedInProjectiveSpace) {
226  auto dotProdSkeletons =
227  ((mySkeleton[2] - mySkeleton[0]).Unit()).Dot((otherSkeleton[2] - otherSkeleton[0]).Unit());
228  bool alignedSkeletons = dotProdSkeletons > dot_prod_th_;
229  LogDebug("TracksterLinkingbySkeletons")
230  << "\t Outer Trackster is Good, checking for skeleton alignment " << alignedSkeletons << " dotProd "
231  << dotProdSkeletons << " Threshold " << dot_prod_th_ << std::endl;
232  if (alignedSkeletons)
233  LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl;
234  return alignedSkeletons;
235  } else {
236  // we measure the distance between the two closest nodes in the two skeletons
237  LogDebug("TracksterLinkingbySkeletons")
238  << "\t Outer Trackster is not aligned, check skeletons distances " << std::endl;
239  int myClosestPoint = -1;
240  int otherClosestPoint = -1;
241  float minDistance_z = std::numeric_limits<float>::max();
242  for (int i = 0; i < 3; i++) {
243  for (int j = 0; j < 3; j++) {
244  float dist_z = std::abs(mySkeleton[i].Z() - otherSkeleton[j].Z());
245  if (dist_z < minDistance_z) {
246  myClosestPoint = i;
247  otherClosestPoint = j;
248  minDistance_z = dist_z;
249  }
250  }
251  }
252  if (minDistance_z < min_distance_z_[isEE]) {
253  LogDebug("TracksterLinkingbySkeletons")
254  << "\t Trackster have distance in Z " << minDistance_z
255  << "Checking if they are aligned in projective space "
256  << projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) << " TH "
257  << max_distance_projective_sqr_[isEE] << std::endl;
258  if (projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) <
260  LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl;
261  }
262  return projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) <
264  } else {
265  LogDebug("TracksterLinkingbySkeletons") << "\t\t Not Linked Distance Z " << minDistance_z << std::endl;
266  return false;
267  }
268  }
269  } else {
270  LogDebug("TracksterLinkingbySkeletons")
271  << "\t Outer Trackster is NOT GOOD, check projective space alignment " << areAlignedInProjectiveSpace
272  << " proj_distance " << max_distance_projective_sqr_[isEE] << std::endl;
273  if (areAlignedInProjectiveSpace) {
274  LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl;
275  return true;
276  } else {
277  LogDebug("TracksterLinkingbySkeletons")
278  << "\t Not aligned in projective space, check distance between closest points in the two skeletons "
279  << std::endl;
280  // we measure the distance between the two closest nodes in the two skeletons
281  int myClosestPoint = -1;
282  int otherClosestPoint = -1;
283  float minDistance_z = std::numeric_limits<float>::max();
284  // we skip the innermost node of mySkeleton
285  for (int i = 1; i < 3; i++) {
286  for (int j = 0; j < 3; j++) {
287  float dist_z = std::abs(mySkeleton[i].Z() - otherSkeleton[j].Z());
288  if (dist_z < minDistance_z) {
289  myClosestPoint = i;
290  otherClosestPoint = j;
291  minDistance_z = dist_z;
292  }
293  }
294  }
295  float d = projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]);
296  LogDebug("TracksterLinkingbySkeletons")
297  << "\t\t Distance between closest points " << d << " TH " << 10.f << " Z Distance " << minDistance_z
298  << " TH " << max_distance_projective_sqr_closest_points_[isEE] << std::endl;
300  minDistance_z < max_z_distance_closest_points_[isEE]) {
301  LogDebug("TracksterLinkingbySkeletons") << "\t\t\t Linked! " << d << std::endl;
302  return true;
303  } else {
304  LogDebug("TracksterLinkingbySkeletons") << "Distance between closest point " << d << " Distance in z "
305  << max_z_distance_closest_points_[isEE] << std::endl;
306  bool isInCyl = isInCylinder(mySkeleton, otherSkeleton, cylinder_radius_sqr_[isEE]);
307  LogDebug("TracksterLinkingbySkeletons") << "Two Points are in Cylinder " << isInCyl << std::endl;
308  if (isInCyl) {
309  LogDebug("TracksterLinkingbySkeletons") << "\t\t\t Linked! " << d << std::endl;
310  }
311  return isInCyl;
312  }
313  }
314  }
315  }
316 }
const float raw_energy() const
Definition: Trackster.h:154
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
std::vector< double > max_distance_projective_sqr_closest_points_
std::vector< unsigned int > & vertices()
Definition: Trackster.h:57
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76
bool isInCylinder(const std::array< ticl::Vector, 3 > &mySkeleton, const std::array< ticl::Vector, 3 > &otherSkeleton, const float radius_sqr)
#define LogDebug(id)

◆ buildLayers()

void TracksterLinkingbySkeletons::buildLayers ( )
private

Definition at line 72 of file TracksterLinkingbySkeletons.cc.

References Disk::build(), firstDisk_, hgcal::RecHitTools::getPositionLayer(), hgcons_, interfaceDisk_, hgcal::RecHitTools::lastLayerEE(), HGCalDDDConstants::rangeR(), rhtools_, and HGCalDDDConstants::waferZ().

Referenced by initialize().

72  {
73  // build disks at HGCal front & EM-Had interface for track propagation
74 
75  float zVal = hgcons_->waferZ(1, true);
76  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
77 
78  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
79  std::pair<float, float> rMinMax_interface = hgcons_->rangeR(zVal_interface, true);
80 
81  for (int iSide = 0; iSide < 2; ++iSide) {
82  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
83  firstDisk_[iSide] =
84  std::make_unique<GeomDet>(Disk::build(Disk::PositionType(0, 0, zSide),
86  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
87  .get());
88 
89  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
90  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
91  Disk::build(Disk::PositionType(0, 0, zSide),
93  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
94  .get());
95  }
96 }
double waferZ(int layer, bool reco) const
static DiskPointer build(Args &&... args)
Definition: BoundDisk.h:38
std::unique_ptr< GeomDet > interfaceDisk_[2]
std::pair< double, double > rangeR(double z, bool reco) const
std::unique_ptr< GeomDet > firstDisk_[2]
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76

◆ dumpLinksFound()

void ticl::TracksterLinkingbySkeletons::dumpLinksFound ( std::vector< std::vector< unsigned >> &  resultCollection,
const char *  label 
) const
private

◆ fillPSetDescription()

static void ticl::TracksterLinkingbySkeletons::fillPSetDescription ( edm::ParameterSetDescription iDesc)
inlinestatic

Definition at line 53 of file TracksterLinkingbySkeletons.h.

References edm::ParameterSetDescription::add(), and ticl::TracksterLinkingAlgoBase::fillPSetDescription().

53  {
54  iDesc.add<double>("track_time_quality_threshold", 0.5);
55  iDesc.add<double>("wind", 0.036);
56  iDesc.add<unsigned int>("min_num_lcs", 7);
57  iDesc.add<double>("min_trackster_energy", 10.);
58  iDesc.add<double>("pca_quality_th", 0.85);
59  iDesc.add<double>("dot_prod_th", 0.97);
60  iDesc.add<std::vector<double>>("max_distance_projective_sqr", {60., 60.});
61  iDesc.add<std::vector<double>>("min_distance_z", {30., 30.});
62  iDesc.add<std::vector<double>>("max_distance_projective_sqr_closest_points", {60., 60.});
63  iDesc.add<std::vector<double>>("max_z_distance_closest_points", {35., 35.});
64  iDesc.add<std::vector<double>>("cylinder_radius_sqr", {9., 9.});
66  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ findSkeletonNodes()

std::array< ticl::Vector, 3 > TracksterLinkingbySkeletons::findSkeletonNodes ( const ticl::Trackster trackster,
float  lower_percentage,
float  upper_percentage,
const std::vector< reco::CaloCluster > &  layerClusters,
const hgcal::RecHitTools rhtools 
)

Definition at line 110 of file TracksterLinkingbySkeletons.cc.

References funct::abs(), ticl::Trackster::barycenter(), ticl::Trackster::eigenvectors(), dqmdumpme::first, hgcal::RecHitTools::getLayerWithOffset(), mps_fire::i, reco::helper::VirtualJetProducerHelper::intersection(), dqmiolumiharvest::j, hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, ticl::Trackster::raw_energy(), jetUpdater_cfi::sort, submitPVValidationJobs::t, findQualityFiles::v, AlignmentTracksFromVertexSelector_cfi::vertices, and ticl::Trackster::vertices().

Referenced by linkTracksters().

115  {
116  auto const &vertices = trackster.vertices();
117  auto const trackster_raw_energy = trackster.raw_energy();
118  // sort vertices by layerId
119  std::vector<unsigned int> sortedVertices(vertices);
120  std::sort(sortedVertices.begin(), sortedVertices.end(), [&layerClusters](unsigned int i, unsigned int j) {
121  return std::abs(layerClusters[i].z()) < std::abs(layerClusters[j].z());
122  });
123 
124  // now loop over sortedVertices and find the layerId that contains the lower_percentage of the energy
125  // and the layerId that contains the upper_percentage of the energy
126  float cumulativeEnergyFraction = 0.f;
127  int innerLayerId = rhtools.getLayerWithOffset(layerClusters[sortedVertices[0]].hitsAndFractions()[0].first);
128  float innerLayerZ = layerClusters[sortedVertices[0]].z();
129  int outerLayerId = rhtools.getLayerWithOffset(layerClusters[sortedVertices.back()].hitsAndFractions()[0].first);
130  float outerLayerZ = layerClusters[sortedVertices.back()].z();
131  bool foundInnerLayer = false;
132  bool foundOuterLayer = false;
133  for (auto const &v : sortedVertices) {
134  auto const &lc = layerClusters[v];
135  auto const &n_lay = rhtools.getLayerWithOffset(lc.hitsAndFractions()[0].first);
136  cumulativeEnergyFraction += lc.energy() / trackster_raw_energy;
137  if (cumulativeEnergyFraction >= lower_percentage and not foundInnerLayer) {
138  innerLayerId = n_lay;
139  innerLayerZ = lc.z();
140  foundInnerLayer = true;
141  }
142  if (cumulativeEnergyFraction >= upper_percentage and not foundOuterLayer) {
143  outerLayerId = n_lay;
144  outerLayerZ = lc.z();
145  foundOuterLayer = true;
146  }
147  }
148  std::array<ticl::Vector, 3> skeleton;
149  int minimumDistanceInLayers = 4;
150  if (outerLayerId - innerLayerId < minimumDistanceInLayers) {
151  skeleton = {{trackster.barycenter(), trackster.barycenter(), trackster.barycenter()}};
152  } else {
153  auto intersectLineWithSurface = [](float surfaceZ, const Vector &origin, const Vector &direction) -> Vector {
154  auto const t = (surfaceZ - origin.Z()) / direction.Z();
155  auto const iX = t * direction.X() + origin.X();
156  auto const iY = t * direction.Y() + origin.Y();
157  auto const iZ = surfaceZ;
158  const Vector intersection(iX, iY, iZ);
159  return intersection;
160  };
161 
162  auto const &t0_p1 = trackster.barycenter();
163  auto const t0_p0 = intersectLineWithSurface(innerLayerZ, t0_p1, trackster.eigenvectors(0));
164  auto const t0_p2 = intersectLineWithSurface(outerLayerZ, t0_p1, trackster.eigenvectors(0));
165  skeleton = {{t0_p0, t0_p1, t0_p2}};
166  std::sort(skeleton.begin(), skeleton.end(), [](Vector &v1, Vector &v2) { return v1.Z() < v2.Z(); });
167  }
168 
169  return skeleton;
170 }
const Vector & barycenter() const
Definition: Trackster.h:159
const std::array< Vector, 3 > & eigenvectors() const
Definition: Trackster.h:161
const float raw_energy() const
Definition: Trackster.h:154
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< unsigned int > & vertices()
Definition: Trackster.h:57
math::XYZVectorF Vector
Definition: Common.h:42
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:381

◆ initialize()

void TracksterLinkingbySkeletons::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 98 of file TracksterLinkingbySkeletons.cc.

References bfield_, buildLayers(), hgcons_, propagator_, and rhtools_.

101  {
102  hgcons_ = hgcons;
103  rhtools_ = rhtools;
104  buildLayers();
105 
106  bfield_ = bfieldH;
107  propagator_ = propH;
108 }
edm::ESHandle< MagneticField > bfield_

◆ linkTracksters()

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

Implements ticl::TracksterLinkingAlgoBase.

Definition at line 318 of file TracksterLinkingbySkeletons.cc.

References funct::abs(), areCompatible(), ticl::Trackster::barycenter(), AlCaHLTBitMon_QueryRunRegistry::comp, makeMuonMisalignmentScenario::components, del_, egammaIdentification::eta_max, egammaIdentification::eta_min, findSkeletonNodes(), TICLGraph::findSubComponents(), mps_fire::i, input, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, LogDebug, WZElectronSkims53X_cff::max, ticl::TileConstants::maxEta, ticl::Trackster::mergeTracksters(), SiStripPI::min, min_num_lcs_, min_trackster_energy_, ticl::TileConstants::minEta, create_idmaps::n, ticl::TileConstants::nPhiBins, or, pca_quality_th_, rhtools_, jetUpdater_cfi::sort, HGCalTileIndex::tileIndex(), and HitToTracksterAssociation_cfi::tracksters.

322  {
323  const auto &tracksters = input.tracksters;
324  const auto &layerClusters = input.layerClusters;
325 
326  // sort tracksters by energy
327  std::vector<unsigned int> sortedTracksters(tracksters.size());
328  std::iota(sortedTracksters.begin(), sortedTracksters.end(), 0);
329  std::sort(sortedTracksters.begin(), sortedTracksters.end(), [&tracksters](unsigned int i, unsigned int j) {
330  return tracksters[i].raw_energy() > tracksters[j].raw_energy();
331  });
332  // fill tiles for trackster linking
333  // tile 0 for negative eta
334  // tile 1 for positive eta
335  std::array<TICLLayerTile, 2> tracksterTile;
336  // loop over tracksters sorted by energy and calculate skeletons
337  // fill tiles for trackster linking
338  std::vector<std::array<ticl::Vector, 3>> skeletons(tracksters.size());
339  for (auto const t_idx : sortedTracksters) {
340  const auto &trackster = tracksters[t_idx];
341  skeletons[t_idx] = findSkeletonNodes(tracksters[t_idx], 0.1, 0.9, layerClusters, rhtools_);
342  tracksterTile[trackster.barycenter().eta() > 0.f].fill(
343  trackster.barycenter().eta(), trackster.barycenter().phi(), t_idx);
344  }
345  std::vector<int> maskReceivedLink(tracksters.size(), 1);
346  std::vector<int> isRootTracksters(tracksters.size(), 1);
347 
348  std::vector<Node> allNodes;
349  for (size_t it = 0; it < tracksters.size(); ++it) {
350  allNodes.emplace_back(it);
351  }
352 
353  // loop over tracksters sorted by energy and link them
354  for (auto const &t_idx : sortedTracksters) {
355  auto const &trackster = tracksters[t_idx];
356  auto const &skeleton = skeletons[t_idx];
357 
358  auto const bary = trackster.barycenter();
359  float eta_min = std::max(abs(bary.eta()) - del_, TileConstants::minEta);
360  float eta_max = std::min(abs(bary.eta()) + del_, TileConstants::maxEta);
361  int tileIndex = bary.eta() > 0.f;
362  const auto &tiles = tracksterTile[tileIndex];
363  std::array<int, 4> search_box = tiles.searchBoxEtaPhi(eta_min, eta_max, bary.phi() - del_, bary.phi() + del_);
364  if (search_box[2] > search_box[3]) {
365  search_box[3] += TileConstants::nPhiBins;
366  }
367 
368  for (int eta_i = search_box[0]; eta_i <= search_box[1]; ++eta_i) {
369  for (int phi_i = search_box[2]; phi_i <= search_box[3]; ++phi_i) {
370  auto &neighbours = tiles[tiles.globalBin(eta_i, (phi_i % TileConstants::nPhiBins))];
371  for (auto n : neighbours) {
372  if (t_idx == n)
373  continue;
374  if (maskReceivedLink[n] == 0 or allNodes[t_idx].isInnerNeighbour(n))
375  continue;
376  if (isGoodTrackster(trackster, skeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) {
377  LogDebug("TracksterLinkingbySkeletons")
378  << "Trying to Link Trackster " << t_idx << " With Trackster " << n << std::endl;
379  if (areCompatible(trackster, tracksters[n], skeleton, skeletons[n])) {
380  LogDebug("TracksterLinkingbySkeletons")
381  << "\t==== LINK: Trackster " << t_idx << " Linked with Trackster " << n << std::endl;
382  maskReceivedLink[n] = 0;
383  allNodes[t_idx].addOuterNeighbour(n);
384  allNodes[n].addInnerNeighbour(t_idx);
385  isRootTracksters[n] = 0;
386  }
387  }
388  }
389  }
390  }
391  }
392 
393  LogDebug("TracksterLinkingbySkeletons") << "**************** FINAL GRAPH **********************" << std::endl;
394  for (auto const &node : allNodes) {
395  if (isRootTracksters[node.getId()]) {
396  LogDebug("TracksterLinkingbySkeletons")
397  << "ISROOT "
398  << " Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy "
399  << tracksters[node.getId()].raw_energy() << std::endl;
400  } else {
401  LogDebug("TracksterLinkingbySkeletons")
402  << "Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy "
403  << tracksters[node.getId()].raw_energy() << std::endl;
404  }
405  }
406  LogDebug("TracksterLinkingbySkeletons") << "********************************************************" << std::endl;
407 
408  TICLGraph graph(allNodes, isRootTracksters);
409 
410  int ic = 0;
411  auto const &components = graph.findSubComponents();
412  linkedTracksterIdToInputTracksterId.resize(components.size());
413  for (auto const &comp : components) {
414  LogDebug("TracksterLinkingbySkeletons") << "Component " << ic << " Node: ";
415  std::vector<unsigned int> linkedTracksters;
416  Trackster outTrackster;
417  if (comp.size() == 1) {
418  if (input.tracksters[comp[0]].vertices().size() <= 3) {
419  continue;
420  }
421  }
422  for (auto const &node : comp) {
423  LogDebug("TracksterLinkingbySkeletons") << node << " ";
424  linkedTracksterIdToInputTracksterId[ic].push_back(node);
425  outTrackster.mergeTracksters(input.tracksters[node]);
426  }
427  linkedTracksters.push_back(resultTracksters.size());
428  resultTracksters.push_back(outTrackster);
429  linkedResultTracksters.push_back(linkedTracksters);
430  LogDebug("TracksterLinkingbySkeletons") << "\n";
431  ++ic;
432  }
433 } // linkTracksters
static constexpr int nPhiBins
Definition: Common.h:15
static constexpr float maxEta
Definition: Common.h:13
bool areCompatible(const ticl::Trackster &myTrackster, const ticl::Trackster &otherTrackster, const std::array< ticl::Vector, 3 > &mySkeleton, const std::array< ticl::Vector, 3 > &otherSkeleton)
static std::string const input
Definition: EdmProvDump.cc:50
int32_t tileIndex(int32_t layer, int32_t ring, int32_t phi)
void mergeTracksters(const Trackster &other)
Definition: Trackster.h:81
std::array< ticl::Vector, 3 > findSkeletonNodes(const ticl::Trackster &trackster, float lower_percentage, float upper_percentage, const std::vector< reco::CaloCluster > &layerClusters, const hgcal::RecHitTools &rhtools)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr float minEta
Definition: Common.h:12
#define LogDebug(id)

Member Data Documentation

◆ bfield_

edm::ESHandle<MagneticField> ticl::TracksterLinkingbySkeletons::bfield_
private

Definition at line 94 of file TracksterLinkingbySkeletons.h.

Referenced by initialize().

◆ cylinder_radius_sqr_

std::vector<double> ticl::TracksterLinkingbySkeletons::cylinder_radius_sqr_
private

Definition at line 85 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ del_

float ticl::TracksterLinkingbySkeletons::del_
private

Definition at line 76 of file TracksterLinkingbySkeletons.h.

Referenced by linkTracksters().

◆ dot_prod_th_

float ticl::TracksterLinkingbySkeletons::dot_prod_th_
private

Definition at line 80 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ firstDisk_

std::unique_ptr<GeomDet> ticl::TracksterLinkingbySkeletons::firstDisk_[2]
private

Definition at line 89 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers().

◆ hgcons_

const HGCalDDDConstants* ticl::TracksterLinkingbySkeletons::hgcons_
private

Definition at line 87 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers(), and initialize().

◆ interfaceDisk_

std::unique_ptr<GeomDet> ticl::TracksterLinkingbySkeletons::interfaceDisk_[2]
private

Definition at line 90 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers().

◆ max_distance_projective_sqr_

std::vector<double> ticl::TracksterLinkingbySkeletons::max_distance_projective_sqr_
private

Definition at line 81 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ max_distance_projective_sqr_closest_points_

std::vector<double> ticl::TracksterLinkingbySkeletons::max_distance_projective_sqr_closest_points_
private

Definition at line 83 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ max_z_distance_closest_points_

std::vector<double> ticl::TracksterLinkingbySkeletons::max_z_distance_closest_points_
private

Definition at line 84 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ min_distance_z_

std::vector<double> ticl::TracksterLinkingbySkeletons::min_distance_z_
private

Definition at line 82 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ min_num_lcs_

unsigned int ticl::TracksterLinkingbySkeletons::min_num_lcs_
private

Definition at line 77 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ min_trackster_energy_

float ticl::TracksterLinkingbySkeletons::min_trackster_energy_
private

Definition at line 78 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ pca_quality_th_

float ticl::TracksterLinkingbySkeletons::pca_quality_th_
private

Definition at line 79 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ propagator_

edm::ESHandle<Propagator> ticl::TracksterLinkingbySkeletons::propagator_
private

Definition at line 95 of file TracksterLinkingbySkeletons.h.

Referenced by initialize().

◆ rhtools_

hgcal::RecHitTools ticl::TracksterLinkingbySkeletons::rhtools_
private

◆ timing_quality_threshold_

float ticl::TracksterLinkingbySkeletons::timing_quality_threshold_
private

Definition at line 75 of file TracksterLinkingbySkeletons.h.