CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
TrackAssociatorByChi2 Class Reference

#include <TrackAssociatorByChi2.h>

Inheritance diagram for TrackAssociatorByChi2:
TrackAssociatorBase

Public Types

typedef std::map< double,
SimTrack
Chi2SimMap
 
typedef std::pair< reco::Track,
Chi2SimMap
RecoToSimPair
 
typedef std::vector
< RecoToSimPair
RecoToSimPairAssociation
 

Public Member Functions

reco::GenToRecoCollection associateGenToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< reco::GenParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
 Association Sim To Reco with Collections (Gen Particle version) More...
 
virtual reco::GenToRecoCollection associateGenToReco (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< reco::GenParticleCollection > &tPCH, const edm::Event *event=0, const edm::EventSetup *setup=0) const
 compare reco to sim the handle of reco::Track and GenParticle collections More...
 
reco::RecoToGenCollection associateRecoToGen (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< reco::GenParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
 Association Sim To Reco with Collections (Gen Particle version) More...
 
virtual reco::RecoToGenCollection associateRecoToGen (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< reco::GenParticleCollection > &tPCH, const edm::Event *event=0, const edm::EventSetup *setup=0) const
 compare reco to sim the handle of reco::Track and GenParticle collections More...
 
double associateRecoToSim (reco::TrackCollection::const_iterator, TrackingParticleCollection::const_iterator, const reco::BeamSpot &) const
 compare reco::TrackCollection and TrackingParticleCollection iterators: returns the chi2 More...
 
virtual reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 Association Reco To Sim with Collections. More...
 
virtual reco::RecoToSimCollection associateRecoToSim (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
virtual reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 Association Sim To Reco with Collections. More...
 
virtual reco::SimToRecoCollection associateSimToReco (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
double compareTracksParam (reco::TrackCollection::const_iterator, edm::SimTrackContainer::const_iterator, const math::XYZTLorentzVectorD &, const GlobalVector &, const reco::TrackBase::CovarianceMatrix &, const reco::BeamSpot &) const
 compare reco::TrackCollection and edm::SimTrackContainer iterators: returns the chi2 More...
 
RecoToSimPairAssociation compareTracksParam (const reco::TrackCollection &, const edm::SimTrackContainer &, const edm::SimVertexContainer &, const reco::BeamSpot &) const
 compare collections reco to sim More...
 
double getChi2 (reco::TrackBase::ParameterVector &rParameters, reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, Basic3DVector< double > &momAtVtx, Basic3DVector< double > &vert, int &charge, const reco::BeamSpot &) const
 basic method where chi2 is computed More...
 
std::pair< bool,
reco::TrackBase::ParameterVector
parametersAtClosestApproach (const Basic3DVector< double > &, const Basic3DVector< double > &, float, const reco::BeamSpot &) const
 propagate the track parameters of TrackinParticle from production vertex to the point of closest approach to the beam line. More...
 
 TrackAssociatorByChi2 (const edm::ESHandle< MagneticField > mF, const edm::ParameterSet &conf)
 Constructor with PSet. More...
 
 TrackAssociatorByChi2 (const edm::ESHandle< MagneticField > mF, double chi2Cut, bool onlyDiag, const edm::InputTag &beamspotSrc)
 Constructor with magnetic field, double, bool and InputTag. More...
 
 ~TrackAssociatorByChi2 ()
 Destructor. More...
 
- Public Member Functions inherited from TrackAssociatorBase
virtual
reco::RecoToSimCollectionSeed 
associateRecoToSim (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::RecoToSimCollectionTCandidate 
associateRecoToSim (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::SimToRecoCollectionSeed 
associateSimToReco (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::SimToRecoCollectionTCandidate 
associateSimToReco (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
 TrackAssociatorBase ()
 Constructor. More...
 
virtual ~TrackAssociatorBase ()
 Destructor. More...
 

Private Attributes

edm::InputTag bsSrc
 
double chi2cut
 
bool onlyDiagonal
 
edm::ESHandle< 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 40 of file TrackAssociatorByChi2.h.

Member Typedef Documentation

typedef std::map<double, SimTrack> TrackAssociatorByChi2::Chi2SimMap

Definition at line 43 of file TrackAssociatorByChi2.h.

Definition at line 44 of file TrackAssociatorByChi2.h.

Definition at line 45 of file TrackAssociatorByChi2.h.

Constructor & Destructor Documentation

TrackAssociatorByChi2::TrackAssociatorByChi2 ( const edm::ESHandle< MagneticField mF,
const edm::ParameterSet conf 
)
inline

Constructor with PSet.

Definition at line 48 of file TrackAssociatorByChi2.h.

References onlyDiagonal, and theMF.

48  :
49  chi2cut(conf.getParameter<double>("chi2cut")),
50  onlyDiagonal(conf.getParameter<bool>("onlyDiagonal")),
51  bsSrc(conf.getParameter<edm::InputTag>("beamSpot")) {
52  theMF=mF;
53  if (onlyDiagonal)
54  edm::LogInfo("TrackAssociator") << " ---- Using Off Diagonal Covariance Terms = 0 ---- " << "\n";
55  else
56  edm::LogInfo("TrackAssociator") << " ---- Using Off Diagonal Covariance Terms != 0 ---- " << "\n";
57  }
T getParameter(std::string const &) const
edm::ESHandle< MagneticField > theMF
TrackAssociatorByChi2::TrackAssociatorByChi2 ( const edm::ESHandle< MagneticField mF,
double  chi2Cut,
bool  onlyDiag,
const edm::InputTag beamspotSrc 
)
inline

Constructor with magnetic field, double, bool and InputTag.

Definition at line 60 of file TrackAssociatorByChi2.h.

References bsSrc, chi2cut, onlyDiagonal, and theMF.

60  {
61  chi2cut=chi2Cut;
62  onlyDiagonal=onlyDiag;
63  theMF=mF;
64  bsSrc = beamspotSrc;
65  }
edm::ESHandle< MagneticField > theMF
TrackAssociatorByChi2::~TrackAssociatorByChi2 ( )
inline

Destructor.

Definition at line 68 of file TrackAssociatorByChi2.h.

68 {}

Member Function Documentation

GenToRecoCollection TrackAssociatorByChi2::associateGenToReco ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< reco::GenParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const

Association Sim To Reco with Collections (Gen Particle version)

Definition at line 345 of file TrackAssociatorByChi2.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::end(), edm::Event::getByLabel(), i, edm::AssociationMap< Tag >::insert(), j, LogDebug, edm::AssociationMap< Tag >::post_insert(), edm::RefVector< C, T, F >::product(), edm::RefVector< C, T, F >::size(), and mathSSE::sqrt().

Referenced by MultiTrackValidatorGenPs::analyze(), and associateGenToReco().

348  {
349 
350  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
351  e->getByLabel(bsSrc,recoBeamSpotHandle);
352  reco::BeamSpot bs = *recoBeamSpotHandle;
353 
354  GenToRecoCollection outputCollection;
355 
357  if (tPCH.size()!=0) tPC = *tPCH.product();
358 
359  int tpindex =0;
360  for (GenParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
361 
362  //skip tps with a very small pt
363  //if (sqrt(tp->momentum().perp2())<0.5) continue;
364  int charge = tp->charge();
365  if (charge==0) continue;
366 
367  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
368  << "TrackingParticle #"<<tpindex<<" with pt=" << sqrt(tp->momentum().perp2()) << "\n"
369  << "===========================================" << "\n";
370 
371  Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
372  Basic3DVector<double> vert(tp->vertex().x(),tp->vertex().y(),tp->vertex().z());
373 
374  int tindex=0;
375  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
376 
377  TrackBase::ParameterVector rParameters = (*rt)->parameters();
378  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
379  if (onlyDiagonal) {
380  for (unsigned int i=0;i<5;i++){
381  for (unsigned int j=0;j<5;j++){
382  if (i!=j) recoTrackCovMatrix(i,j)=0;
383  }
384  }
385  }
386  recoTrackCovMatrix.Invert();
387 
388  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
389 
390  if (chi2<chi2cut) {
391  outputCollection.insert(edm::Ref<GenParticleCollection>(tPCH, tpindex),
392  std::make_pair(tC[tindex],
393  -chi2));//-chi2 because the Association Map is ordered using std::greater
394  }
395  }
396  }
397  outputCollection.post_insert();
398  return outputCollection;
399 }
#define LogDebug(id)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
int i
Definition: DBlmapReader.cc:9
C const * product() const
Accessor for product collection.
Definition: RefVector.h:272
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
double charge(const std::vector< uint8_t > &Ampls)
void post_insert()
post insert action
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
double getChi2(reco::TrackBase::ParameterVector &rParameters, reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, Basic3DVector< double > &momAtVtx, Basic3DVector< double > &vert, int &charge, const reco::BeamSpot &) const
basic method where chi2 is computed
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:89
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70
virtual reco::GenToRecoCollection TrackAssociatorByChi2::associateGenToReco ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< reco::GenParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
inlinevirtual

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

Definition at line 161 of file TrackAssociatorByChi2.h.

References associateGenToReco(), event(), edm::HandleBase::id(), j, edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), and HcalObjRepresent::setup().

164  {
166  for (unsigned int j=0; j<tCH->size();j++)
167  tc.push_back(edm::RefToBase<reco::Track>(tCH,j));
168 
170  for (unsigned int j=0; j<tPCH->size();j++)
172 
173  return associateGenToReco(tc,tpc,event,setup);
174  }
ProductID id() const
Definition: HandleBase.cc:15
int j
Definition: DBlmapReader.cc:9
reco::GenToRecoCollection associateGenToReco(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< reco::GenParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Sim To Reco with Collections (Gen Particle version)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
RecoToGenCollection TrackAssociatorByChi2::associateRecoToGen ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< reco::GenParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const

Association Sim To Reco with Collections (Gen Particle version)

Definition at line 288 of file TrackAssociatorByChi2.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::end(), edm::Event::getByLabel(), i, edm::AssociationMap< Tag >::insert(), j, LogDebug, edm::AssociationMap< Tag >::post_insert(), edm::RefVector< C, T, F >::product(), and edm::RefVector< C, T, F >::size().

Referenced by MultiTrackValidatorGenPs::analyze(), and associateRecoToGen().

291  {
292  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
293  e->getByLabel(bsSrc,recoBeamSpotHandle);
294  reco::BeamSpot bs = *recoBeamSpotHandle;
295 
296  RecoToGenCollection outputCollection;
297 
299  if (tPCH.size()!=0) tPC = *tPCH.product();
300 
301  int tindex=0;
302  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
303 
304  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
305  << "rec::Track #"<<tindex<<" with pt=" << (*rt)->pt() << "\n"
306  << "===========================================" << "\n";
307 
308  TrackBase::ParameterVector rParameters = (*rt)->parameters();
309 
310  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
311  if (onlyDiagonal){
312  for (unsigned int i=0;i<5;i++){
313  for (unsigned int j=0;j<5;j++){
314  if (i!=j) recoTrackCovMatrix(i,j)=0;
315  }
316  }
317  }
318 
319  recoTrackCovMatrix.Invert();
320 
321  int tpindex =0;
322  for (GenParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
323 
324  //skip tps with a very small pt
325  //if (sqrt(tp->momentum().perp2())<0.5) continue;
326  int charge = tp->charge();
327  if (charge==0) continue;
328  Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
329  Basic3DVector<double> vert=(Basic3DVector<double>) tp->vertex();
330 
331  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
332 
333  if (chi2<chi2cut) {
334  outputCollection.insert(tC[tindex],
335  std::make_pair(edm::Ref<GenParticleCollection>(tPCH, tpindex),
336  -chi2));//-chi2 because the Association Map is ordered using std::greater
337  }
338  }
339  }
340  outputCollection.post_insert();
341  return outputCollection;
342 }
#define LogDebug(id)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
int i
Definition: DBlmapReader.cc:9
C const * product() const
Accessor for product collection.
Definition: RefVector.h:272
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
double charge(const std::vector< uint8_t > &Ampls)
void post_insert()
post insert action
int j
Definition: DBlmapReader.cc:9
double getChi2(reco::TrackBase::ParameterVector &rParameters, reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, Basic3DVector< double > &momAtVtx, Basic3DVector< double > &vert, int &charge, const reco::BeamSpot &) const
basic method where chi2 is computed
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:89
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70
virtual reco::RecoToGenCollection TrackAssociatorByChi2::associateRecoToGen ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< reco::GenParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
inlinevirtual

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

Definition at line 145 of file TrackAssociatorByChi2.h.

References associateRecoToGen(), event(), edm::HandleBase::id(), j, edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), and HcalObjRepresent::setup().

148  {
150  for (unsigned int j=0; j<tCH->size();j++)
151  tc.push_back(edm::RefToBase<reco::Track>(tCH,j));
152 
154  for (unsigned int j=0; j<tPCH->size();j++)
156 
157  return associateRecoToGen(tc,tpc,event,setup);
158  }
ProductID id() const
Definition: HandleBase.cc:15
int j
Definition: DBlmapReader.cc:9
reco::RecoToGenCollection associateRecoToGen(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< reco::GenParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Sim To Reco with Collections (Gen Particle version)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
double TrackAssociatorByChi2::associateRecoToSim ( reco::TrackCollection::const_iterator  ,
TrackingParticleCollection::const_iterator  ,
const reco::BeamSpot  
) const

compare reco::TrackCollection and TrackingParticleCollection iterators: returns the chi2

Referenced by KVFTest::analyze().

RecoToSimCollection TrackAssociatorByChi2::associateRecoToSim ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
overridevirtual

Association Reco To Sim with Collections.

Implements TrackAssociatorBase.

Definition at line 173 of file TrackAssociatorByChi2.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::end(), edm::Event::getByLabel(), i, edm::AssociationMap< Tag >::insert(), j, LogDebug, edm::AssociationMap< Tag >::post_insert(), edm::RefVector< C, T, F >::product(), and edm::RefVector< C, T, F >::size().

176  {
177  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
178  e->getByLabel(bsSrc,recoBeamSpotHandle);
179  reco::BeamSpot bs = *recoBeamSpotHandle;
180 
181  RecoToSimCollection outputCollection;
182 
184  if (tPCH.size()!=0) tPC = *tPCH.product();
185 
186  int tindex=0;
187  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
188 
189  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
190  << "rec::Track #"<<tindex<<" with pt=" << (*rt)->pt() << "\n"
191  << "===========================================" << "\n";
192 
193  TrackBase::ParameterVector rParameters = (*rt)->parameters();
194 
195  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
196  if (onlyDiagonal){
197  for (unsigned int i=0;i<5;i++){
198  for (unsigned int j=0;j<5;j++){
199  if (i!=j) recoTrackCovMatrix(i,j)=0;
200  }
201  }
202  }
203 
204  recoTrackCovMatrix.Invert();
205 
206  int tpindex =0;
207  for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
208 
209  //skip tps with a very small pt
210  //if (sqrt(tp->momentum().perp2())<0.5) continue;
211  int charge = tp->charge();
212  if (charge==0) continue;
213  Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
214  Basic3DVector<double> vert=(Basic3DVector<double>) tp->vertex();
215 
216  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
217 
218  if (chi2<chi2cut) {
219  outputCollection.insert(tC[tindex],
220  std::make_pair(edm::Ref<TrackingParticleCollection>(tPCH, tpindex),
221  -chi2));//-chi2 because the Association Map is ordered using std::greater
222  }
223  }
224  }
225  outputCollection.post_insert();
226  return outputCollection;
227 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< TrackingParticle > TrackingParticleCollection
C const * product() const
Accessor for product collection.
Definition: RefVector.h:272
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
double charge(const std::vector< uint8_t > &Ampls)
void post_insert()
post insert action
int j
Definition: DBlmapReader.cc:9
double getChi2(reco::TrackBase::ParameterVector &rParameters, reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, Basic3DVector< double > &momAtVtx, Basic3DVector< double > &vert, int &charge, const reco::BeamSpot &) const
basic method where chi2 is computed
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:89
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70
virtual reco::RecoToSimCollection TrackAssociatorByChi2::associateRecoToSim ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
inlineoverridevirtual

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

Reimplemented from TrackAssociatorBase.

Definition at line 117 of file TrackAssociatorByChi2.h.

References TrackAssociatorBase::associateRecoToSim(), event(), and HcalObjRepresent::setup().

120  {
121  return TrackAssociatorBase::associateRecoToSim(tCH,tPCH,event,setup);
122  }
virtual reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
SimToRecoCollection TrackAssociatorByChi2::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
overridevirtual

Association Sim To Reco with Collections.

Implements TrackAssociatorBase.

Definition at line 230 of file TrackAssociatorByChi2.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::end(), edm::Event::getByLabel(), i, edm::AssociationMap< Tag >::insert(), j, LogDebug, edm::AssociationMap< Tag >::post_insert(), edm::RefVector< C, T, F >::product(), edm::RefVector< C, T, F >::size(), and mathSSE::sqrt().

233  {
234  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
235  e->getByLabel(bsSrc,recoBeamSpotHandle);
236  reco::BeamSpot bs = *recoBeamSpotHandle;
237 
238  SimToRecoCollection outputCollection;
239 
241  if (tPCH.size()!=0) tPC = *tPCH.product();
242 
243  int tpindex =0;
244  for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
245 
246  //skip tps with a very small pt
247  //if (sqrt(tp->momentum().perp2())<0.5) continue;
248  int charge = tp->charge();
249  if (charge==0) continue;
250 
251  LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
252  << "TrackingParticle #"<<tpindex<<" with pt=" << sqrt(tp->momentum().perp2()) << "\n"
253  << "===========================================" << "\n";
254 
255  Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
256  Basic3DVector<double> vert(tp->vertex().x(),tp->vertex().y(),tp->vertex().z());
257 
258  int tindex=0;
259  for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
260 
261  TrackBase::ParameterVector rParameters = (*rt)->parameters();
262  TrackBase::CovarianceMatrix recoTrackCovMatrix = (*rt)->covariance();
263  if (onlyDiagonal) {
264  for (unsigned int i=0;i<5;i++){
265  for (unsigned int j=0;j<5;j++){
266  if (i!=j) recoTrackCovMatrix(i,j)=0;
267  }
268  }
269  }
270  recoTrackCovMatrix.Invert();
271 
272  double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);
273 
274  if (chi2<chi2cut) {
275  outputCollection.insert(edm::Ref<TrackingParticleCollection>(tPCH, tpindex),
276  std::make_pair(tC[tindex],
277  -chi2));//-chi2 because the Association Map is ordered using std::greater
278  }
279  }
280  }
281  outputCollection.post_insert();
282  return outputCollection;
283 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< TrackingParticle > TrackingParticleCollection
C const * product() const
Accessor for product collection.
Definition: RefVector.h:272
const_iterator end() const
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
double charge(const std::vector< uint8_t > &Ampls)
void post_insert()
post insert action
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
double getChi2(reco::TrackBase::ParameterVector &rParameters, reco::TrackBase::CovarianceMatrix &recoTrackCovMatrix, Basic3DVector< double > &momAtVtx, Basic3DVector< double > &vert, int &charge, const reco::BeamSpot &) const
basic method where chi2 is computed
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:89
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70
virtual reco::SimToRecoCollection TrackAssociatorByChi2::associateSimToReco ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
inlineoverridevirtual

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

Reimplemented from TrackAssociatorBase.

Definition at line 126 of file TrackAssociatorByChi2.h.

References TrackAssociatorBase::associateSimToReco(), event(), and HcalObjRepresent::setup().

129  {
130  return TrackAssociatorBase::associateSimToReco(tCH,tPCH,event,setup);
131  }
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
double TrackAssociatorByChi2::compareTracksParam ( reco::TrackCollection::const_iterator  ,
edm::SimTrackContainer::const_iterator  ,
const math::XYZTLorentzVectorD ,
const GlobalVector ,
const reco::TrackBase::CovarianceMatrix ,
const reco::BeamSpot  
) const

compare reco::TrackCollection and edm::SimTrackContainer iterators: returns the chi2

TrackAssociatorByChi2::RecoToSimPairAssociation TrackAssociatorByChi2::compareTracksParam ( const reco::TrackCollection rtColl,
const edm::SimTrackContainer stColl,
const edm::SimVertexContainer svColl,
const reco::BeamSpot bs 
) const

compare collections reco to sim

Definition at line 41 of file TrackAssociatorByChi2.cc.

References reco::deltaPhi(), f, i, and j.

44  {
45 
46  RecoToSimPairAssociation outputVec;
47 
48  for (TrackCollection::const_iterator track=rtColl.begin(); track!=rtColl.end(); track++){
49  Chi2SimMap outMap;
50 
51  TrackBase::ParameterVector rParameters = track->parameters();
52 
53  TrackBase::CovarianceMatrix recoTrackCovMatrix = track->covariance();
54  if (onlyDiagonal){
55  for (unsigned int i=0;i<5;i++){
56  for (unsigned int j=0;j<5;j++){
57  if (i!=j) recoTrackCovMatrix(i,j)=0;
58  }
59  }
60  }
61  recoTrackCovMatrix.Invert();
62 
63  for (SimTrackContainer::const_iterator st=stColl.begin(); st!=stColl.end(); st++){
64 
65  Basic3DVector<double> momAtVtx(st->momentum().x(),st->momentum().y(),st->momentum().z());
66  Basic3DVector<double> vert = (Basic3DVector<double>) svColl[st->vertIndex()].position();
67 
68  std::pair<bool,reco::TrackBase::ParameterVector> params = parametersAtClosestApproach(vert, momAtVtx, st->charge(), bs);
69  if (params.first){
70  TrackBase::ParameterVector sParameters = params.second;
71 
72  TrackBase::ParameterVector diffParameters = rParameters - sParameters;
73  diffParameters[2] = reco::deltaPhi(diffParameters[2],0.f);
74  double chi2 = ROOT::Math::Dot(diffParameters * recoTrackCovMatrix, diffParameters);
75  chi2/=5;
76  if (chi2<chi2cut) outMap[chi2]=*st;
77  }
78  }
79  outputVec.push_back(RecoToSimPair(*track,outMap));
80  }
81  return outputVec;
82 }
int i
Definition: DBlmapReader.cc:9
std::pair< bool, reco::TrackBase::ParameterVector > parametersAtClosestApproach(const Basic3DVector< double > &, const Basic3DVector< double > &, float, const reco::BeamSpot &) const
propagate the track parameters of TrackinParticle from production vertex to the point of closest appr...
std::pair< reco::Track, Chi2SimMap > RecoToSimPair
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
int j
Definition: DBlmapReader.cc:9
double f[11][100]
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
std::map< double, SimTrack > Chi2SimMap
std::vector< RecoToSimPair > RecoToSimPairAssociation
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70
double TrackAssociatorByChi2::getChi2 ( reco::TrackBase::ParameterVector rParameters,
reco::TrackBase::CovarianceMatrix recoTrackCovMatrix,
Basic3DVector< double > &  momAtVtx,
Basic3DVector< double > &  vert,
int &  charge,
const reco::BeamSpot bs 
) const

basic method where chi2 is computed

Definition at line 84 of file TrackAssociatorByChi2.cc.

References reco::deltaPhi(), f, LogDebug, and funct::sin().

89  {
90 
91  double chi2;
92 
93  std::pair<bool,reco::TrackBase::ParameterVector> params = parametersAtClosestApproach(vert, momAtVtx, charge, bs);
94  if (params.first){
95  TrackBase::ParameterVector sParameters=params.second;
96 
97  TrackBase::ParameterVector diffParameters = rParameters - sParameters;
98  diffParameters[2] = reco::deltaPhi(diffParameters[2],0.f);
99  chi2 = ROOT::Math::Dot(diffParameters * recoTrackCovMatrix, diffParameters);
100  chi2 /= 5;
101 
102  LogDebug("TrackAssociator") << "====NEW RECO TRACK WITH PT=" << sin(rParameters[1])*float(charge)/rParameters[0] << "====\n"
103  << "qoverp sim: " << sParameters[0] << "\n"
104  << "lambda sim: " << sParameters[1] << "\n"
105  << "phi sim: " << sParameters[2] << "\n"
106  << "dxy sim: " << sParameters[3] << "\n"
107  << "dsz sim: " << sParameters[4] << "\n"
108  << ": " /*<< */ << "\n"
109  << "qoverp rec: " << rParameters[0] << "\n"
110  << "lambda rec: " << rParameters[1] << "\n"
111  << "phi rec: " << rParameters[2] << "\n"
112  << "dxy rec: " << rParameters[3] << "\n"
113  << "dsz rec: " << rParameters[4] << "\n"
114  << ": " /*<< */ << "\n"
115  << "chi2: " << chi2 << "\n";
116 
117  return chi2;
118  } else {
119  return 10000000000.;
120  }
121 }
#define LogDebug(id)
std::pair< bool, reco::TrackBase::ParameterVector > parametersAtClosestApproach(const Basic3DVector< double > &, const Basic3DVector< double > &, float, const reco::BeamSpot &) const
propagate the track parameters of TrackinParticle from production vertex to the point of closest appr...
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
double charge(const std::vector< uint8_t > &Ampls)
double f[11][100]
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
pair< bool, TrackBase::ParameterVector > TrackAssociatorByChi2::parametersAtClosestApproach ( const Basic3DVector< double > &  vertex,
const Basic3DVector< double > &  momAtVtx,
float  charge,
const reco::BeamSpot bs 
) const

propagate the track parameters of TrackinParticle from production vertex to the point of closest approach to the beam line.

Definition at line 145 of file TrackAssociatorByChi2.cc.

References FreeTrajectoryState::charge(), funct::cos(), Geom::halfPi(), PV3DBase< T, PVType, FrameType >::mag(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), funct::sin(), PV3DBase< T, PVType, FrameType >::theta(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), Basic3DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), Basic3DVector< T >::y(), PV3DBase< T, PVType, FrameType >::z(), and Basic3DVector< T >::z().

Referenced by VertexFitterResult::fill().

148  {
149 
150  TrackBase::ParameterVector sParameters;
151  try {
152  FreeTrajectoryState ftsAtProduction(GlobalPoint(vertex.x(),vertex.y(),vertex.z()),
153  GlobalVector(momAtVtx.x(),momAtVtx.y(),momAtVtx.z()),
155  theMF.product());
156  TSCBLBuilderNoMaterial tscblBuilder;
157  TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,bs);//as in TrackProducerAlgorithm
158 
159  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
160  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
161  sParameters[0] = tsAtClosestApproach.trackStateAtPCA().charge()/p.mag();
162  sParameters[1] = Geom::halfPi() - p.theta();
163  sParameters[2] = p.phi();
164  sParameters[3] = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
165  sParameters[4] = v.z()*p.perp()/p.mag() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.mag();
166 
167  return pair<bool,TrackBase::ParameterVector>(true,sParameters);
168  } catch ( ... ) {
169  return pair<bool,TrackBase::ParameterVector>(false,sParameters);
170  }
171 }
T y() const
Cartesian y coordinate.
T perp() const
Definition: PV3DBase.h:72
T x() const
Cartesian x coordinate.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:68
TrackCharge charge() const
double charge(const std::vector< uint8_t > &Ampls)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int TrackCharge
Definition: TrackCharge.h:4
T mag() const
Definition: PV3DBase.h:67
T z() const
Cartesian z coordinate.
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double halfPi()
Definition: Pi.h:33
GlobalVector momentum() const
edm::ESHandle< MagneticField > theMF
GlobalPoint position() const
T const * product() const
Definition: ESHandle.h:62
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

edm::InputTag TrackAssociatorByChi2::bsSrc
private

Definition at line 181 of file TrackAssociatorByChi2.h.

Referenced by TrackAssociatorByChi2().

double TrackAssociatorByChi2::chi2cut
private

Definition at line 179 of file TrackAssociatorByChi2.h.

Referenced by TrackAssociatorByChi2().

bool TrackAssociatorByChi2::onlyDiagonal
private

Definition at line 180 of file TrackAssociatorByChi2.h.

Referenced by TrackAssociatorByChi2().

edm::ESHandle<MagneticField> TrackAssociatorByChi2::theMF
private

Definition at line 178 of file TrackAssociatorByChi2.h.

Referenced by TrackAssociatorByChi2().