CMS 3D CMS Logo

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

#include <TrackAssociatorByChi2Impl.h>

Inheritance diagram for TrackAssociatorByChi2Impl:
reco::TrackToTrackingParticleAssociatorBaseImpl

Public Types

typedef std::map< double, SimTrackChi2SimMap
 
typedef std::pair< reco::Track, Chi2SimMapRecoToSimPair
 
typedef std::vector< RecoToSimPairRecoToSimPairAssociation
 

Public Member Functions

reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &) const override
 Association Reco To Sim with Collections. More...
 
reco::RecoToSimCollection associateRecoToSim (const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &) const override
 Association Sim To Reco with Collections. More...
 
reco::SimToRecoCollection associateSimToReco (const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
 TrackAssociatorByChi2Impl (const MagneticField &mF, const reco::BeamSpot &bs, double chi2Cut, bool onlyDiag)
 Constructor. More...
 
- 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::RecoToSimCollectionTCandidate associateRecoToSim (const edm::Handle< TrackCandidateCollection > &, 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
 
virtual reco::SimToRecoCollectionTCandidate associateSimToReco (const edm::Handle< TrackCandidateCollection > &, const edm::Handle< TrackingParticleCollection > &) const
 
 TrackToTrackingParticleAssociatorBaseImpl ()
 Constructor. More...
 
virtual ~TrackToTrackingParticleAssociatorBaseImpl ()
 Destructor. More...
 

Private Member Functions

double getChi2 (const reco::TrackBase::ParameterVector &rParameters, const reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, const Basic3DVector< double > &momAtVtx, const Basic3DVector< double > &vert, int charge, const reco::BeamSpot &) const
 basic method where chi2 is computed More...
 

Private Attributes

double chi2cut
 
bool onlyDiagonal
 
const reco::BeamSpottheBeamSpot
 
const MagneticFieldtheMF
 

Detailed Description

Class that performs the association of reco::Tracks and TrackingParticles evaluating the chi2 of reco tracks parameters and sim tracks parameters. The cut can be tuned from the config file: see data/TrackAssociatorByChi2.cfi. Note that the Association Map is filled with -ch2 and not chi2 because it is ordered using std::greater: the track with the lowest association chi2 will be the first in the output map.It is possible to use only diagonal terms (associator by pulls) seeting onlyDiagonal = true in the PSet

Author
cerati, magni

Definition at line 35 of file TrackAssociatorByChi2Impl.h.

Member Typedef Documentation

Definition at line 38 of file TrackAssociatorByChi2Impl.h.

Definition at line 39 of file TrackAssociatorByChi2Impl.h.

Definition at line 40 of file TrackAssociatorByChi2Impl.h.

Constructor & Destructor Documentation

TrackAssociatorByChi2Impl::TrackAssociatorByChi2Impl ( const MagneticField mF,
const reco::BeamSpot bs,
double  chi2Cut,
bool  onlyDiag 
)
inline

Member Function Documentation

RecoToSimCollection TrackAssociatorByChi2Impl::associateRecoToSim ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  tPCH 
) const
overridevirtual

Association Reco To Sim with Collections.

Implements reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 23 of file TrackAssociatorByChi2Impl.cc.

References edm::RefToBaseVector< T >::begin(), ALCARECOTkAlJpsiMuMu_cff::charge, vertices_cff::chi2, trackAssociatorByChi2_cfi::chi2cut, edm::RefToBaseVector< T >::end(), mps_fire::i, edm::AssociationMap< Tag >::insert(), LogDebug, trackAssociatorByChi2_cfi::onlyDiagonal, edm::AssociationMap< Tag >::post_insert(), and edm::RefVector< C, T, F >::size().

24  {
25 
26  const reco::BeamSpot& bs = *theBeamSpot;
27 
28  RecoToSimCollection outputCollection;
29 
30  //dereference the edm::Refs only once
31  std::vector<TrackingParticle const*> tPC;
32  tPC.reserve(tPCH.size());
33  for(auto const& ref: tPCH) {
34  tPC.push_back(&(*ref));
35  }
36 
37  int tindex=0;
38  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
39 
40  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
41  << "rec::Track #"<<tindex<<" with pt=" << (*rt)->pt() << "\n"
42  << "===========================================" << "\n";
43 
44  TrackBase::ParameterVector rParameters = (*rt)->parameters();
45 
46  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
47  if (onlyDiagonal){
48  for (unsigned int i=0;i<5;i++){
49  for (unsigned int j=0;j<5;j++){
50  if (i!=j) recoTrackCovMatrix(i,j)=0;
51  }
52  }
53  }
54 
55  recoTrackCovMatrix.Invert();
56 
57  int tpindex =0;
58  for (auto tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
59 
60  //skip tps with a very small pt
61  //if (sqrt((*tp)->momentum().perp2())<0.5) continue;
62  int charge = (*tp)->charge();
63  if (charge==0) continue;
64  Basic3DVector<double> momAtVtx((*tp)->momentum().x(),(*tp)->momentum().y(),(*tp)->momentum().z());
65  Basic3DVector<double> vert=(Basic3DVector<double>) (*tp)->vertex();
66 
67  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
68 
69  if (chi2<chi2cut) {
70  outputCollection.insert(tC[tindex],
71  std::make_pair(tPCH[tpindex],
72  -chi2));//-chi2 because the Association Map is ordered using std::greater
73  }
74  }
75  }
76  outputCollection.post_insert();
77  return outputCollection;
78 }
#define LogDebug(id)
const reco::BeamSpot * theBeamSpot
double getChi2(const reco::TrackBase::ParameterVector &rParameters, const reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, const Basic3DVector< double > &momAtVtx, const Basic3DVector< double > &vert, int charge, const reco::BeamSpot &) const
basic method where chi2 is computed
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:74
void post_insert()
post insert action
void insert(const key_type &k, const data_type &v)
insert an association
const_iterator begin() const
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:77
reco::RecoToSimCollection TrackAssociatorByChi2Impl::associateRecoToSim ( const edm::Handle< edm::View< reco::Track > > &  tCH,
const edm::Handle< TrackingParticleCollection > &  tPCH 
) const
inlineoverride

compare reco to sim the handle of reco::Track and TrackingParticle collections

Definition at line 78 of file TrackAssociatorByChi2Impl.h.

References reco::TrackToTrackingParticleAssociatorBaseImpl::associateRecoToSim().

79  {
80  return TrackToTrackingParticleAssociatorBaseImpl::associateRecoToSim(tCH,tPCH);
81  }
SimToRecoCollection TrackAssociatorByChi2Impl::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  tPCH 
) const
overridevirtual

Association Sim To Reco with Collections.

Implements reco::TrackToTrackingParticleAssociatorBaseImpl.

Definition at line 81 of file TrackAssociatorByChi2Impl.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefVector< C, T, F >::begin(), ALCARECOTkAlJpsiMuMu_cff::charge, vertices_cff::chi2, trackAssociatorByChi2_cfi::chi2cut, edm::RefToBaseVector< T >::end(), edm::RefVector< C, T, F >::end(), mps_fire::i, edm::AssociationMap< Tag >::insert(), LogDebug, trackAssociatorByChi2_cfi::onlyDiagonal, edm::AssociationMap< Tag >::post_insert(), and mathSSE::sqrt().

82  {
83  const reco::BeamSpot& bs = *theBeamSpot;
84 
85  SimToRecoCollection outputCollection;
86 
87  int tpindex =0;
88  for (auto tp=tPCH.begin(); tp!=tPCH.end(); tp++, ++tpindex){
89 
90  //skip tps with a very small pt
91  //if (sqrt(tp->momentum().perp2())<0.5) continue;
92  int charge = (*tp)->charge();
93  if (charge==0) continue;
94 
95  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
96  << "TrackingParticle #"<<tpindex<<" with pt=" << sqrt((*tp)->momentum().perp2()) << "\n"
97  << "===========================================" << "\n";
98 
99  Basic3DVector<double> momAtVtx((*tp)->momentum().x(),(*tp)->momentum().y(),(*tp)->momentum().z());
100  Basic3DVector<double> vert((*tp)->vertex().x(),(*tp)->vertex().y(),(*tp)->vertex().z());
101 
102  int tindex=0;
103  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
104 
105  TrackBase::ParameterVector rParameters = (*rt)->parameters();
106  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
107  if (onlyDiagonal) {
108  for (unsigned int i=0;i<5;i++){
109  for (unsigned int j=0;j<5;j++){
110  if (i!=j) recoTrackCovMatrix(i,j)=0;
111  }
112  }
113  }
114  recoTrackCovMatrix.Invert();
115 
116  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
117 
118  if (chi2<chi2cut) {
119  outputCollection.insert(*tp,
120  std::make_pair(tC[tindex],
121  -chi2));//-chi2 because the Association Map is ordered using std::greater
122  }
123  }
124  }
125  outputCollection.post_insert();
126  return outputCollection;
127 }
#define LogDebug(id)
const reco::BeamSpot * theBeamSpot
double getChi2(const reco::TrackBase::ParameterVector &rParameters, const reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, const Basic3DVector< double > &momAtVtx, const Basic3DVector< double > &vert, int charge, const reco::BeamSpot &) const
basic method where chi2 is computed
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:74
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
void post_insert()
post insert action
T sqrt(T t)
Definition: SSEVec.h:18
void insert(const key_type &k, const data_type &v)
insert an association
const_iterator begin() const
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:77
reco::SimToRecoCollection TrackAssociatorByChi2Impl::associateSimToReco ( const edm::Handle< edm::View< reco::Track > > &  tCH,
const edm::Handle< TrackingParticleCollection > &  tPCH 
) const
inlineoverride

compare reco to sim the handle of reco::Track and TrackingParticle collections

Definition at line 85 of file TrackAssociatorByChi2Impl.h.

References reco::TrackToTrackingParticleAssociatorBaseImpl::associateSimToReco(), and ALCARECOTkAlJpsiMuMu_cff::charge.

86  {
87  return TrackToTrackingParticleAssociatorBaseImpl::associateSimToReco(tCH,tPCH);
88  }
double TrackAssociatorByChi2Impl::getChi2 ( const reco::TrackBase::ParameterVector rParameters,
const reco::TrackBase::CovarianceMatrix recoTrackCovMatrix,
const Basic3DVector< double > &  momAtVtx,
const Basic3DVector< double > &  vert,
int  charge,
const reco::BeamSpot bs 
) const
private

basic method where chi2 is computed

Definition at line 13 of file TrackAssociatorByChi2Impl.cc.

References track_associator::trackAssociationChi2().

18  {
19  return track_associator::trackAssociationChi2(rParameters, recoTrackCovMatrix,momAtVtx, vert, charge, *theMF, bs);
20 }
double trackAssociationChi2(const reco::TrackBase::ParameterVector &rParameters, const reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, const Basic3DVector< double > &momAtVtx, const Basic3DVector< double > &vert, int charge, const MagneticField &magfield, const reco::BeamSpot &bs)
basic method where chi2 is computed

Member Data Documentation

double TrackAssociatorByChi2Impl::chi2cut
private

Definition at line 101 of file TrackAssociatorByChi2Impl.h.

bool TrackAssociatorByChi2Impl::onlyDiagonal
private

Definition at line 102 of file TrackAssociatorByChi2Impl.h.

const reco::BeamSpot* TrackAssociatorByChi2Impl::theBeamSpot
private

Definition at line 100 of file TrackAssociatorByChi2Impl.h.

const MagneticField* TrackAssociatorByChi2Impl::theMF
private

Definition at line 99 of file TrackAssociatorByChi2Impl.h.