ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::CompressedLayerMaterialCreator Class Reference

LayerMaterialProperties creator for CompressedLayerMaterial. More...

#include <CompressedLayerMaterialCreator.h>

Inheritance diagram for Trk::CompressedLayerMaterialCreator:
Collaboration diagram for Trk::CompressedLayerMaterialCreator:

Public Member Functions

 CompressedLayerMaterialCreator (const std::string &, const std::string &, const IInterface *)
 Constructor.
 ~CompressedLayerMaterialCreator ()
 Destructor.
LayerMaterialPropertiescreateLayerMaterial (const LayerMaterialRecord &lmr) const
 process the material properties
LayerMaterialPropertiesconvertLayerMaterial (const LayerMaterialProperties &lmr) const
 create layer material properties from layer material properties - simply clones
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
 DeclareInterfaceID (ILayerMaterialCreator, 1, 0)
const std::string & layerMaterialName () const
 the name of the created material map

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

std::string m_layerMaterialName
std::string m_layerMaterialDirectory

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

LayerMaterialPropertiescreateCompressedLayerMaterial (const MaterialPropertiesMatrix &lmm, const BinUtility &lmbu) const
 private method that can be called by both create/convertLayerMaterial
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

double m_compressedMaterialThickness
unsigned int m_compressedMaterialX0Bins
unsigned int m_compressedMaterialZARhoBins
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared
CxxUtils::CachedValue< std::string > m_layerMaterialFullName

Detailed Description

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CompressedLayerMaterialCreator()

Trk::CompressedLayerMaterialCreator::CompressedLayerMaterialCreator ( const std::string & t,
const std::string & n,
const IInterface * p )

Constructor.

Definition at line 19 of file CompressedLayerMaterialCreator.cxx.

20: AthAlgTool(t,n,p),
24{
25 declareInterface<Trk::ILayerMaterialCreator>(this);
26
27 // give the map a name
28 declareProperty("LayerMaterialName" , m_layerMaterialName);
29 declareProperty("LayerMaterialDirectory" , m_layerMaterialDirectory);
30 // setup for compressed layer creation
34
35}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~CompressedLayerMaterialCreator()

Trk::CompressedLayerMaterialCreator::~CompressedLayerMaterialCreator ( )
default

Destructor.

Member Function Documentation

◆ convertLayerMaterial()

Trk::LayerMaterialProperties * Trk::CompressedLayerMaterialCreator::convertLayerMaterial ( const LayerMaterialProperties & lmr) const
virtual

create layer material properties from layer material properties - simply clones

Implements Trk::ILayerMaterialCreator.

Definition at line 56 of file CompressedLayerMaterialCreator.cxx.

57{
58 // the return object
59 Trk::LayerMaterialProperties* bLayerMaterial = nullptr;
60 // get the binUtility of the LayerMaterialProperties
61 const Trk::BinUtility* bUtility = lmProperties.binUtility();
62 // we have a bin utility, get the matrix and fill it
63 if (bUtility){
64 // prepare the matrix
65 // nF x nS
66 size_t nBins0 = bUtility->max(0)+1;
67 size_t nBins1 = bUtility->max(1)+1;
68 // create the MaterialMatrix
69 Trk::MaterialPropertiesMatrix materialMatrix;
70 materialMatrix.reserve(nBins1);
71 // fill the matrix
72 for (size_t ibin1 = 0; ibin1 < nBins1; ++ibin1) {
73 // create the vector first
74 Trk::MaterialPropertiesVector materialVector;
75 materialVector.reserve(nBins0);
76 // loop over local 1 bins
77 for (size_t ibin0 = 0; ibin0 < nBins0; ++ibin0) {
78 // get the material from the properties and push them into the matrix (no cloning !)
79 const Trk::MaterialProperties* mProperties = lmProperties.material(ibin0,ibin1);
80 materialVector.push_back(mProperties);
81 }
82 // now pus the vector into the matrix
83 materialMatrix.push_back(materialVector);
84 }
85
86 // create the material
87 ATH_MSG_VERBOSE("Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
88 bLayerMaterial = createCompressedLayerMaterial(materialMatrix,*bUtility);
89
90 } else {
91 // must be homogenous material, can be transformed into a 0-bin material, would be silly though
92 ATH_MSG_DEBUG("No BinUtility provided - return a simple clone.");
93 bLayerMaterial = lmProperties.clone();
94 }
95 //
96 return bLayerMaterial;
97}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
size_t max(size_t ba=0) const
First bin maximal value.
Definition BinUtility.h:212
LayerMaterialProperties * createCompressedLayerMaterial(const MaterialPropertiesMatrix &lmm, const BinUtility &lmbu) const
private method that can be called by both create/convertLayerMaterial
virtual LayerMaterialProperties * clone() const =0
Pseudo-Constructor clone()
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
std::vector< std::vector< const MaterialProperties * > > MaterialPropertiesMatrix

◆ createCompressedLayerMaterial()

Trk::LayerMaterialProperties * Trk::CompressedLayerMaterialCreator::createCompressedLayerMaterial ( const MaterialPropertiesMatrix & lmm,
const BinUtility & lmbu ) const
private

private method that can be called by both create/convertLayerMaterial

Definition at line 99 of file CompressedLayerMaterialCreator.cxx.

100{
101 // the vector to be created and reserve the maximum
102 Trk::MaterialPropertiesVector materialVector;
104 // nF x nS
105 size_t nFirstBins = lBinUtility.max(0)+1;
106 size_t nSecondBins = lBinUtility.max(1)+1;
107 // low, high boundaries
108 double x0min = 10e10;
109 double x0max = 0.;
110 double avZArhoMin = 10e10;
111 double avZArhoMax = 0.;
112 // create two maps, the compression map and the index map
113 std::vector< std::vector<unsigned short int> > materialBins;
114 // (1) FIRST LOOP, get boundaries
115 materialBins.reserve(nSecondBins);
116 for (size_t isec = 0; isec < nSecondBins; ++isec) {
117 std::vector<unsigned short int> firstbins(nFirstBins,0);
118 materialBins.push_back(firstbins);
119 // loop over the bins
120 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
121 // get the current material properties
122 const Trk::MaterialProperties* matProp = materialProperties[isec][ifir];
123 if (matProp) {
124 double tinX0 = matProp->thicknessInX0();
125 double avZArho = matProp->zOverAtimesRho();
126 x0min = tinX0 < x0min ? tinX0 : x0min;
127 x0max = tinX0 > x0max ? tinX0 : x0max;
128 avZArhoMin = avZArho < avZArhoMin ? avZArho : avZArhoMin;
129 avZArhoMax = avZArho > avZArhoMax ? avZArho : avZArhoMax;
130 }
131 }
132 }
133 // min / max is defined, find step size
134 double stepX0 = (x0max-x0min)/m_compressedMaterialX0Bins;
135 double stepZArho = (avZArhoMax-avZArhoMin)/m_compressedMaterialZARhoBins;
136 // get the material histogram
137 std::vector< std::vector< std::vector< Trk::IndexedMaterial> > > materialHistogram;
138 materialHistogram.reserve(m_compressedMaterialZARhoBins);
139 // prepare the histogram
140 for (size_t izarho = 0; izarho < m_compressedMaterialZARhoBins; ++izarho) {
141 std::vector< std::vector < Trk::IndexedMaterial > > x0materialbins;
142 x0materialbins.reserve(m_compressedMaterialX0Bins);
143 for (size_t ix0 = 0; ix0 < m_compressedMaterialX0Bins; ++ix0) {
144 std::vector < Trk::IndexedMaterial > materialBin;
145 x0materialbins.push_back( materialBin );
146 }
147 materialHistogram.push_back(x0materialbins);
148 }
149 // fill the histogram
150 for (size_t isec = 0; isec < nSecondBins; ++isec) {
151 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
152 // get the material properties
153 const Trk::MaterialProperties* matProp = dynamic_cast<const Trk::MaterialProperties*>(materialProperties[isec][ifir]);
154 if (matProp) {
155 // calculate the bins of the material histogram
156 double tinX0 = matProp->thicknessInX0();
157 double avZArho = matProp->zOverAtimesRho();
158 int x0bin = int( (tinX0-x0min)/stepX0 );
159 int zarhobin = int( (avZArho-avZArhoMin)/stepZArho );
160 // range protection
161 x0bin = ( (size_t)x0bin >= m_compressedMaterialX0Bins) ? m_compressedMaterialX0Bins-1 : x0bin;
162 x0bin = x0bin < 0 ? 0 : x0bin;
163 zarhobin = ( (size_t)zarhobin >= m_compressedMaterialZARhoBins) ? m_compressedMaterialZARhoBins-1 : zarhobin;
164 zarhobin = zarhobin < 0 ? 0 : zarhobin;
165 // create indexed material
166 Trk::IndexedMaterial idxMaterial{};
167 idxMaterial.materialProperties = matProp;
168 idxMaterial.firstBin = ifir;
169 idxMaterial.secondBin = isec;
170 // fill into the material histogram
171 materialHistogram[zarhobin][x0bin].push_back(idxMaterial);
172 }
173 }
174 }
175 // merge the bins and ready
176 materialVector.push_back(nullptr);
177 // prepare the histogram
178 for (size_t izarho = 0; izarho < m_compressedMaterialZARhoBins; ++izarho) {
179 for (size_t ix0 = 0; ix0 < m_compressedMaterialX0Bins; ++ix0) {
180 // get the indexed material properties
181 std::vector< Trk::IndexedMaterial > indexedMaterial = materialHistogram[izarho][ix0];
182 if (!indexedMaterial.empty()) {
183 double avT = 0.; // thickness: by default on one layer it should be the same !
184 double tinX0 = 0.;
185 double tinL0 = 0.;
186 double avA = 0.;
187 double avZ = 0.;
188 double avRho = 0.;
189 std::vector< Trk::IndexedMaterial >::iterator idmIter = indexedMaterial.begin();
190 std::vector< Trk::IndexedMaterial >::iterator idmIterEnd = indexedMaterial.end();
191 for ( ; idmIter != idmIterEnd; ++idmIter ) {
192 tinX0 += (*idmIter).materialProperties->thicknessInX0();
193 tinL0 += (*idmIter).materialProperties->thicknessInL0();
194 avA += (*idmIter).materialProperties->averageA();
195 avZ += (*idmIter).materialProperties->averageZ();
196 avRho += (*idmIter).materialProperties->averageRho();
197 }
198 double measure = 1./(indexedMaterial.size());
199 // average it
200 tinX0 *= measure;
201 tinL0 *= measure;
202 avA *= measure;
203 avZ *= measure;
204 avRho *= measure;
205 avT *= measure;
206 // compress to a model thickness [ rho affected ]
208 materialVector.push_back(new Trk::MaterialProperties(m_compressedMaterialThickness,
211 avA,
212 avZ,
213 avRho));
214 // now set the index
215 int matindex = int(materialVector.size()-1);
216 idmIter = indexedMaterial.begin();
217 for ( ; idmIter != idmIterEnd; ++idmIter )
218 materialBins[(*idmIter).secondBin][(*idmIter).firstBin] = matindex;
219 }
220 }
221 }
222
223 // change the 2bin matrix to a 1bin vector (better for persistency)
224 std::vector<unsigned short int> materialBinsVector;
225 materialBinsVector.reserve( (lBinUtility.max(0)+1)*(lBinUtility.max(1)+1) );
226 std::vector< std::vector<unsigned short int> >::iterator binVecIter = materialBins.begin();
227 std::vector< std::vector<unsigned short int> >::iterator binVecIterEnd = materialBins.end();
228 for ( ; binVecIter != binVecIterEnd; ++binVecIter) {
229 std::vector<unsigned short int>::iterator binIter = (*binVecIter).begin();
230 std::vector<unsigned short int>::iterator binIterEnd = (*binVecIter).end();
231 for ( ; binIter != binIterEnd; ++binIter )
232 materialBinsVector.push_back(*binIter);
233 }
234
236
237 // create the compressed material
238 return new Trk::CompressedLayerMaterial(lBinUtility,materialVector,materialBinsVector);
239}
float thicknessInX0() const
Return the radiationlength fraction.
float zOverAtimesRho() const
Return the .
const Trk::MaterialProperties * materialProperties

◆ createLayerMaterial()

Trk::LayerMaterialProperties * Trk::CompressedLayerMaterialCreator::createLayerMaterial ( const LayerMaterialRecord & lmr) const
virtual

process the material properties

Implements Trk::ILayerMaterialCreator.

Definition at line 41 of file CompressedLayerMaterialCreator.cxx.

42{
43 // get the material matrix
44 const Trk::MaterialPropertiesMatrix& materialProperties = lmr.associatedLayerMaterial();
45 // get the bin utility
46 const Trk::BinUtility* lBinUtility = lmr.binUtility();
47 if (lBinUtility){
48 ATH_MSG_VERBOSE("Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
49 return createCompressedLayerMaterial(materialProperties,*lBinUtility);
50 }
51 // we can not do anything without a bin utility
52 ATH_MSG_DEBUG("No BinUtility provided - return 0");
53 return nullptr;
54}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ DeclareInterfaceID()

Trk::ILayerMaterialCreator::DeclareInterfaceID ( ILayerMaterialCreator ,
1 ,
0  )
inherited

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ layerMaterialName()

const std::string & Trk::ILayerMaterialCreator::layerMaterialName ( ) const
inlineinherited

the name of the created material map

Definition at line 47 of file ILayerMaterialCreator.h.

47 {
48 if (!m_layerMaterialFullName.isValid()) {
50 }
51 return *m_layerMaterialFullName.ptr();
52 }
CxxUtils::CachedValue< std::string > m_layerMaterialFullName

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_compressedMaterialThickness

double Trk::CompressedLayerMaterialCreator::m_compressedMaterialThickness
private

Definition at line 62 of file CompressedLayerMaterialCreator.h.

◆ m_compressedMaterialX0Bins

unsigned int Trk::CompressedLayerMaterialCreator::m_compressedMaterialX0Bins
private

Definition at line 63 of file CompressedLayerMaterialCreator.h.

◆ m_compressedMaterialZARhoBins

unsigned int Trk::CompressedLayerMaterialCreator::m_compressedMaterialZARhoBins
private

Definition at line 64 of file CompressedLayerMaterialCreator.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_layerMaterialDirectory

std::string Trk::ILayerMaterialCreator::m_layerMaterialDirectory
protectedinherited

Definition at line 56 of file ILayerMaterialCreator.h.

◆ m_layerMaterialFullName

CxxUtils::CachedValue<std::string> Trk::ILayerMaterialCreator::m_layerMaterialFullName
privateinherited

Definition at line 59 of file ILayerMaterialCreator.h.

◆ m_layerMaterialName

std::string Trk::ILayerMaterialCreator::m_layerMaterialName
protectedinherited

Definition at line 55 of file ILayerMaterialCreator.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: