ATLAS Offline Software
Loading...
Searching...
No Matches
InDetMaterialManager.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef INDETMATERIALMANAGER_H
6#define INDETMATERIALMANAGER_H
7
10#include "GeoModelKernel/GeoIntrusivePtr.h"
11#include "GeoModelKernel/GeoMaterial.h"
12
13#include <string>
14#include <map>
15
16class GeoElement;
18class StoreGateSvc;
19
20namespace InDetDD
21{
22 class AthenaComps;
23}
24
30
31
33{
34
35public:
36
37 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore);
38 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
39 const IRDBRecordset_ptr& weightTable,
40 const std::string & space = "",
41 bool extraFunctionality = false);
42 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
43 const IRDBRecordset_ptr& weightTable,
44 const IRDBRecordset_ptr& compositionTable,
45 const std::string & space = "");
46 InDetMaterialManager(const std::string & managerName,
49
50 void addWeightTable(const IRDBRecordset_ptr& weightTable, const std::string & space = "");
51 void addWeightMaterial(const std::string& materialName, const std::string& materialBase, double weight, int linearWeightFlag);
52 void addCompositionTable(const IRDBRecordset_ptr& compositionTable, const std::string & space = "");
53 void addScalingTable(const IRDBRecordset_ptr& scalingTable);
54
55
56 bool hasMaterial(const std::string &materialName) const;
57
59 const GeoMaterial* getMaterial(const std::string & materialName);
60
62 const GeoElement* getElement(const std::string & elementName);
63
71 const GeoMaterial* getMaterial(const std::string & origMaterialName,
72 double density,
73 const std::string & newName = "");
74
75 // Creates a new material based on origMaterialName but with denisty scaled
76 // by scaleFactor. If no newName then will add the string containing the scale
77 // factor. Eg if scale 12.345678 "Silicon" -> "Silicon12_3456"
78 // If the scale factor is 1 and there is no newName then it just returns the
79 // original material.
80 // scaleFactor must be between 0.001 and 1000.
81 const GeoMaterial* getMaterialScaled(const std::string & origMaterialName,
82 double scaleFactor,
83 const std::string & newName = "");
84
86 const GeoMaterial * getMaterialForVolume(const std::string & materialName,
87 double volume,
88 const std::string & newName = "");
89
90 // Similar to getMaterialForVolume but if weight table uses linear weight, then determine weight
91 // using length. First looks in special table of material compositions which can specify several
92 // components and their count.
93 const GeoMaterial * getMaterialForVolumeLength(const std::string & materialName,
94 double volume,
95 double length,
96 const std::string & newName = "");
97
98 // As above but rather than using the special table of material compositions, the compositions is specified
99 // in the arguments as a vector of materials and multiplictive factors.
100 const GeoMaterial * getMaterialForVolumeLength(const std::string & name,
101 const std::vector<std::string> & materialComponents,
102 const std::vector<double>& factors,
103 double volume,
104 double length);
105
106 // As above but only one material making up the composition.
107 const GeoMaterial * getMaterialForVolumeLength(const std::string & name,
108 const std::string & materialComponent,
109 double factor,
110 double volume,
111 double length);
112
113 // Define composite material : function used to create dynamically a new composite material by adding
114 // a defined volume of glue/grease to an already existing material (IBL stave)
115 const GeoMaterial * getCompositeMaterialForVolume(const std::string & newMatName,
116 const double volumeTot,
117 const double volume1, const std::string & matName1,
118 const double volume2, const std::string & matName2
119 );
120
121 // Define a new material composition.
122 const GeoMaterial * getMaterial(const std::string & name,
123 const std::vector<std::string> & materialComponents,
124 const std::vector<double> & fractWeights,
125 double density);
126
127
129 void addMaterial(GeoMaterial *material);
130
131
132private:
133
135 public:
137 MaterialByWeight(const std::string & name_in, double weight_in, bool linearWeightFlag_in)
138 : name(name_in), weight(weight_in), linearWeightFlag(linearWeightFlag_in) {}
139 MaterialByWeight(double weight_in)
140 : weight(weight_in), linearWeightFlag(false) {}
141 std::string name;
142 double weight;
144 };
145
147 public:
149 MaterialComponent(const std::string & name_in, double factor_in = 1, bool actualLength_in = -1)
150 : name(name_in), factor(factor_in), actualLength(actualLength_in) {}
151 std::string name;
152 double factor;
154 };
155
158 public:
159 MaterialDef();
160 MaterialDef(const std::string & name, double density);
161 void addComponent(const std::string & compName, double fraction);
162 void setCreated() {m_created = true;}
163 unsigned int numComponents() const {return m_components.size();}
164 bool isCreated() const {return m_created;}
165 const std::string & name() const {return m_name;}
166 double density() const {return m_density;}
167 const std::string & compName(unsigned int i) const {return m_components[i];}
168 double fraction(unsigned int i) const {return m_fractions[i];}
169 double totalFraction() const;
170
171 private:
172 std::string m_name;
173 double m_density;
174 std::vector<std::string> m_components;
175 std::vector<double> m_fractions;
177 };
178
179
181 const GeoMaterial* getAdditionalMaterial(const std::string & materialName) const;
182 bool compareDensity(double d1, double d2) const;
183
184 // Internal versions. The public versions allow materials to be have extra scaling.
185 const GeoMaterial* getMaterialInternal(const std::string & materialName);
186 const GeoMaterial* getMaterialInternal(const std::string & origMaterialName,
187 double density,
188 const std::string & newName = "");
189 const GeoMaterial* getMaterialScaledInternal(const std::string & origMaterialName,
190 double scaleFactor,
191 const std::string & newName = "");
192 const GeoMaterial * getMaterialInternal(const std::string & name,
193 const std::vector<std::string> & materialComponents,
194 const std::vector<double> & fractWeights,
195 double density);
196
197 // Methods to return material with extra scaling.
198 const GeoMaterial * extraScaledMaterial(const std::string & materialName,
199 const std::string & newName,
200 const GeoMaterial * origMaterial);
201
202 const GeoMaterial * extraScaledMaterial(const std::string & materialName,
203 const GeoMaterial * origMaterial);
204
205 void createMaterial(const MaterialDef & material);
206 double getExtraScaleFactor(const std::string & materialName);
207
209 std::string m_managerName;
210
211 using MaterialStore = std::map<std::string, GeoIntrusivePtr<const GeoMaterial>>;
213
214 typedef std::map<std::string, MaterialByWeight > MaterialWeightMap;
216
217 typedef std::map<std::string, MaterialComponent > MaterialCompositionMap;
219
220 typedef std::map<std::string, double > ExtraScaleFactorMap;
222
223 // Has linear weight flag.
225
226};
227
228
229#endif // INDETMATERIALMANAGER_H
double length(const pvec &v)
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Class to hold various Athena components.
MaterialByWeight(const std::string &name_in, double weight_in, bool linearWeightFlag_in)
MaterialComponent(const std::string &name_in, double factor_in=1, bool actualLength_in=-1)
Class to hold information need to create a material.
void addComponent(const std::string &compName, double fraction)
const std::string & compName(unsigned int i) const
std::vector< std::string > m_components
double fraction(unsigned int i) const
std::map< std::string, double > ExtraScaleFactorMap
ExtraScaleFactorMap m_scalingMap
const GeoElement * getElement(const std::string &elementName)
Get element from GeoModel material manager.
MaterialWeightMap m_weightMap
bool compareDensity(double d1, double d2) const
const GeoMaterial * getMaterialInternal(const std::string &materialName)
void addMaterial(GeoMaterial *material)
Add material.
void createMaterial(const MaterialDef &material)
double getExtraScaleFactor(const std::string &materialName)
MaterialCompositionMap m_matCompositionMap
const GeoMaterial * getMaterialScaledInternal(const std::string &origMaterialName, double scaleFactor, const std::string &newName="")
void addCompositionTable(const IRDBRecordset_ptr &compositionTable, const std::string &space="")
const GeoMaterial * extraScaledMaterial(const std::string &materialName, const std::string &newName, const GeoMaterial *origMaterial)
const GeoMaterial * getMaterialForVolume(const std::string &materialName, double volume, const std::string &newName="")
Create and get material with a density calculated to give weight in predefined weight table.
const GeoMaterial * getCompositeMaterialForVolume(const std::string &newMatName, const double volumeTot, const double volume1, const std::string &matName1, const double volume2, const std::string &matName2)
const GeoMaterial * getAdditionalMaterial(const std::string &materialName) const
StoredMaterialManager * retrieveManager(const StoreGateSvc *detStore)
const GeoMaterial * getMaterialScaled(const std::string &origMaterialName, double scaleFactor, const std::string &newName="")
void addScalingTable(const IRDBRecordset_ptr &scalingTable)
std::map< std::string, MaterialByWeight > MaterialWeightMap
void addWeightTable(const IRDBRecordset_ptr &weightTable, const std::string &space="")
const GeoMaterial * getMaterial(const std::string &materialName)
Get material. First looks for locally defined material and if not found looks in GeoModel material ma...
StoredMaterialManager * m_materialManager
void addWeightMaterial(const std::string &materialName, const std::string &materialBase, double weight, int linearWeightFlag)
bool hasMaterial(const std::string &materialName) const
InDetMaterialManager(const std::string &managerName, StoreGateSvc *detStore)
const GeoMaterial * getMaterialForVolumeLength(const std::string &materialName, double volume, double length, const std::string &newName="")
std::map< std::string, GeoIntrusivePtr< const GeoMaterial > > MaterialStore
std::map< std::string, MaterialComponent > MaterialCompositionMap
The Athena Transient Store API.
This class holds one or more material managers and makes them storeable, under StoreGate.
Message Stream Member.