ATLAS Offline Software
Loading...
Searching...
No Matches
InDetMaterialManager.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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;
19class IGeometryDBSvc;
20
21namespace InDetDD
22{
23 class AthenaComps;
24}
25
31
32
34{
35
36public:
37
38 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore);
39 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
40 const IRDBRecordset_ptr& weightTable,
41 const std::string & space = "",
42 bool extraFunctionality = false);
43 InDetMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
44 const IRDBRecordset_ptr& weightTable,
45 const IRDBRecordset_ptr& compositionTable,
46 const std::string & space = "");
47 InDetMaterialManager(const std::string & managerName,
50
51 void addWeightTable(const IRDBRecordset_ptr& weightTable, const std::string & space = "");
52 void addWeightMaterial(const std::string& materialName, const std::string& materialBase, double weight, int linearWeightFlag);
53 void addCompositionTable(const IRDBRecordset_ptr& compositionTable, const std::string & space = "");
54 void addScalingTable(const IRDBRecordset_ptr& scalingTable);
55
56
57 bool hasMaterial(const std::string &materialName) const;
58
60 const GeoMaterial* getMaterial(const std::string & materialName);
61
63 const GeoElement* getElement(const std::string & elementName);
64
72 const GeoMaterial* getMaterial(const std::string & origMaterialName,
73 double density,
74 const std::string & newName = "");
75
76 // Creates a new material based on origMaterialName but with denisty scaled
77 // by scaleFactor. If no newName then will add the string containing the scale
78 // factor. Eg if scale 12.345678 "Silicon" -> "Silicon12_3456"
79 // If the scale factor is 1 and there is no newName then it just returns the
80 // original material.
81 // scaleFactor must be between 0.001 and 1000.
82 const GeoMaterial* getMaterialScaled(const std::string & origMaterialName,
83 double scaleFactor,
84 const std::string & newName = "");
85
87 const GeoMaterial * getMaterialForVolume(const std::string & materialName,
88 double volume,
89 const std::string & newName = "");
90
91 // Similar to getMaterialForVolume but if weight table uses linear weight, then determine weight
92 // using length. First looks in special table of material compositions which can specify several
93 // components and their count.
94 const GeoMaterial * getMaterialForVolumeLength(const std::string & materialName,
95 double volume,
96 double length,
97 const std::string & newName = "");
98
99 // As above but rather than using the special table of material compositions, the compositions is specified
100 // in the arguments as a vector of materials and multiplictive factors.
101 const GeoMaterial * getMaterialForVolumeLength(const std::string & name,
102 const std::vector<std::string> & materialComponents,
103 const std::vector<double>& factors,
104 double volume,
105 double length);
106
107 // As above but only one material making up the composition.
108 const GeoMaterial * getMaterialForVolumeLength(const std::string & name,
109 const std::string & materialComponent,
110 double factor,
111 double volume,
112 double length);
113
114 // Define composite material : function used to create dynamically a new composite material by adding
115 // a defined volume of glue/grease to an already existing material (IBL stave)
116 const GeoMaterial * getCompositeMaterialForVolume(const std::string & newMatName,
117 const double volumeTot,
118 const double volume1, const std::string & matName1,
119 const double volume2, const std::string & matName2
120 );
121
122 // Define a new material composition.
123 const GeoMaterial * getMaterial(const std::string & name,
124 const std::vector<std::string> & materialComponents,
125 const std::vector<double> & fractWeights,
126 double density);
127
128
130 void addMaterial(GeoMaterial *material);
131
132
133private:
134
136 public:
138 MaterialByWeight(const std::string & name_in, double weight_in, bool linearWeightFlag_in)
139 : name(name_in), weight(weight_in), linearWeightFlag(linearWeightFlag_in) {}
140 MaterialByWeight(double weight_in)
141 : weight(weight_in), linearWeightFlag(false) {}
142 std::string name;
143 double weight;
145 };
146
148 public:
150 MaterialComponent(const std::string & name_in, double factor_in = 1, bool actualLength_in = -1)
151 : name(name_in), factor(factor_in), actualLength(actualLength_in) {}
152 std::string name;
153 double factor;
155 };
156
159 public:
160 MaterialDef();
161 MaterialDef(const std::string & name, double density);
162 void addComponent(const std::string & compName, double fraction);
163 void setCreated() {m_created = true;}
164 unsigned int numComponents() const {return m_components.size();}
165 bool isCreated() const {return m_created;}
166 const std::string & name() const {return m_name;}
167 double density() const {return m_density;}
168 const std::string & compName(unsigned int i) const {return m_components[i];}
169 double fraction(unsigned int i) const {return m_fractions[i];}
170 double totalFraction() const;
171
172 private:
173 std::string m_name;
174 double m_density;
175 std::vector<std::string> m_components;
176 std::vector<double> m_fractions;
178 };
179
180
182 const GeoMaterial* getAdditionalMaterial(const std::string & materialName) const;
183 bool compareDensity(double d1, double d2) const;
184 void addWeightTableOld(const IRDBRecordset_ptr& weightTable, const std::string & space);
185
186 // Internal versions. The public versions allow materials to be have extra scaling.
187 const GeoMaterial* getMaterialInternal(const std::string & materialName);
188 const GeoMaterial* getMaterialInternal(const std::string & origMaterialName,
189 double density,
190 const std::string & newName = "");
191 const GeoMaterial* getMaterialScaledInternal(const std::string & origMaterialName,
192 double scaleFactor,
193 const std::string & newName = "");
194 const GeoMaterial * getMaterialInternal(const std::string & name,
195 const std::vector<std::string> & materialComponents,
196 const std::vector<double> & fractWeights,
197 double density);
198
199 // Methods to return material with extra scaling.
200 const GeoMaterial * extraScaledMaterial(const std::string & materialName,
201 const std::string & newName,
202 const GeoMaterial * origMaterial);
203
204 const GeoMaterial * extraScaledMaterial(const std::string & materialName,
205 const GeoMaterial * origMaterial);
206
207 const IGeometryDBSvc * db();
209 void createMaterial(const MaterialDef & material);
210 double getExtraScaleFactor(const std::string & materialName);
211
213 std::string m_managerName;
214
215 using MaterialStore = std::map<std::string, GeoIntrusivePtr<const GeoMaterial>>;
217
218 typedef std::map<std::string, MaterialByWeight > MaterialWeightMap;
220
221 typedef std::map<std::string, MaterialComponent > MaterialCompositionMap;
223
224 typedef std::map<std::string, double > ExtraScaleFactorMap;
226
227 // Has linear weight flag.
229
231
232};
233
234
235#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.
Interface class to access geometry database with possibility to override parameters from a text file.
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
const IGeometryDBSvc * db()
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 addWeightTableOld(const IRDBRecordset_ptr &weightTable, const std::string &space)
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
const InDetDD::AthenaComps * m_athenaComps
The Athena Transient Store API.
This class holds one or more material managers and makes them storeable, under StoreGate.
Message Stream Member.