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)
 
 ~TracksterLinkingbySkeletons () override
 
- Public Member Functions inherited from ticl::TracksterLinkingAlgoBase
 TracksterLinkingAlgoBase (const edm::ParameterSet &conf, edm::ConsumesCollector)
 
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_
 

Detailed Description

Definition at line 24 of file TracksterLinkingbySkeletons.h.

Member Typedef Documentation

◆ Vector

Definition at line 67 of file TracksterLinkingbySkeletons.h.

Constructor & Destructor Documentation

◆ TracksterLinkingbySkeletons()

TracksterLinkingbySkeletons::TracksterLinkingbySkeletons ( const edm::ParameterSet conf,
edm::ConsumesCollector  iC 
)

Definition at line 53 of file TracksterLinkingbySkeletons.cc.

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

◆ ~TracksterLinkingbySkeletons()

ticl::TracksterLinkingbySkeletons::~TracksterLinkingbySkeletons ( )
inlineoverride

Definition at line 28 of file TracksterLinkingbySkeletons.h.

28 {}

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 199 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, SiStripPI::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().

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

70  {
71  // build disks at HGCal front & EM-Had interface for track propagation
72 
73  float zVal = hgcons_->waferZ(1, true);
74  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
75 
76  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
77  std::pair<float, float> rMinMax_interface = hgcons_->rangeR(zVal_interface, true);
78 
79  for (int iSide = 0; iSide < 2; ++iSide) {
80  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
81  firstDisk_[iSide] =
82  std::make_unique<GeomDet>(Disk::build(Disk::PositionType(0, 0, zSide),
84  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
85  .get());
86 
87  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
88  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
89  Disk::build(Disk::PositionType(0, 0, zSide),
91  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
92  .get());
93  }
94 }
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 51 of file TracksterLinkingbySkeletons.h.

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

51  {
52  iDesc.add<double>("track_time_quality_threshold", 0.5);
53  iDesc.add<double>("wind", 0.036);
54  iDesc.add<unsigned int>("min_num_lcs", 7);
55  iDesc.add<double>("min_trackster_energy", 10.);
56  iDesc.add<double>("pca_quality_th", 0.85);
57  iDesc.add<double>("dot_prod_th", 0.97);
58  iDesc.add<std::vector<double>>("max_distance_projective_sqr", {60., 60.});
59  iDesc.add<std::vector<double>>("min_distance_z", {30., 30.});
60  iDesc.add<std::vector<double>>("max_distance_projective_sqr_closest_points", {60., 60.});
61  iDesc.add<std::vector<double>>("max_z_distance_closest_points", {35., 35.});
62  iDesc.add<std::vector<double>>("cylinder_radius_sqr", {9., 9.});
64  }
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 108 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().

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

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

99  {
100  hgcons_ = hgcons;
101  rhtools_ = rhtools;
102  buildLayers();
103 
104  bfield_ = bfieldH;
105  propagator_ = propH;
106 }
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 316 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, SiStripPI::max, ticl::TileConstants::maxEta, ticl::Trackster::mergeTracksters(), SiStripPI::min, min_num_lcs_, min_trackster_energy_, ticl::TileConstants::minEta, dqmiodumpmetadata::n, ticl::TileConstants::nPhiBins, or, pca_quality_th_, rhtools_, jetUpdater_cfi::sort, and HGCalTileIndex::tileIndex().

320  {
321  const auto &tracksters = input.tracksters;
322  const auto &layerClusters = input.layerClusters;
323 
324  // sort tracksters by energy
325  std::vector<unsigned int> sortedTracksters(tracksters.size());
326  std::iota(sortedTracksters.begin(), sortedTracksters.end(), 0);
327  std::sort(sortedTracksters.begin(), sortedTracksters.end(), [&tracksters](unsigned int i, unsigned int j) {
328  return tracksters[i].raw_energy() > tracksters[j].raw_energy();
329  });
330  // fill tiles for trackster linking
331  // tile 0 for negative eta
332  // tile 1 for positive eta
333  std::array<TICLLayerTile, 2> tracksterTile;
334  // loop over tracksters sorted by energy and calculate skeletons
335  // fill tiles for trackster linking
336  std::vector<std::array<ticl::Vector, 3>> skeletons(tracksters.size());
337  for (auto const t_idx : sortedTracksters) {
338  const auto &trackster = tracksters[t_idx];
339  skeletons[t_idx] = findSkeletonNodes(tracksters[t_idx], 0.1, 0.9, layerClusters, rhtools_);
340  tracksterTile[trackster.barycenter().eta() > 0.f].fill(
341  trackster.barycenter().eta(), trackster.barycenter().phi(), t_idx);
342  }
343  std::vector<int> maskReceivedLink(tracksters.size(), 1);
344  std::vector<int> isRootTracksters(tracksters.size(), 1);
345 
346  std::vector<Node> allNodes;
347  for (size_t it = 0; it < tracksters.size(); ++it) {
348  allNodes.emplace_back(it);
349  }
350 
351  // loop over tracksters sorted by energy and link them
352  for (auto const &t_idx : sortedTracksters) {
353  auto const &trackster = tracksters[t_idx];
354  auto const &skeleton = skeletons[t_idx];
355 
356  auto const bary = trackster.barycenter();
357  float eta_min = std::max(abs(bary.eta()) - del_, TileConstants::minEta);
358  float eta_max = std::min(abs(bary.eta()) + del_, TileConstants::maxEta);
359  int tileIndex = bary.eta() > 0.f;
360  const auto &tiles = tracksterTile[tileIndex];
361  std::array<int, 4> search_box = tiles.searchBoxEtaPhi(eta_min, eta_max, bary.phi() - del_, bary.phi() + del_);
362  if (search_box[2] > search_box[3]) {
363  search_box[3] += TileConstants::nPhiBins;
364  }
365 
366  for (int eta_i = search_box[0]; eta_i <= search_box[1]; ++eta_i) {
367  for (int phi_i = search_box[2]; phi_i <= search_box[3]; ++phi_i) {
368  auto &neighbours = tiles[tiles.globalBin(eta_i, (phi_i % TileConstants::nPhiBins))];
369  for (auto n : neighbours) {
370  if (t_idx == n)
371  continue;
372  if (maskReceivedLink[n] == 0 or allNodes[t_idx].isInnerNeighbour(n))
373  continue;
374  if (isGoodTrackster(trackster, skeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) {
375  LogDebug("TracksterLinkingbySkeletons")
376  << "Trying to Link Trackster " << t_idx << " With Trackster " << n << std::endl;
377  if (areCompatible(trackster, tracksters[n], skeleton, skeletons[n])) {
378  LogDebug("TracksterLinkingbySkeletons")
379  << "\t==== LINK: Trackster " << t_idx << " Linked with Trackster " << n << std::endl;
380  maskReceivedLink[n] = 0;
381  allNodes[t_idx].addOuterNeighbour(n);
382  allNodes[n].addInnerNeighbour(t_idx);
383  isRootTracksters[n] = 0;
384  }
385  }
386  }
387  }
388  }
389  }
390 
391  LogDebug("TracksterLinkingbySkeletons") << "**************** FINAL GRAPH **********************" << std::endl;
392  for (auto const &node : allNodes) {
393  if (isRootTracksters[node.getId()]) {
394  LogDebug("TracksterLinkingbySkeletons")
395  << "ISROOT "
396  << " Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy "
397  << tracksters[node.getId()].raw_energy() << std::endl;
398  } else {
399  LogDebug("TracksterLinkingbySkeletons")
400  << "Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy "
401  << tracksters[node.getId()].raw_energy() << std::endl;
402  }
403  }
404  LogDebug("TracksterLinkingbySkeletons") << "********************************************************" << std::endl;
405 
406  TICLGraph graph(allNodes, isRootTracksters);
407 
408  int ic = 0;
409  auto const &components = graph.findSubComponents();
410  linkedTracksterIdToInputTracksterId.resize(components.size());
411  for (auto const &comp : components) {
412  LogDebug("TracksterLinkingbySkeletons") << "Component " << ic << " Node: ";
413  std::vector<unsigned int> linkedTracksters;
414  Trackster outTrackster;
415  if (comp.size() == 1) {
416  if (input.tracksters[comp[0]].vertices().size() <= 3) {
417  continue;
418  }
419  }
420  for (auto const &node : comp) {
421  LogDebug("TracksterLinkingbySkeletons") << node << " ";
422  linkedTracksterIdToInputTracksterId[ic].push_back(node);
423  outTrackster.mergeTracksters(input.tracksters[node]);
424  }
425  linkedTracksters.push_back(resultTracksters.size());
426  resultTracksters.push_back(outTrackster);
427  linkedResultTracksters.push_back(linkedTracksters);
428  LogDebug("TracksterLinkingbySkeletons") << "\n";
429  ++ic;
430  }
431 } // 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 92 of file TracksterLinkingbySkeletons.h.

Referenced by initialize().

◆ cylinder_radius_sqr_

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

Definition at line 83 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ del_

float ticl::TracksterLinkingbySkeletons::del_
private

Definition at line 74 of file TracksterLinkingbySkeletons.h.

Referenced by linkTracksters().

◆ dot_prod_th_

float ticl::TracksterLinkingbySkeletons::dot_prod_th_
private

Definition at line 78 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ firstDisk_

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

Definition at line 87 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers().

◆ hgcons_

const HGCalDDDConstants* ticl::TracksterLinkingbySkeletons::hgcons_
private

Definition at line 85 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers(), and initialize().

◆ interfaceDisk_

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

Definition at line 88 of file TracksterLinkingbySkeletons.h.

Referenced by buildLayers().

◆ max_distance_projective_sqr_

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

Definition at line 79 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 81 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 82 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ min_distance_z_

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

Definition at line 80 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible().

◆ min_num_lcs_

unsigned int ticl::TracksterLinkingbySkeletons::min_num_lcs_
private

Definition at line 75 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ min_trackster_energy_

float ticl::TracksterLinkingbySkeletons::min_trackster_energy_
private

Definition at line 76 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ pca_quality_th_

float ticl::TracksterLinkingbySkeletons::pca_quality_th_
private

Definition at line 77 of file TracksterLinkingbySkeletons.h.

Referenced by areCompatible(), and linkTracksters().

◆ propagator_

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

Definition at line 93 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 73 of file TracksterLinkingbySkeletons.h.