CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
ticl::LinkingAlgoByDirectionGeometric Class Referencefinal

#include <LinkingAlgoByDirectionGeometric.h>

Inheritance diagram for ticl::LinkingAlgoByDirectionGeometric:
ticl::LinkingAlgoBase

Public Member Functions

void initialize (const HGCalDDDConstants *hgcons, const hgcal::RecHitTools rhtools, const edm::ESHandle< MagneticField > bfieldH, const edm::ESHandle< Propagator > propH) override
 
 LinkingAlgoByDirectionGeometric (const edm::ParameterSet &conf)
 
void linkTracksters (const edm::Handle< std::vector< reco::Track >>, const edm::Handle< edm::ValueMap< float >>, const edm::Handle< edm::ValueMap< float >>, const edm::Handle< edm::ValueMap< float >>, const std::vector< reco::Muon > &, const edm::Handle< std::vector< Trackster >>, const bool useMTDTiming, std::vector< TICLCandidate > &, std::vector< TICLCandidate > &) override
 
 ~LinkingAlgoByDirectionGeometric () override
 
- Public Member Functions inherited from ticl::LinkingAlgoBase
 LinkingAlgoBase (const edm::ParameterSet &conf)
 
virtual ~LinkingAlgoBase ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from ticl::LinkingAlgoBase
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
 
void findTrackstersInWindow (const std::vector< std::pair< Vector, unsigned >> &seedingCollection, const std::array< TICLLayerTile, 2 > &tracksterTiles, const std::vector< Vector > &tracksterPropPoints, float delta, unsigned trackstersSize, std::vector< std::vector< unsigned >> &resultCollection, bool useMask)
 
Vector propagateTrackster (const Trackster &t, const unsigned idx, float zVal, std::array< TICLLayerTile, 2 > &tracksterTiles)
 
void recordTrackster (const unsigned ts, const std::vector< Trackster > &tracksters, const edm::Handle< std::vector< Trackster >> tsH, std::vector< unsigned > &ts_mask, float &energy_in_candidate, TICLCandidate &candidate)
 
bool timeAndEnergyCompatible (float &total_raw_energy, const reco::Track &track, const Trackster &trackster, const float &tkTime, const float &tkTimeErr, const float &tkTimeQual, bool useMTDTiming)
 

Private Attributes

edm::ESHandle< MagneticFieldbfield_
 
const StringCutObjectSelector< reco::TrackcutTk_
 
const float del_tk_ts_int_
 
const float del_tk_ts_layer1_
 
const float del_ts_em_had_
 
const float del_ts_had_had_
 
std::unique_ptr< GeomDetfirstDisk_ [2]
 
const HGCalDDDConstantshgcons_
 
std::once_flag initializeGeometry_
 
std::unique_ptr< GeomDetinterfaceDisk_ [2]
 
const float maxDeltaT_ = 3.0f
 
edm::ESHandle< Propagatorpropagator_
 
hgcal::RecHitTools rhtools_
 
const float timing_quality_threshold_
 
const float tkEnergyCut_ = 2.0f
 

Additional Inherited Members

- Protected Attributes inherited from ticl::LinkingAlgoBase
int algo_verbosity_
 

Detailed Description

Definition at line 26 of file LinkingAlgoByDirectionGeometric.h.

Member Typedef Documentation

◆ Vector

Definition at line 49 of file LinkingAlgoByDirectionGeometric.h.

Constructor & Destructor Documentation

◆ LinkingAlgoByDirectionGeometric()

LinkingAlgoByDirectionGeometric::LinkingAlgoByDirectionGeometric ( const edm::ParameterSet conf)

Definition at line 17 of file LinkingAlgoByDirectionGeometric.cc.

18  : LinkingAlgoBase(conf),
19  del_tk_ts_layer1_(conf.getParameter<double>("delta_tk_ts_layer1")),
20  del_tk_ts_int_(conf.getParameter<double>("delta_tk_ts_interface")),
21  del_ts_em_had_(conf.getParameter<double>("delta_ts_em_had")),
22  del_ts_had_had_(conf.getParameter<double>("delta_ts_had_had")),
23  timing_quality_threshold_(conf.getParameter<double>("track_time_quality_threshold")),
24  cutTk_(conf.getParameter<std::string>("cutTk")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
LinkingAlgoBase(const edm::ParameterSet &conf)
const StringCutObjectSelector< reco::Track > cutTk_

◆ ~LinkingAlgoByDirectionGeometric()

LinkingAlgoByDirectionGeometric::~LinkingAlgoByDirectionGeometric ( )
override

Definition at line 26 of file LinkingAlgoByDirectionGeometric.cc.

26 {}

Member Function Documentation

◆ buildLayers()

void LinkingAlgoByDirectionGeometric::buildLayers ( )
private

Definition at line 207 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by initialize().

207  {
208  // build disks at HGCal front & EM-Had interface for track propagation
209 
210  float zVal = hgcons_->waferZ(1, true);
211  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
212 
213  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
214  std::pair<float, float> rMinMax_interface = hgcons_->rangeR(zVal_interface, true);
215 
216  for (int iSide = 0; iSide < 2; ++iSide) {
217  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
218  firstDisk_[iSide] =
219  std::make_unique<GeomDet>(Disk::build(Disk::PositionType(0, 0, zSide),
221  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
222  .get());
223 
224  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
225  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
226  Disk::build(Disk::PositionType(0, 0, zSide),
228  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
229  .get());
230  }
231 }
double waferZ(int layer, bool reco) const
static DiskPointer build(Args &&... args)
Definition: BoundDisk.h:38
std::pair< double, double > rangeR(double z, bool reco) const
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 LinkingAlgoByDirectionGeometric::dumpLinksFound ( std::vector< std::vector< unsigned >> &  resultCollection,
const char *  label 
) const
private

Definition at line 188 of file LinkingAlgoByDirectionGeometric.cc.

References ticl::Advanced, ticl::LinkingAlgoBase::algo_verbosity_, mps_fire::i, dqmiolumiharvest::j, label, electronStore::links, and LogDebug.

Referenced by linkTracksters().

189  {
190 #ifdef EDM_ML_DEBUG
192  return;
193 
194  LogDebug("LinkingAlgoByDirectionGeometric") << "All links found - " << label << "\n";
195  LogDebug("LinkingAlgoByDirectionGeometric") << "(seed can either be a track or trackster depending on the step)\n";
196  for (unsigned i = 0; i < resultCollection.size(); ++i) {
197  LogDebug("LinkingAlgoByDirectionGeometric") << "seed " << i << " - tracksters : ";
198  const auto &links = resultCollection[i];
199  for (unsigned j = 0; j < links.size(); ++j) {
200  LogDebug("LinkingAlgoByDirectionGeometric") << j;
201  }
202  LogDebug("LinkingAlgoByDirectionGeometric") << "\n";
203  }
204 #endif // EDM_ML_DEBUG
205 }
char const * label
#define LogDebug(id)

◆ fillPSetDescription()

void LinkingAlgoByDirectionGeometric::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 570 of file LinkingAlgoByDirectionGeometric.cc.

References submitPVResolutionJobs::desc, ticl::LinkingAlgoBase::fillPSetDescription(), and AlCaHLTBitMon_QueryRunRegistry::string.

570  {
571  desc.add<std::string>("cutTk",
572  "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
573  "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
574  desc.add<double>("delta_tk_ts_layer1", 0.02);
575  desc.add<double>("delta_tk_ts_interface", 0.03);
576  desc.add<double>("delta_ts_em_had", 0.03);
577  desc.add<double>("delta_ts_had_had", 0.03);
578  desc.add<double>("track_time_quality_threshold", 0.5);
580 }
static void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ findTrackstersInWindow()

void LinkingAlgoByDirectionGeometric::findTrackstersInWindow ( const std::vector< std::pair< Vector, unsigned >> &  seedingCollection,
const std::array< TICLLayerTile, 2 > &  tracksterTiles,
const std::vector< Vector > &  tracksterPropPoints,
float  delta,
unsigned  trackstersSize,
std::vector< std::vector< unsigned >> &  resultCollection,
bool  useMask = false 
)
private

Definition at line 73 of file LinkingAlgoByDirectionGeometric.cc.

References funct::abs(), dumpMFGeometry_cfg::delta, egammaIdentification::eta_max, egammaIdentification::eta_min, mps_fire::i, dqmdumpme::indices, dqmiolumiharvest::j, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, WZElectronSkims53X_cff::max, ticl::TileConstants::maxEta, SiStripPI::min, ticl::TileConstants::minEta, ticl::TileConstants::nPhiBins, VtxSmearedParameters_cfi::Phi, run3scouting_cff::seedId, and jetUpdater_cfi::sort.

Referenced by linkTracksters().

80  {
81  // Finds tracksters in tracksterTiles within an eta-phi window
82  // (given by delta) of the objects (track/trackster) in the seedingCollection.
83  // Element i in resultCollection is the vector of trackster
84  // indices found close to the i-th object in the seedingCollection.
85  // If specified, Tracksters are masked once found as close to an object.
86  std::vector<int> mask(trackstersSize, 0);
87  float delta2 = delta * delta;
88 
89  for (auto &i : seedingCollection) {
90  float seed_eta = i.first.Eta();
91  float seed_phi = i.first.Phi();
92  unsigned seedId = i.second;
93  auto sideZ = seed_eta > 0; //forward or backward region
94  const TICLLayerTile &tile = tracksterTiles[sideZ];
95  float eta_min = std::max(abs(seed_eta) - delta, (float)TileConstants::minEta);
96  float eta_max = std::min(abs(seed_eta) + delta, (float)TileConstants::maxEta);
97 
98  // get range of bins touched by delta
99  std::array<int, 4> search_box = tile.searchBoxEtaPhi(eta_min, eta_max, seed_phi - delta, seed_phi + delta);
100 
101  std::vector<unsigned> in_delta;
102  std::vector<float> distances2;
103  for (int eta_i = search_box[0]; eta_i <= search_box[1]; ++eta_i) {
104  for (int phi_i = search_box[2]; phi_i <= search_box[3]; ++phi_i) {
105  const auto &in_tile = tile[tile.globalBin(eta_i, (phi_i % TileConstants::nPhiBins))];
106  for (const unsigned &t_i : in_tile) {
107  // calculate actual distances of tracksters to the seed for a more accurate cut
108  auto sep2 = (tracksterPropPoints[t_i].Eta() - seed_eta) * (tracksterPropPoints[t_i].Eta() - seed_eta) +
109  (tracksterPropPoints[t_i].Phi() - seed_phi) * (tracksterPropPoints[t_i].Phi() - seed_phi);
110  if (sep2 < delta2) {
111  in_delta.push_back(t_i);
112  distances2.push_back(sep2);
113  }
114  }
115  }
116  }
117 
118  // sort tracksters found in ascending order of their distances from the seed
119  std::vector<unsigned> indices(in_delta.size());
120  std::iota(indices.begin(), indices.end(), 0);
121  std::sort(indices.begin(), indices.end(), [&](unsigned i, unsigned j) { return distances2[i] < distances2[j]; });
122 
123  // push back sorted tracksters in the result collection
124  for (const unsigned &index : indices) {
125  const auto &t_i = in_delta[index];
126  if (!mask[t_i]) {
127  resultCollection[seedId].push_back(t_i);
128  if (useMask)
129  mask[t_i] = 1;
130  }
131  }
132 
133  } // seeding collection loop
134 }
static constexpr int nPhiBins
Definition: Common.h:15
static constexpr float maxEta
Definition: Common.h:13
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr float minEta
Definition: Common.h:12

◆ initialize()

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

◆ linkTracksters()

void LinkingAlgoByDirectionGeometric::linkTracksters ( const edm::Handle< std::vector< reco::Track >>  tkH,
const edm::Handle< edm::ValueMap< float >>  tkTime_h,
const edm::Handle< edm::ValueMap< float >>  tkTimeErr_h,
const edm::Handle< edm::ValueMap< float >>  tkTimeQual_h,
const std::vector< reco::Muon > &  muons,
const edm::Handle< std::vector< Trackster >>  tsH,
const bool  useMTDTiming,
std::vector< TICLCandidate > &  resultLinked,
std::vector< TICLCandidate > &  chargedHadronsFromTk 
)
overridevirtual

Implements ticl::LinkingAlgoBase.

Definition at line 233 of file LinkingAlgoByDirectionGeometric.cc.

References funct::abs(), TICLCandidate::addTrackster(), ticl::Advanced, ticl::LinkingAlgoBase::algo_verbosity_, bfield_, cutTk_, del_tk_ts_int_, del_tk_ts_layer1_, del_ts_em_had_, del_ts_had_had_, dumpLinksFound(), relativeConstraints::empty, EcalPhiSymFlatTableProducers_cfi::fill, findTrackstersInWindow(), firstDisk_, hgcal::RecHitTools::getPositionLayer(), hgcons_, mps_fire::i, createfilelist::int, interfaceDisk_, hgcal::RecHitTools::lastLayerEE(), LogDebug, ticl::mpion2, PFMuonAlgo::muAssocToTrack(), DiMuonV_cfg::muons, or, trajectoryStateTransform::outerFreeState(), edm::ESHandle< T >::product(), Propagator::propagate(), propagateTrackster(), recordTrackster(), rhtools_, TICLCandidate::setTrackPtr(), mathSSE::sqrt(), submitPVValidationJobs::t, timeAndEnergyCompatible(), tkEnergyCut_, DiMuonV_cfg::tracks, HitToTracksterAssociation_cfi::tracksters, TICLCandidate::tracksters(), hltPfTICL_cfi::useMTDTiming, and HGCalDDDConstants::waferZ().

241  {
242  const auto &tracks = *tkH;
243  const auto &tracksters = *tsH;
244 
245  auto bFieldProd = bfield_.product();
246  const Propagator &prop = (*propagator_);
247 
248  // propagated point collections
249  // elements in the propagated points collecions are used
250  // to look for potential linkages in the appropriate tiles
251  std::vector<std::pair<Vector, unsigned>> trackPColl; // propagated track points and index of track in collection
252  std::vector<std::pair<Vector, unsigned>> tkPropIntColl; // tracks propagated to lastLayerEE
253  std::vector<std::pair<Vector, unsigned>> tsPropIntColl; // Tracksters in CE-E, propagated to lastLayerEE
254  std::vector<std::pair<Vector, unsigned>> tsHadPropIntColl; // Tracksters in CE-H, propagated to lastLayerEE
255  trackPColl.reserve(tracks.size());
256  tkPropIntColl.reserve(tracks.size());
257  tsPropIntColl.reserve(tracksters.size());
258  tsHadPropIntColl.reserve(tracksters.size());
259  // tiles, element 0 is bw, 1 is fw
260  std::array<TICLLayerTile, 2> tracksterPropTiles = {}; // all Tracksters, propagated to layer 1
261  std::array<TICLLayerTile, 2> tsPropIntTiles = {}; // all Tracksters, propagated to lastLayerEE
262  std::array<TICLLayerTile, 2> tsHadPropIntTiles = {}; // Tracksters in CE-H, propagated to lastLayerEE
263 
264  // linking : trackster is hadronic if its barycenter is in CE-H
265  auto isHadron = [&](const Trackster &t) -> bool {
266  auto boundary_z = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
267  return (std::abs(t.barycenter().Z()) > boundary_z);
268  };
269 
271  LogDebug("LinkingAlgoByDirectionGeometric") << "------- Geometric Linking ------- \n";
272 
273  // Propagate tracks
274  std::vector<unsigned> candidateTrackIds;
275  candidateTrackIds.reserve(tracks.size());
276  for (unsigned i = 0; i < tracks.size(); ++i) {
277  const auto &tk = tracks[i];
278  reco::TrackRef trackref = reco::TrackRef(tkH, i);
279 
280  // veto tracks associated to muons
281  int muId = PFMuonAlgo::muAssocToTrack(trackref, muons);
282 
284  if (useMTDTiming) {
285  LogDebug("LinkingAlgoByDirectionGeometric")
286  << "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " time "
287  << (*tkTime_h)[reco::TrackRef(tkH, i)] << " time qual " << (*tkTimeQual_h)[reco::TrackRef(tkH, i)]
288  << " muid " << muId << "\n";
289  } else {
290  LogDebug("LinkingAlgoByDirectionGeometric")
291  << "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " muid " << muId << "\n";
292  }
293  }
294 
295  if (!cutTk_((tk)) or muId != -1)
296  continue;
297 
298  // record tracks that can be used to make a ticlcandidate
299  candidateTrackIds.push_back(i);
300 
301  // don't consider tracks below 2 GeV for linking
302  if (std::sqrt(tk.p() * tk.p() + ticl::mpion2) < tkEnergyCut_)
303  continue;
304 
305  int iSide = int(tk.eta() > 0);
306  const auto &fts = trajectoryStateTransform::outerFreeState((tk), bFieldProd);
307  // to the HGCal front
308  const auto &tsos = prop.propagate(fts, firstDisk_[iSide]->surface());
309  if (tsos.isValid()) {
310  Vector trackP(tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z());
311  trackPColl.emplace_back(trackP, i);
312  }
313  // to lastLayerEE
314  const auto &tsos_int = prop.propagate(fts, interfaceDisk_[iSide]->surface());
315  if (tsos_int.isValid()) {
316  Vector trackP(tsos_int.globalPosition().x(), tsos_int.globalPosition().y(), tsos_int.globalPosition().z());
317  tkPropIntColl.emplace_back(trackP, i);
318  }
319  } // Tracks
320  tkPropIntColl.shrink_to_fit();
321  trackPColl.shrink_to_fit();
322  candidateTrackIds.shrink_to_fit();
323 
324  // Propagate tracksters
325 
326  // Record postions of all tracksters propagated to layer 1 and lastLayerEE,
327  // to be used later for distance calculation in the link finding stage
328  // indexed by trackster index in event collection
329  std::vector<Vector> tsAllProp;
330  std::vector<Vector> tsAllPropInt;
331  tsAllProp.reserve(tracksters.size());
332  tsAllPropInt.reserve(tracksters.size());
333 
334  for (unsigned i = 0; i < tracksters.size(); ++i) {
335  const auto &t = tracksters[i];
337  LogDebug("LinkingAlgoByDirectionGeometric")
338  << "trackster " << i << " - eta " << t.barycenter().eta() << " phi " << t.barycenter().phi() << " time "
339  << t.time() << " energy " << t.raw_energy() << "\n";
340 
341  // to HGCal front
342  float zVal = hgcons_->waferZ(1, true);
343  auto tsP = propagateTrackster(t, i, zVal, tracksterPropTiles);
344  tsAllProp.emplace_back(tsP);
345 
346  // to lastLayerEE
348  tsP = propagateTrackster(t, i, zVal, tsPropIntTiles);
349  tsAllPropInt.emplace_back(tsP);
350 
351  if (!isHadron(t)) // EM tracksters
352  tsPropIntColl.emplace_back(tsP, i);
353  else { // HAD
354  tsHadPropIntTiles[(t.barycenter().Z() > 0) ? 1 : 0].fill(tsP.Eta(), tsP.Phi(), i);
355  tsHadPropIntColl.emplace_back(tsP, i);
356  }
357  } // TS
358  tsPropIntColl.shrink_to_fit();
359  tsHadPropIntColl.shrink_to_fit();
360 
361  // Track - Trackster link finding
362  // step 3: tracks -> all tracksters, at layer 1
363 
364  std::vector<std::vector<unsigned>> tsNearTk(tracks.size());
365  findTrackstersInWindow(trackPColl, tracksterPropTiles, tsAllProp, del_tk_ts_layer1_, tracksters.size(), tsNearTk);
366 
367  // step 4: tracks -> all tracksters, at lastLayerEE
368 
369  std::vector<std::vector<unsigned>> tsNearTkAtInt(tracks.size());
370  findTrackstersInWindow(tkPropIntColl, tsPropIntTiles, tsAllPropInt, del_tk_ts_int_, tracksters.size(), tsNearTkAtInt);
371 
372  // Trackster - Trackster link finding
373  // step 2: tracksters EM -> HAD, at lastLayerEE
374 
375  std::vector<std::vector<unsigned>> tsNearAtInt(tracksters.size());
377  tsPropIntColl, tsHadPropIntTiles, tsAllPropInt, del_ts_em_had_, tracksters.size(), tsNearAtInt);
378 
379  // step 1: tracksters HAD -> HAD, at lastLayerEE
380 
381  std::vector<std::vector<unsigned>> tsHadNearAtInt(tracksters.size());
383  tsHadPropIntColl, tsHadPropIntTiles, tsAllPropInt, del_ts_had_had_, tracksters.size(), tsHadNearAtInt);
384 
385 #ifdef EDM_ML_DEBUG
386  dumpLinksFound(tsNearTk, "track -> tracksters at layer 1");
387  dumpLinksFound(tsNearTkAtInt, "track -> tracksters at lastLayerEE");
388  dumpLinksFound(tsNearAtInt, "EM -> HAD tracksters at lastLayerEE");
389  dumpLinksFound(tsHadNearAtInt, "HAD -> HAD tracksters at lastLayerEE");
390 #endif //EDM_ML_DEBUG
391 
392  // make final collections
393 
394  std::vector<TICLCandidate> chargedCandidates;
395  std::vector<unsigned int> chargedMask(tracksters.size(), 0);
396  for (unsigned &i : candidateTrackIds) {
397  if (tsNearTk[i].empty() && tsNearTkAtInt[i].empty()) { // nothing linked to track, make charged hadrons
398  TICLCandidate chargedHad;
399  chargedHad.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
400  chargedHadronsFromTk.push_back(chargedHad);
401  continue;
402  }
403 
404  TICLCandidate chargedCandidate;
405  float total_raw_energy = 0.;
406 
407  auto tkRef = reco::TrackRef(tkH, i);
408  float track_time = 0.f;
409  float track_timeErr = 0.f;
410  float track_timeQual = 0.f;
411  if (useMTDTiming) {
412  track_time = (*tkTime_h)[tkRef];
413  track_timeErr = (*tkTimeErr_h)[tkRef];
414  track_timeQual = (*tkTimeQual_h)[tkRef];
415  }
416 
417  for (const unsigned ts3_idx : tsNearTk[i]) { // tk -> ts
418  if (timeAndEnergyCompatible(total_raw_energy,
419  tracks[i],
420  tracksters[ts3_idx],
421  track_time,
422  track_timeErr,
423  track_timeQual,
424  useMTDTiming)) {
425  recordTrackster(ts3_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
426  }
427  for (const unsigned ts2_idx : tsNearAtInt[ts3_idx]) { // ts_EM -> ts_HAD
428  if (timeAndEnergyCompatible(total_raw_energy,
429  tracks[i],
430  tracksters[ts2_idx],
431  track_time,
432  track_timeErr,
433  track_timeQual,
434  useMTDTiming)) {
435  recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
436  }
437  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) { // ts_HAD -> ts_HAD
438  if (timeAndEnergyCompatible(total_raw_energy,
439  tracks[i],
440  tracksters[ts1_idx],
441  track_time,
442  track_timeErr,
443  track_timeQual,
444  useMTDTiming)) {
445  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
446  }
447  }
448  }
449  for (const unsigned ts1_idx : tsHadNearAtInt[ts3_idx]) { // ts_HAD -> ts_HAD
450  if (timeAndEnergyCompatible(total_raw_energy,
451  tracks[i],
452  tracksters[ts1_idx],
453  track_time,
454  track_timeErr,
455  track_timeQual,
456  useMTDTiming)) {
457  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
458  }
459  }
460  }
461  for (const unsigned ts4_idx : tsNearTkAtInt[i]) { // do the same for tk -> ts links at the interface
462  if (timeAndEnergyCompatible(total_raw_energy,
463  tracks[i],
464  tracksters[ts4_idx],
465  track_time,
466  track_timeErr,
467  track_timeQual,
468  useMTDTiming)) {
469  recordTrackster(ts4_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
470  }
471  for (const unsigned ts2_idx : tsNearAtInt[ts4_idx]) {
472  if (timeAndEnergyCompatible(total_raw_energy,
473  tracks[i],
474  tracksters[ts2_idx],
475  track_time,
476  track_timeErr,
477  track_timeQual,
478  useMTDTiming)) {
479  recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
480  }
481  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) {
482  if (timeAndEnergyCompatible(total_raw_energy,
483  tracks[i],
484  tracksters[ts1_idx],
485  track_time,
486  track_timeErr,
487  track_timeQual,
488  useMTDTiming)) {
489  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
490  }
491  }
492  }
493  for (const unsigned ts1_idx : tsHadNearAtInt[ts4_idx]) {
494  if (timeAndEnergyCompatible(total_raw_energy,
495  tracks[i],
496  tracksters[ts1_idx],
497  track_time,
498  track_timeErr,
499  track_timeQual,
500  useMTDTiming)) {
501  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
502  }
503  }
504  }
505 
506  // do not create a candidate if no tracksters were added to candidate
507  // can happen if all the tracksters linked to that track were already masked
508  if (!chargedCandidate.tracksters().empty()) {
509  chargedCandidate.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
510  chargedCandidates.push_back(chargedCandidate);
511  } else { // create charged hadron
512  TICLCandidate chargedHad;
513  chargedHad.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
514  chargedHadronsFromTk.push_back(chargedHad);
515  }
516  }
517 
518  std::vector<TICLCandidate> neutralCandidates;
519  std::vector<int> neutralMask(tracksters.size(), 0);
520  for (unsigned i = 0; i < tracksters.size(); ++i) {
521  if (chargedMask[i])
522  continue;
523 
524  TICLCandidate neutralCandidate;
525  if (tsNearAtInt[i].empty() && tsHadNearAtInt[i].empty() && !neutralMask[i]) { // nothing linked to this ts
526  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, i));
527  neutralMask[i] = 1;
528  neutralCandidates.push_back(neutralCandidate);
529  continue;
530  }
531  if (!neutralMask[i]) {
532  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, i));
533  neutralMask[i] = 1;
534  }
535  for (const unsigned ts2_idx : tsNearAtInt[i]) {
536  if (chargedMask[ts2_idx])
537  continue;
538  if (!neutralMask[ts2_idx]) {
539  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts2_idx));
540  neutralMask[ts2_idx] = 1;
541  }
542  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) {
543  if (chargedMask[ts1_idx])
544  continue;
545  if (!neutralMask[ts1_idx]) {
546  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts1_idx));
547  neutralMask[ts1_idx] = 1;
548  }
549  }
550  }
551  for (const unsigned ts1_idx : tsHadNearAtInt[i]) {
552  if (chargedMask[ts1_idx])
553  continue;
554  if (!neutralMask[ts1_idx]) {
555  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts1_idx));
556  neutralMask[ts1_idx] = 1;
557  }
558  }
559  // filter empty candidates
560  if (!neutralCandidate.tracksters().empty()) {
561  neutralCandidates.push_back(neutralCandidate);
562  }
563  }
564 
565  resultLinked.insert(std::end(resultLinked), std::begin(neutralCandidates), std::end(neutralCandidates));
566  resultLinked.insert(std::end(resultLinked), std::begin(chargedCandidates), std::end(chargedCandidates));
567 
568 } // linkTracksters
double waferZ(int layer, bool reco) const
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
T const * product() const
Definition: ESHandle.h:86
Vector propagateTrackster(const Trackster &t, const unsigned idx, float zVal, std::array< TICLLayerTile, 2 > &tracksterTiles)
const StringCutObjectSelector< reco::Track > cutTk_
void recordTrackster(const unsigned ts, const std::vector< Trackster > &tracksters, const edm::Handle< std::vector< Trackster >> tsH, std::vector< unsigned > &ts_mask, float &energy_in_candidate, TICLCandidate &candidate)
T sqrt(T t)
Definition: SSEVec.h:23
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
void dumpLinksFound(std::vector< std::vector< unsigned >> &resultCollection, const char *label) const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
void findTrackstersInWindow(const std::vector< std::pair< Vector, unsigned >> &seedingCollection, const std::array< TICLLayerTile, 2 > &tracksterTiles, const std::vector< Vector > &tracksterPropPoints, float delta, unsigned trackstersSize, std::vector< std::vector< unsigned >> &resultCollection, bool useMask)
math::XYZVectorF Vector
Definition: Common.h:42
constexpr float mpion2
Definition: Common.h:41
void addTrackster(const edm::Ptr< ticl::Trackster > &trackster)
bool timeAndEnergyCompatible(float &total_raw_energy, const reco::Track &track, const Trackster &trackster, const float &tkTime, const float &tkTimeErr, const float &tkTimeQual, bool useMTDTiming)
const std::vector< edm::Ptr< ticl::Trackster > > tracksters() const
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
void setTrackPtr(const edm::Ptr< reco::Track > &trackPtr)
Definition: TICLCandidate.h:99
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76
#define LogDebug(id)

◆ propagateTrackster()

Vector LinkingAlgoByDirectionGeometric::propagateTrackster ( const Trackster t,
const unsigned  idx,
float  zVal,
std::array< TICLLayerTile, 2 > &  tracksterTiles 
)
private

Definition at line 40 of file LinkingAlgoByDirectionGeometric.cc.

References EcalPhiSymFlatTableProducers_cfi::fill, heavyIonCSV_trainingSettings::idx, and submitPVValidationJobs::t.

Referenced by linkTracksters().

43  {
44  // needs only the positive Z co-ordinate of the surface to propagate to
45  // the correct sign is calculated inside according to the barycenter of trackster
46  Vector const &baryc = t.barycenter();
47  Vector directnv = t.eigenvectors(0);
48 
49  // barycenter as direction for tracksters w/ poor PCA
50  // propagation still done to get the cartesian coords
51  // which are anyway converted to eta, phi in linking
52  // -> can be simplified later
53 
54  //FP: disable PCA propagation for the moment and fallback to barycenter position
55  // if (t.eigenvalues()[0] / t.eigenvalues()[1] < 20)
56  directnv = baryc.unit();
57 
58  zVal *= (baryc.Z() > 0) ? 1 : -1;
59 
60  float par = (zVal - baryc.Z()) / directnv.Z();
61  float xOnSurface = par * directnv.X() + baryc.X();
62  float yOnSurface = par * directnv.Y() + baryc.Y();
63  Vector tPoint(xOnSurface, yOnSurface, zVal);
64  if (tPoint.Eta() > 0)
65  tracksterTiles[1].fill(tPoint.Eta(), tPoint.Phi(), idx);
66 
67  else if (tPoint.Eta() < 0)
68  tracksterTiles[0].fill(tPoint.Eta(), tPoint.Phi(), idx);
69 
70  return tPoint;
71 }
math::XYZVectorF Vector
Definition: Common.h:42

◆ recordTrackster()

void LinkingAlgoByDirectionGeometric::recordTrackster ( const unsigned  ts,
const std::vector< Trackster > &  tracksters,
const edm::Handle< std::vector< Trackster >>  tsH,
std::vector< unsigned > &  ts_mask,
float &  energy_in_candidate,
TICLCandidate candidate 
)
private

Definition at line 175 of file LinkingAlgoByDirectionGeometric.cc.

References TICLCandidate::addTrackster(), and HitToTracksterAssociation_cfi::tracksters.

Referenced by linkTracksters().

180  {
181  if (ts_mask[ts])
182  return;
183  candidate.addTrackster(edm::Ptr<Trackster>(tsH, ts));
184  ts_mask[ts] = 1;
185  energy_in_candidate += tracksters[ts].raw_energy();
186 }
void addTrackster(const edm::Ptr< ticl::Trackster > &trackster)

◆ timeAndEnergyCompatible()

bool LinkingAlgoByDirectionGeometric::timeAndEnergyCompatible ( float &  total_raw_energy,
const reco::Track track,
const Trackster trackster,
const float &  tkTime,
const float &  tkTimeErr,
const float &  tkTimeQual,
bool  useMTDTiming 
)
private

Definition at line 136 of file LinkingAlgoByDirectionGeometric.cc.

References funct::abs(), ticl::Advanced, ticl::LinkingAlgoBase::algo_verbosity_, LogDebug, maxDeltaT_, SiStripPI::min, or, ticl::Trackster::raw_energy(), mathSSE::sqrt(), DiMuonV_cfg::threshold, ticl::Trackster::time(), ticl::Trackster::timeError(), timing_quality_threshold_, HLT_2024v14_cff::track, and hltPfTICL_cfi::useMTDTiming.

Referenced by linkTracksters().

142  {
143  float threshold = std::min(0.2 * trackster.raw_energy(), 10.0);
144 
145  bool energyCompatible = (total_raw_energy + trackster.raw_energy() < track.p() + threshold);
146 
147  if (!useMTDTiming)
148  return energyCompatible;
149 
150  // compatible if trackster time is within 3sigma of
151  // track time; compatible if either: no time assigned
152  // to trackster or track time quality is below threshold
153  float tsT = trackster.time();
154  float tsTErr = trackster.timeError();
155 
156  bool timeCompatible = false;
157 
158  if (tsT == -99. or tkTimeQual < timing_quality_threshold_)
159  timeCompatible = true;
160  else {
161  timeCompatible = (std::abs(tsT - tkT) < maxDeltaT_ * sqrt(tsTErr * tsTErr + tkTErr * tkTErr));
162  }
163 
165  if (!(energyCompatible))
166  LogDebug("LinkingAlgoByDirectionGeometric")
167  << "energy incompatible : track p " << track.p() << " trackster energy " << trackster.raw_energy() << "\n";
168  if (!(timeCompatible))
169  LogDebug("LinkingAlgoByDirectionGeometric") << "time incompatible : track time " << tkT << " +/- " << tkTErr
170  << " trackster time " << tsT << " +/- " << tsTErr << "\n";
171  }
172  return energyCompatible && timeCompatible;
173 }
const float timeError() const
Definition: Trackster.h:152
const float raw_energy() const
Definition: Trackster.h:154
T sqrt(T t)
Definition: SSEVec.h:23
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
const float time() const
Definition: Trackster.h:151
#define LogDebug(id)

Member Data Documentation

◆ bfield_

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

Definition at line 102 of file LinkingAlgoByDirectionGeometric.h.

Referenced by initialize(), and linkTracksters().

◆ cutTk_

const StringCutObjectSelector<reco::Track> ticl::LinkingAlgoByDirectionGeometric::cutTk_
private

Definition at line 92 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_int_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_int_
private

Definition at line 86 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_layer1_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_layer1_
private

Definition at line 85 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_em_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_em_had_
private

Definition at line 87 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_had_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_had_had_
private

Definition at line 88 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ firstDisk_

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

Definition at line 97 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ hgcons_

const HGCalDDDConstants* ticl::LinkingAlgoByDirectionGeometric::hgcons_
private

Definition at line 95 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), initialize(), and linkTracksters().

◆ initializeGeometry_

std::once_flag ticl::LinkingAlgoByDirectionGeometric::initializeGeometry_
private

Definition at line 93 of file LinkingAlgoByDirectionGeometric.h.

◆ interfaceDisk_

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

Definition at line 98 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ maxDeltaT_

const float ticl::LinkingAlgoByDirectionGeometric::maxDeltaT_ = 3.0f
private

Definition at line 84 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ propagator_

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

Definition at line 103 of file LinkingAlgoByDirectionGeometric.h.

Referenced by initialize().

◆ rhtools_

hgcal::RecHitTools ticl::LinkingAlgoByDirectionGeometric::rhtools_
private

Definition at line 100 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), initialize(), and linkTracksters().

◆ timing_quality_threshold_

const float ticl::LinkingAlgoByDirectionGeometric::timing_quality_threshold_
private

Definition at line 90 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ tkEnergyCut_

const float ticl::LinkingAlgoByDirectionGeometric::tkEnergyCut_ = 2.0f
private

Definition at line 83 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().