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::ValueMap< float > &, const edm::ValueMap< float > &, const edm::ValueMap< float > &, const std::vector< reco::Muon > &, const edm::Handle< std::vector< Trackster >>, 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)
 

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 47 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:307
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 201 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().

201  {
202  // build disks at HGCal front & EM-Had interface for track propagation
203 
204  float zVal = hgcons_->waferZ(1, true);
205  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
206 
207  float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
208  std::pair<float, float> rMinMax_interface = hgcons_->rangeR(zVal_interface, true);
209 
210  for (int iSide = 0; iSide < 2; ++iSide) {
211  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
212  firstDisk_[iSide] =
213  std::make_unique<GeomDet>(Disk::build(Disk::PositionType(0, 0, zSide),
215  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
216  .get());
217 
218  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
219  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
220  Disk::build(Disk::PositionType(0, 0, zSide),
222  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
223  .get());
224  }
225 }
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 182 of file LinkingAlgoByDirectionGeometric.cc.

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

Referenced by linkTracksters().

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

◆ fillPSetDescription()

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

Definition at line 511 of file LinkingAlgoByDirectionGeometric.cc.

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

511  {
512  desc.add<std::string>("cutTk",
513  "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
514  "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
515  desc.add<double>("delta_tk_ts_layer1", 0.02);
516  desc.add<double>("delta_tk_ts_interface", 0.03);
517  desc.add<double>("delta_ts_em_had", 0.03);
518  desc.add<double>("delta_ts_had_had", 0.03);
519  desc.add<double>("track_time_quality_threshold", 0.5);
521 }
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::ValueMap< float > &  tkTime,
const edm::ValueMap< float > &  tkTimeErr,
const edm::ValueMap< float > &  tkTimeQual,
const std::vector< reco::Muon > &  muons,
const edm::Handle< std::vector< Trackster >>  tsH,
std::vector< TICLCandidate > &  resultLinked,
std::vector< TICLCandidate > &  chargedHadronsFromTk 
)
overridevirtual

Implements ticl::LinkingAlgoBase.

Definition at line 227 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(), and HGCalDDDConstants::waferZ().

234  {
235  const auto &tracks = *tkH;
236  const auto &tracksters = *tsH;
237 
238  auto bFieldProd = bfield_.product();
239  const Propagator &prop = (*propagator_);
240 
241  // propagated point collections
242  // elements in the propagated points collecions are used
243  // to look for potential linkages in the appropriate tiles
244  std::vector<std::pair<Vector, unsigned>> trackPColl; // propagated track points and index of track in collection
245  std::vector<std::pair<Vector, unsigned>> tkPropIntColl; // tracks propagated to lastLayerEE
246  std::vector<std::pair<Vector, unsigned>> tsPropIntColl; // Tracksters in CE-E, propagated to lastLayerEE
247  std::vector<std::pair<Vector, unsigned>> tsHadPropIntColl; // Tracksters in CE-H, propagated to lastLayerEE
248  trackPColl.reserve(tracks.size());
249  tkPropIntColl.reserve(tracks.size());
250  tsPropIntColl.reserve(tracksters.size());
251  tsHadPropIntColl.reserve(tracksters.size());
252  // tiles, element 0 is bw, 1 is fw
253  std::array<TICLLayerTile, 2> tracksterPropTiles = {}; // all Tracksters, propagated to layer 1
254  std::array<TICLLayerTile, 2> tsPropIntTiles = {}; // all Tracksters, propagated to lastLayerEE
255  std::array<TICLLayerTile, 2> tsHadPropIntTiles = {}; // Tracksters in CE-H, propagated to lastLayerEE
256 
257  // linking : trackster is hadronic if its barycenter is in CE-H
258  auto isHadron = [&](const Trackster &t) -> bool {
259  auto boundary_z = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z();
260  return (std::abs(t.barycenter().Z()) > boundary_z);
261  };
262 
264  LogDebug("LinkingAlgoByDirectionGeometric") << "------- Geometric Linking ------- \n";
265 
266  // Propagate tracks
267  std::vector<unsigned> candidateTrackIds;
268  candidateTrackIds.reserve(tracks.size());
269  for (unsigned i = 0; i < tracks.size(); ++i) {
270  const auto &tk = tracks[i];
271  reco::TrackRef trackref = reco::TrackRef(tkH, i);
272 
273  // veto tracks associated to muons
274  int muId = PFMuonAlgo::muAssocToTrack(trackref, muons);
275 
277  LogDebug("LinkingAlgoByDirectionGeometric")
278  << "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " time " << tkTime[reco::TrackRef(tkH, i)]
279  << " time qual " << tkTimeQual[reco::TrackRef(tkH, i)] << " muid " << muId << "\n";
280 
281  if (!cutTk_((tk)) or muId != -1)
282  continue;
283 
284  // record tracks that can be used to make a ticlcandidate
285  candidateTrackIds.push_back(i);
286 
287  // don't consider tracks below 2 GeV for linking
288  if (std::sqrt(tk.p() * tk.p() + ticl::mpion2) < tkEnergyCut_)
289  continue;
290 
291  int iSide = int(tk.eta() > 0);
292  const auto &fts = trajectoryStateTransform::outerFreeState((tk), bFieldProd);
293  // to the HGCal front
294  const auto &tsos = prop.propagate(fts, firstDisk_[iSide]->surface());
295  if (tsos.isValid()) {
296  Vector trackP(tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z());
297  trackPColl.emplace_back(trackP, i);
298  }
299  // to lastLayerEE
300  const auto &tsos_int = prop.propagate(fts, interfaceDisk_[iSide]->surface());
301  if (tsos_int.isValid()) {
302  Vector trackP(tsos_int.globalPosition().x(), tsos_int.globalPosition().y(), tsos_int.globalPosition().z());
303  tkPropIntColl.emplace_back(trackP, i);
304  }
305  } // Tracks
306  tkPropIntColl.shrink_to_fit();
307  trackPColl.shrink_to_fit();
308  candidateTrackIds.shrink_to_fit();
309 
310  // Propagate tracksters
311 
312  // Record postions of all tracksters propagated to layer 1 and lastLayerEE,
313  // to be used later for distance calculation in the link finding stage
314  // indexed by trackster index in event collection
315  std::vector<Vector> tsAllProp;
316  std::vector<Vector> tsAllPropInt;
317  tsAllProp.reserve(tracksters.size());
318  tsAllPropInt.reserve(tracksters.size());
319 
320  for (unsigned i = 0; i < tracksters.size(); ++i) {
321  const auto &t = tracksters[i];
323  LogDebug("LinkingAlgoByDirectionGeometric")
324  << "trackster " << i << " - eta " << t.barycenter().eta() << " phi " << t.barycenter().phi() << " time "
325  << t.time() << " energy " << t.raw_energy() << "\n";
326 
327  // to HGCal front
328  float zVal = hgcons_->waferZ(1, true);
329  auto tsP = propagateTrackster(t, i, zVal, tracksterPropTiles);
330  tsAllProp.emplace_back(tsP);
331 
332  // to lastLayerEE
334  tsP = propagateTrackster(t, i, zVal, tsPropIntTiles);
335  tsAllPropInt.emplace_back(tsP);
336 
337  if (!isHadron(t)) // EM tracksters
338  tsPropIntColl.emplace_back(tsP, i);
339  else { // HAD
340  tsHadPropIntTiles[(t.barycenter().Z() > 0) ? 1 : 0].fill(tsP.Eta(), tsP.Phi(), i);
341  tsHadPropIntColl.emplace_back(tsP, i);
342  }
343  } // TS
344  tsPropIntColl.shrink_to_fit();
345  tsHadPropIntColl.shrink_to_fit();
346 
347  // Track - Trackster link finding
348  // step 3: tracks -> all tracksters, at layer 1
349 
350  std::vector<std::vector<unsigned>> tsNearTk(tracks.size());
351  findTrackstersInWindow(trackPColl, tracksterPropTiles, tsAllProp, del_tk_ts_layer1_, tracksters.size(), tsNearTk);
352 
353  // step 4: tracks -> all tracksters, at lastLayerEE
354 
355  std::vector<std::vector<unsigned>> tsNearTkAtInt(tracks.size());
356  findTrackstersInWindow(tkPropIntColl, tsPropIntTiles, tsAllPropInt, del_tk_ts_int_, tracksters.size(), tsNearTkAtInt);
357 
358  // Trackster - Trackster link finding
359  // step 2: tracksters EM -> HAD, at lastLayerEE
360 
361  std::vector<std::vector<unsigned>> tsNearAtInt(tracksters.size());
363  tsPropIntColl, tsHadPropIntTiles, tsAllPropInt, del_ts_em_had_, tracksters.size(), tsNearAtInt);
364 
365  // step 1: tracksters HAD -> HAD, at lastLayerEE
366 
367  std::vector<std::vector<unsigned>> tsHadNearAtInt(tracksters.size());
369  tsHadPropIntColl, tsHadPropIntTiles, tsAllPropInt, del_ts_had_had_, tracksters.size(), tsHadNearAtInt);
370 
371 #ifdef EDM_ML_DEBUG
372  dumpLinksFound(tsNearTk, "track -> tracksters at layer 1");
373  dumpLinksFound(tsNearTkAtInt, "track -> tracksters at lastLayerEE");
374  dumpLinksFound(tsNearAtInt, "EM -> HAD tracksters at lastLayerEE");
375  dumpLinksFound(tsHadNearAtInt, "HAD -> HAD tracksters at lastLayerEE");
376 #endif //EDM_ML_DEBUG
377 
378  // make final collections
379 
380  std::vector<TICLCandidate> chargedCandidates;
381  std::vector<unsigned int> chargedMask(tracksters.size(), 0);
382  for (unsigned &i : candidateTrackIds) {
383  if (tsNearTk[i].empty() && tsNearTkAtInt[i].empty()) { // nothing linked to track, make charged hadrons
384  TICLCandidate chargedHad;
385  chargedHad.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
386  chargedHadronsFromTk.push_back(chargedHad);
387  continue;
388  }
389 
390  TICLCandidate chargedCandidate;
391  float total_raw_energy = 0.;
392 
393  auto tkRef = reco::TrackRef(tkH, i);
394  auto track_time = tkTime[tkRef];
395  auto track_timeErr = tkTimeErr[tkRef];
396  auto track_timeQual = tkTimeQual[tkRef];
397 
398  for (const unsigned ts3_idx : tsNearTk[i]) { // tk -> ts
400  total_raw_energy, tracks[i], tracksters[ts3_idx], track_time, track_timeErr, track_timeQual)) {
401  recordTrackster(ts3_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
402  }
403  for (const unsigned ts2_idx : tsNearAtInt[ts3_idx]) { // ts_EM -> ts_HAD
405  total_raw_energy, tracks[i], tracksters[ts2_idx], track_time, track_timeErr, track_timeQual)) {
406  recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
407  }
408  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) { // ts_HAD -> ts_HAD
410  total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
411  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
412  }
413  }
414  }
415  for (const unsigned ts1_idx : tsHadNearAtInt[ts3_idx]) { // ts_HAD -> ts_HAD
417  total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
418  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
419  }
420  }
421  }
422  for (const unsigned ts4_idx : tsNearTkAtInt[i]) { // do the same for tk -> ts links at the interface
424  total_raw_energy, tracks[i], tracksters[ts4_idx], track_time, track_timeErr, track_timeQual)) {
425  recordTrackster(ts4_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
426  }
427  for (const unsigned ts2_idx : tsNearAtInt[ts4_idx]) {
429  total_raw_energy, tracks[i], tracksters[ts2_idx], track_time, track_timeErr, track_timeQual)) {
430  recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
431  }
432  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) {
434  total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
435  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
436  }
437  }
438  }
439  for (const unsigned ts1_idx : tsHadNearAtInt[ts4_idx]) {
441  total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
442  recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
443  }
444  }
445  }
446 
447  // do not create a candidate if no tracksters were added to candidate
448  // can happen if all the tracksters linked to that track were already masked
449  if (!chargedCandidate.tracksters().empty()) {
450  chargedCandidate.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
451  chargedCandidates.push_back(chargedCandidate);
452  } else { // create charged hadron
453  TICLCandidate chargedHad;
454  chargedHad.setTrackPtr(edm::Ptr<reco::Track>(tkH, i));
455  chargedHadronsFromTk.push_back(chargedHad);
456  }
457  }
458 
459  std::vector<TICLCandidate> neutralCandidates;
460  std::vector<int> neutralMask(tracksters.size(), 0);
461  for (unsigned i = 0; i < tracksters.size(); ++i) {
462  if (chargedMask[i])
463  continue;
464 
465  TICLCandidate neutralCandidate;
466  if (tsNearAtInt[i].empty() && tsHadNearAtInt[i].empty() && !neutralMask[i]) { // nothing linked to this ts
467  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, i));
468  neutralMask[i] = 1;
469  neutralCandidates.push_back(neutralCandidate);
470  continue;
471  }
472  if (!neutralMask[i]) {
473  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, i));
474  neutralMask[i] = 1;
475  }
476  for (const unsigned ts2_idx : tsNearAtInt[i]) {
477  if (chargedMask[ts2_idx])
478  continue;
479  if (!neutralMask[ts2_idx]) {
480  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts2_idx));
481  neutralMask[ts2_idx] = 1;
482  }
483  for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) {
484  if (chargedMask[ts1_idx])
485  continue;
486  if (!neutralMask[ts1_idx]) {
487  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts1_idx));
488  neutralMask[ts1_idx] = 1;
489  }
490  }
491  }
492  for (const unsigned ts1_idx : tsHadNearAtInt[i]) {
493  if (chargedMask[ts1_idx])
494  continue;
495  if (!neutralMask[ts1_idx]) {
496  neutralCandidate.addTrackster(edm::Ptr<Trackster>(tsH, ts1_idx));
497  neutralMask[ts1_idx] = 1;
498  }
499  }
500  // filter empty candidates
501  if (!neutralCandidate.tracksters().empty()) {
502  neutralCandidates.push_back(neutralCandidate);
503  }
504  }
505 
506  resultLinked.insert(std::end(resultLinked), std::begin(neutralCandidates), std::end(neutralCandidates));
507  resultLinked.insert(std::end(resultLinked), std::begin(chargedCandidates), std::end(chargedCandidates));
508 
509 } // 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
bool timeAndEnergyCompatible(float &total_raw_energy, const reco::Track &track, const Trackster &trackster, const float &tkTime, const float &tkTimeErr, const float &tkTimeQual)
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
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 169 of file LinkingAlgoByDirectionGeometric.cc.

References TICLCandidate::addTrackster().

Referenced by linkTracksters().

174  {
175  if (ts_mask[ts])
176  return;
177  candidate.addTrackster(edm::Ptr<Trackster>(tsH, ts));
178  ts_mask[ts] = 1;
179  energy_in_candidate += tracksters[ts].raw_energy();
180 }
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 
)
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_, and HLT_2023v12_cff::track.

Referenced by linkTracksters().

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

Referenced by initialize(), and linkTracksters().

◆ cutTk_

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

Definition at line 89 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_int_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_int_
private

Definition at line 83 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_tk_ts_layer1_

const float ticl::LinkingAlgoByDirectionGeometric::del_tk_ts_layer1_
private

Definition at line 82 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_em_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_em_had_
private

Definition at line 84 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ del_ts_had_had_

const float ticl::LinkingAlgoByDirectionGeometric::del_ts_had_had_
private

Definition at line 85 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().

◆ firstDisk_

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

Definition at line 94 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ hgcons_

const HGCalDDDConstants* ticl::LinkingAlgoByDirectionGeometric::hgcons_
private

Definition at line 92 of file LinkingAlgoByDirectionGeometric.h.

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

◆ initializeGeometry_

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

Definition at line 90 of file LinkingAlgoByDirectionGeometric.h.

◆ interfaceDisk_

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

Definition at line 95 of file LinkingAlgoByDirectionGeometric.h.

Referenced by buildLayers(), and linkTracksters().

◆ maxDeltaT_

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

Definition at line 81 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ propagator_

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

Definition at line 100 of file LinkingAlgoByDirectionGeometric.h.

Referenced by initialize().

◆ rhtools_

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

Definition at line 97 of file LinkingAlgoByDirectionGeometric.h.

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

◆ timing_quality_threshold_

const float ticl::LinkingAlgoByDirectionGeometric::timing_quality_threshold_
private

Definition at line 87 of file LinkingAlgoByDirectionGeometric.h.

Referenced by timeAndEnergyCompatible().

◆ tkEnergyCut_

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

Definition at line 80 of file LinkingAlgoByDirectionGeometric.h.

Referenced by linkTracksters().