CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
QuickTrackAssociatorByHitsImpl Class Reference

TrackToTrackingParticleAssociator that associates by hits a bit quicker than the normal TrackAssociatorByHitsImpl class. More...

#include <QuickTrackAssociatorByHitsImpl.h>

Inheritance diagram for QuickTrackAssociatorByHitsImpl:
reco::TrackToTrackingParticleAssociatorBaseImpl

Public Types

enum  SimToRecoDenomType { denomnone, denomsim, denomreco }
 

Public Member Functions

reco::RecoToSimCollection associateRecoToSim (const edm::Handle< edm::View< reco::Track > > &trackCollectionHandle, const edm::Handle< TrackingParticleCollection > &trackingParticleCollectionHandle) const override
 
reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &trackCollection, const edm::RefVector< TrackingParticleCollection > &trackingParticleCollection) const override
 Association Reco To Sim with Collections. More...
 
reco::RecoToSimCollectionSeed associateRecoToSim (const edm::Handle< edm::View< TrajectorySeed > > &, const edm::Handle< TrackingParticleCollection > &) const override
 
reco::RecoToSimCollectionTCandidate associateRecoToSim (const edm::Handle< TrackCandidateCollection > &, const edm::RefVector< TrackingParticleCollection > &) const override
 
reco::SimToRecoCollection associateSimToReco (const edm::Handle< edm::View< reco::Track > > &trackCollectionHandle, const edm::Handle< TrackingParticleCollection > &trackingParticleCollectionHandle) const override
 
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &trackCollection, const edm::RefVector< TrackingParticleCollection > &trackingParticleCollection) const override
 Association Sim To Reco with Collections. More...
 
reco::SimToRecoCollectionSeed associateSimToReco (const edm::Handle< edm::View< TrajectorySeed > > &, const edm::Handle< TrackingParticleCollection > &) const override
 
reco::SimToRecoCollectionTCandidate associateSimToReco (const edm::Handle< TrackCandidateCollection > &, const edm::RefVector< TrackingParticleCollection > &) const override
 
 QuickTrackAssociatorByHitsImpl (edm::EDProductGetter const &productGetter, std::unique_ptr< const TrackerHitAssociator > hitAssoc, const ClusterTPAssociation *clusterToTPMap, bool absoluteNumberOfHits, double qualitySimToReco, double puritySimToReco, double cutRecoToSim, double pixelHitWeight, bool threeHitTracksAreSpecial, SimToRecoDenomType simToRecoDenominator)
 
template<>
double weightedNumberOfTrackClusters (const reco::Track &track, const TrackerHitAssociator &) const
 
template<>
double weightedNumberOfTrackClusters (const reco::Track &track, const ClusterTPAssociation &) const
 
- Public Member Functions inherited from reco::TrackToTrackingParticleAssociatorBaseImpl
virtual reco::RecoToSimCollection associateRecoToSim (const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
 
virtual reco::RecoToSimCollectionSeed associateRecoToSim (const edm::Handle< edm::View< TrajectorySeed >> &, const edm::Handle< TrackingParticleCollection > &) const
 
virtual reco::SimToRecoCollection associateSimToReco (const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
 
virtual reco::SimToRecoCollectionSeed associateSimToReco (const edm::Handle< edm::View< TrajectorySeed >> &, const edm::Handle< TrackingParticleCollection > &) const
 
 TrackToTrackingParticleAssociatorBaseImpl ()
 Constructor. More...
 
virtual ~TrackToTrackingParticleAssociatorBaseImpl ()
 Destructor. More...
 

Private Types

typedef std::pair< uint32_t, EncodedEventIdSimTrackIdentifiers
 This is enough information to uniquely identify a sim track. More...
 
typedef edm::IndexSet TrackingParticleRefKeySet
 Set for TrackingParticleRef keys. More...
 

Private Member Functions

template<class T_RecoToSimCollection , class T_TrackCollection , class T_TrackingParticleCollection , class T_hitOrClusterAssociator >
T_RecoToSimCollection associateRecoToSimImplementation (const T_TrackCollection &trackCollection, const T_TrackingParticleCollection &trackingParticleCollection, const TrackingParticleRefKeySet *trackingParticleKeys, T_hitOrClusterAssociator hitOrClusterAssociator) const
 The method that does the work for both overloads of associateRecoToSim. More...
 
template<class T_SimToRecoCollection , class T_TrackCollection , class T_TrackingParticleCollection , class T_hitOrClusterAssociator >
T_SimToRecoCollection associateSimToRecoImplementation (const T_TrackCollection &trackCollection, const T_TrackingParticleCollection &trackingParticleCollection, const TrackingParticleRefKeySet *trackingParticleKeys, T_hitOrClusterAssociator hitOrClusterAssociator) const
 The method that does the work for both overloads of associateSimToReco. More...
 
template<typename T_TPCollection , typename iter >
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > associateTrack (const TrackerHitAssociator &hitAssociator, const T_TPCollection &trackingParticles, const TrackingParticleRefKeySet *trackingParticleKeys, iter begin, iter end) const
 Returns the TrackingParticle that has the most associated hits to the given track. More...
 
template<typename T_TPCollection , typename iter >
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > associateTrack (const ClusterTPAssociation &clusterToTPMap, const T_TPCollection &trackingParticles, const TrackingParticleRefKeySet *trackingParticleKeys, iter begin, iter end) const
 Returns the TrackingParticle that has the most associated hits to the given track. More...
 
template<typename iter >
std::vector< std::pair< SimTrackIdentifiers, double > > getAllSimTrackIdentifiers (const TrackerHitAssociator &hitAssociator, iter begin, iter end) const
 Returns a vector of pairs where first is a SimTrackIdentifiers (see typedef above) and second is the number of hits that came from that sim track. More...
 
template<typename iter >
double getDoubleCount (const TrackerHitAssociator &hitAssociator, iter begin, iter end, TrackingParticleRef associatedTrackingParticle) const
 This method was copied almost verbatim from the standard TrackAssociatorByHits. More...
 
template<typename iter >
double getDoubleCount (const ClusterTPAssociation &clusterToTPList, iter begin, iter end, TrackingParticleRef associatedTrackingParticle) const
 Overload for when using cluster to TrackingParticle association list. More...
 
bool trackingParticleContainsIdentifier (const TrackingParticle *pTrackingParticle, const SimTrackIdentifiers &identifier) const
 Returns true if the supplied TrackingParticle has the supplied g4 track identifiers. More...
 
template<typename T_Track >
double weightedNumberOfTrackClusters (const T_Track &track, const TrackerHitAssociator &) const
 
template<typename T_Track >
double weightedNumberOfTrackClusters (const T_Track &track, const ClusterTPAssociation &) const
 
template<typename iter >
double weightedNumberOfTrackClusters (iter begin, iter end) const
 

Static Private Member Functions

static bool tpIntPairGreater (std::pair< edm::Ref< TrackingParticleCollection >, size_t > i, std::pair< edm::Ref< TrackingParticleCollection >, size_t > j)
 

Private Attributes

bool absoluteNumberOfHits_
 
const ClusterTPAssociationclusterToTPMap_
 
double cutRecoToSim_
 
std::unique_ptr< const TrackerHitAssociatorhitAssociator_
 
double pixelHitWeight_
 
edm::EDProductGetter const * productGetter_
 creates either a ClusterTPAssociation OR a TrackerHitAssociator and stores it in the provided unique_ptr. The other will be null. More...
 
double puritySimToReco_
 
double qualitySimToReco_
 
SimToRecoDenomType simToRecoDenominator_
 
bool threeHitTracksAreSpecial_
 

Detailed Description

TrackToTrackingParticleAssociator that associates by hits a bit quicker than the normal TrackAssociatorByHitsImpl class.

NOTE - Doesn't implement the TrackCandidate association methods (from TrackAssociatorBase) so will always return empty associations for those.

This track associator (mostly) does the same as TrackAssociatorByHitsImpl, but faster. I've tested it a fair bit and can't find any differences between the results of this and the standard TrackAssociatorByHitsImpl.

Configuration parameters:

AbsoluteNumberOfHits - bool - if true, Quality_SimToReco and Cut_RecoToSim are the absolute number of shared hits required for association, not the percentage.

Quality_SimToReco - double - The minimum amount of shared hits required, as a percentage of either the reconstructed hits or simulated hits (see SimToRecoDenominator), for the track to be considered associated during a call to associateSimToReco. See also AbsoluteNumberOfHits.

Purity_SimToReco - double - The minimum amount of shared hits required, as a percentage of the reconstructed hits, for the track to be considered associated during a call to associateSimToReco. Has no effect if AbsoluteNumberOfHits is true.

Cut_RecoToSim - double - The minimum amount of shared hits required, as a percentage of the reconstructed hits, for the track to be considered associated during a call to associateRecoToSim. See also AbsoluteNumberOfHits.

ThreeHitTracksAreSpecial - bool - If true, tracks with 3 hits must have all their hits associated.

SimToRecoDenominator - string - Must be either "sim" or "reco". If "sim" Quality_SimToReco is the percentage of simulated hits that need to be shared. If "reco" then it's the percentage of reconstructed hits (i.e. same as Purity_SimToReco).

associatePixel - bool - Passed on to the hit associator.

associateStrip - bool - Passed on to the hit associator.

requireStoredHits - bool - Whether or not to insist all TrackingParticles have at least one PSimHit. The PSimHits are not required for the association, but the old TrackAssociatorByHitsImpl still had this requirement. Storing PSimHits in the TrackingParticle is now optional (see TrackingTruthAccumulator which replaces TrackingTruthProducer). Having requireStoredHits set to true will mean no TrackingParticles will be associated if you have chosen not to store the hits. The flag is only kept in order to retain the old behaviour which can give very slightly different results.

Note that the TrackAssociatorByHitsImpl parameters UseGrouped and UseSplitting are not used.

Author
Mark Grimes (mark..nosp@m.grim.nosp@m.es@ce.nosp@m.rn.c.nosp@m.h)
Date
09/Nov/2010 Significant changes to remove any differences to the standard TrackAssociatorByHitsImpl results 07/Jul/2011. Association for TrajectorySeeds added by Giuseppe Cerati sometime between 2011 and 2013. Functionality to associate using pre calculated cluster to TrackingParticle maps added by Subir Sarker sometime in 2013. Overhauled to remove mutables to make it thread safe by Mark Grimes 01/May/2014.

Definition at line 66 of file QuickTrackAssociatorByHitsImpl.h.

Member Typedef Documentation

◆ SimTrackIdentifiers

This is enough information to uniquely identify a sim track.

Definition at line 111 of file QuickTrackAssociatorByHitsImpl.h.

◆ TrackingParticleRefKeySet

Set for TrackingParticleRef keys.

Definition at line 113 of file QuickTrackAssociatorByHitsImpl.h.

Member Enumeration Documentation

◆ SimToRecoDenomType

Constructor & Destructor Documentation

◆ QuickTrackAssociatorByHitsImpl()

QuickTrackAssociatorByHitsImpl::QuickTrackAssociatorByHitsImpl ( edm::EDProductGetter const &  productGetter,
std::unique_ptr< const TrackerHitAssociator hitAssoc,
const ClusterTPAssociation clusterToTPMap,
bool  absoluteNumberOfHits,
double  qualitySimToReco,
double  puritySimToReco,
double  cutRecoToSim,
double  pixelHitWeight,
bool  threeHitTracksAreSpecial,
SimToRecoDenomType  simToRecoDenominator 
)

Definition at line 111 of file QuickTrackAssociatorByHitsImpl.cc.

123  hitAssociator_(std::move(hitAssoc)),
124  clusterToTPMap_(clusterToTPMap),
125  qualitySimToReco_(qualitySimToReco),
126  puritySimToReco_(puritySimToReco),
127  pixelHitWeight_(pixelHitWeight),
128  cutRecoToSim_(cutRecoToSim),
129  simToRecoDenominator_(simToRecoDenominator),
130  threeHitTracksAreSpecial_(threeHitTracksAreSpecial),
131  absoluteNumberOfHits_(absoluteNumberOfHits) {}
edm::EDProductGetter const * productGetter_
creates either a ClusterTPAssociation OR a TrackerHitAssociator and stores it in the provided unique_...
const ClusterTPAssociation * clusterToTPMap_
EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< const TrackerHitAssociator > hitAssociator_

Member Function Documentation

◆ associateRecoToSim() [1/4]

reco::RecoToSimCollection QuickTrackAssociatorByHitsImpl::associateRecoToSim ( const edm::Handle< edm::View< reco::Track > > &  trackCollectionHandle,
const edm::Handle< TrackingParticleCollection > &  trackingParticleCollectionHandle 
) const
override

◆ associateRecoToSim() [2/4]

reco::RecoToSimCollection QuickTrackAssociatorByHitsImpl::associateRecoToSim ( const edm::RefToBaseVector< reco::Track > &  tc,
const edm::RefVector< TrackingParticleCollection > &  tpc 
) const
overridevirtual

Association Reco To Sim with Collections.

Implements reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 157 of file QuickTrackAssociatorByHitsImpl.cc.

References clusterToTPMap_, hitAssociator_, JetHT_cfg::trackCollection, and PrimaryVertexAnalyzer4PUSlimmed_cfi::trackingParticleCollection.

159  {
160  // Only pass the one that was successfully created to the templated method.
161  if (not clusterToTPMap_)
162  return associateRecoToSimImplementation<reco::RecoToSimCollection>(
164  else {
166  fillKeys(tpKeys, trackingParticleCollection);
167  return associateRecoToSimImplementation<reco::RecoToSimCollection>(
169  }
170 }
const ClusterTPAssociation * clusterToTPMap_
trackCollection
Definition: JetHT_cfg.py:51
edm::IndexSet TrackingParticleRefKeySet
Set for TrackingParticleRef keys.
std::unique_ptr< const TrackerHitAssociator > hitAssociator_

◆ associateRecoToSim() [3/4]

reco::RecoToSimCollectionSeed QuickTrackAssociatorByHitsImpl::associateRecoToSim ( const edm::Handle< edm::View< TrajectorySeed > > &  ,
const edm::Handle< TrackingParticleCollection > &   
) const
override

◆ associateRecoToSim() [4/4]

reco::RecoToSimCollectionTCandidate QuickTrackAssociatorByHitsImpl::associateRecoToSim ( const edm::Handle< TrackCandidateCollection > &  trackCollectionHandle,
const edm::RefVector< TrackingParticleCollection > &  trackingParticleCollectionHandle 
) const
overridevirtual

Reimplemented from reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 781 of file QuickTrackAssociatorByHitsImpl.cc.

References clusterToTPMap_, and hitAssociator_.

783  {
784  // Only pass the one that was successfully created to the templated method.
785  if (not clusterToTPMap_)
786  return associateRecoToSimImplementation<reco::RecoToSimCollectionTCandidate>(
787  trackCollectionHandle, trackingParticleCollectionHandle, nullptr, *hitAssociator_);
788  else
789  return associateRecoToSimImplementation<reco::RecoToSimCollectionTCandidate>(
790  trackCollectionHandle, trackingParticleCollectionHandle, nullptr, *clusterToTPMap_);
791 }
const ClusterTPAssociation * clusterToTPMap_
std::unique_ptr< const TrackerHitAssociator > hitAssociator_

◆ associateRecoToSimImplementation()

template<class T_RecoToSimCollection , class T_TrackCollection , class T_TrackingParticleCollection , class T_hitOrClusterAssociator >
T_RecoToSimCollection QuickTrackAssociatorByHitsImpl::associateRecoToSimImplementation ( const T_TrackCollection &  trackCollection,
const T_TrackingParticleCollection &  trackingParticleCollection,
const TrackingParticleRefKeySet trackingParticleKeys,
T_hitOrClusterAssociator  hitOrClusterAssociator 
) const
private

The method that does the work for both overloads of associateRecoToSim.

Parts that actually rely on the type of the collections are delegated out to overloaded functions in the unnamed namespace of the .cc file. Parts that rely on the type of T_hitOrClusterAssociator are delegated out to overloaded methods.

Definition at line 191 of file QuickTrackAssociatorByHitsImpl.cc.

References funct::abs(), absoluteNumberOfHits_, associateTrack(), cutRecoToSim_, getDoubleCount(), mps_fire::i, TrackCollections2monitor_cff::numberOfValidHits, productGetter_, quality, threeHitTracksAreSpecial_, JetHT_cfg::trackCollection, PrimaryVertexAnalyzer4PUSlimmed_cfi::trackingParticleCollection, and weightedNumberOfTrackClusters().

195  {
196  T_RecoToSimCollection returnValue(productGetter_);
197  if (::collectionSize(trackingParticleCollection) == 0)
198  return returnValue;
199 
200  checkClusterMapProductID(hitOrClusterAssociator, trackingParticleCollection);
201 
202  size_t collectionSize = ::collectionSize(trackCollection); // Delegate away type specific part
203 
204  for (size_t i = 0; i < collectionSize; ++i) {
205  // Get a normal pointer for ease of use. This part is type specific so delegate.
206  const auto* pTrack = ::getTrackAt(trackCollection, i);
207 
208  // The return of this function has first as the index and second as the number of associated hits
209  std::vector<std::pair<edm::Ref<TrackingParticleCollection>, double>> trackingParticleQualityPairs =
210  associateTrack(hitOrClusterAssociator,
212  trackingParticleKeys,
213  pTrack->recHits().begin(),
214  pTrack->recHits().end());
215 
216  // int nt = 0;
217  for (auto iTrackingParticleQualityPair = trackingParticleQualityPairs.begin();
218  iTrackingParticleQualityPair != trackingParticleQualityPairs.end();
219  ++iTrackingParticleQualityPair) {
220  const edm::Ref<TrackingParticleCollection>& trackingParticleRef = iTrackingParticleQualityPair->first;
221  double numberOfSharedClusters = iTrackingParticleQualityPair->second;
222  double numberOfValidTrackClusters = weightedNumberOfTrackClusters(*pTrack, hitOrClusterAssociator);
223 
224  if (numberOfSharedClusters == 0.0)
225  continue; // No point in continuing if there was no association
226 
227  //if electron subtract double counting
228  if (abs(trackingParticleRef->pdgId()) == 11 &&
229  (trackingParticleRef->g4Track_end() - trackingParticleRef->g4Track_begin()) > 1) {
230  numberOfSharedClusters -= getDoubleCount(
231  hitOrClusterAssociator, pTrack->recHits().begin(), pTrack->recHits().end(), trackingParticleRef);
232  }
233 
234  double quality;
236  quality = numberOfSharedClusters;
237  else if (numberOfValidTrackClusters != 0.0)
238  quality = numberOfSharedClusters / numberOfValidTrackClusters;
239  else
240  quality = 0;
241  if (quality > cutRecoToSim_ &&
242  !(threeHitTracksAreSpecial_ && ::numberOfValidHits(*pTrack) == 3 && numberOfSharedClusters < 3.0)) {
243  // Getting the RefToBase is dependent on the type of trackCollection, so delegate that to an overload.
244  returnValue.insert(::getRefToTrackAt(trackCollection, i), std::make_pair(trackingParticleRef, quality));
245  }
246  }
247  }
248  returnValue.post_insert();
249  return returnValue;
250 }
double weightedNumberOfTrackClusters(const T_Track &track, const TrackerHitAssociator &) const
edm::EDProductGetter const * productGetter_
creates either a ClusterTPAssociation OR a TrackerHitAssociator and stores it in the provided unique_...
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > associateTrack(const TrackerHitAssociator &hitAssociator, const T_TPCollection &trackingParticles, const TrackingParticleRefKeySet *trackingParticleKeys, iter begin, iter end) const
Returns the TrackingParticle that has the most associated hits to the given track.
string quality
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trackCollection
Definition: JetHT_cfg.py:51
double getDoubleCount(const TrackerHitAssociator &hitAssociator, iter begin, iter end, TrackingParticleRef associatedTrackingParticle) const
This method was copied almost verbatim from the standard TrackAssociatorByHits.

◆ associateSimToReco() [1/4]

reco::SimToRecoCollection QuickTrackAssociatorByHitsImpl::associateSimToReco ( const edm::Handle< edm::View< reco::Track > > &  trackCollectionHandle,
const edm::Handle< TrackingParticleCollection > &  trackingParticleCollectionHandle 
) const
override

◆ associateSimToReco() [2/4]

reco::SimToRecoCollection QuickTrackAssociatorByHitsImpl::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  tc,
const edm::RefVector< TrackingParticleCollection > &  tpc 
) const
overridevirtual

Association Sim To Reco with Collections.

Implements reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 172 of file QuickTrackAssociatorByHitsImpl.cc.

References clusterToTPMap_, hitAssociator_, JetHT_cfg::trackCollection, and PrimaryVertexAnalyzer4PUSlimmed_cfi::trackingParticleCollection.

174  {
175  // Only pass the one that was successfully created to the templated method.
176  if (not clusterToTPMap_)
177  return associateSimToRecoImplementation<reco::SimToRecoCollection>(
179  else {
181  fillKeys(tpKeys, trackingParticleCollection);
182  return associateSimToRecoImplementation<reco::SimToRecoCollection>(
184  }
185 }
const ClusterTPAssociation * clusterToTPMap_
trackCollection
Definition: JetHT_cfg.py:51
edm::IndexSet TrackingParticleRefKeySet
Set for TrackingParticleRef keys.
std::unique_ptr< const TrackerHitAssociator > hitAssociator_

◆ associateSimToReco() [3/4]

reco::SimToRecoCollectionSeed QuickTrackAssociatorByHitsImpl::associateSimToReco ( const edm::Handle< edm::View< TrajectorySeed > > &  ,
const edm::Handle< TrackingParticleCollection > &   
) const
override

◆ associateSimToReco() [4/4]

reco::SimToRecoCollectionTCandidate QuickTrackAssociatorByHitsImpl::associateSimToReco ( const edm::Handle< TrackCandidateCollection > &  trackCollectionHandle,
const edm::RefVector< TrackingParticleCollection > &  trackingParticleCollectionHandle 
) const
overridevirtual

Reimplemented from reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 793 of file QuickTrackAssociatorByHitsImpl.cc.

References clusterToTPMap_, and hitAssociator_.

795  {
796  // Only pass the one that was successfully created to the templated method.
797  if (not clusterToTPMap_)
798  return associateSimToRecoImplementation<reco::SimToRecoCollectionTCandidate>(
799  trackCollectionHandle, trackingParticleCollectionHandle, nullptr, *hitAssociator_);
800  else
801  return associateSimToRecoImplementation<reco::SimToRecoCollectionTCandidate>(
802  trackCollectionHandle, trackingParticleCollectionHandle, nullptr, *clusterToTPMap_);
803 }
const ClusterTPAssociation * clusterToTPMap_
std::unique_ptr< const TrackerHitAssociator > hitAssociator_

◆ associateSimToRecoImplementation()

template<class T_SimToRecoCollection , class T_TrackCollection , class T_TrackingParticleCollection , class T_hitOrClusterAssociator >
T_SimToRecoCollection QuickTrackAssociatorByHitsImpl::associateSimToRecoImplementation ( const T_TrackCollection &  trackCollection,
const T_TrackingParticleCollection &  trackingParticleCollection,
const TrackingParticleRefKeySet trackingParticleKeys,
T_hitOrClusterAssociator  hitOrClusterAssociator 
) const
private

The method that does the work for both overloads of associateSimToReco.

Parts that actually rely on the type of the collections are delegated out to overloaded functions in the unnamed namespace of the .cc file. Parts that rely on the type of T_hitOrClusterAssociator are delegated out to overloaded methods.

Definition at line 256 of file QuickTrackAssociatorByHitsImpl.cc.

References funct::abs(), absoluteNumberOfHits_, associateTrack(), denomreco, denomsim, getDoubleCount(), mps_fire::i, productGetter_, puritySimToReco_, quality, qualitySimToReco_, simToRecoDenominator_, threeHitTracksAreSpecial_, JetHT_cfg::trackCollection, PrimaryVertexAnalyzer4PUSlimmed_cfi::trackingParticleCollection, and weightedNumberOfTrackClusters().

260  {
261  T_SimToRecoCollection returnValue(productGetter_);
262  if (::collectionSize(trackingParticleCollection) == 0)
263  return returnValue;
264 
265  checkClusterMapProductID(hitOrClusterAssociator, trackingParticleCollection);
266 
267  size_t collectionSize = ::collectionSize(trackCollection); // Delegate away type specific part
268 
269  for (size_t i = 0; i < collectionSize; ++i) {
270  // Get a normal pointer for ease of use. This part is type specific so delegate.
271  const auto* pTrack = ::getTrackAt(trackCollection, i);
272 
273  // The return of this function has first as an edm:Ref to the associated TrackingParticle, and second as the number of associated hits
274  std::vector<std::pair<edm::Ref<TrackingParticleCollection>, double>> trackingParticleQualityPairs =
275  associateTrack(hitOrClusterAssociator,
277  trackingParticleKeys,
278  pTrack->recHits().begin(),
279  pTrack->recHits().end());
280 
281  // int nt = 0;
282  for (auto iTrackingParticleQualityPair = trackingParticleQualityPairs.begin();
283  iTrackingParticleQualityPair != trackingParticleQualityPairs.end();
284  ++iTrackingParticleQualityPair) {
285  const edm::Ref<TrackingParticleCollection>& trackingParticleRef = iTrackingParticleQualityPair->first;
286  double numberOfSharedClusters = iTrackingParticleQualityPair->second;
287  double numberOfValidTrackClusters = weightedNumberOfTrackClusters(*pTrack, hitOrClusterAssociator);
288  size_t numberOfSimulatedHits = 0; // Set a few lines below, but only if required.
289 
290  if (numberOfSharedClusters == 0.0)
291  continue; // No point in continuing if there was no association
292 
294  (numberOfSharedClusters < 3.0 &&
295  threeHitTracksAreSpecial_)) // the numberOfSimulatedHits is not always required, so can skip counting in some circumstances
296  {
297  // Note that in the standard TrackAssociatorByHits, all of the hits in associatedTrackingParticleHits are checked for
298  // various things. I'm not sure what these checks are for but they depend on the UseGrouping and UseSplitting settings.
299  // This associator works as though both UseGrouping and UseSplitting were set to true, i.e. just counts the number of
300  // hits in the tracker.
301  numberOfSimulatedHits = trackingParticleRef->numberOfTrackerHits();
302  }
303 
304  //if electron subtract double counting
305  if (abs(trackingParticleRef->pdgId()) == 11 &&
306  (trackingParticleRef->g4Track_end() - trackingParticleRef->g4Track_begin()) > 1) {
307  numberOfSharedClusters -= getDoubleCount(
308  hitOrClusterAssociator, pTrack->recHits().begin(), pTrack->recHits().end(), trackingParticleRef);
309  }
310 
311  double purity = numberOfSharedClusters / numberOfValidTrackClusters;
312  double quality;
314  quality = numberOfSharedClusters;
315  else if (simToRecoDenominator_ == denomsim && numberOfSimulatedHits != 0)
316  quality = numberOfSharedClusters / static_cast<double>(numberOfSimulatedHits);
317  else if (simToRecoDenominator_ == denomreco && numberOfValidTrackClusters != 0)
318  quality = purity;
319  else
320  quality = 0;
321 
322  if (quality > qualitySimToReco_ &&
323  !(threeHitTracksAreSpecial_ && numberOfSimulatedHits == 3 && numberOfSharedClusters < 3.0) &&
324  (absoluteNumberOfHits_ || (purity > puritySimToReco_))) {
325  // Getting the RefToBase is dependent on the type of trackCollection, so delegate that to an overload.
326  returnValue.insert(trackingParticleRef, std::make_pair(::getRefToTrackAt(trackCollection, i), quality));
327  }
328  }
329  }
330  returnValue.post_insert();
331  return returnValue;
332 }
double weightedNumberOfTrackClusters(const T_Track &track, const TrackerHitAssociator &) const
edm::EDProductGetter const * productGetter_
creates either a ClusterTPAssociation OR a TrackerHitAssociator and stores it in the provided unique_...
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > associateTrack(const TrackerHitAssociator &hitAssociator, const T_TPCollection &trackingParticles, const TrackingParticleRefKeySet *trackingParticleKeys, iter begin, iter end) const
Returns the TrackingParticle that has the most associated hits to the given track.
string quality
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trackCollection
Definition: JetHT_cfg.py:51
double getDoubleCount(const TrackerHitAssociator &hitAssociator, iter begin, iter end, TrackingParticleRef associatedTrackingParticle) const
This method was copied almost verbatim from the standard TrackAssociatorByHits.

◆ associateTrack() [1/2]

template<typename T_TPCollection , typename iter >
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > QuickTrackAssociatorByHitsImpl::associateTrack ( const TrackerHitAssociator hitAssociator,
const T_TPCollection &  trackingParticles,
const TrackingParticleRefKeySet trackingParticleKeys,
iter  begin,
iter  end 
) const
private

Returns the TrackingParticle that has the most associated hits to the given track.

Return value is a vector of pairs, where first is an edm::Ref to the associated TrackingParticle, and second is the number of associated hits.

Definition at line 335 of file QuickTrackAssociatorByHitsImpl.cc.

References mps_fire::end, getAllSimTrackIdentifiers(), TrackQuality_cff::hitAssociator, mps_fire::i, trackingParticleContainsIdentifier(), and muonClassificationByHits_cfi::trackingParticles.

Referenced by associateRecoToSimImplementation(), and associateSimToRecoImplementation().

340  {
341  // The pairs in this vector have a Ref to the associated TrackingParticle as "first" and the weighted number of associated hits as "second"
342  std::vector<std::pair<edm::Ref<TrackingParticleCollection>, double>> returnValue;
343 
344  // The pairs in this vector have first as the sim track identifiers, and second the number of reco hits associated to that sim track.
345  // Most reco hits will probably have come from the same sim track, so the number of entries in this vector should be fewer than the
346  // number of reco hits. The pair::second entries should add up to the total number of reco hits though.
347  std::vector<std::pair<SimTrackIdentifiers, double>> hitIdentifiers =
349 
350  // Loop over the TrackingParticles
351  size_t collectionSize = ::collectionSize(trackingParticles);
352 
353  for (size_t i = 0; i < collectionSize; ++i) {
354  const TrackingParticle* pTrackingParticle = getTrackingParticleAt(trackingParticles, i);
355 
356  // Historically there was a requirement that pTrackingParticle->numberOfHits() > 0
357  // However, in TrackingTruthAccumulator, the numberOfHits is calculated from a subset
358  // of the SimHits of the SimTracks of a TrackingParticle (essentially limiting the
359  // processType and particleType to those of the "first" hit, and particleType to the pdgId of the SimTrack).
360  // But, here the association between tracks and TrackingParticles is done with *all* the hits of
361  // TrackingParticle, so we should not rely on the numberOfHits() calculated with a subset of SimHits.
362 
363  double numberOfAssociatedHits = 0;
364  // Loop over all of the sim track identifiers and see if any of them are part of this TrackingParticle. If they are, add
365  // the number of reco hits associated to that sim track to the total number of associated hits.
366  for (const auto& identifierCountPair : hitIdentifiers) {
367  if (trackingParticleContainsIdentifier(pTrackingParticle, identifierCountPair.first))
368  numberOfAssociatedHits += identifierCountPair.second;
369  }
370 
371  if (numberOfAssociatedHits > 0) {
372  returnValue.push_back(std::make_pair(getRefToTrackingParticleAt(trackingParticles, i), numberOfAssociatedHits));
373  }
374  }
375 
376  return returnValue;
377 }
std::vector< std::pair< SimTrackIdentifiers, double > > getAllSimTrackIdentifiers(const TrackerHitAssociator &hitAssociator, iter begin, iter end) const
Returns a vector of pairs where first is a SimTrackIdentifiers (see typedef above) and second is the ...
Monte Carlo truth information used for tracking validation.
bool trackingParticleContainsIdentifier(const TrackingParticle *pTrackingParticle, const SimTrackIdentifiers &identifier) const
Returns true if the supplied TrackingParticle has the supplied g4 track identifiers.

◆ associateTrack() [2/2]

template<typename T_TPCollection , typename iter >
std::vector< std::pair< edm::Ref< TrackingParticleCollection >, double > > QuickTrackAssociatorByHitsImpl::associateTrack ( const ClusterTPAssociation clusterToTPMap,
const T_TPCollection &  trackingParticles,
const TrackingParticleRefKeySet trackingParticleKeys,
iter  begin,
iter  end 
) const
private

Returns the TrackingParticle that has the most associated hits to the given track.

See the notes for the other overload for the return type.

Note that the trackingParticles parameter is not actually required since all the information is in clusterToTPMap, but the method signature has to match the other overload because it is called from a templated method.

Definition at line 380 of file QuickTrackAssociatorByHitsImpl.cc.

References ClusterTPAssociation::empty(), mps_fire::end, ClusterTPAssociation::equal_range(), edm::IndexSet::has(), track_associator::hitsToClusterRefs(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, edm::Ref< C, T, F >::key(), pixelHitWeight_, and FastTimerService_cff::range.

385  {
386  // Note that the trackingParticles parameter is not actually required since all the information is in clusterToTPMap,
387  // but the method signature has to match the other overload because it is called from a templated method.
388 
389  // Note further, that we can't completely ignore the
390  // trackingParticles parameter, in case it is a subset of those
391  // TrackingParticles used to construct clusterToTPMap (via the
392  // TrackingParticleRefVector overloads). The trackingParticles
393  // parameter is still ignored since looping over it on every call
394  // would be expensive, but the keys of the TrackingParticleRefs are
395  // cached to an IndexSet (trackingParticleKeys) which is used
396  // as a fast search structure.
397 
398  // The pairs in this vector have a Ref to the associated TrackingParticle as "first" and the weighted number of associated clusters as "second"
399  // Note: typedef edm::Ref<TrackingParticleCollection> TrackingParticleRef;
400  std::vector<std::pair<edm::Ref<TrackingParticleCollection>, double>> returnValue;
401  if (clusterToTPMap.empty())
402  return returnValue;
403 
404  // The pairs in this vector have first as the TP, and second the number of reco clusters associated to that TP.
405  // Most reco clusters will probably have come from the same sim track (i.e TP), so the number of entries in this
406  // vector should be fewer than the number of clusters. The pair::second entries should add up to the total
407  // number of reco clusters though.
408  std::vector<OmniClusterRef> oClusters = track_associator::hitsToClusterRefs(begin, end);
409 
410  std::map<TrackingParticleRef, double> lmap;
411  for (std::vector<OmniClusterRef>::const_iterator it = oClusters.begin(); it != oClusters.end(); ++it) {
412  auto range = clusterToTPMap.equal_range(*it);
413  const double weight = it->isPixel() ? pixelHitWeight_ : 1.0;
414  if (range.first != range.second) {
415  for (auto ip = range.first; ip != range.second; ++ip) {
416  const TrackingParticleRef trackingParticle = (ip->second);
417 
418  if (trackingParticleKeys && !trackingParticleKeys->has(trackingParticle.key()))
419  continue;
420 
421  // Historically there was a requirement that pTrackingParticle->numberOfHits() > 0
422  // However, in TrackingTruthAccumulator, the numberOfHits is calculated from a subset
423  // of the SimHits of the SimTracks of a TrackingParticle (essentially limiting the
424  // processType and particleType to those of the "first" hit, and particleType to the pdgId of the SimTrack).
425  // But, here the association between tracks and TrackingParticles is done with *all* the hits of
426  // TrackingParticle, so we should not rely on the numberOfHits() calculated with a subset of SimHits.
427 
428  /* Alternative implementation to avoid the use of lmap... memory slightly improved but slightly slower...
429  std::pair<edm::Ref<TrackingParticleCollection>,size_t> tpIntPair(trackingParticle, 1);
430  auto tp_range = std::equal_range(returnValue.begin(), returnValue.end(), tpIntPair, tpIntPairGreater);
431  if ((tp_range.second-tp_range.first)>1) {
432  edm::LogError("TrackAssociator") << ">>> Error in counting TPs!" << " file: " << __FILE__ << " line: " << __LINE__;
433  }
434  if(tp_range.first != tp_range.second) {
435  tp_range.first->second++;
436  } else {
437  returnValue.push_back(tpIntPair);
438  std::sort(returnValue.begin(), returnValue.end(), tpIntPairGreater);
439  }
440  */
441  auto jpos = lmap.find(trackingParticle);
442  if (jpos != lmap.end())
443  jpos->second += weight;
444  else
445  lmap.insert(std::make_pair(trackingParticle, weight));
446  }
447  }
448  }
449  // now copy the map to returnValue
450  for (auto ip = lmap.begin(); ip != lmap.end(); ++ip) {
451  returnValue.push_back(std::make_pair(ip->first, ip->second));
452  }
453  return returnValue;
454 }
range equal_range(const OmniClusterRef &key) const
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
Definition: weight.py:1
key_type key() const
Accessor for product key.
Definition: Ref.h:250

◆ getAllSimTrackIdentifiers()

template<typename iter >
std::vector< std::pair< QuickTrackAssociatorByHitsImpl::SimTrackIdentifiers, double > > QuickTrackAssociatorByHitsImpl::getAllSimTrackIdentifiers ( const TrackerHitAssociator hitAssociator,
iter  begin,
iter  end 
) const
private

Returns a vector of pairs where first is a SimTrackIdentifiers (see typedef above) and second is the number of hits that came from that sim track.

This is used so that the TrackingParticle collection only has to be looped over once to search for each sim track, rather than once per hit. E.g. If all the hits in the reco track come from the same sim track, then there will only be one entry with second as the number of hits in the track.

Definition at line 458 of file QuickTrackAssociatorByHitsImpl.cc.

References mps_fire::end, TrackingRecHit::geographicalId(), track_associator::getHitFromIter(), TrackQuality_cff::hitAssociator, sistrip::SpyUtilities::isValid(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHitWeight_, DetId::subdetId(), and mps_merge::weight.

Referenced by associateTrack().

460  {
461  // The pairs in this vector have first as the sim track identifiers, and second the number of reco hits associated to that sim track.
462  std::vector<std::pair<SimTrackIdentifiers, double>> returnValue;
463 
464  std::vector<SimTrackIdentifiers> simTrackIdentifiers;
465  // Loop over all of the rec hits in the track
466  //iter tRHIterBeginEnd = getTRHIterBeginEnd( pTrack );
467  for (iter iRecHit = begin; iRecHit != end; ++iRecHit) {
468  if (track_associator::getHitFromIter(iRecHit)->isValid()) {
469  simTrackIdentifiers.clear();
470 
471  // Get the identifiers for the sim track that this hit came from. There should only be one entry unless clusters
472  // have merged (as far as I know).
473  hitAssociator.associateHitId(*(track_associator::getHitFromIter(iRecHit)),
474  simTrackIdentifiers); // This call fills simTrackIdentifiers
475 
476  const auto subdetId = track_associator::getHitFromIter(iRecHit)->geographicalId().subdetId();
477  const double weight = (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
479  : 1.0;
480 
481  // Loop over each identifier, and add it to the return value only if it's not already in there
482  for (std::vector<SimTrackIdentifiers>::const_iterator iIdentifier = simTrackIdentifiers.begin();
483  iIdentifier != simTrackIdentifiers.end();
484  ++iIdentifier) {
485  std::vector<std::pair<SimTrackIdentifiers, double>>::iterator iIdentifierCountPair;
486  for (auto iIdentifierCountPair = returnValue.begin(); iIdentifierCountPair != returnValue.end();
487  ++iIdentifierCountPair) {
488  if (iIdentifierCountPair->first.first == iIdentifier->first &&
489  iIdentifierCountPair->first.second == iIdentifier->second) {
490  // This sim track identifier is already in the list, so increment the count of how many hits it relates to.
491  iIdentifierCountPair->second += weight;
492  break;
493  }
494  }
495  if (iIdentifierCountPair == returnValue.end())
496  returnValue.push_back(std::make_pair(*iIdentifier, 1.0));
497  // This identifier wasn't found, so add it
498  }
499  }
500  }
501  return returnValue;
502 }
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: weight.py:1
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
DetId geographicalId() const

◆ getDoubleCount() [1/2]

template<typename iter >
double QuickTrackAssociatorByHitsImpl::getDoubleCount ( const TrackerHitAssociator hitAssociator,
iter  begin,
iter  end,
TrackingParticleRef  associatedTrackingParticle 
) const
private

This method was copied almost verbatim from the standard TrackAssociatorByHits.

Modified 01/May/2014 to take the TrackerHitAssociator as a parameter rather than using a member.

Definition at line 522 of file QuickTrackAssociatorByHitsImpl.cc.

References spr::find(), TrackingRecHit::geographicalId(), track_associator::getHitFromIter(), TrackQuality_cff::hitAssociator, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHitWeight_, and DetId::subdetId().

Referenced by associateRecoToSimImplementation(), and associateSimToRecoImplementation().

525  {
526  // This method is largely copied from the standard TrackAssociatorByHits. Once I've tested how much difference
527  // it makes I'll go through and comment it properly.
528 
529  // FIXME: It may be that this piece is not fully correct for
530  // counting how many times a single *cluster* is matched to many
531  // SimTracks of a single TrackingParticle (see comments in
532  // getDoubleCount(ClusterTPAssociation) overload). To be verified
533  // some time.
534 
535  double doubleCount = 0.0;
536  std::vector<SimHitIdpr> SimTrackIdsDC;
537 
538  for (iter iHit = startIterator; iHit != endIterator; iHit++) {
539  int idcount = 0;
540 
541  SimTrackIdsDC.clear();
542  hitAssociator.associateHitId(*(track_associator::getHitFromIter(iHit)), SimTrackIdsDC);
543  if (SimTrackIdsDC.size() > 1) {
544  for (TrackingParticle::g4t_iterator g4T = associatedTrackingParticle->g4Track_begin();
545  g4T != associatedTrackingParticle->g4Track_end();
546  ++g4T) {
547  if (find(SimTrackIdsDC.begin(),
548  SimTrackIdsDC.end(),
549  SimHitIdpr((*g4T).trackId(), SimTrackIdsDC.begin()->second)) != SimTrackIdsDC.end()) {
550  idcount++;
551  }
552  }
553  }
554  if (idcount > 1) {
555  const auto subdetId = track_associator::getHitFromIter(iHit)->geographicalId().subdetId();
556  const double weight = (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
558  : 1.0;
559  doubleCount += weight * (idcount - 1);
560  }
561  }
562 
563  return doubleCount;
564 }
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
std::vector< SimTrack >::const_iterator g4t_iterator
std::pair< uint32_t, EncodedEventId > SimHitIdpr
DetId geographicalId() const

◆ getDoubleCount() [2/2]

template<typename iter >
double QuickTrackAssociatorByHitsImpl::getDoubleCount ( const ClusterTPAssociation clusterToTPList,
iter  begin,
iter  end,
TrackingParticleRef  associatedTrackingParticle 
) const
private

Overload for when using cluster to TrackingParticle association list.

Definition at line 567 of file QuickTrackAssociatorByHitsImpl.cc.

References ClusterTPAssociation::equal_range(), TrackingRecHit::geographicalId(), track_associator::getHitFromIter(), track_associator::hitsToClusterRefs(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHitWeight_, FastTimerService_cff::range, and DetId::subdetId().

570  {
571  // This code here was written by Subir Sarkar. I'm just splitting it off into a
572  // separate method. - Grimes 01/May/2014
573 
574  // The point here is that the electron TrackingParticles may contain
575  // multiple SimTracks (from the bremsstrahling), and (historically)
576  // the each matched hit/cluster has been multiplied by "how many
577  // SimTracks from the TrackingParticle" it contains charge from.
578  // Here the amount of this double counting is calculated, so that it
579  // can be subtracted by the calling code.
580  //
581  // Note that recently (hence "historically" in the paragraph above)
582  // the ClusterTPAssociationProducer was changed to remove the
583  // duplicate cluster->TP associations (hence making this function
584  // obsolete), but there is more recent proof that there is some
585  // duplication left (to be investigated).
586 
587  double doubleCount = 0;
588  std::vector<SimHitIdpr> SimTrackIdsDC;
589 
590  for (iter iHit = startIterator; iHit != endIterator; iHit++) {
591  std::vector<OmniClusterRef> oClusters =
592  track_associator::hitsToClusterRefs(iHit, iHit + 1); //only for the cluster being checked
593  for (std::vector<OmniClusterRef>::const_iterator it = oClusters.begin(); it != oClusters.end(); ++it) {
594  int idcount = 0;
595 
596  auto range = clusterToTPList.equal_range(*it);
597  if (range.first != range.second) {
598  for (auto ip = range.first; ip != range.second; ++ip) {
599  const TrackingParticleRef trackingParticle = (ip->second);
600  if (associatedTrackingParticle == trackingParticle) {
601  idcount++;
602  }
603  }
604  }
605 
606  if (idcount > 1) {
607  const auto subdetId = track_associator::getHitFromIter(iHit)->geographicalId().subdetId();
608  const double weight = (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
610  : 1.0;
611  doubleCount += weight * (idcount - 1);
612  }
613  }
614  }
615 
616  return doubleCount;
617 }
range equal_range(const OmniClusterRef &key) const
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
Definition: weight.py:1
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
DetId geographicalId() const

◆ tpIntPairGreater()

static bool QuickTrackAssociatorByHitsImpl::tpIntPairGreater ( std::pair< edm::Ref< TrackingParticleCollection >, size_t >  i,
std::pair< edm::Ref< TrackingParticleCollection >, size_t >  j 
)
inlinestaticprivate

Definition at line 116 of file QuickTrackAssociatorByHitsImpl.h.

References mps_fire::i, and dqmiolumiharvest::j.

117  {
118  return (i.first.key() > j.first.key());
119  }

◆ trackingParticleContainsIdentifier()

bool QuickTrackAssociatorByHitsImpl::trackingParticleContainsIdentifier ( const TrackingParticle pTrackingParticle,
const SimTrackIdentifiers identifier 
) const
private

Returns true if the supplied TrackingParticle has the supplied g4 track identifiers.

Definition at line 504 of file QuickTrackAssociatorByHitsImpl.cc.

References TrackingParticle::g4Track_begin(), and TrackingParticle::g4Track_end().

Referenced by associateTrack().

505  {
506  // Loop over all of the g4 tracks in the tracking particle
507  for (std::vector<SimTrack>::const_iterator iSimTrack = pTrackingParticle->g4Track_begin();
508  iSimTrack != pTrackingParticle->g4Track_end();
509  ++iSimTrack) {
510  // And see if the sim track identifiers match
511  if (iSimTrack->eventId() == identifier.second && iSimTrack->trackId() == identifier.first) {
512  return true;
513  }
514  }
515 
516  // If control has made it this far then none of the identifiers were found in
517  // any of the g4 tracks, so return false.
518  return false;
519 }
g4t_iterator g4Track_end() const
g4t_iterator g4Track_begin() const

◆ weightedNumberOfTrackClusters() [1/5]

template<typename T_Track >
double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters ( const T_Track &  track,
const TrackerHitAssociator  
) const
private

Definition at line 816 of file QuickTrackAssociatorByHitsImpl.cc.

References TrackingRecHit::geographicalId(), track_associator::getHitFromIter(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHitWeight_, fileCollector::seed, DetId::subdetId(), and mps_merge::weight.

Referenced by associateRecoToSimImplementation(), associateSimToRecoImplementation(), and weightedNumberOfTrackClusters().

817  {
818  double sum = 0.0;
819  for (auto iHit = seed.recHits().begin(); iHit != seed.recHits().end(); ++iHit) {
820  const auto subdetId = track_associator::getHitFromIter(iHit)->geographicalId().subdetId();
821  const double weight = (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
823  : 1.0;
824  sum += weight;
825  }
826  return sum;
827 }
Definition: weight.py:1
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
DetId geographicalId() const

◆ weightedNumberOfTrackClusters() [2/5]

template<typename T_Track >
double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters ( const T_Track &  track,
const ClusterTPAssociation  
) const
private

Definition at line 836 of file QuickTrackAssociatorByHitsImpl.cc.

References fileCollector::seed, and weightedNumberOfTrackClusters().

837  {
838  const auto& hitRange = seed.recHits();
839  return weightedNumberOfTrackClusters(hitRange.begin(), hitRange.end());
840 }
double weightedNumberOfTrackClusters(const T_Track &track, const TrackerHitAssociator &) const

◆ weightedNumberOfTrackClusters() [3/5]

template<typename iter >
double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters ( iter  begin,
iter  end 
) const
private

Definition at line 843 of file QuickTrackAssociatorByHitsImpl.cc.

References mps_fire::end, TrackingRecHit::geographicalId(), track_associator::getHitFromIter(), track_associator::hitsToClusterRefs(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogTrace, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHitWeight_, DetId::rawId(), DetId::subdetId(), and mps_merge::weight.

843  {
844  double weightedClusters = 0.0;
845  for (iter iRecHit = begin; iRecHit != end; ++iRecHit) {
846  const auto subdetId = track_associator::getHitFromIter(iRecHit)->geographicalId().subdetId();
847  const double weight = (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap)
849  : 1.0;
850  LogTrace("QuickTrackAssociatorByHitsImpl")
851  << " detId: " << track_associator::getHitFromIter(iRecHit)->geographicalId().rawId();
852  LogTrace("QuickTrackAssociatorByHitsImpl") << " weight: " << weight;
853  std::vector<OmniClusterRef> oClusters =
854  track_associator::hitsToClusterRefs(iRecHit, iRecHit + 1); //only for the cluster being checked
855  for (std::vector<OmniClusterRef>::const_iterator it = oClusters.begin(); it != oClusters.end(); ++it) {
856  weightedClusters += weight;
857  }
858  }
859  LogTrace("QuickTrackAssociatorByHitsImpl") << " total weighted clusters: " << weightedClusters;
860  return weightedClusters;
861 }
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
Definition: weight.py:1
#define LogTrace(id)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
DetId geographicalId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57

◆ weightedNumberOfTrackClusters() [4/5]

template<>
double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters ( const reco::Track track,
const TrackerHitAssociator  
) const

Definition at line 807 of file QuickTrackAssociatorByHitsImpl.cc.

References AlCaHLTBitMon_ParallelJobs::p, InitialStepPreSplitting_cff::pixelHits, pixelHitWeight_, and HLT_2024v11_cff::track.

808  {
809  const reco::HitPattern& p = track.hitPattern();
810  const auto pixelHits = p.numberOfValidPixelHits();
811  const auto otherHits = p.numberOfValidHits() - pixelHits;
812  return pixelHits * pixelHitWeight_ + otherHits;
813 }

◆ weightedNumberOfTrackClusters() [5/5]

template<>
double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters ( const reco::Track track,
const ClusterTPAssociation  
) const

Definition at line 831 of file QuickTrackAssociatorByHitsImpl.cc.

References HLT_2024v11_cff::track, and weightedNumberOfTrackClusters().

832  {
833  return weightedNumberOfTrackClusters(track.recHitsBegin(), track.recHitsEnd());
834 }
double weightedNumberOfTrackClusters(const T_Track &track, const TrackerHitAssociator &) const

Member Data Documentation

◆ absoluteNumberOfHits_

bool QuickTrackAssociatorByHitsImpl::absoluteNumberOfHits_
private

◆ clusterToTPMap_

const ClusterTPAssociation* QuickTrackAssociatorByHitsImpl::clusterToTPMap_
private

Definition at line 236 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateRecoToSim(), and associateSimToReco().

◆ cutRecoToSim_

double QuickTrackAssociatorByHitsImpl::cutRecoToSim_
private

Definition at line 241 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateRecoToSimImplementation().

◆ hitAssociator_

std::unique_ptr<const TrackerHitAssociator> QuickTrackAssociatorByHitsImpl::hitAssociator_
private

Definition at line 235 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateRecoToSim(), and associateSimToReco().

◆ pixelHitWeight_

double QuickTrackAssociatorByHitsImpl::pixelHitWeight_
private

◆ productGetter_

edm::EDProductGetter const* QuickTrackAssociatorByHitsImpl::productGetter_
private

creates either a ClusterTPAssociation OR a TrackerHitAssociator and stores it in the provided unique_ptr. The other will be null.

A decision is made whether to create a ClusterTPAssociation or a TrackerHitAssociator depending on how this track associator was configured. If the ClusterTPAssociation couldn't be fetched from the event then it falls back to creating a TrackerHitAssociator.

Only one type will be created, never both. The other unique_ptr reference will be null so check for that and decide which to use.

N.B. The value of useClusterTPAssociation_ should not be used to decide which of the two pointers to use. If the cluster to TrackingParticle couldn't be retrieved from the event then pClusterToTPMap will be null but useClusterTPAssociation_ is no longer changed to false.

Definition at line 234 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateRecoToSimImplementation(), and associateSimToRecoImplementation().

◆ puritySimToReco_

double QuickTrackAssociatorByHitsImpl::puritySimToReco_
private

Definition at line 239 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateSimToRecoImplementation().

◆ qualitySimToReco_

double QuickTrackAssociatorByHitsImpl::qualitySimToReco_
private

Definition at line 238 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateSimToRecoImplementation().

◆ simToRecoDenominator_

SimToRecoDenomType QuickTrackAssociatorByHitsImpl::simToRecoDenominator_
private

Definition at line 242 of file QuickTrackAssociatorByHitsImpl.h.

Referenced by associateSimToRecoImplementation().

◆ threeHitTracksAreSpecial_

bool QuickTrackAssociatorByHitsImpl::threeHitTracksAreSpecial_
private