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

LayerMaterialProperties creator for CompoundLayerMaterial (i.e. More...

#include <CompoundLayerMaterialCreator.h>

Inheritance diagram for Trk::CompoundLayerMaterialCreator:
Collaboration diagram for Trk::CompoundLayerMaterialCreator:

Public Member Functions

 CompoundLayerMaterialCreator (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

LayerMaterialPropertiescreateCompoundLayerMaterial (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< bool > m_fullCompoundCalculation {this, "FullCompoundCalculation", false}
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

LayerMaterialProperties creator for CompoundLayerMaterial (i.e.

a composit of materials)

The convertLayerMaterial() method converts into CompoundLayerMaterial (if possible).

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 42 of file CompoundLayerMaterialCreator.h.

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

◆ CompoundLayerMaterialCreator()

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

Constructor.

Definition at line 23 of file CompoundLayerMaterialCreator.cxx.

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

Member Function Documentation

◆ convertLayerMaterial()

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

create layer material properties from layer material properties - simply clones

Implements Trk::ILayerMaterialCreator.

Definition at line 49 of file CompoundLayerMaterialCreator.cxx.

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

◆ createCompoundLayerMaterial()

Trk::LayerMaterialProperties * Trk::CompoundLayerMaterialCreator::createCompoundLayerMaterial ( const MaterialPropertiesMatrix & lmm,
const BinUtility & lmbu ) const
private

private method that can be called by both create/convertLayerMaterial

Definition at line 93 of file CompoundLayerMaterialCreator.cxx.

94{
95
96
97 // analyse the material bins
98 double tMin = 10e10;
99 double xMin = 10e10;
100 double lMin = 10e10;
101 double aMin = 10e10;
102 double zMin = 10e10;
103 double rMin = 10e10;
104 double tMax = 0.;
105 double xMax = 0.;
106 double lMax = 0.;
107 double aMax = 0.;
108 double zMax = 0.;
109 double rMax = 0.;
110
111 // first loop to get the min/max values
112 for (const auto & mo : materialMatrix)
113 for (const auto & mi : mo) {
114 if (mi){
115 const Trk::MaterialProperties& mp = (*mi);
116 // macro defined in GeometryStatics
117 minMaxValue(tMin, tMax, mp.thickness());
118 minMaxValue(xMin, xMax, mp.x0());
119 minMaxValue(lMin, lMax, mp.l0());
120 minMaxValue(aMin, aMax, mp.averageA());
121 minMaxValue(zMin, zMax, mp.averageZ());
122 minMaxValue(rMin, rMax, mp.averageRho());
123 }
124 }
125
126 ATH_MSG_DEBUG( "Preparing the store: min/max values for t, x0, l0, a, z, rho estimated." );
127
128
129 // the bin matrices in the store
130 Trk::ValueMatrix binMatrix( lBinUtility.max(1)+1, Trk::ValueVector(lBinUtility.max(0)+1, static_cast<unsigned char>(0) ) );
131 // 255 bins, the 0 bin indicates empy
132 Trk::ValueStore tStore;
133 Trk::ValueStore xStore;
134 Trk::ValueStore lStore;
135 Trk::ValueStore aStore;
136 Trk::ValueStore zStore;
137 Trk::ValueStore rStore;
138 // set the store min, max
139 tStore.valueMin = tMin;
140 xStore.valueMin = xMin;
141 lStore.valueMin = lMin;
142 aStore.valueMin = aMin;
143 zStore.valueMin = zMin;
144 rStore.valueMin = rMin;
145 tStore.valueStep = fabs(tMin-tMax)<10e-8 ? 0. : (tMax-tMin)/double(static_cast<int>(UCHAR_MAX)-1);
146 xStore.valueStep = (xMax-xMin)/double(static_cast<int>(UCHAR_MAX)-1);
147 lStore.valueStep = (lMax-lMin)/double(static_cast<int>(UCHAR_MAX)-1);
148 aStore.valueStep = (aMax-aMin)/double(static_cast<int>(UCHAR_MAX)-1);
149 zStore.valueStep = (zMax-zMin)/double(static_cast<int>(UCHAR_MAX)-1);
150 rStore.valueStep = (rMax-rMin)/double(static_cast<int>(UCHAR_MAX)-1);
151
152 ATH_MSG_VERBOSE(" - t [ min/max/step ] = " << tMin << " / " << tMax << " / " << tStore.valueStep );
153 ATH_MSG_VERBOSE(" - x0 [ min/max/step ] = " << xMin << " / " << xMax << " / " << xStore.valueStep );
154 ATH_MSG_VERBOSE(" - l0 [ min/max/step ] = " << lMin << " / " << lMax << " / " << lStore.valueStep );
155 ATH_MSG_VERBOSE(" - a [ min/max/step ] = " << aMin << " / " << aMax << " / " << aStore.valueStep );
156 ATH_MSG_VERBOSE(" - z [ min/max/step ] = " << zMin << " / " << zMax << " / " << zStore.valueStep );
157 ATH_MSG_VERBOSE(" - rho [ min/max/step ] = " << rMin << " / " << rMax << " / " << rStore.valueStep );
158
159 // set the initally empty - thickness store can be empty
160 if (tStore.valueStep > 0.)
161 tStore.valueBinMatrix = binMatrix;
162 else
163 ATH_MSG_VERBOSE("Thickness has been estimated to be constant - matrix is not prepared.");
164 xStore.valueBinMatrix = binMatrix;
165 lStore.valueBinMatrix = binMatrix;
166 aStore.valueBinMatrix = binMatrix;
167 zStore.valueBinMatrix = binMatrix;
168 rStore.valueBinMatrix = binMatrix;
169
170 ATH_MSG_VERBOSE( "Material stores prepared, now preparing composition matrix." );
171
172 // the compound material
173 std::vector< std::vector< Trk::MaterialComposition > > compositionMatrix( lBinUtility.max(1)+1, std::vector< Trk::MaterialComposition >( lBinUtility.max(0)+1, Trk::MaterialComposition()) );
174
175 ATH_MSG_VERBOSE( "Composition matrix created." );
176
177 // second loop : assign the bins & and copy the material composition
178 size_t obin = 0;
179 for (const auto & mo : materialMatrix){
180 size_t ibin =0;
181 for (const auto & mi : mo) {
182 if (mi){
183 const Trk::MaterialProperties& mp = (*mi);
184 if (tStore.valueStep > 0.) tStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.thickness()/tStore.valueStep)+1);
185 xStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.x0()/xStore.valueStep)+1);
186 lStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.l0()/lStore.valueStep)+1);
187 aStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.averageA()/aStore.valueStep)+1);
188 zStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.averageZ()/zStore.valueStep)+1);
189 rStore.valueBinMatrix[obin][ibin] = static_cast<unsigned char>(std::lrint(mp.averageRho()/rStore.valueStep)+1);
190 // set the material composition
191 if (mp.material().composition) {
192 compositionMatrix[obin][ibin] = Trk::MaterialComposition(*(mp.material().composition));
193 ATH_MSG_VERBOSE(" - composition is copied.");
194 }
195 }
196 ++ibin;
197 }
198 ++obin;
199 }
200 ATH_MSG_VERBOSE( "Returning the new compound material." );
201
202 // now create the compound material propertis
203 return new Trk::CompoundLayerMaterial(lBinUtility, tStore, xStore, lStore, aStore, zStore, rStore, compositionMatrix, m_fullCompoundCalculation);
204
205}
#define minMaxValue(currentMin, currentMax, test)
float averageRho() const
Return the average density of the material.
float averageA() const
Return the average A of the material [gram/mole].
float averageZ() const
Returns the average Z of the material.
const Material & material() const
Return the stored Material.
float l0() const
Return the nuclear interaction length.
float x0() const
Return the radiation length.
float thickness() const
Return the thickness in mm.
MaterialComposition * composition
Definition Material.h:127
std::vector< ValueVector > ValueMatrix
std::vector< unsigned char > ValueVector

◆ createLayerMaterial()

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

process the material properties

Implements Trk::ILayerMaterialCreator.

Definition at line 33 of file CompoundLayerMaterialCreator.cxx.

34{
35 // get the material matrix
36 const Trk::MaterialPropertiesMatrix& materialMatrix = lmr.associatedLayerMaterial();
37 // get the bin untility
38 const Trk::BinUtility* binUtility = lmr.binUtility();
39 // if there's no bin utility - bail out
40 if (!binUtility){
41 ATH_MSG_WARNING( "No BinUtility given - Bailing out." );
42 return nullptr;
43 } else
44 ATH_MSG_DEBUG( "BinUtility provided, creating binned array in dimensions " << binUtility->max(0)+1 << " x " << binUtility->max(1)+1 );
45 // return the created compound material
46 return createCompoundLayerMaterial(materialMatrix,*binUtility);
47}
#define ATH_MSG_WARNING(x)

◆ 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_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_fullCompoundCalculation

Gaudi::Property<bool> Trk::CompoundLayerMaterialCreator::m_fullCompoundCalculation {this, "FullCompoundCalculation", false}
private

Definition at line 58 of file CompoundLayerMaterialCreator.h.

58{this, "FullCompoundCalculation", false};

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