81 {
82
85 }
86
87
88
89
90
91
92
93 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
94 unsigned size = measurements.size() + 1;
95 if (leadingTSOS)
97 trackStateOnSurfaces->reserve(
size);
98 std::unique_ptr<AlignmentEffectsOnTrack> alignmentEffects{};
99 const FitMeasurement* fitMeasurement = measurements.front();
100 const FitQualityOnSurface fitQoS{};
101 std::unique_ptr<MaterialEffectsBase> materialEffects{};
102 std::unique_ptr<MeasurementBase> measurementBase{};
103 const Surface* surface = nullptr;
104 std::unique_ptr<TrackParameters> trackParameters{};
105 std::bitset<TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
106 const defaultPattern;
107 std::bitset<TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
108 typePattern = defaultPattern;
109
110
111 unsigned scatter = 0;
112 unsigned tsos = 0;
113 std::unique_ptr<Perigee> perigee(
parameters.perigee());
115 trackStateOnSurfaces->push_back(new TrackStateOnSurface(
116 fitQoS, std::move(measurementBase), std::move(perigee),
117 std::move(materialEffects), typePattern, std::move(alignmentEffects)));
118 ++tsos;
119
120
121 if (leadingTSOS) {
122 for (const auto* t : *leadingTSOS) {
124 trackStateOnSurfaces->push_back((*t).clone());
125 ++tsos;
126 }
127 }
128 }
129
130
131 for (auto* m : measurements) {
132 if (
m->isMaterialDelimiter())
133 continue;
134
135
136 if (
m->surface() != surface || alignmentEffects ||
m->alignmentEffects()) {
137 if (surface) {
138 if (typePattern == defaultPattern) {
140 *
cache.log << MSG::DEBUG <<
" skip empty TSOS# " << tsos + 1;
141 if (
m->materialEffects())
142 *
cache.log <<
" with material";
145 }
146 } else {
147
148 bool const withCovariance = true;
149 trackParameters.reset(
parameters.trackParameters(
150 *
cache.log, *fitMeasurement, withCovariance));
151
152 if (!trackParameters) {
154 << MSG::WARNING
155 << " fail track with incomplete return TSOS: no trackParameters"
157 return nullptr;
158 }
160 trackStateOnSurfaces->push_back(new TrackStateOnSurface(
161 fitQoS, std::move(measurementBase), std::move(trackParameters),
162 std::move(materialEffects), typePattern,
163 std::move(alignmentEffects)));
164 ++tsos;
165 }
166 }
168 surface =
m->surface();
169 measurementBase.reset();
170 materialEffects.reset();
171 typePattern = defaultPattern;
172 alignmentEffects.reset();
173 } else {
176 *
cache.log << MSG::VERBOSE <<
" tsos# " << tsos <<
" shared surface"
178 }
179
180
181 if (
m->measurementBase()) {
182
183
184 if (measurementBase) {
185
186 bool const withCovariance = true;
187 trackParameters.reset(
parameters.trackParameters(
188 *
cache.log, *fitMeasurement, withCovariance));
189 if (!trackParameters) {
191 << MSG::WARNING
192 << " fail track with incomplete return TSOS: no trackParameters"
194 return nullptr;
195 }
197 trackStateOnSurfaces->push_back(new TrackStateOnSurface(
198 fitQoS, std::move(measurementBase), std::move(trackParameters),
199 std::move(materialEffects), typePattern,
200 std::move(alignmentEffects)));
201 ++tsos;
203 materialEffects.reset();
204 typePattern = defaultPattern;
205 alignmentEffects.reset();
206 }
207
208 measurementBase =
m->measurementBase()->uniqueClone();
212 }
213
214
215 if (
m->materialEffects()) {
216
217
218 if (
m->isEnergyDeposit()) {
219 materialEffects =
m->materialEffects()->uniqueClone();
221 }
else if (
m->isScatterer()) {
222
223 std::bitset<MaterialEffectsBase::NumberOfMaterialEffectsTypes>
224 typeMaterial;
226 const MaterialEffectsOnTrack* meot =
227 dynamic_cast<const MaterialEffectsOnTrack*
>(
m->materialEffects());
228 if (meot && meot->energyLoss())
229 {
230 auto energyLoss =
231 std::unique_ptr<EnergyLoss>(meot->energyLoss()->clone());
234 {
235 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
236 m->materialEffects()->thicknessInX0(),
237 parameters.scatteringAngles(*m, scatter), std::move(energyLoss),
238 m->materialEffects()->associatedSurface(), typeMaterial);
239 ++scatter;
240 } else
241 {
242 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
243 m->materialEffects()->thicknessInX0(),
244 parameters.scatteringAngles(*m), std::move(energyLoss),
245 m->materialEffects()->associatedSurface(), typeMaterial);
246 }
247 } else
248 {
250 {
251 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
252 m->materialEffects()->thicknessInX0(),
254 m->materialEffects()->associatedSurface(), typeMaterial);
255 ++scatter;
256 } else
257 {
258 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
259 m->materialEffects()->thicknessInX0(),
261 m->materialEffects()->associatedSurface(), typeMaterial);
262 }
263 }
264
266 } else {
267 *
cache.log << MSG::WARNING
268 << " deprecated TrackStateOnSurface::InertMaterial"
270 materialEffects =
m->materialEffects()->uniqueClone();
272 }
273 }
274
275
276 if (
m->isPerigee()) {
278 }
279
280
281 else if (
m->alignmentEffects()) {
282 const AlignmentEffectsOnTrack& AEOT = *
m->alignmentEffects();
283 unsigned const align =
m->alignmentParameter() - 1;
284
285 *
cache.log << MSG::VERBOSE <<
" Fitprocedure AEOT input deltaTranslation "
286 << AEOT.deltaTranslation() << " deltaAngle "
287 << AEOT.deltaAngle() << " output Trans "
288 <<
parameters.alignmentOffset(align) <<
" deltaAngle "
290 alignmentEffects = std::make_unique<Trk::AlignmentEffectsOnTrack>(
291 parameters.alignmentOffset(align), AEOT.sigmaDeltaTranslation(),
292 parameters.alignmentAngle(align), AEOT.sigmaDeltaAngle(),
293 AEOT.vectorOfAffectedTSOS(), *
m->surface());
295 }
296
297
298 else if (
m->isPassive()) {
299 if (
m->type() ==
hole)
301 }
302 }
303
304
305 bool const withCovariance = true;
306 trackParameters.reset(
307 parameters.trackParameters(*
cache.log, *fitMeasurement, withCovariance));
308 if (!trackParameters) {
309 *
cache.log << MSG::WARNING
310 << " fail track with incomplete return TSOS: no trackParameters"
312 return nullptr;
313 }
315 trackStateOnSurfaces->push_back(new TrackStateOnSurface(
316 fitQoS, std::move(measurementBase), std::move(trackParameters),
317 std::move(materialEffects), typePattern, std::move(alignmentEffects)));
318 ++tsos;
319
320
323 std::make_unique<FitQuality>(chiSquared,
cache.numberDoF));
324
326 *
cache.log << MSG::VERBOSE <<
" track with " << tsos <<
" TSOS " <<
endmsg;
328}
size_t size() const
Number of registered mappings.
size_type size() const noexcept
Returns the number of elements in the collection.
static void reportQuality(FitProcedure::Cache &cache, const std::vector< FitMeasurement * > &measurements, const FitParameters ¶meters)
@ FittedMaterialEffects
contains values obtained by fitting the scatterer or e-loss
@ EnergyLossEffects
contains energy loss corrections
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Parameter
This TSOS contains a Trk::ParameterBase.
@ Alignment
This TSOS contains a Trk::AlignmentEffectsOnTrack.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ InertMaterial
This represents inert material, and so will contain MaterialEffectsBase.
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
@ Hole
A hole on the track - this is defined in the following way.
@ CaloDeposit
This TSOS contains a CaloEnergy object.
float chiSquared(const U &p)