93 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
94 unsigned size = measurements.size() + 1;
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>
107 std::bitset<TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
108 typePattern = defaultPattern;
111 unsigned scatter = 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)));
122 for (
const auto*
t : *leadingTSOS) {
124 trackStateOnSurfaces->push_back((*t).clone());
131 for (
auto*
m : measurements) {
132 if (
m->isMaterialDelimiter())
136 if (
m->surface() != surface || alignmentEffects ||
m->alignmentEffects()) {
138 if (typePattern == defaultPattern) {
140 *cache.log <<
MSG::DEBUG <<
" skip empty TSOS# " << tsos + 1;
141 if (
m->materialEffects())
142 *cache.log <<
" with material";
143 m->print(*cache.log);
148 bool withCovariance =
true;
149 trackParameters.reset(
parameters.trackParameters(
150 *cache.log, *fitMeasurement, withCovariance));
152 if (!trackParameters) {
155 <<
" fail track with incomplete return TSOS: no trackParameters"
160 trackStateOnSurfaces->push_back(
new TrackStateOnSurface(
161 fitQoS, std::move(measurementBase), std::move(trackParameters),
162 std::move(materialEffects), typePattern,
163 std::move(alignmentEffects)));
168 surface =
m->surface();
169 measurementBase.reset();
170 materialEffects.reset();
171 typePattern = defaultPattern;
172 alignmentEffects.reset();
176 *cache.log <<
MSG::VERBOSE <<
" tsos# " << tsos <<
" shared surface"
181 if (
m->measurementBase()) {
184 if (measurementBase) {
186 bool withCovariance =
true;
187 trackParameters.reset(
parameters.trackParameters(
188 *cache.log, *fitMeasurement, withCovariance));
189 if (!trackParameters) {
192 <<
" fail track with incomplete return TSOS: no trackParameters"
197 trackStateOnSurfaces->push_back(
new TrackStateOnSurface(
198 fitQoS, std::move(measurementBase), std::move(trackParameters),
199 std::move(materialEffects), typePattern,
200 std::move(alignmentEffects)));
203 materialEffects.reset();
204 typePattern = defaultPattern;
205 alignmentEffects.reset();
208 measurementBase =
m->measurementBase()->uniqueClone();
215 if (
m->materialEffects()) {
218 if (
m->isEnergyDeposit()) {
219 materialEffects =
m->materialEffects()->uniqueClone();
221 }
else if (
m->isScatterer()) {
223 std::bitset<MaterialEffectsBase::NumberOfMaterialEffectsTypes>
226 const MaterialEffectsOnTrack* meot =
227 dynamic_cast<const MaterialEffectsOnTrack*
>(
m->materialEffects());
228 if (meot && meot->energyLoss())
231 std::unique_ptr<EnergyLoss>(meot->energyLoss()->clone());
235 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
236 m->materialEffects()->thicknessInX0(),
237 parameters.scatteringAngles(*
m, scatter), std::move(energyLoss),
238 m->materialEffects()->associatedSurface(), typeMaterial);
242 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
243 m->materialEffects()->thicknessInX0(),
244 parameters.scatteringAngles(*
m), std::move(energyLoss),
245 m->materialEffects()->associatedSurface(), typeMaterial);
251 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
252 m->materialEffects()->thicknessInX0(),
254 m->materialEffects()->associatedSurface(), typeMaterial);
258 materialEffects = std::make_unique<MaterialEffectsOnTrack>(
259 m->materialEffects()->thicknessInX0(),
261 m->materialEffects()->associatedSurface(), typeMaterial);
267 *cache.log << MSG::WARNING
268 <<
" deprecated TrackStateOnSurface::InertMaterial"
270 materialEffects =
m->materialEffects()->uniqueClone();
276 if (
m->isPerigee()) {
281 else if (
m->alignmentEffects()) {
282 const AlignmentEffectsOnTrack& AEOT = *
m->alignmentEffects();
283 unsigned align =
m->alignmentParameter() - 1;
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());
298 else if (
m->isPassive()) {
299 if (
m->type() ==
hole)
305 bool 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"
315 trackStateOnSurfaces->push_back(
new TrackStateOnSurface(
316 fitQoS, std::move(measurementBase), std::move(trackParameters),
317 std::move(materialEffects), typePattern, std::move(alignmentEffects)));
321 double chiSquared = cache.chiSq *
static_cast<double>(cache.numberDoF);
323 std::make_unique<FitQuality>(
chiSquared, cache.numberDoF));