TrackAssociator that associates by hits a bit quicker than the normal TrackAssociatorByHits class. More...
#include <QuickTrackAssociatorByHits.h>
Private Types | |
typedef std::vector< std::pair < OmniClusterRef, TrackingParticleRef > > | ClusterTPAssociationList |
enum | SimToRecoDenomType { denomnone, denomsim, denomreco } |
typedef std::pair< uint32_t, EncodedEventId > | SimTrackIdentifiers |
Private Member Functions | |
reco::RecoToSimCollection | associateRecoToSimImplementation () const |
The method that does the work for both overloads of associateRecoToSim. More... | |
reco::SimToRecoCollection | associateSimToRecoImplementation () const |
The method that does the work for both overloads of associateSimToReco. More... | |
template<typename iter > | |
std::vector< std::pair < edm::Ref < TrackingParticleCollection > , size_t > > | associateTrack (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 < edm::Ref < TrackingParticleCollection > , size_t > > | associateTrackByCluster (iter begin, iter end) const |
template<typename iter > | |
std::vector< std::pair < SimTrackIdentifiers, size_t > > | getAllSimTrackIdentifiers (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 > | |
int | getDoubleCount (iter begin, iter end, TrackingParticleRef associatedTrackingParticle) const |
This method was copied almost verbatim from the standard TrackAssociatorByHits. More... | |
const TrackingRecHit * | getHitFromIter (trackingRecHit_iterator iter) const |
const TrackingRecHit * | getHitFromIter (TrackingRecHitCollection::const_iterator iter) const |
template<typename iter > | |
std::vector< OmniClusterRef > | getMatchedClusters (iter begin, iter end) const |
void | initialiseHitAssociator (const edm::Event *event) const |
bool | trackingParticleContainsIdentifier (const TrackingParticle *pTrackingParticle, const SimTrackIdentifiers &identifier) const |
Returns true if the supplied TrackingParticle has the supplied g4 track identifiers. More... | |
Static Private Member Functions | |
static bool | clusterTPAssociationListGreater (std::pair< OmniClusterRef, TrackingParticleRef > i, std::pair< OmniClusterRef, TrackingParticleRef > j) |
static bool | tpIntPairGreater (std::pair< edm::Ref< TrackingParticleCollection >, size_t > i, std::pair< edm::Ref< TrackingParticleCollection >, size_t > j) |
Private Attributes | |
bool | absoluteNumberOfHits_ |
edm::InputTag | cluster2TPSrc_ |
double | cutRecoToSim_ |
edm::ParameterSet | hitAssociatorParameters_ |
ClusterTPAssociationList | pCluster2TPList_ |
const edm::Event * | pEventForWhichAssociatorIsValid_ |
TrackerHitAssociator * | pHitAssociator_ |
const edm::RefToBaseVector < reco::Track > * | pTrackCollection_ |
Pointer to the track collection. More... | |
edm::Handle< edm::View < reco::Track > > * | pTrackCollectionHandle_ |
Pointer to the handle to the track collection. More... | |
const edm::RefVector < TrackingParticleCollection > * | pTrackingParticleCollection_ |
Pointer to the TrackingParticle collection handle. More... | |
edm::Handle < TrackingParticleCollection > * | pTrackingParticleCollectionHandle_ |
Pointer to the TrackingParticle collection handle. More... | |
double | puritySimToReco_ |
double | qualitySimToReco_ |
SimToRecoDenomType | simToRecoDenominator_ |
bool | threeHitTracksAreSpecial_ |
bool | useClusterTPAssociation_ |
TrackAssociator that associates by hits a bit quicker than the normal TrackAssociatorByHits 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 TrackAssociatorByHits, but faster. I've tested it a fair bit and can't find any differences between the results of this and the standard TrackAssociatorByHits.
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 TrackAssociatorByHits 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 TrackAssociatorByHits parameters UseGrouped and UseSplitting are not used.
Definition at line 59 of file QuickTrackAssociatorByHits.h.
|
private |
Definition at line 107 of file QuickTrackAssociatorByHits.h.
|
private |
Definition at line 103 of file QuickTrackAssociatorByHits.h.
|
private |
Enumerator | |
---|---|
denomnone | |
denomsim | |
denomreco |
Definition at line 104 of file QuickTrackAssociatorByHits.h.
QuickTrackAssociatorByHits::QuickTrackAssociatorByHits | ( | const edm::ParameterSet & | config | ) |
Definition at line 17 of file QuickTrackAssociatorByHits.cc.
References edm::ParameterSet::addParameter(), denomreco, denomsim, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), hitAssociatorParameters_, simToRecoDenominator_, and AlCaHLTBitMon_QueryRunRegistry::string.
QuickTrackAssociatorByHits::~QuickTrackAssociatorByHits | ( | ) |
Definition at line 65 of file QuickTrackAssociatorByHits.cc.
References pHitAssociator_.
QuickTrackAssociatorByHits::QuickTrackAssociatorByHits | ( | const QuickTrackAssociatorByHits & | otherAssociator | ) |
Definition at line 70 of file QuickTrackAssociatorByHits.cc.
References pHitAssociator_.
|
overridevirtual |
compare reco to sim the handle of reco::Track and TrackingParticle collections
Reimplemented from TrackAssociatorBase.
Definition at line 126 of file QuickTrackAssociatorByHits.cc.
References associateRecoToSimImplementation(), initialiseHitAssociator(), prepareCluster2TPMap(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, and useClusterTPAssociation_.
|
overridevirtual |
Association Reco To Sim with Collections.
Implements TrackAssociatorBase.
Definition at line 165 of file QuickTrackAssociatorByHits.cc.
References associateRecoToSimImplementation(), initialiseHitAssociator(), prepareCluster2TPMap(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, and useClusterTPAssociation_.
|
overridevirtual |
Reimplemented from TrackAssociatorBase.
Definition at line 608 of file QuickTrackAssociatorByHits.cc.
References funct::abs(), absoluteNumberOfHits_, associateTrack(), associateTrackByCluster(), cutRecoToSim_, getDoubleCount(), i, initialiseHitAssociator(), edm::AssociationMap< Tag >::insert(), LogTrace, edm::AssociationMap< Tag >::post_insert(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, TrajectorySeed::recHits(), edm::AssociationMap< Tag >::size(), threeHitTracksAreSpecial_, and useClusterTPAssociation_.
|
private |
The method that does the work for both overloads of associateRecoToSim.
Definition at line 203 of file QuickTrackAssociatorByHits.cc.
References funct::abs(), absoluteNumberOfHits_, associateTrack(), associateTrackByCluster(), cutRecoToSim_, reco::Track::found(), getDoubleCount(), i, edm::AssociationMap< Tag >::insert(), edm::Handle< T >::product(), pTrackCollection_, pTrackCollectionHandle_, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), edm::RefToBaseVector< T >::size(), threeHitTracksAreSpecial_, and useClusterTPAssociation_.
Referenced by associateRecoToSim().
|
overridevirtual |
compare reco to sim the handle of reco::Track and TrackingParticle collections
Reimplemented from TrackAssociatorBase.
Definition at line 145 of file QuickTrackAssociatorByHits.cc.
References associateSimToRecoImplementation(), initialiseHitAssociator(), prepareCluster2TPMap(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, and useClusterTPAssociation_.
|
overridevirtual |
Association Sim To Reco with Collections.
Implements TrackAssociatorBase.
Definition at line 184 of file QuickTrackAssociatorByHits.cc.
References associateSimToRecoImplementation(), initialiseHitAssociator(), prepareCluster2TPMap(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, and useClusterTPAssociation_.
|
overridevirtual |
Reimplemented from TrackAssociatorBase.
Definition at line 669 of file QuickTrackAssociatorByHits.cc.
References funct::abs(), absoluteNumberOfHits_, associateTrack(), associateTrackByCluster(), denomreco, denomsim, getDoubleCount(), i, initialiseHitAssociator(), edm::AssociationMap< Tag >::insert(), LogTrace, edm::AssociationMap< Tag >::post_insert(), pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, puritySimToReco_, qualitySimToReco_, TrajectorySeed::recHits(), simToRecoDenominator_, edm::AssociationMap< Tag >::size(), threeHitTracksAreSpecial_, and useClusterTPAssociation_.
|
private |
The method that does the work for both overloads of associateSimToReco.
Definition at line 258 of file QuickTrackAssociatorByHits.cc.
References funct::abs(), absoluteNumberOfHits_, associateTrack(), associateTrackByCluster(), denomreco, denomsim, reco::Track::found(), getDoubleCount(), i, edm::AssociationMap< Tag >::insert(), edm::Handle< T >::product(), pTrackCollection_, pTrackCollectionHandle_, puritySimToReco_, qualitySimToReco_, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), simToRecoDenominator_, edm::RefToBaseVector< T >::size(), threeHitTracksAreSpecial_, and useClusterTPAssociation_.
Referenced by associateSimToReco().
|
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 325 of file QuickTrackAssociatorByHits.cc.
References getAllSimTrackIdentifiers(), i, TrackingParticle::numberOfHits(), edm::Handle< T >::product(), pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, edm::RefVector< C, T, F >::size(), and trackingParticleContainsIdentifier().
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), and associateSimToRecoImplementation().
|
private |
Definition at line 383 of file QuickTrackAssociatorByHits.cc.
References clusterTPAssociationListGreater(), getMatchedClusters(), and pCluster2TPList_.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), and associateSimToRecoImplementation().
|
inlinestaticprivate |
Definition at line 108 of file QuickTrackAssociatorByHits.h.
Referenced by associateTrackByCluster(), getDoubleCount(), and prepareCluster2TPMap().
|
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 483 of file QuickTrackAssociatorByHits.cc.
References TrackerHitAssociator::associateHitId(), end, getHitFromIter(), and pHitAssociator_.
Referenced by associateTrack().
|
private |
This method was copied almost verbatim from the standard TrackAssociatorByHits.
Definition at line 540 of file QuickTrackAssociatorByHits.cc.
References TrackerHitAssociator::associateHitId(), clusterTPAssociationListGreater(), spr::find(), getHitFromIter(), getMatchedClusters(), pCluster2TPList_, pHitAssociator_, and useClusterTPAssociation_.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), and associateSimToRecoImplementation().
|
inlineprivate |
Definition at line 145 of file QuickTrackAssociatorByHits.h.
Referenced by getAllSimTrackIdentifiers(), getDoubleCount(), and getMatchedClusters().
|
inlineprivate |
Definition at line 149 of file QuickTrackAssociatorByHits.h.
|
private |
Definition at line 437 of file QuickTrackAssociatorByHits.cc.
References end, TrackingRecHit::geographicalId(), getHitFromIter(), TrackingRecHit::isValid(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, and SiStripDetId::TOB.
Referenced by associateTrackByCluster(), and getDoubleCount().
|
private |
Definition at line 588 of file QuickTrackAssociatorByHits.cc.
References hitAssociatorParameters_, pEventForWhichAssociatorIsValid_, and pHitAssociator_.
Referenced by associateRecoToSim(), associateSimToReco(), and prepareCluster2TPMap().
QuickTrackAssociatorByHits & QuickTrackAssociatorByHits::operator= | ( | const QuickTrackAssociatorByHits & | otherAssociator | ) |
Definition at line 97 of file QuickTrackAssociatorByHits.cc.
References absoluteNumberOfHits_, cluster2TPSrc_, cutRecoToSim_, hitAssociatorParameters_, pEventForWhichAssociatorIsValid_, pHitAssociator_, pTrackCollection_, pTrackCollectionHandle_, pTrackingParticleCollection_, pTrackingParticleCollectionHandle_, puritySimToReco_, qualitySimToReco_, simToRecoDenominator_, threeHitTracksAreSpecial_, and useClusterTPAssociation_.
void QuickTrackAssociatorByHits::prepareCluster2TPMap | ( | const edm::Event * | pEvent | ) | const |
Definition at line 367 of file QuickTrackAssociatorByHits.cc.
References cluster2TPSrc_, clusterTPAssociationListGreater(), edm::Event::getByLabel(), initialiseHitAssociator(), edm::HandleBase::isValid(), pCluster2TPList_, edm::Handle< T >::product(), python.multivaluedict::sort(), and useClusterTPAssociation_.
Referenced by associateRecoToSim(), and associateSimToReco().
|
inlinestaticprivate |
Definition at line 109 of file QuickTrackAssociatorByHits.h.
|
private |
Returns true if the supplied TrackingParticle has the supplied g4 track identifiers.
Definition at line 523 of file QuickTrackAssociatorByHits.cc.
References TrackingParticle::g4Track_begin(), and TrackingParticle::g4Track_end().
Referenced by associateTrack().
|
private |
Definition at line 163 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
private |
Definition at line 203 of file QuickTrackAssociatorByHits.h.
Referenced by operator=(), and prepareCluster2TPMap().
|
private |
Definition at line 166 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), and operator=().
|
private |
Definition at line 161 of file QuickTrackAssociatorByHits.h.
Referenced by initialiseHitAssociator(), operator=(), and QuickTrackAssociatorByHits().
|
mutableprivate |
Definition at line 204 of file QuickTrackAssociatorByHits.h.
Referenced by associateTrackByCluster(), getDoubleCount(), and prepareCluster2TPMap().
|
mutableprivate |
Definition at line 158 of file QuickTrackAssociatorByHits.h.
Referenced by initialiseHitAssociator(), and operator=().
|
mutableprivate |
Definition at line 157 of file QuickTrackAssociatorByHits.h.
Referenced by getAllSimTrackIdentifiers(), getDoubleCount(), initialiseHitAssociator(), operator=(), QuickTrackAssociatorByHits(), and ~QuickTrackAssociatorByHits().
|
mutableprivate |
Pointer to the track collection.
Either this or pTrackCollectionHandle_ will be set, the other will be Null. See the comment on pTrackCollectionHandle_ for reasons why.
Definition at line 185 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
mutableprivate |
Pointer to the handle to the track collection.
Only one of pTrackCollectionHandle_ or pTrackCollection_ will ever be non Null. This is so that both flavours of the associateRecoToSim (one takes a Handle, the other a RefToBaseVector) can use the same associateRecoToSimImplementation method and keep the logic for both in one place. The old implementation for the handle flavour copied everything into a new RefToBaseVector, wasting memory. I tried to do something clever with templates but couldn't get it to work, so the associateRecoToSimImplementation method checks which is non Null and uses that to get the tracks.
Definition at line 178 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
mutableprivate |
Pointer to the TrackingParticle collection handle.
Either this or pTrackingParticleCollectionHandle_ will be set, the other will be Null. See the comment on pTrackCollectionHandle_ for reasons why.
Definition at line 199 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateSimToReco(), associateTrack(), and operator=().
|
mutableprivate |
Pointer to the TrackingParticle collection handle.
Either this or pTrackingParticleCollection_ will be set, the other will be Null. See the comment on pTrackCollectionHandle_ for reasons why.
Definition at line 192 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateSimToReco(), associateTrack(), and operator=().
|
private |
Definition at line 165 of file QuickTrackAssociatorByHits.h.
Referenced by associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
private |
Definition at line 164 of file QuickTrackAssociatorByHits.h.
Referenced by associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
private |
Definition at line 168 of file QuickTrackAssociatorByHits.h.
Referenced by associateSimToReco(), associateSimToRecoImplementation(), operator=(), and QuickTrackAssociatorByHits().
|
private |
Definition at line 167 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), associateSimToRecoImplementation(), and operator=().
|
mutableprivate |
Definition at line 202 of file QuickTrackAssociatorByHits.h.
Referenced by associateRecoToSim(), associateRecoToSimImplementation(), associateSimToReco(), associateSimToRecoImplementation(), getDoubleCount(), operator=(), and prepareCluster2TPMap().