ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4tgbMaterialMixtureByVolume.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4tgbMaterialMixtureByVolume.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
//
28
//
29
// class G4tgbMaterialMixtureByVolume
30
31
// History:
32
// - Created. P.Arce, CIEMAT (November 2007)
33
// -------------------------------------------------------------------------
34
35
#include "
G4tgbMaterialMixtureByVolume.hh
"
36
37
#include "
G4SystemOfUnits.hh
"
38
#include "
G4tgbMaterial.hh
"
39
#include "
G4tgbMaterialMgr.hh
"
40
#include "
G4tgrMessenger.hh
"
41
42
// -------------------------------------------------------------------------
43
G4tgbMaterialMixtureByVolume::G4tgbMaterialMixtureByVolume
()
44
{
45
}
46
47
48
// -------------------------------------------------------------------------
49
G4tgbMaterialMixtureByVolume::~G4tgbMaterialMixtureByVolume
()
50
{
51
}
52
53
54
// -------------------------------------------------------------------------
55
G4tgbMaterialMixtureByVolume::G4tgbMaterialMixtureByVolume
(
G4tgrMaterial
* hg )
56
{
57
theTgrMate
= hg;
58
}
59
60
61
// -------------------------------------------------------------------------
62
G4Material
*
G4tgbMaterialMixtureByVolume::BuildG4Material
()
63
{
64
65
//----- construct new G4Material with components materials (a mixture)
66
G4Material
* mate =
new
G4Material
(
theTgrMate
->
GetName
(),
67
theTgrMate
->
GetDensity
(),
68
theTgrMate
->
GetNumberOfComponents
(),
69
theTgrMate
->
GetState
(),
70
theTgrMate
->
GetTemperature
(),
71
theTgrMate
->
GetPressure
() );
72
#ifdef G4VERBOSE
73
if
(
G4tgrMessenger::GetVerboseLevel
() >= 2 )
74
{
75
G4cout
<<
" G4tgbMaterialMixtureByVolume::buildG4Material() -"
76
<<
" Constructing new G4Material:"
77
<<
" "
<<
theTgrMate
->
GetName
()
78
<<
" "
<<
theTgrMate
->
GetDensity
()/
g
*
cm3
79
<<
" "
<<
theTgrMate
->
GetNumberOfComponents
()
80
<<
" "
<<
theTgrMate
->
GetState
()
81
<<
" "
<<
theTgrMate
->
GetTemperature
()
82
<<
" "
<<
theTgrMate
->
GetPressure
() <<
G4endl
;
83
}
84
#endif
85
86
//----- Transform fractions by volume to fractions by weight
87
TransformToFractionsByWeight
();
88
89
//----- Add components
90
G4Material
* compMate = 0;
91
G4tgbMaterialMgr
* mf =
G4tgbMaterialMgr::GetInstance
();
92
for
(
G4int
ii = 0; ii <
theTgrMate
->
GetNumberOfComponents
(); ii++)
93
{
94
// Look if this component is a material
95
compMate = mf->
FindOrBuildG4Material
(
GetComponent
(ii) );
96
if
( compMate != 0 )
97
{
98
// If it is a material add it by weight fraction
99
mate->
AddMaterial
( compMate,
theFractionsByWeight
[ii] );
100
}
101
else
102
{
103
G4String
ErrMessage =
"Component "
+
GetComponent
(ii)
104
+
" of material "
+
theTgrMate
->
GetName
()
105
+
"\n"
+
"is not an element nor a material !"
;
106
G4Exception
(
"G4tgbMaterialMixtureByVolume::BuildG4Material()"
,
107
"InvalidSetup"
,
FatalException
, ErrMessage);
108
}
109
}
110
111
#ifdef G4VERBOSE
112
if
(
G4tgrMessenger::GetVerboseLevel
() >= 1 )
113
{
114
G4cout
<<
" Constructing new G4Material by volume: "
<< *mate <<
G4endl
;
115
}
116
#endif
117
118
return
mate;
119
}
120
121
122
// -------------------------------------------------------------------------
123
void
G4tgbMaterialMixtureByVolume::TransformToFractionsByWeight
()
124
{
125
G4tgbMaterialMgr
* mf =
G4tgbMaterialMgr::GetInstance
();
126
G4Material
* compMate = 0;
127
G4double
totalfd = 0.;
128
for
(
G4int
ii = 0; ii <
theTgrMate
->
GetNumberOfComponents
(); ii++ )
129
{
130
compMate = mf->
FindOrBuildG4Material
(
GetComponent
(ii) );
131
if
( compMate != 0 )
132
{
133
// If it is a material add it by weight fraction
134
theFractionsByWeight
.push_back(
GetFraction
(ii)*compMate->
GetDensity
() );
135
totalfd +=
theFractionsByWeight
[ii];
136
}
137
else
138
{
139
G4String
ErrMessage =
"Component "
+
GetComponent
(ii)
140
+
" of material "
+
theTgrMate
->
GetName
()
141
+
"\n"
+
"is not a material !"
;
142
G4Exception
(
"G4tgbMaterialMixtureByVolume::BuildG4Material()"
,
143
"InvalidSetup"
,
FatalException
, ErrMessage);
144
}
145
}
146
for
(
G4int
ii = 0; ii <
theTgrMate
->
GetNumberOfComponents
(); ii++ )
147
{
148
theFractionsByWeight
[ii] /= totalfd;
149
#ifdef G4VERBOSE
150
if
(
G4tgrMessenger::GetVerboseLevel
() >= 2 )
151
{
152
G4cout
<<
" G4tgbMaterialMixtureByVolume::TransformToFractionsByWeight()"
153
<<
" Component "
<< ii <<
" : "
154
<< mf->
FindOrBuildG4Material
(
GetComponent
(ii) )->
GetName
()
155
<<
" FractionByVolume= "
<<
GetFraction
(ii)
156
<<
" FractionByWeight= "
<<
theFractionsByWeight
[ii]
157
<<
G4endl
;
158
}
159
#endif
160
}
161
}
geant4
tree
geant4-10.6-release
source
persistency
ascii
src
G4tgbMaterialMixtureByVolume.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:25
using
1.8.2 with
ECCE GitHub integration