56updateP(
double& qOverP,
double deltaP)
58 double p = 1. / std::abs(qOverP);
67std::pair<const Trk::MaterialProperties*, double>
73 double pathCorrection(0.);
76 if (!materialProperties) {
77 return {
nullptr, 0 };
83 :
layer.surfaceRepresentation().pathCorrection(
88 const double pathLength = pathCorrection * materialProperties->thickness();
89 return { materialProperties, pathLength };
93 std::vector<GsfMaterial::Combined>& caches,
94 const std::vector<std::pair<size_t, size_t>>& indices,
98 size_t numComponents =
indices.size();
100 std::vector<char>
isMerged(numComponents, 0);
102 const int returnedMerges = merges.size();
103 for (
int i = 0;
i < returnedMerges; ++
i) {
104 const int mini = merges[
i].To;
105 const int minj = merges[
i].From;
107 const size_t stateIndex =
indices[mini].first;
108 const size_t materialIndex =
indices[mini].second;
112 caches[stateIndex].parameters[materialIndex];
113 const double firstWeight = caches[stateIndex].
weights[materialIndex];
115 const size_t stateIndex2 = indices[minj].first;
116 const size_t materialIndex2 = indices[minj].second;
120 Trk::MultiComponentStateCombiner::combineParametersWithWeight(
121 caches[stateIndex].parameters[materialIndex],
122 caches[stateIndex].
weights[materialIndex],
123 caches[stateIndex2].parameters[materialIndex2],
124 caches[stateIndex2].
weights[materialIndex2]);
126 Trk::MultiComponentStateCombiner::combineCovWithWeight(
127 firstParameters, caches[stateIndex].covariances[materialIndex],
128 firstWeight, caches[stateIndex2].parameters[materialIndex2],
129 caches[stateIndex2].covariances[materialIndex2],
130 caches[stateIndex2].
weights[materialIndex2]);
132 caches[stateIndex2].parameters[materialIndex2].setZero();
133 caches[stateIndex2].covariances[materialIndex2].setZero();
137 for (
size_t i(0); i < numComponents; ++i) {
142 const size_t stateIndex =
indices[
i].first;
143 const size_t materialIndex =
indices[
i].second;
145 caches[stateIndex].parameters[materialIndex];
147 caches[stateIndex].covariances[materialIndex];
149 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
150 inputState[stateIndex]
151 .params->associatedSurface()
152 .createUniqueTrackParameters(
157 const double updatedWeight = caches[stateIndex].weights[materialIndex];
160 {std::move(updatedTrackParameters), updatedWeight});
164 std::move(assemblerCache));
169 const std::string&
type,
170 const std::string& name,
171 const IInterface* parent)
174 declareInterface<IMaterialMixtureConvolution>(
this);
185 return StatusCode::FAILURE;
190 return StatusCode::SUCCESS;
198 std::vector<GsfMaterial::Combined>& caches,
203 const double updateFactor = 1.0;
205 caches, multiComponentState, layer,
direction, updateFactor);
207 if (updatedMergedState.empty()) {
211 return updatedMergedState;
219 std::vector<GsfMaterial::Combined>& caches,
224 const double updateFactor =
225 layer.preUpdateMaterialFactor(*multiComponentState.front().params,
direction);
232 if (updatedMergedState.empty()) {
236 return updatedMergedState;
244 std::vector<GsfMaterial::Combined>& caches,
249 const double updateFactor = layer.postUpdateMaterialFactor(
250 *multiComponentState.front().params,
direction);
255 if (updatedMergedState.empty()) {
259 return updatedMergedState;
264 std::vector<GsfMaterial::Combined>& caches,
268 double updateFactor)
const
272 if (inputState.empty()) {
275 if (updateFactor < 0.01) {
279 caches.resize(inputState.size());
282 size_t numComponents(0);
283 for (
size_t i(0); i < inputState.size(); ++i) {
284 const AmgSymMatrix(5)* measuredCov = inputState[i].params->covariance();
286 if (inputState[i].params->momentum().mag() <= 250. * Gaudi::Units::MeV) {
287 dummyCacheElement(caches[i]);
288 updateCacheElement(caches[i], 0, inputState[i].params->parameters(), measuredCov);
289 caches[i].weights[0] = inputState[i].weight;
290 numComponents += caches[i].numEntries;
294 std::pair<const Trk::MaterialProperties*, double> matPropPair =
295 getMaterialProperties(inputState[i].params.get(), layer);
297 if (!matPropPair.first) {
298 dummyCacheElement(caches[i]);
299 updateCacheElement(caches[i], 0, inputState[i].params->parameters(), measuredCov);
300 caches[i].weights[0] = inputState[i].weight;
301 numComponents += caches[i].numEntries;
306 matPropPair.second *= updateFactor;
317 for (
size_t j(0); j < caches[i].numEntries; ++j) {
318 updateCacheElement(caches[i], j, inputState[i].params->parameters(), measuredCov);
322 caches[i].deltaPs[j])) {
327 caches[i].weights[j] *= inputState[i].weight;
331 if (caches[i].
weights[j] < std::numeric_limits<float>::min()) {
332 caches[i].weights[j] = std::numeric_limits<float>::min();
335 numComponents += caches[i].numEntries;
343 bool componentWithoutMeasurement =
false;
347 std::vector<std::pair<size_t, size_t>>
indices{};
351 for (
size_t i(0); i < inputState.size(); ++i) {
352 for (
size_t j(0); j < caches[i].numEntries; ++j) {
353 const AmgSymMatrix(5)* measuredCov = inputState[i].params->covariance();
359 componentWithoutMeasurement =
true;
361 componentsArray[k].mean = caches[i].parameters[j][
Trk::qOverP];
362 componentsArray[k].cov = cov;
363 componentsArray[k].invCov = cov > 0 ? 1. / cov : 1e10;
364 componentsArray[k].weight = caches[i].weights[j];
371 if (componentWithoutMeasurement) {
372 auto* result = std::max_element(
373 componentsArray.
begin(), componentsArray.
end(),
374 [](
const auto&
a,
const auto& b) { return a.weight < b.weight; });
375 auto index = std::distance(componentsArray.
begin(), result);
379 AmgVector(5)& updatedStateVector = caches[stateIndex].parameters[materialIndex];
380 const AmgSymMatrix(5)* measuredCov = inputState[stateIndex].params->covariance();
381 std::optional<
AmgSymMatrix(5)> updatedCovariance = std::nullopt;
382 if (measuredCov && caches[stateIndex].covariances.size() > materialIndex) {
384 AmgSymMatrix(5)(caches[stateIndex].covariances[materialIndex]);
386 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
387 inputState[stateIndex]
388 .params->associatedSurface()
389 .createUniqueTrackParameters(
392 updatedStateVector[
Trk::qOverP], std::move(updatedCovariance));
395 std::move(updatedTrackParameters), 1.};
397 returnMultiState.push_back(std::move(dummyCompParams));
398 return returnMultiState;
406 auto mergedState = createMergedState(merges, caches,
indices, inputState);
411 << mergedState.size());
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_FATAL(x,...)
Definition of component parameters for use in a mixture of many components. In this regime each track...
Class description for convolution of GSF material mixture.
#define AmgSymMatrix(dim)
Utilities to facilitate the calculation of the KL divergence/distance between components of the mixtu...
virtual ~ElectronMaterialMixtureConvolution()
AlgTool initialise method.
virtual MultiComponentState preUpdate(std::vector< GsfMaterial::Combined > &, const MultiComponentState &, const Layer &, PropDirection direction=anyDirection) const override final
Convolution with post-measurement-update material properties.
Gaudi::Property< std::string > m_parameterisationFileName
virtual MultiComponentState update(std::vector< GsfMaterial::Combined > &, const MultiComponentState &, const Layer &, PropDirection direction=anyDirection) const override final
Convolution with pre-measurement-update material properties.
std::unique_ptr< ElectronCombinedMaterialEffects > m_materialEffects
Gaudi::Property< std::string > m_parameterisationFileNameHighX0
virtual StatusCode initialize() override final
Convolution with full material properties.
ElectronMaterialMixtureConvolution(const std::string &, const std::string &, const IInterface *)
Destructor.
virtual MultiComponentState postUpdate(std::vector< GsfMaterial::Combined > &, const MultiComponentState &, const Layer &, PropDirection direction=anyDirection) const override final
The particle hypothesis we implement material effects for.
Gaudi::Property< unsigned int > m_maximumNumberOfComponents
Base Class for a Detector Layer in the Tracking realm.
Material with information about thickness of material.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
constexpr int8_t maxNumberofStateComponents
The state is described by N Gaussian components The Beth Heitler Material effect are also described b...
AlignedDynArray< Component1D, GSFConstants::alignment > Component1DArray
std::vector< Merge > MergeArray
bool isMerged(int matchInfo)
MultiComponentState assembledState(MultiComponentStateAssembler::Cache &&cache)
Method to return the cached state object - it performs a reweighting before returning the object base...
void renormaliseState(MultiComponentState &, double norm=1)
Performing renormalisation of total state weighting to one.
Ensure that the ATLAS eigen extensions are properly loaded.
PropDirection
PropDirection, enum for direction of the propagation.
std::vector< ComponentParameters > MultiComponentState
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
@ loc2
generic first and second local coordinate
std::pair< long int, long int > indices
ParametersBase< TrackParametersDim, Charged > TrackParameters
iterator end() noexcept
iterator pointing to the past-the-end element
iterator begin() noexcept
iterator pointing to the first element
Helper struct for combined material effects, multicomponent description.
std::array< AmgVector(5), GSFConstants::maxNumberofMatComponents > parameters
std::array< AmgSymMatrix(5), GSFConstants::maxNumberofMatComponents > covariances
Trk::MultiComponentState multiComponentState