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.
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

Gaudi::Property< double > m_compressedMaterialThickness {this, "MaterialThickness", 1.}
Gaudi::Property< unsigned int > m_compressedMaterialX0Bins {this, "MaterialBinsX0", 256}
Gaudi::Property< unsigned int > m_compressedMaterialZARhoBins {this, "MaterialBinsZARho", 256}
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)
21{
22 declareInterface<Trk::ILayerMaterialCreator>(this);
23
24 // give the map a name
25 declareProperty("LayerMaterialName" , m_layerMaterialName);
26 declareProperty("LayerMaterialDirectory" , m_layerMaterialDirectory);
27}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

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 44 of file CompressedLayerMaterialCreator.cxx.

45{
46 // the return object
47 Trk::LayerMaterialProperties* bLayerMaterial = nullptr;
48 // get the binUtility of the LayerMaterialProperties
49 const Trk::BinUtility* bUtility = lmProperties.binUtility();
50 // we have a bin utility, get the matrix and fill it
51 if (bUtility){
52 // prepare the matrix
53 // nF x nS
54 size_t nBins0 = bUtility->max(0)+1;
55 size_t nBins1 = bUtility->max(1)+1;
56 // create the MaterialMatrix
57 Trk::MaterialPropertiesMatrix materialMatrix;
58 materialMatrix.reserve(nBins1);
59 // fill the matrix
60 for (size_t ibin1 = 0; ibin1 < nBins1; ++ibin1) {
61 // create the vector first
62 Trk::MaterialPropertiesVector materialVector;
63 materialVector.reserve(nBins0);
64 // loop over local 1 bins
65 for (size_t ibin0 = 0; ibin0 < nBins0; ++ibin0) {
66 // get the material from the properties and push them into the matrix (no cloning !)
67 const Trk::MaterialProperties* mProperties = lmProperties.material(ibin0,ibin1);
68 materialVector.push_back(mProperties);
69 }
70 // now pus the vector into the matrix
71 materialMatrix.push_back(materialVector);
72 }
73
74 // create the material
75 ATH_MSG_VERBOSE("Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
76 bLayerMaterial = createCompressedLayerMaterial(materialMatrix,*bUtility);
77
78 } else {
79 // must be homogenous material, can be transformed into a 0-bin material, would be silly though
80 ATH_MSG_DEBUG("No BinUtility provided - return a simple clone.");
81 bLayerMaterial = lmProperties.clone();
82 }
83 //
84 return bLayerMaterial;
85}
#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 87 of file CompressedLayerMaterialCreator.cxx.

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

30{
31 // get the material matrix
32 const Trk::MaterialPropertiesMatrix& materialProperties = lmr.associatedLayerMaterial();
33 // get the bin utility
34 const Trk::BinUtility* lBinUtility = lmr.binUtility();
35 if (lBinUtility){
36 ATH_MSG_VERBOSE("Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
37 return createCompressedLayerMaterial(materialProperties,*lBinUtility);
38 }
39 // we can not do anything without a bin utility
40 ATH_MSG_DEBUG("No BinUtility provided - return 0");
41 return nullptr;
42}

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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

Gaudi::Property<double> Trk::CompressedLayerMaterialCreator::m_compressedMaterialThickness {this, "MaterialThickness", 1.}
private

Definition at line 60 of file CompressedLayerMaterialCreator.h.

61{this, "MaterialThickness", 1.};

◆ m_compressedMaterialX0Bins

Gaudi::Property<unsigned int> Trk::CompressedLayerMaterialCreator::m_compressedMaterialX0Bins {this, "MaterialBinsX0", 256}
private

Definition at line 62 of file CompressedLayerMaterialCreator.h.

63{this, "MaterialBinsX0", 256};

◆ m_compressedMaterialZARhoBins

Gaudi::Property<unsigned int> Trk::CompressedLayerMaterialCreator::m_compressedMaterialZARhoBins {this, "MaterialBinsZARho", 256}
private

Definition at line 64 of file CompressedLayerMaterialCreator.h.

65{this, "MaterialBinsZARho", 256};

◆ 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: