ATLAS Offline Software
InDetMaterialManager.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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 class GeoElement;
15 class StoreGateSvc;
16 class IGeometryDBSvc;
17 
18 namespace InDetDD
19 {
20  class AthenaComps;
21 }
22 
23 #include <string>
24 #include <map>
25 
31 
32 
34 {
35 
36 public:
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 
133 private:
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;
154  double actualLength;
155  };
156 
158  class MaterialDef {
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;
177  bool m_created;
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();
208  void addTextFileMaterials();
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
InDetMaterialManager::addMaterial
void addMaterial(GeoMaterial *material)
Add material.
Definition: InDetMaterialManager.cxx:299
InDetMaterialManager::addWeightTable
void addWeightTable(const IRDBRecordset_ptr &weightTable, const std::string &space="")
Definition: InDetMaterialManager.cxx:321
InDetMaterialManager::MaterialDef::fraction
double fraction(unsigned int i) const
Definition: InDetMaterialManager.h:169
InDetMaterialManager::m_athenaComps
const InDetDD::AthenaComps * m_athenaComps
Definition: InDetMaterialManager.h:230
InDetMaterialManager::getAdditionalMaterial
const GeoMaterial * getAdditionalMaterial(const std::string &materialName) const
Definition: InDetMaterialManager.cxx:124
InDetMaterialManager::m_materialManager
StoredMaterialManager * m_materialManager
Definition: InDetMaterialManager.h:212
InDetMaterialManager::MaterialDef::m_name
std::string m_name
Definition: InDetMaterialManager.h:173
InDetMaterialManager::MaterialByWeight::linearWeightFlag
bool linearWeightFlag
Definition: InDetMaterialManager.h:144
InDetDD::AthenaComps
Class to hold various Athena components.
Definition: InDetDDAthenaComps.h:21
InDetMaterialManager::MaterialDef::compName
const std::string & compName(unsigned int i) const
Definition: InDetMaterialManager.h:168
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
InDetMaterialManager::getMaterialScaledInternal
const GeoMaterial * getMaterialScaledInternal(const std::string &origMaterialName, double scaleFactor, const std::string &newName="")
Definition: InDetMaterialManager.cxx:261
InDetMaterialManager::MaterialCompositionMap
std::map< std::string, MaterialComponent > MaterialCompositionMap
Definition: InDetMaterialManager.h:221
InDetMaterialManager::MaterialComponent::MaterialComponent
MaterialComponent()
Definition: InDetMaterialManager.h:149
InDetMaterialManager::MaterialDef::numComponents
unsigned int numComponents() const
Definition: InDetMaterialManager.h:164
InDetMaterialManager::m_matCompositionMap
MaterialCompositionMap m_matCompositionMap
Definition: InDetMaterialManager.h:222
InDetMaterialManager::MaterialStore
std::map< std::string, GeoIntrusivePtr< const GeoMaterial > > MaterialStore
Definition: InDetMaterialManager.h:215
InDetMaterialManager::getMaterialInternal
const GeoMaterial * getMaterialInternal(const std::string &materialName)
Definition: InDetMaterialManager.cxx:106
InDetMaterialManager::MaterialByWeight::name
std::string name
Definition: InDetMaterialManager.h:142
InDetMaterialManager::MaterialDef::density
double density() const
Definition: InDetMaterialManager.h:167
InDetMaterialManager::addTextFileMaterials
void addTextFileMaterials()
Definition: InDetMaterialManager.cxx:764
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
InDetMaterialManager::MaterialByWeight
Definition: InDetMaterialManager.h:135
InDetMaterialManager::~InDetMaterialManager
~InDetMaterialManager()
InDetMaterialManager::MaterialDef::totalFraction
double totalFraction() const
Definition: InDetMaterialManager.cxx:933
InDetMaterialManager::m_store
MaterialStore m_store
Definition: InDetMaterialManager.h:216
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
InDetMaterialManager::MaterialDef::name
const std::string & name() const
Definition: InDetMaterialManager.h:166
InDetMaterialManager::MaterialDef::addComponent
void addComponent(const std::string &compName, double fraction)
Definition: InDetMaterialManager.cxx:927
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDetMaterialManager::MaterialComponent
Definition: InDetMaterialManager.h:147
InDetMaterialManager::addWeightTableOld
void addWeightTableOld(const IRDBRecordset_ptr &weightTable, const std::string &space)
Definition: InDetMaterialManager.cxx:378
InDetMaterialManager::MaterialDef::m_fractions
std::vector< double > m_fractions
Definition: InDetMaterialManager.h:176
InDetMaterialManager::addCompositionTable
void addCompositionTable(const IRDBRecordset_ptr &compositionTable, const std::string &space="")
Definition: InDetMaterialManager.cxx:406
InDetMaterialManager::createMaterial
void createMaterial(const MaterialDef &material)
Definition: InDetMaterialManager.cxx:845
InDetMaterialManager::m_scalingMap
ExtraScaleFactorMap m_scalingMap
Definition: InDetMaterialManager.h:225
InDetMaterialManager::getMaterialForVolume
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.
Definition: InDetMaterialManager.cxx:460
IGeometryDBSvc
Definition: IGeometryDBSvc.h:21
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
InDetMaterialManager::m_extraFunctionality
bool m_extraFunctionality
Definition: InDetMaterialManager.h:228
InDetMaterialManager::getMaterialForVolumeLength
const GeoMaterial * getMaterialForVolumeLength(const std::string &materialName, double volume, double length, const std::string &newName="")
Definition: InDetMaterialManager.cxx:514
InDetMaterialManager::MaterialDef
Class to hold information need to create a material.
Definition: InDetMaterialManager.h:158
InDetMaterialManager::extraScaledMaterial
const GeoMaterial * extraScaledMaterial(const std::string &materialName, const std::string &newName, const GeoMaterial *origMaterial)
Definition: InDetMaterialManager.cxx:950
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
InDetMaterialManager::ExtraScaleFactorMap
std::map< std::string, double > ExtraScaleFactorMap
Definition: InDetMaterialManager.h:224
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
InDetMaterialManager
InDetMaterialManager.
Definition: InDetMaterialManager.h:34
InDetMaterialManager::getElement
const GeoElement * getElement(const std::string &elementName)
Get element from GeoModel material manager.
Definition: InDetMaterialManager.cxx:86
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MakeNewFileFromOldAndSubstitution.newName
dictionary newName
Definition: ICHEP2016/MakeNewFileFromOldAndSubstitution.py:95
InDetMaterialManager::MaterialDef::m_components
std::vector< std::string > m_components
Definition: InDetMaterialManager.h:175
InDetMaterialManager::m_managerName
std::string m_managerName
Definition: InDetMaterialManager.h:213
InDetMaterialManager::addWeightMaterial
void addWeightMaterial(const std::string &materialName, const std::string &materialBase, double weight, int linearWeightFlag)
Definition: InDetMaterialManager.cxx:361
InDetMaterialManager::addScalingTable
void addScalingTable(const IRDBRecordset_ptr &scalingTable)
Definition: InDetMaterialManager.cxx:431
InDetMaterialManager::InDetMaterialManager
InDetMaterialManager(const std::string &managerName, StoreGateSvc *detStore)
Definition: InDetMaterialManager.cxx:24
InDetMaterialManager::retrieveManager
StoredMaterialManager * retrieveManager(const StoreGateSvc *detStore)
Definition: InDetMaterialManager.cxx:81
InDetMaterialManager::MaterialDef::MaterialDef
MaterialDef()
Definition: InDetMaterialManager.cxx:915
InDetMaterialManager::getMaterialScaled
const GeoMaterial * getMaterialScaled(const std::string &origMaterialName, double scaleFactor, const std::string &newName="")
Definition: InDetMaterialManager.cxx:253
InDetMaterialManager::MaterialComponent::factor
double factor
Definition: InDetMaterialManager.h:153
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetMaterialManager::db
const IGeometryDBSvc * db()
Definition: InDetMaterialManager.cxx:757
InDetMaterialManager::MaterialDef::isCreated
bool isCreated() const
Definition: InDetMaterialManager.h:165
InDetMaterialManager::MaterialDef::m_created
bool m_created
Definition: InDetMaterialManager.h:177
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81
InDetMaterialManager::getExtraScaleFactor
double getExtraScaleFactor(const std::string &materialName)
Definition: InDetMaterialManager.cxx:992
AthMessaging.h
InDetMaterialManager::MaterialByWeight::MaterialByWeight
MaterialByWeight()
Definition: InDetMaterialManager.h:137
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
InDetMaterialManager::MaterialByWeight::MaterialByWeight
MaterialByWeight(double weight_in)
Definition: InDetMaterialManager.h:140
InDetMaterialManager::m_weightMap
MaterialWeightMap m_weightMap
Definition: InDetMaterialManager.h:219
InDetMaterialManager::MaterialByWeight::MaterialByWeight
MaterialByWeight(const std::string &name_in, double weight_in, bool linearWeightFlag_in)
Definition: InDetMaterialManager.h:138
InDetMaterialManager::compareDensity
bool compareDensity(double d1, double d2) const
Definition: InDetMaterialManager.cxx:316
InDetMaterialManager::MaterialDef::setCreated
void setCreated()
Definition: InDetMaterialManager.h:163
InDetMaterialManager::getCompositeMaterialForVolume
const GeoMaterial * getCompositeMaterialForVolume(const std::string &newMatName, const double volumeTot, const double volume1, const std::string &matName1, const double volume2, const std::string &matName2)
Definition: InDetMaterialManager.cxx:134
InDetMaterialManager::getMaterial
const GeoMaterial * getMaterial(const std::string &materialName)
Get material. First looks for locally defined material and if not found looks in GeoModel material ma...
Definition: InDetMaterialManager.cxx:96
InDetMaterialManager::MaterialByWeight::weight
double weight
Definition: InDetMaterialManager.h:143
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
InDetMaterialManager::MaterialComponent::MaterialComponent
MaterialComponent(const std::string &name_in, double factor_in=1, bool actualLength_in=-1)
Definition: InDetMaterialManager.h:150
InDetMaterialManager::MaterialWeightMap
std::map< std::string, MaterialByWeight > MaterialWeightMap
Definition: InDetMaterialManager.h:218
InDetMaterialManager::MaterialComponent::name
std::string name
Definition: InDetMaterialManager.h:152
InDetMaterialManager::hasMaterial
bool hasMaterial(const std::string &materialName) const
Definition: InDetMaterialManager.cxx:101
InDetMaterialManager::MaterialDef::m_density
double m_density
Definition: InDetMaterialManager.h:174
InDetMaterialManager::MaterialComponent::actualLength
double actualLength
Definition: InDetMaterialManager.h:154