convert track to segment, express the new segment parameters on the surface of the first segment
37 {
38
41
43
45 if (!perigee) {
47 return nullptr;
48 }
49
50 const Trk::FitQuality* fq =
track.fitQuality();
51 if (!fq) {
53 return nullptr;
54 }
55
56 std::set<Identifier> chIds;
57
58
59 DataVector<const Trk::MeasurementBase> rots{};
61
62
64 if (!states) {
66 return nullptr;
67 }
68
70
73 std::unique_ptr<Amg::Transform3D> surfaceTransformToBeDeleted;
74 double weightedDistanceSquared{0}, weightSquared{0};
75 for (const Trk::TrackStateOnSurface* tsos : *states) {
76
78 if (!pars) continue;
79
80
81 const Trk::MeasurementBase* meas = tsos->measurementOnTrack();
84
85
87 if (!
id.is_valid() ||
m_idHelperSvc->measuresPhi(
id))
continue;
88
97 if (!surfaceTransform) {
98 const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(meas);
99 if (mdt) {
100
103 surfaceTransform = surfaceTransformToBeDeleted.get();
104 }
105 }
107 surfaceTransform = &(meas)->associatedSurface().transform();
108 } else if (!surfaceTransform && !backupTransform) {
109 backupTransform = &(meas)->associatedSurface().transform();
110 }
111 }
112 if (!surfaceTransform) surfaceTransform = backupTransform;
113
114 double refDistance = (weightSquared > 0 ? weightedDistanceSquared / weightSquared : 1) - 100;
116
118
119
120 double minDist = -1e6;
122 for (const Trk::TrackStateOnSurface* tsos : *states) {
123
125 if (!pars || !
pars->covariance())
continue;
126
127
129 if (distance < 0 && std::abs(distance) < std::abs(minDist)) {
132 }
133 }
134
135 if (!surfaceTransform) {
136 ATH_MSG_DEBUG(
" failed to create a PlaneSurface for the track, cannot make segment!!! " << std::endl
138 << std::endl
140 return nullptr;
141 }
142
143 if (!closestPars) {
144 closestPars = perigee;
145 minDist = (perigee->
position() - refPos).dot(dir);
146 }
147
150 constexpr double surfDim = 500.;
151 std::unique_ptr<Trk::PlaneSurface> surf = std::make_unique<Trk::PlaneSurface>(transform, surfDim, surfDim);
154 if (!exPars || !exPars->covariance()) {
155 ATH_MSG_VERBOSE(
"First trial reaching the surface failed. This is presumably due to a too large momentum. Let's try with a dummy 1 GeV momentum");
156 std::unique_ptr<Trk::TrackParameters> cloned_pars {closestPars->
clone()};
157 constexpr double OneOverGeV = 1./ Gaudi::Units::GeV;
158 cloned_pars->parameters()[
Trk::qOverP] = cloned_pars->charge() *OneOverGeV;
161
162 if (!exPars){
163 ATH_MSG_DEBUG(
" propagation failed!!! "<<*cloned_pars<<std::endl<<std::endl<<*surf);
164 return nullptr;
165 }
167 }
169 if (!surf->globalToLocal(exPars->position(), exPars->momentum(), locPos)) {
171 return nullptr;
172 }
173 Trk::LocalDirection
locDir;
174 surf->globalToLocalDirection(exPars->momentum(), locDir);
175
176
177 Trk::JacobianPhiThetaLocalAngles globalToLocalMeasAnglesJacobian(exPars->parameters()[
Trk::phi], exPars->parameters()[
Trk::theta],
178 exPars->associatedSurface().transform().rotation().inverse());
179
180
181
185 globalToLocalMeasJacobian(
Trk::phi,
Trk::phi) = globalToLocalMeasAnglesJacobian(0, 0);
187 globalToLocalMeasJacobian(
Trk::theta,
Trk::phi) = globalToLocalMeasAnglesJacobian(0, 1);
190
192
193 Trk::FitQuality* quality = nullptr;
195
196 std::vector<Identifier>
holes;
197 for (const Identifier& chid : chIds) {
199 holes.insert(
holes.end(), holesChamber.begin(), holesChamber.end());
200 }
202
203 } else {
205 }
207 locPos, locDir, cov, surf.release(), std::move(rots), quality);
208 return seg;
209 }
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarity(const MatrixBase< OtherDerived > &m) const
similarity method : yields ms = m*s*m^T
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
MuonSegment_v1 MuonSegment
Reference the current persistent version:
static const Attributes_t empty
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const PtrVector & stdcont() const
Return the underlying std::vector of the container.
virtual const MuonGM::MdtReadoutElement * detectorElement() const override final
Returns the detector element, assoicated with the PRD of this class.
virtual const Amg::Vector3D & center(const Identifier &) const override final
Return the center of the surface associated with this identifier In the case of silicon it returns th...
virtual Amg::Transform3D AmdbLRSToGlobalTransform() const
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
double chiSquared() const
returns the of the overall track fit
virtual MeasurementBase * clone() const =0
Pseudo-Constructor.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
const Amg::Vector3D & momentum() const
Access method for the momentum.
virtual ParametersBase< DIM, T > * clone() const override=0
clone method for polymorphic deep copy
const Amg::Vector3D & position() const
Access method for the position.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Affine3d Transform3D
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Eigen::Matrix< double, 2, 1 > Vector2D
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Matrix< double, 3, 1 > Vector3D
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ NoField
Field is set to 0., 0., 0.,.
ParametersBase< TrackParametersDim, Charged > TrackParameters
#define CXXUTILS_TRAPPING_FP