CMS 3D CMS Logo

VertexFitterResult.cc
Go to the documentation of this file.
5 
6 using namespace reco;
7 using namespace std;
8 
9 VertexFitterResult::VertexFitterResult(const int maxTracks, const MagneticField* magField) : 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 }
35 
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 }
51 
53  const TrackingVertex* simv,
54  reco::RecoToSimCollection* recSimColl,
55  const float& time) {
56  TTrackCont recTrackV;
57  if (recVertex.isValid())
58  recTrackV = recVertex.originalTracks();
59  fill(recVertex, recTrackV, simv, recSimColl, time);
60 }
61 
63  const TTrackCont& recTrackV,
64  const TrackingVertex* simv,
65  reco::RecoToSimCollection* recSimColl,
66  const float& time) {
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 }
175 
177  float* params[5],
178  int trackNumber) {
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 }
185 
186 void VertexFitterResult::fillParameters(const PerigeeTrajectoryParameters& ptp, float* params[5], int trackNumber) {
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 }
194 
195 void VertexFitterResult::fillErrors(const PerigeeTrajectoryError& pte, float* errors[5], int trackNumber) {
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 }
202 
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 }
PerigeeTrajectoryError::thetaError
double thetaError() const
Definition: PerigeeTrajectoryError.h:50
cscDigiValidation_cfi.simTrack
simTrack
Definition: cscDigiValidation_cfi.py:29
mps_fire.i
i
Definition: mps_fire.py:428
TransientVertex::isValid
bool isValid() const
Definition: TransientVertex.h:195
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
ChiSquaredProbability
float ChiSquaredProbability(double chiSquared, double nrDOF)
Definition: ChiSquaredProbability.cc:13
VertexFitterResult::refErrs
float * refErrs[5]
Definition: VertexFitterResult.h:126
VertexFitterResult::theMaxTracks
int theMaxTracks
Definition: VertexFitterResult.h:121
PerigeeTrajectoryParameters
Definition: PerigeeTrajectoryParameters.h:16
TrackingVertex::daughterTracks_begin
tp_iterator daughterTracks_begin() const
Definition: TrackingVertex.cc:42
VertexFitterResult::~VertexFitterResult
~VertexFitterResult()
Definition: VertexFitterResult.cc:36
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
TrackingVertex::position
const LorentzVector & position() const
Definition: TrackingVertex.h:71
VertexFitterResult::reset
void reset()
Definition: VertexFitterResult.cc:203
TrackingVertex::daughterTracks_end
tp_iterator daughterTracks_end() const
Definition: TrackingVertex.cc:43
TransientVertex::position
GlobalPoint position() const
Definition: TransientVertex.h:169
protons_cff.time
time
Definition: protons_cff.py:39
ChiSquaredProbability.h
edm::RefVector< TrackingParticleCollection >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
VertexFitterResult::VertexFitterResult
VertexFitterResult(const int maxTracks=100, const MagneticField *=nullptr)
Definition: VertexFitterResult.cc:9
PerigeeTrajectoryError
Definition: PerigeeTrajectoryError.h:14
VertexFitterResult::tracks
int tracks[3]
Definition: VertexFitterResult.h:117
VertexFitterResult::vertex
int vertex
Definition: VertexFitterResult.h:118
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GlobalErrorBase::cyy
T cyy() const
Definition: GlobalErrorBase.h:101
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
errors
Definition: errors.py:1
PerigeeTrajectoryError::longitudinalImpactParameterError
double longitudinalImpactParameterError() const
Definition: PerigeeTrajectoryError.h:68
VertexFitterResult::recErrs
float * recErrs[5]
Definition: VertexFitterResult.h:125
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
VertexFitterResult::theMagField
const MagneticField * theMagField
Definition: VertexFitterResult.h:111
reco::TrackBase::ParameterVector
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:71
TrackingVertex::daughterTracks
const TrackingParticleRefVector & daughterTracks() const
Definition: TrackingVertex.cc:52
TrajectoryStateClosestToPoint::perigeeError
const PerigeeTrajectoryError & perigeeError() const
Definition: TrajectoryStateClosestToPoint.h:84
GlobalErrorBase::cxx
T cxx() const
Definition: GlobalErrorBase.h:97
VertexFitterResult::trackWeight
float * trackWeight
Definition: VertexFitterResult.h:128
VertexFitterResult::simPars
float * simPars[5]
Definition: VertexFitterResult.h:122
PerigeeTrajectoryError::transverseCurvatureError
double transverseCurvatureError() const
Definition: PerigeeTrajectoryError.h:44
VertexFitterResult::time
const float * time() const
Definition: VertexFitterResult.h:49
VertexFitterResult::simIndex
int * simIndex
Definition: VertexFitterResult.h:129
VertexFitterResult::recIndex
int * recIndex
Definition: VertexFitterResult.h:129
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
TrackingVertex
Definition: TrackingVertex.h:22
HLT_FULL_cff.maxTracks
maxTracks
Definition: HLT_FULL_cff.py:33252
VertexFitterResult::recErr
float recErr[3]
Definition: VertexFitterResult.h:115
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrackTransientTrack.h
PerigeeTrajectoryParameters::vector
const AlgebraicVector5 & vector() const
Definition: PerigeeTrajectoryParameters.h:82
reco::trackingParametersAtClosestApproachToBeamSpot
std::pair< bool, reco::TrackBase::ParameterVector > trackingParametersAtClosestApproachToBeamSpot(const Basic3DVector< double > &vertex, const Basic3DVector< double > &momAtVtx, float charge, const MagneticField &magField, const BeamSpot &bs)
Definition: trackingParametersAtClosestApproachToBeamSpot.cc:21
TransientVertex
Definition: TransientVertex.h:18
TrajectoryStateClosestToPoint
Definition: TrajectoryStateClosestToPoint.h:18
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
VertexFitterResult::simPos
float simPos[3]
Definition: VertexFitterResult.h:113
VertexFitterResult::chi
float chi[3]
Definition: VertexFitterResult.h:116
VertexFitterResult::fillParameters
void fillParameters(const reco::TrackBase::ParameterVector &perigee, float *params[5], int trackNumber)
Definition: VertexFitterResult.cc:176
VertexFitterResult::numberOfRecTracks
int numberOfRecTracks
Definition: VertexFitterResult.h:127
std
Definition: JetResolutionObject.h:76
VertexFitterResult::fill
void fill(const TransientVertex &recv, const TrackingVertex *simv=nullptr, reco::RecoToSimCollection *recSimColl=nullptr, const float &time=0)
Definition: VertexFitterResult.cc:52
PerigeeTrajectoryError::phiError
double phiError() const
Definition: PerigeeTrajectoryError.h:56
reco::TrackTransientTrack::trackBaseRef
TrackBaseRef trackBaseRef() const override
Definition: TrackTransientTrack.h:82
edm::RefVectorIterator
Definition: EDProductfwd.h:33
TransientVertex::originalTracks
std::vector< reco::TransientTrack > const & originalTracks() const
Definition: TransientVertex.h:200
VertexFitterResult::TTrackCont
std::vector< reco::TransientTrack > TTrackCont
Definition: VertexFitterResult.h:27
VertexFitterResult::numberOfSimTracks
int numberOfSimTracks
Definition: VertexFitterResult.h:127
VertexFitterResult.h
VertexFitterResult::refPars
float * refPars[5]
Definition: VertexFitterResult.h:124
VertexFitterResult::recPars
float * recPars[5]
Definition: VertexFitterResult.h:123
GlobalErrorBase::czz
T czz() const
Definition: GlobalErrorBase.h:107
VertexFitterResult::fillErrors
void fillErrors(const PerigeeTrajectoryError &pte, float *errors[5], int trackNumber)
Definition: VertexFitterResult.cc:195
cms::Exception
Definition: Exception.h:70
PerigeeTrajectoryError::transverseImpactParameterError
double transverseImpactParameterError() const
Definition: PerigeeTrajectoryError.h:62
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
MagneticField
Definition: MagneticField.h:19
reco::TrackTransientTrack
Definition: TrackTransientTrack.h:18
VertexFitterResult::recPos
float recPos[3]
Definition: VertexFitterResult.h:114
Basic3DVector
Definition: extBasic3DVector.h:30
trackingParametersAtClosestApproachToBeamSpot.h
TransientVertex::positionError
GlobalError positionError() const
Definition: TransientVertex.h:170
VertexFitterResult::fitTime
float fitTime
Definition: VertexFitterResult.h:119
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37