CMS 3D CMS Logo

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::TransientTrackTTrackCont
 

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

◆ TTrackCont

Definition at line 27 of file VertexFitterResult.h.

Constructor & Destructor Documentation

◆ VertexFitterResult()

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

Definition at line 9 of file VertexFitterResult.cc.

References mps_fire::i, HLT_2022v11_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::~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

◆ chi2Information()

const float* VertexFitterResult::chi2Information ( ) const
inline

Definition at line 47 of file VertexFitterResult.h.

References chi.

Referenced by SimpleVertexTree::SimpleVertexTree().

47 { return chi; }

◆ fill() [1/2]

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(), TransientVertex::originalTracks(), and time().

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

◆ fill() [2/2]

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(), MillePedeFileConverter_cfg::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 }
float totalChiSquared() const
const MagneticField * theMagField
GlobalPoint position() const
void fillErrors(const PerigeeTrajectoryError &pte, float *errors[5], int trackNumber)
T z() const
Definition: PV3DBase.h:61
GlobalError positionError() const
void fillParameters(const reco::TrackBase::ParameterVector &perigee, float *params[5], int trackNumber)
tp_iterator daughterTracks_begin() const
const PerigeeTrajectoryError & perigeeError() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
float degreesOfFreedom() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
bool isValid() const
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< reco::TransientTrack > const & originalTracks() const
float ChiSquaredProbability(double chiSquared, double nrDOF)
const LorentzVector & position() 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 float * time() const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const TrackingParticleRefVector & daughterTracks() const
tp_iterator daughterTracks_end() const
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
TrackBaseRef trackBaseRef() const override

◆ fillErrors()

void VertexFitterResult::fillErrors ( const PerigeeTrajectoryError pte,
float *  errors[5],
int  trackNumber 
)
private

◆ fillParameters() [1/2]

void VertexFitterResult::fillParameters ( const reco::TrackBase::ParameterVector perigee,
float *  params[5],
int  trackNumber 
)
private

Definition at line 176 of file VertexFitterResult.cc.

References submitPVValidationJobs::params.

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 }

◆ fillParameters() [2/2]

void VertexFitterResult::fillParameters ( const PerigeeTrajectoryParameters ptp,
float *  params[5],
int  trackNumber 
)
private

Definition at line 186 of file VertexFitterResult.cc.

References submitPVValidationJobs::params, and 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

◆ numberRecTracks()

const int* VertexFitterResult::numberRecTracks ( )
inline

Definition at line 52 of file VertexFitterResult.h.

References numberOfRecTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

52 { return &numberOfRecTracks; }

◆ numberSimTracks()

const int* VertexFitterResult::numberSimTracks ( )
inline

Definition at line 51 of file VertexFitterResult.h.

References numberOfSimTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

51 { return &numberOfSimTracks; }

◆ recErrors()

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  }

◆ recParameters()

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  }

◆ recTrack_simIndex()

const int* VertexFitterResult::recTrack_simIndex ( )
inline

Definition at line 56 of file VertexFitterResult.h.

References simIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

56 { return simIndex; }

◆ recTrackWeight()

const float* VertexFitterResult::recTrackWeight ( )
inline

Definition at line 57 of file VertexFitterResult.h.

References trackWeight.

Referenced by SimpleVertexTree::SimpleVertexTree().

57 { return trackWeight; }

◆ recVertexErr()

const float* VertexFitterResult::recVertexErr ( ) const
inline

Definition at line 45 of file VertexFitterResult.h.

References recErr.

Referenced by SimpleVertexTree::SimpleVertexTree().

45 { return recErr; }

◆ recVertexPos()

const float* VertexFitterResult::recVertexPos ( ) const
inline

Definition at line 44 of file VertexFitterResult.h.

References recPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

44 { return recPos; }

◆ refErrors()

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  }

◆ refParameters()

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  }

◆ reset()

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 }

◆ simParameters()

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  }

◆ simTrack_recIndex()

const int* VertexFitterResult::simTrack_recIndex ( )
inline

Definition at line 54 of file VertexFitterResult.h.

References recIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

54 { return recIndex; }

◆ simVertexPos()

const float* VertexFitterResult::simVertexPos ( ) const
inline

Definition at line 43 of file VertexFitterResult.h.

References simPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

43 { return simPos; }

◆ time()

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; }

◆ trackInformation()

const int* VertexFitterResult::trackInformation ( ) const
inline

Definition at line 46 of file VertexFitterResult.h.

References tracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

46 { return tracks; }

◆ vertexPresent()

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

◆ chi

float VertexFitterResult::chi[3]
private

Definition at line 116 of file VertexFitterResult.h.

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

◆ fitTime

float VertexFitterResult::fitTime
private

Definition at line 119 of file VertexFitterResult.h.

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

◆ numberOfRecTracks

int VertexFitterResult::numberOfRecTracks
private

Definition at line 127 of file VertexFitterResult.h.

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

◆ numberOfSimTracks

int VertexFitterResult::numberOfSimTracks
private

Definition at line 127 of file VertexFitterResult.h.

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

◆ recErr

float VertexFitterResult::recErr[3]
private

Definition at line 115 of file VertexFitterResult.h.

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

◆ recErrs

float* VertexFitterResult::recErrs[5]
private

Definition at line 125 of file VertexFitterResult.h.

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

◆ recIndex

int * VertexFitterResult::recIndex
private

◆ recPars

float* VertexFitterResult::recPars[5]
private

◆ recPos

float VertexFitterResult::recPos[3]
private

Definition at line 114 of file VertexFitterResult.h.

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

◆ refErrs

float* VertexFitterResult::refErrs[5]
private

Definition at line 126 of file VertexFitterResult.h.

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

◆ refPars

float* VertexFitterResult::refPars[5]
private

◆ simIndex

int* VertexFitterResult::simIndex
private

◆ simPars

float* VertexFitterResult::simPars[5]
private

◆ simPos

float VertexFitterResult::simPos[3]
private

Definition at line 113 of file VertexFitterResult.h.

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

◆ theMagField

const MagneticField* VertexFitterResult::theMagField
private

Definition at line 111 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

◆ theMaxTracks

int VertexFitterResult::theMaxTracks
private

Definition at line 121 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

◆ tracks

int VertexFitterResult::tracks[3]
private

Definition at line 117 of file VertexFitterResult.h.

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

◆ trackWeight

float* VertexFitterResult::trackWeight
private

◆ vertex

int VertexFitterResult::vertex
private

Definition at line 118 of file VertexFitterResult.h.

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