CMS 3D CMS Logo

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

#include <VertexFitterResult.h>

Public Types

typedef std::vector
< reco::TransientTrack
TTrackCont
 

Public Member Functions

const float * chi2Information () const
 
void fill (const TransientVertex &recv, const TrackingVertex *simv=nullptr, reco::RecoToSimCollection *recSimColl=nullptr, const float &time=0)
 
void fill (const TransientVertex &recVertex, const TTrackCont &recTrackV, const TrackingVertex *simv=nullptr, reco::RecoToSimCollection *recSimColl=nullptr, const float &time=0)
 
const int * numberRecTracks ()
 
const int * numberSimTracks ()
 
const float * recErrors (const int i) const
 
const float * recParameters (const int i) const
 
const int * recTrack_simIndex ()
 
const float * recTrackWeight ()
 
const float * recVertexErr () const
 
const float * recVertexPos () const
 
const float * refErrors (const int i) const
 
const float * refParameters (const int i) const
 
void reset ()
 
const float * simParameters (const int i) const
 
const int * simTrack_recIndex ()
 
const float * simVertexPos () const
 
const float * time () const
 
const int * trackInformation () const
 
 VertexFitterResult (const int maxTracks=100, const MagneticField *=nullptr)
 
const int * vertexPresent () const
 
 ~VertexFitterResult ()
 

Private Member Functions

void fillErrors (const PerigeeTrajectoryError &pte, float *errors[5], int trackNumber)
 
void fillParameters (const reco::TrackBase::ParameterVector &perigee, float *params[5], int trackNumber)
 
void fillParameters (const PerigeeTrajectoryParameters &ptp, float *params[5], int trackNumber)
 

Private Attributes

float chi [3]
 
float fitTime
 
int numberOfRecTracks
 
int numberOfSimTracks
 
float recErr [3]
 
float * recErrs [5]
 
int * recIndex
 
float * recPars [5]
 
float recPos [3]
 
float * refErrs [5]
 
float * refPars [5]
 
int * simIndex
 
float * simPars [5]
 
float simPos [3]
 
const MagneticFieldtheMagField
 
int theMaxTracks
 
int tracks [3]
 
float * trackWeight
 
int vertex
 

Detailed Description

Very basic class containing only the positions of the simulated and reconstructed vertices, total chi**2, chi**2 probability and number of degrees of freedom. The only thing to be done is to call the method fill for each vertex.

Definition at line 24 of file VertexFitterResult.h.

Member Typedef Documentation

Definition at line 27 of file VertexFitterResult.h.

Constructor & Destructor Documentation

VertexFitterResult::VertexFitterResult ( const int  maxTracks = 100,
const MagneticField magField = nullptr 
)

Definition at line 9 of file VertexFitterResult.cc.

References mps_fire::i, HLT_FULL_cff::maxTracks, numberOfRecTracks, numberOfSimTracks, recErrs, recIndex, recPars, refErrs, refPars, reset(), simIndex, simPars, theMagField, theMaxTracks, and trackWeight.

9  : theMagField(magField) {
11  if (theMagField == nullptr)
12  theMaxTracks = 0;
13  for (int i = 0; i < 5; i++) {
14  if (maxTracks > 0) {
15  simPars[i] = new float[maxTracks];
16  recPars[i] = new float[maxTracks];
17  refPars[i] = new float[maxTracks];
18  recErrs[i] = new float[maxTracks];
19  refErrs[i] = new float[maxTracks];
20  } else {
21  simPars[i] = nullptr;
22  recPars[i] = nullptr;
23  refPars[i] = nullptr;
24  recErrs[i] = nullptr;
25  refErrs[i] = nullptr;
26  }
27  }
28  trackWeight = new float[maxTracks];
29  simIndex = new int[maxTracks];
30  recIndex = new int[maxTracks];
33  reset();
34 }
const MagneticField * theMagField
VertexFitterResult::~VertexFitterResult ( )

Definition at line 36 of file VertexFitterResult.cc.

References mps_fire::i, recErrs, recIndex, recPars, refErrs, refPars, simIndex, simPars, and trackWeight.

36  {
37  //
38  // delete arrays
39  //
40  for (int i = 0; i < 5; i++) {
41  delete[] simPars[i];
42  delete[] recPars[i];
43  delete[] refPars[i];
44  delete[] recErrs[i];
45  delete[] refErrs[i];
46  }
47  delete trackWeight;
48  delete simIndex;
49  delete recIndex;
50 }

Member Function Documentation

const float* VertexFitterResult::chi2Information ( ) const
inline

Definition at line 47 of file VertexFitterResult.h.

References chi.

Referenced by SimpleVertexTree::SimpleVertexTree().

47 { return chi; }
void VertexFitterResult::fill ( const TransientVertex recv,
const TrackingVertex simv = nullptr,
reco::RecoToSimCollection recSimColl = nullptr,
const float &  time = 0 
)

Definition at line 52 of file VertexFitterResult.cc.

References TransientVertex::isValid(), and TransientVertex::originalTracks().

Referenced by SimpleVertexTree::fill().

55  {
56  TTrackCont recTrackV;
57  if (recVertex.isValid())
58  recTrackV = recVertex.originalTracks();
59  fill(recVertex, recTrackV, simv, recSimColl, time);
60 }
void fill(const TransientVertex &recv, const TrackingVertex *simv=nullptr, reco::RecoToSimCollection *recSimColl=nullptr, const float &time=0)
std::vector< reco::TransientTrack > TTrackCont
const float * time() const
void VertexFitterResult::fill ( const TransientVertex recVertex,
const TTrackCont recTrackV,
const TrackingVertex simv = nullptr,
reco::RecoToSimCollection recSimColl = nullptr,
const float &  time = 0 
)

Definition at line 62 of file VertexFitterResult.cc.

References edm::RefVector< C, T, F >::begin(), chi, ChiSquaredProbability(), GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czz(), TrackingVertex::daughterTracks(), TrackingVertex::daughterTracks_begin(), TrackingVertex::daughterTracks_end(), TransientVertex::degreesOfFreedom(), alignCSCRings::e, edm::RefVector< C, T, F >::end(), fillErrors(), fillParameters(), spr::find(), fitTime, TransientVertex::isValid(), numberOfRecTracks, numberOfSimTracks, TransientVertex::originalTracks(), TrajectoryStateClosestToPoint::perigeeError(), TrackingVertex::position(), TransientVertex::position(), TransientVertex::positionError(), recErr, recErrs, recIndex, recPars, recPos, simIndex, simPars, simPos, cscDigiValidation_cfi::simTrack, mathSSE::sqrt(), theMagField, theMaxTracks, time(), TransientVertex::totalChiSquared(), reco::TrackTransientTrack::trackBaseRef(), reco::trackingParametersAtClosestApproachToBeamSpot(), tracks, vertex, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

66  {
67  TrackingParticleRefVector simTrackV;
68 
70  if (recVertex.isValid()) {
71  recPos[0] = recVertex.position().x();
72  recPos[1] = recVertex.position().y();
73  recPos[2] = recVertex.position().z();
74 
75  recErr[0] = sqrt(recVertex.positionError().cxx());
76  recErr[1] = sqrt(recVertex.positionError().cyy());
77  recErr[2] = sqrt(recVertex.positionError().czz());
78  vert = (Basic3DVector<double>)recVertex.position();
79 
80  chi[0] = recVertex.totalChiSquared();
81  chi[1] = recVertex.degreesOfFreedom();
82  chi[2] = ChiSquaredProbability(recVertex.totalChiSquared(), recVertex.degreesOfFreedom());
83  vertex = 2;
84  fitTime = time;
85  tracks[1] = recVertex.originalTracks().size();
86  }
87 
88  if (simv != nullptr) {
89  simPos[0] = simv->position().x();
90  simPos[1] = simv->position().y();
91  simPos[2] = simv->position().z();
92 
93  simTrackV = simv->daughterTracks();
94  vertex += 1;
97  simTrack++) {
98  Basic3DVector<double> momAtVtx((**simTrack).momentum());
99 
100  std::pair<bool, reco::TrackBase::ParameterVector> paramPair = reco::trackingParametersAtClosestApproachToBeamSpot(
101  vert, momAtVtx, (float)(**simTrack).charge(), *theMagField, recTrackV.front().stateAtBeamLine().beamSpot());
102  if (paramPair.first) {
103  fillParameters(paramPair.second, simPars, numberOfSimTracks);
106  }
107  }
109  }
110 
111  // now store all the recTrack...
112 
113  for (TTrackCont::const_iterator recTrack = recTrackV.begin();
114  (recTrack != recTrackV.end() && (numberOfRecTracks < theMaxTracks));
115  recTrack++) {
116  // std::cout << "Input; 1/Pt " << 1./(*recTrack).momentumAtVertex().transverse() << std::endl;
117 
118  //looking for sim tracks corresponding to our reconstructed tracks:
120 
121  std::vector<std::pair<TrackingParticleRef, double> > simFound;
122  try {
123  const TrackTransientTrack* ttt = dynamic_cast<const TrackTransientTrack*>(recTrack->basicTransientTrack());
124  if ((ttt != nullptr) && (recSimColl != nullptr))
125  simFound = (*recSimColl)[ttt->trackBaseRef()];
126  // if (recSimColl!=0) simFound = (*recSimColl)[recTrack->persistentTrackRef()];
127  // if (recSimColl!=0) simFound = (*recSimColl)[recTrack];
128 
129  } catch (cms::Exception const& e) {
130  // LogDebug("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
131  // << " NOT associated to any TrackingParticle" << "\n";
132  // edm::LogError("TrackValidator") << e.what() << "\n";
133  }
134 
135  if (!simFound.empty()) {
136  //OK, it was associated, so get the state on the same surface as the 'SimState'
137  TrackingParticleRefVector::const_iterator simTrackI = find(simTrackV.begin(), simTrackV.end(), simFound[0].first);
138  if (simTrackI != simTrackV.end())
139  ++tracks[2];
140  int simTrackIndex = simTrackI - simTrackV.begin();
141  if (simTrackIndex < numberOfSimTracks) {
142  simIndex[numberOfRecTracks] = simTrackIndex;
143  recIndex[simTrackIndex] = numberOfRecTracks;
144  // cout << "Assoc; 1/Pt " << 1./(*recTrack).momentumAtVertex().transverse() << std::endl;
145  }
146  }
147 
148  TrajectoryStateClosestToPoint tscp = recTrack->trajectoryStateClosestToPoint(recVertex.position());
149  fillParameters(recTrack->track().parameters(), recPars, numberOfRecTracks);
151  // trackWeight[numberOfRecTracks] = recVertex.trackWeight(*recTrack);
152  //
153  // if ((recVertex.isValid())&&(recVertex.hasRefittedTracks())) {
154  // //looking for corresponding refitted tracks:
155  // TrajectoryStateOnSurface refip;
156  // RecTrackCont::iterator refTrackI =
157  // find_if(refTracks.begin(), refTracks.end(), RecTrackMatch(*recTrack));
158  // if (refTrackI!=refTracks.end()) {
159  // // If it was not found, it would mean that it was not used in the fit,
160  // // or with a low weight such that the track was then discarded.
161  // if(simFound.size() != 0) {
162  // refip = refTrackI->stateOnSurface(simFound[0]->impactPointStateOnSurface().surface());
163  // } else {
164  // refip = refTrackI->innermostState();
165  // }
166  //
167  // fillParameters(refip, refPars, numberOfRecTracks);
168  // fillErrors(refip, refErrs, numberOfRecTracks);
169  // }
170  // }
171  //
173  }
174 }
GlobalError positionError() const
tp_iterator daughterTracks_begin() const
const MagneticField * theMagField
void fillErrors(const PerigeeTrajectoryError &pte, float *errors[5], int trackNumber)
const PerigeeTrajectoryError & perigeeError() const
float totalChiSquared() const
T y() const
Definition: PV3DBase.h:60
void fillParameters(const reco::TrackBase::ParameterVector &perigee, float *params[5], int trackNumber)
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
std::vector< reco::TransientTrack > const & originalTracks() const
float degreesOfFreedom() const
T sqrt(T t)
Definition: SSEVec.h:19
GlobalPoint position() const
T z() const
Definition: PV3DBase.h:61
float ChiSquaredProbability(double chiSquared, double nrDOF)
tp_iterator daughterTracks_end() const
std::pair< bool, reco::TrackBase::ParameterVector > trackingParametersAtClosestApproachToBeamSpot(const Basic3DVector< double > &vertex, const Basic3DVector< double > &momAtVtx, float charge, const MagneticField &magField, const BeamSpot &bs)
const TrackingParticleRefVector & daughterTracks() const
const float * time() const
T x() const
Definition: PV3DBase.h:59
bool isValid() const
const LorentzVector & position() const
TrackBaseRef trackBaseRef() const override
void VertexFitterResult::fillErrors ( const PerigeeTrajectoryError pte,
float *  errors[5],
int  trackNumber 
)
private

Definition at line 195 of file VertexFitterResult.cc.

References PerigeeTrajectoryError::longitudinalImpactParameterError(), PerigeeTrajectoryError::phiError(), PerigeeTrajectoryError::thetaError(), PerigeeTrajectoryError::transverseCurvatureError(), and PerigeeTrajectoryError::transverseImpactParameterError().

Referenced by fill().

195  {
196  errors[0][trackNumber] = pte.transverseCurvatureError();
197  errors[1][trackNumber] = pte.thetaError();
198  errors[2][trackNumber] = pte.phiError();
199  errors[3][trackNumber] = pte.transverseImpactParameterError();
200  errors[4][trackNumber] = pte.longitudinalImpactParameterError();
201 }
double longitudinalImpactParameterError() const
double transverseImpactParameterError() const
double transverseCurvatureError() const
void VertexFitterResult::fillParameters ( const reco::TrackBase::ParameterVector perigee,
float *  params[5],
int  trackNumber 
)
private

Definition at line 176 of file VertexFitterResult.cc.

Referenced by fill().

178  {
179  params[0][trackNumber] = perigee[0];
180  params[1][trackNumber] = perigee[1];
181  params[2][trackNumber] = perigee[2];
182  params[3][trackNumber] = perigee[3];
183  params[4][trackNumber] = perigee[4];
184 }
void VertexFitterResult::fillParameters ( const PerigeeTrajectoryParameters ptp,
float *  params[5],
int  trackNumber 
)
private

Definition at line 186 of file VertexFitterResult.cc.

References PerigeeTrajectoryParameters::vector().

186  {
187  const AlgebraicVector5& perigee = ptp.vector();
188  params[0][trackNumber] = perigee[0];
189  params[1][trackNumber] = perigee[1];
190  params[2][trackNumber] = perigee[2];
191  params[3][trackNumber] = perigee[3];
192  params[4][trackNumber] = perigee[4];
193 }
const AlgebraicVector5 & vector() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const int* VertexFitterResult::numberRecTracks ( )
inline

Definition at line 52 of file VertexFitterResult.h.

References numberOfRecTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

52 { return &numberOfRecTracks; }
const int* VertexFitterResult::numberSimTracks ( )
inline

Definition at line 51 of file VertexFitterResult.h.

References numberOfSimTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

51 { return &numberOfSimTracks; }
const float* VertexFitterResult::recErrors ( const int  i) const
inline

Definition at line 73 of file VertexFitterResult.h.

References mps_fire::i, and recErrs.

Referenced by SimpleVertexTree::SimpleVertexTree().

73  {
74  if (i < 0 || i >= 5)
75  return nullptr;
76  return recErrs[i];
77  }
const float* VertexFitterResult::recParameters ( const int  i) const
inline

Definition at line 58 of file VertexFitterResult.h.

References mps_fire::i, and recPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

58  {
59  if (i < 0 || i >= 5)
60  return nullptr;
61  return recPars[i];
62  }
const int* VertexFitterResult::recTrack_simIndex ( )
inline

Definition at line 56 of file VertexFitterResult.h.

References simIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

56 { return simIndex; }
const float* VertexFitterResult::recTrackWeight ( )
inline

Definition at line 57 of file VertexFitterResult.h.

References trackWeight.

Referenced by SimpleVertexTree::SimpleVertexTree().

57 { return trackWeight; }
const float* VertexFitterResult::recVertexErr ( ) const
inline

Definition at line 45 of file VertexFitterResult.h.

References recErr.

Referenced by SimpleVertexTree::SimpleVertexTree().

45 { return recErr; }
const float* VertexFitterResult::recVertexPos ( ) const
inline

Definition at line 44 of file VertexFitterResult.h.

References recPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

44 { return recPos; }
const float* VertexFitterResult::refErrors ( const int  i) const
inline

Definition at line 78 of file VertexFitterResult.h.

References mps_fire::i, and refErrs.

Referenced by SimpleVertexTree::SimpleVertexTree().

78  {
79  if (i < 0 || i >= 5)
80  return nullptr;
81  return refErrs[i];
82  }
const float* VertexFitterResult::refParameters ( const int  i) const
inline

Definition at line 63 of file VertexFitterResult.h.

References mps_fire::i, and refPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

63  {
64  if (i < 0 || i >= 5)
65  return nullptr;
66  return refPars[i];
67  }
void VertexFitterResult::reset ( void  )

Definition at line 203 of file VertexFitterResult.cc.

References chi, fitTime, mps_fire::i, dqmiolumiharvest::j, numberOfRecTracks, numberOfSimTracks, recErr, recErrs, recIndex, recPars, recPos, refErrs, refPars, simIndex, simPars, simPos, tracks, trackWeight, and vertex.

Referenced by SimpleVertexTree::fill(), and VertexFitterResult().

203  {
204  for (int i = 0; i < 3; ++i) {
205  simPos[i] = 0.;
206  recPos[i] = 0.;
207  recErr[i] = 0.;
208  chi[i] = 0.;
209  tracks[i] = 0;
210  }
211  vertex = 0;
212  fitTime = 0;
213 
214  for (int j = 0; j < numberOfRecTracks; ++j) {
215  for (int i = 0; i < 5; ++i) {
216  recPars[i][j] = 0;
217  refPars[i][j] = 0;
218  recErrs[i][j] = 0;
219  refErrs[i][j] = 0;
220  }
221  trackWeight[j] = 0;
222  simIndex[j] = -1;
223  }
224  for (int j = 0; j < numberOfSimTracks; ++j) {
225  for (int i = 0; i < 5; ++i) {
226  simPars[i][j] = 0;
227  }
228  recIndex[j] = -1;
229  }
230 
231  numberOfRecTracks = 0;
232  numberOfSimTracks = 0;
233 }
const float* VertexFitterResult::simParameters ( const int  i) const
inline

Definition at line 68 of file VertexFitterResult.h.

References mps_fire::i, and simPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

68  {
69  if (i < 0 || i >= 5)
70  return nullptr;
71  return simPars[i];
72  }
const int* VertexFitterResult::simTrack_recIndex ( )
inline

Definition at line 54 of file VertexFitterResult.h.

References recIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

54 { return recIndex; }
const float* VertexFitterResult::simVertexPos ( ) const
inline

Definition at line 43 of file VertexFitterResult.h.

References simPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

43 { return simPos; }
const float* VertexFitterResult::time ( ) const
inline

Definition at line 49 of file VertexFitterResult.h.

References fitTime.

Referenced by fill(), and SimpleVertexTree::SimpleVertexTree().

49 { return &fitTime; }
const int* VertexFitterResult::trackInformation ( ) const
inline

Definition at line 46 of file VertexFitterResult.h.

References tracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

46 { return tracks; }
const int* VertexFitterResult::vertexPresent ( ) const
inline

Definition at line 48 of file VertexFitterResult.h.

References vertex.

Referenced by SimpleVertexTree::SimpleVertexTree().

48 { return &vertex; }

Member Data Documentation

float VertexFitterResult::chi[3]
private

Definition at line 116 of file VertexFitterResult.h.

Referenced by chi2Information(), fill(), and reset().

float VertexFitterResult::fitTime
private

Definition at line 119 of file VertexFitterResult.h.

Referenced by fill(), reset(), and time().

int VertexFitterResult::numberOfRecTracks
private

Definition at line 127 of file VertexFitterResult.h.

Referenced by fill(), numberRecTracks(), reset(), and VertexFitterResult().

int VertexFitterResult::numberOfSimTracks
private

Definition at line 127 of file VertexFitterResult.h.

Referenced by fill(), numberSimTracks(), reset(), and VertexFitterResult().

float VertexFitterResult::recErr[3]
private

Definition at line 115 of file VertexFitterResult.h.

Referenced by fill(), recVertexErr(), and reset().

float* VertexFitterResult::recErrs[5]
private

Definition at line 125 of file VertexFitterResult.h.

Referenced by fill(), recErrors(), reset(), VertexFitterResult(), and ~VertexFitterResult().

int * VertexFitterResult::recIndex
private
float* VertexFitterResult::recPars[5]
private
float VertexFitterResult::recPos[3]
private

Definition at line 114 of file VertexFitterResult.h.

Referenced by fill(), recVertexPos(), and reset().

float* VertexFitterResult::refErrs[5]
private

Definition at line 126 of file VertexFitterResult.h.

Referenced by refErrors(), reset(), VertexFitterResult(), and ~VertexFitterResult().

float* VertexFitterResult::refPars[5]
private
int* VertexFitterResult::simIndex
private
float* VertexFitterResult::simPars[5]
private
float VertexFitterResult::simPos[3]
private

Definition at line 113 of file VertexFitterResult.h.

Referenced by fill(), reset(), and simVertexPos().

const MagneticField* VertexFitterResult::theMagField
private

Definition at line 111 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

int VertexFitterResult::theMaxTracks
private

Definition at line 121 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

int VertexFitterResult::tracks[3]
private

Definition at line 117 of file VertexFitterResult.h.

Referenced by fill(), reset(), and trackInformation().

float* VertexFitterResult::trackWeight
private
int VertexFitterResult::vertex
private

Definition at line 118 of file VertexFitterResult.h.

Referenced by Tau.Tau::dxy(), fill(), reset(), and vertexPresent().