55 updateP(
double&
qOverP,
double deltaP)
57 double p = 1. / std::abs(
qOverP);
66 std::pair<const Trk::MaterialProperties*, double>
72 double pathCorrection(0.);
76 materialProperties = materialProperties
78 :
layer.fullUpdateMaterialProperties(*trackParameters);
80 if (!materialProperties) {
81 return {
nullptr, 0 };
87 :
layer.surfaceRepresentation().pathCorrection(
92 double pathLength = pathCorrection * materialProperties->thickness();
93 return { materialProperties, pathLength };
99 const std::string&
type,
100 const std::string&
name,
104 declareInterface<IMaterialMixtureConvolution>(
this);
116 return StatusCode::FAILURE;
120 m_parameterisationFileName, m_parameterisationFileNameHighX0);
121 return StatusCode::SUCCESS;
130 std::vector<GsfMaterial::Combined>& caches,
138 caches, multiComponentState,
layer, direction, particleHypothesis,
Normal);
140 if (updatedMergedState.empty()) {
146 return updatedMergedState;
155 std::vector<GsfMaterial::Combined>& caches,
170 if (updatedMergedState.empty()) {
176 return updatedMergedState;
185 std::vector<GsfMaterial::Combined>& caches,
203 if (updatedMergedState.empty()) {
209 return updatedMergedState;
214 std::vector<GsfMaterial::Combined>& caches,
223 if (inputState.empty()) {
227 double updateFactor(1.);
229 if (updateType == Preupdate) {
231 layer.preUpdateMaterialFactor(*inputState.front().params, direction);
232 }
else if (updateType == Postupdate) {
234 layer.postUpdateMaterialFactor(*inputState.front().params, direction);
237 if (updateFactor < 0.01) {
242 caches.resize(inputState.size());
246 for (
size_t i(0);
i < inputState.size(); ++
i) {
247 const AmgSymMatrix(5)* measuredCov = inputState[
i].params->covariance();
250 dummyCacheElement(caches[
i]);
252 caches[
i], 0, inputState[
i].
params->parameters(), measuredCov);
253 caches[
i].weights[0] = inputState[
i].weight;
254 n += caches[
i].numEntries;
259 std::pair<const Trk::MaterialProperties*, double> matPropPair =
260 getMaterialProperties(inputState[
i].
params.get(),
layer);
262 if (!matPropPair.first) {
263 dummyCacheElement(caches[
i]);
265 caches[
i], 0, inputState[
i].
params->parameters(), measuredCov);
266 caches[
i].weights[0] = inputState[
i].weight;
267 n += caches[
i].numEntries;
272 matPropPair.second *= updateFactor;
273 m_materialEffects.compute(caches[
i],
280 for (
size_t j(0); j < caches[
i].numEntries; ++j) {
282 caches[
i], j, inputState[
i].
params->parameters(), measuredCov);
286 caches[
i].deltaPs[j])) {
291 caches[
i].weights[j] *= inputState[
i].weight;
299 n += caches[
i].numEntries;
305 bool componentWithoutMeasurement =
false;
309 std::array<std::pair<size_t, size_t>,
314 for (
size_t i(0);
i < inputState.size(); ++
i) {
315 for (
size_t j(0); j < caches[
i].numEntries; ++j) {
316 const AmgSymMatrix(5)* measuredCov = inputState[
i].params->covariance();
322 componentWithoutMeasurement =
true;
329 componentsArray.
components[
k].weight = caches[
i].weights[j];
336 if (componentWithoutMeasurement) {
337 auto*
result = std::max_element(
340 [](
const auto&
a,
const auto&
b) { return a.weight < b.weight; });
348 caches[stateIndex].deltaParameters[materialIndex];
350 inputState[stateIndex].params->covariance();
351 std::optional<
AmgSymMatrix(5)> updatedCovariance = std::nullopt;
353 caches[stateIndex].deltaCovariances.size() > materialIndex) {
355 AmgSymMatrix(5)(caches[stateIndex].deltaCovariances[materialIndex]);
357 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
358 inputState[stateIndex]
359 .params->associatedSurface()
360 .createUniqueTrackParameters(updatedStateVector[
Trk::loc1],
365 std::move(updatedCovariance));
370 returnMultiState.push_back(std::move(dummyCompParams));
371 return returnMultiState;
376 if (
n > m_maximumNumberOfComponents) {
377 KL =
findMerges(componentsArray, m_maximumNumberOfComponents);
382 std::array<bool, GSFConstants::maxComponentsAfterConvolution>
isMerged = {};
385 for (
int i = 0;
i < returnedMerges; ++
i) {
386 const int8_t mini = KL.
merges[
i].To;
387 const int8_t minj = KL.
merges[
i].From;
389 ATH_MSG_WARNING(
"Component is already merged " <<
static_cast<int>(minj));
393 size_t stateIndex =
indices[mini].first;
394 size_t materialIndex =
indices[mini].second;
398 caches[stateIndex].deltaParameters[materialIndex];
399 double firstWeight = caches[stateIndex].weights[materialIndex];
402 size_t stateIndex2 =
indices[minj].first;
403 size_t materialIndex2 =
indices[minj].second;
410 caches[stateIndex].deltaParameters[materialIndex],
411 caches[stateIndex].
weights[materialIndex],
412 caches[stateIndex2].deltaParameters[materialIndex2],
413 caches[stateIndex2].
weights[materialIndex2]);
418 caches[stateIndex].deltaCovariances[materialIndex],
420 caches[stateIndex2].deltaParameters[materialIndex2],
421 caches[stateIndex2].deltaCovariances[materialIndex2],
422 caches[stateIndex2].
weights[materialIndex2]);
425 caches[stateIndex2].deltaParameters[materialIndex2].setZero();
426 caches[stateIndex2].deltaCovariances[materialIndex2].setZero();
430 for (
size_t i(0);
i <
n; ++
i) {
436 size_t stateIndex =
indices[
i].first;
437 size_t materialIndex =
indices[
i].second;
439 caches[stateIndex].deltaParameters[materialIndex];
441 caches[stateIndex].deltaCovariances[materialIndex];
443 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
444 inputState[stateIndex]
445 .params->associatedSurface()
446 .createUniqueTrackParameters(stateVector[
Trk::loc1],
453 double updatedWeight = caches[stateIndex].weights[materialIndex];
456 std::move(updatedTrackParameters), updatedWeight});
464 if (mergedState.size() > m_maximumNumberOfComponents)
465 ATH_MSG_ERROR(
"Merging failed, target size: " << m_maximumNumberOfComponents
467 << mergedState.size());