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

typedef math::XYZVector 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)
 
math::XYZVector 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 25 of file LinkingAlgoByDirectionGeometric.h.

Member Typedef Documentation

◆ Vector

Definition at line 48 of file LinkingAlgoByDirectionGeometric.h.

Constructor & Destructor Documentation

◆ LinkingAlgoByDirectionGeometric()

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

Definition at line 16 of file LinkingAlgoByDirectionGeometric.cc.

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

◆ ~LinkingAlgoByDirectionGeometric()

LinkingAlgoByDirectionGeometric::~LinkingAlgoByDirectionGeometric ( )
override

Definition at line 25 of file LinkingAlgoByDirectionGeometric.cc.

25 {}

Member Function Documentation

◆ buildLayers()

void LinkingAlgoByDirectionGeometric::buildLayers ( )
private

Definition at line 206 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().

206  {
207  // build disks at HGCal front & EM-Had interface for track propagation
208 
209  float zVal = hgcons_->waferZ(1, true);
210  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
211 
212  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
213  std::pair<float, float> rMinMax_interface = hgcons_->rangeR(zVal_interface, true);
214 
215  for (int iSide = 0; iSide < 2; ++iSide) {
216  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
217  firstDisk_[iSide] =
218  std::make_unique<GeomDet>(Disk::build(Disk::PositionType(0, 0, zSide),
220  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
221  .get());
222 
223  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
224  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
225  Disk::build(Disk::PositionType(0, 0, zSide),
227  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
228  .get());
229  }
230 }
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:141
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:75

◆ dumpLinksFound()

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

Definition at line 187 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by linkTracksters().

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

◆ fillPSetDescription()

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

Definition at line 569 of file LinkingAlgoByDirectionGeometric.cc.

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

569  {
570  desc.add<std::string>("cutTk",
571  "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
572  "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
573  desc.add<double>("delta_tk_ts_layer1", 0.02);
574  desc.add<double>("delta_tk_ts_interface", 0.03);
575  desc.add<double>("delta_ts_em_had", 0.03);
576  desc.add<double>("delta_ts_had_had", 0.03);
577  desc.add<double>("track_time_quality_threshold", 0.5);
579 }
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 72 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by linkTracksters().

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

◆ initialize()

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

Implements ticl::LinkingAlgoBase.

Definition at line 27 of file LinkingAlgoByDirectionGeometric.cc.

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

30  {
31  hgcons_ = hgcons;
32  rhtools_ = rhtools;
33  buildLayers();
34 
35  bfield_ = bfieldH;
36  propagator_ = propH;
37 }

◆ 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 232 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, ntuplemaker::fill, findTrackstersInWindow(), firstDisk_, hgcal::RecHitTools::getPositionLayer(), hgcons_, mps_fire::i, createfilelist::int, interfaceDisk_, hgcal::RecHitTools::lastLayerEE(), LogDebug, ticl::mpion2, PFMuonAlgo::muAssocToTrack(), PDWG_BPHSkim_cff::muons, or, trajectoryStateTransform::outerFreeState(), edm::ESHandle< T >::product(), Propagator::propagate(), propagateTrackster(), recordTrackster(), rhtools_, TICLCandidate::setTrackPtr(), mathSSE::sqrt(), submitPVValidationJobs::t, timeAndEnergyCompatible(), tkEnergyCut_, pwdgSkimBPark_cfi::tracks, TICLCandidate::tracksters(), pfTICL_cfi::useMTDTiming, and HGCalDDDConstants::waferZ().

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

◆ propagateTrackster()

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

Definition at line 39 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by linkTracksters().

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

◆ 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 174 of file LinkingAlgoByDirectionGeometric.cc.

References TICLCandidate::addTrackster().

Referenced by linkTracksters().

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

◆ 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 135 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by linkTracksters().

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

Member Data Documentation

◆ bfield_

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

Definition at line 101 of file LinkingAlgoByDirectionGeometric.h.

Referenced by initialize(), and linkTracksters().

◆ cutTk_

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

Definition at line 91 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_int_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_int_
private

Definition at line 85 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_layer1_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_layer1_
private

Definition at line 84 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_em_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_em_had_
private

Definition at line 86 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_had_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_had_had_
private

Definition at line 87 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ firstDisk_

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

Definition at line 96 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ hgcons_

const HGCalDDDConstants* ticl::LinkingAlgoByDirectionGeometric::hgcons_
private

Definition at line 94 of file LinkingAlgoByDirectionGeometric.h.

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

◆ initializeGeometry_

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

Definition at line 92 of file LinkingAlgoByDirectionGeometric.h.

◆ interfaceDisk_

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

Definition at line 97 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ maxDeltaT_

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

Definition at line 83 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ propagator_

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

Definition at line 102 of file LinkingAlgoByDirectionGeometric.h.

Referenced by initialize().

◆ rhtools_

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

Definition at line 99 of file LinkingAlgoByDirectionGeometric.h.

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

◆ timing_quality_threshold_

const float ticl::LinkingAlgoByDirectionGeometric::timing_quality_threshold_
private

Definition at line 89 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ tkEnergyCut_

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

Definition at line 82 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().