ATLAS Offline Software
Classes | Functions
Trk::MultiComponentStateAssembler Namespace Reference

Helper struct representing a cache of the Multicomponent state under assembly. More...

Classes

struct  Cache
 

Functions

void addComponent (MultiComponentStateAssembler::Cache &cache, ComponentParameters &&multiComponentState)
 Method to add a single set of Trk::ComponentParameters to the cached Trk::MultiComponentState object under construction. More...
 
void addMultiState (MultiComponentStateAssembler::Cache &cache, Trk::MultiComponentState &&multiComponentState)
 Method to add a new Trk::MultiComponentState to the cached Trk::MultiComponentState object under construction. More...
 
MultiComponentState assembledState (MultiComponentStateAssembler::Cache &&cache)
 Method to return the cached state object - it performs a reweighting before returning the object based on the valid and invaid weights. More...
 

Detailed Description

Helper struct representing a cache of the Multicomponent state under assembly.

Function Documentation

◆ addComponent()

void Trk::MultiComponentStateAssembler::addComponent ( MultiComponentStateAssembler::Cache cache,
ComponentParameters &&  multiComponentState 
)
inline

Method to add a single set of Trk::ComponentParameters to the cached Trk::MultiComponentState object under construction.

Definition at line 71 of file MultiComponentStateAssembler.h.

72  {
73 
74  cache.validWeightSum += componentParameters.weight;
75  cache.multiComponentState.push_back({std::move(componentParameters.params),
76  componentParameters.weight});
77 }

◆ addMultiState()

void Trk::MultiComponentStateAssembler::addMultiState ( MultiComponentStateAssembler::Cache cache,
Trk::MultiComponentState &&  multiComponentState 
)
inline

Method to add a new Trk::MultiComponentState to the cached Trk::MultiComponentState object under construction.

Definition at line 79 of file MultiComponentStateAssembler.h.

80  {
81 
82  double sumW(0.);
83  for (auto& component : multiComponentState) {
84  sumW += component.weight;
85  cache.multiComponentState.push_back({std::move(component.params),
86  component.weight});
87  }
88  cache.validWeightSum += sumW;
89 }

◆ assembledState()

Trk::MultiComponentState Trk::MultiComponentStateAssembler::assembledState ( MultiComponentStateAssembler::Cache &&  cache)

Method to return the cached state object - it performs a reweighting before returning the object based on the valid and invaid weights.

Definition at line 120 of file MultiComponentStateAssembler.cxx.

122 {
123  if (!prepareStateForAssembly(cache)) {
124  return {};
125  }
126  double totalWeight = cache.validWeightSum;
127  if (cache.invalidWeightSum > 0. || cache.validWeightSum <= 0.) {
128  totalWeight = cache.validWeightSum + cache.invalidWeightSum;
129  }
130 
131  return doStateAssembly(std::move(cache), totalWeight);
132 }