56updateP(
double& qOverP,
double deltaP)
58 double p = 1. / std::abs(qOverP);
67std::pair<const Trk::MaterialProperties*, double>
73 double pathCorrection(0.);
77 materialProperties = materialProperties
79 :
layer.fullUpdateMaterialProperties(*trackParameters);
81 if (!materialProperties) {
82 return {
nullptr, 0 };
88 :
layer.surfaceRepresentation().pathCorrection(
93 const double pathLength = pathCorrection * materialProperties->thickness();
94 return { materialProperties, pathLength };
98 std::vector<GsfMaterial::Combined>& caches,
99 const std::vector<std::pair<size_t, size_t>>& indices,
103 size_t numComponents =
indices.size();
105 std::vector<char>
isMerged(numComponents, 0);
107 const int returnedMerges = merges.size();
108 for (
int i = 0;
i < returnedMerges; ++
i) {
109 const int mini = merges[
i].To;
110 const int minj = merges[
i].From;
112 const size_t stateIndex =
indices[mini].first;
113 const size_t materialIndex =
indices[mini].second;
117 caches[stateIndex].parameters[materialIndex];
118 const double firstWeight = caches[stateIndex].
weights[materialIndex];
120 const size_t stateIndex2 = indices[minj].first;
121 const size_t materialIndex2 = indices[minj].second;
125 Trk::MultiComponentStateCombiner::combineParametersWithWeight(
126 caches[stateIndex].parameters[materialIndex],
127 caches[stateIndex].
weights[materialIndex],
128 caches[stateIndex2].parameters[materialIndex2],
129 caches[stateIndex2].
weights[materialIndex2]);
131 Trk::MultiComponentStateCombiner::combineCovWithWeight(
132 firstParameters, caches[stateIndex].covariances[materialIndex],
133 firstWeight, caches[stateIndex2].parameters[materialIndex2],
134 caches[stateIndex2].covariances[materialIndex2],
135 caches[stateIndex2].
weights[materialIndex2]);
137 caches[stateIndex2].parameters[materialIndex2].setZero();
138 caches[stateIndex2].covariances[materialIndex2].setZero();
142 for (
size_t i(0); i < numComponents; ++i) {
147 const size_t stateIndex =
indices[
i].first;
148 const size_t materialIndex =
indices[
i].second;
150 caches[stateIndex].parameters[materialIndex];
152 caches[stateIndex].covariances[materialIndex];
154 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
155 inputState[stateIndex]
156 .params->associatedSurface()
157 .createUniqueTrackParameters(
162 const double updatedWeight = caches[stateIndex].weights[materialIndex];
165 {std::move(updatedTrackParameters), updatedWeight});
169 std::move(assemblerCache));
174 const std::string&
type,
175 const std::string& name,
176 const IInterface* parent)
179 declareInterface<IMaterialMixtureConvolution>(
this);
190 return StatusCode::FAILURE;
195 return StatusCode::SUCCESS;
203 std::vector<GsfMaterial::Combined>& caches,
208 const double updateFactor = 1.0;
210 caches, multiComponentState, layer, direction, updateFactor);
212 if (updatedMergedState.empty()) {
216 return updatedMergedState;
224 std::vector<GsfMaterial::Combined>& caches,
229 const double updateFactor =
230 layer.preUpdateMaterialFactor(*multiComponentState.front().params, direction);
237 if (updatedMergedState.empty()) {
241 return updatedMergedState;
249 std::vector<GsfMaterial::Combined>& caches,
254 const double updateFactor = layer.postUpdateMaterialFactor(
255 *multiComponentState.front().params, direction);
258 update(caches, multiComponentState, layer, direction, updateFactor);
260 if (updatedMergedState.empty()) {
264 return updatedMergedState;
269 std::vector<GsfMaterial::Combined>& caches,
273 double updateFactor)
const
277 if (inputState.empty()) {
280 if (updateFactor < 0.01) {
284 caches.resize(inputState.size());
287 size_t numComponents(0);
288 for (
size_t i(0); i < inputState.size(); ++i) {
289 const AmgSymMatrix(5)* measuredCov = inputState[i].params->covariance();
291 if (inputState[i].params->momentum().mag() <= 250. * Gaudi::Units::MeV) {
292 dummyCacheElement(caches[i]);
293 updateCacheElement(caches[i], 0, inputState[i].params->parameters(), measuredCov);
294 caches[i].weights[0] = inputState[i].weight;
295 numComponents += caches[i].numEntries;
299 std::pair<const Trk::MaterialProperties*, double> matPropPair =
300 getMaterialProperties(inputState[i].params.get(), layer);
302 if (!matPropPair.first) {
303 dummyCacheElement(caches[i]);
304 updateCacheElement(caches[i], 0, inputState[i].params->parameters(), measuredCov);
305 caches[i].weights[0] = inputState[i].weight;
306 numComponents += caches[i].numEntries;
311 matPropPair.second *= updateFactor;
322 for (
size_t j(0); j < caches[i].numEntries; ++j) {
323 updateCacheElement(caches[i], j, inputState[i].params->parameters(), measuredCov);
327 caches[i].deltaPs[j])) {
332 caches[i].weights[j] *= inputState[i].weight;
336 if (caches[i].
weights[j] < std::numeric_limits<float>::min()) {
337 caches[i].weights[j] = std::numeric_limits<float>::min();
340 numComponents += caches[i].numEntries;
348 bool componentWithoutMeasurement =
false;
352 std::vector<std::pair<size_t, size_t>>
indices{};
356 for (
size_t i(0); i < inputState.size(); ++i) {
357 for (
size_t j(0); j < caches[i].numEntries; ++j) {
358 const AmgSymMatrix(5)* measuredCov = inputState[i].params->covariance();
364 componentWithoutMeasurement =
true;
366 componentsArray[k].mean = caches[i].parameters[j][
Trk::qOverP];
367 componentsArray[k].cov = cov;
368 componentsArray[k].invCov = cov > 0 ? 1. / cov : 1e10;
369 componentsArray[k].weight = caches[i].weights[j];
376 if (componentWithoutMeasurement) {
377 auto*
result = std::max_element(
378 componentsArray.
begin(), componentsArray.
end(),
379 [](
const auto&
a,
const auto& b) { return a.weight < b.weight; });
384 AmgVector(5)& updatedStateVector = caches[stateIndex].parameters[materialIndex];
385 const AmgSymMatrix(5)* measuredCov = inputState[stateIndex].params->covariance();
386 std::optional<
AmgSymMatrix(5)> updatedCovariance = std::nullopt;
387 if (measuredCov && caches[stateIndex].covariances.size() > materialIndex) {
389 AmgSymMatrix(5)(caches[stateIndex].covariances[materialIndex]);
391 std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
392 inputState[stateIndex]
393 .params->associatedSurface()
394 .createUniqueTrackParameters(
397 updatedStateVector[
Trk::qOverP], std::move(updatedCovariance));
400 std::move(updatedTrackParameters), 1.};
402 returnMultiState.push_back(std::move(dummyCompParams));
403 return returnMultiState;
411 auto mergedState = createMergedState(merges, caches,
indices, inputState);
416 << mergedState.size());
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
@ 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