ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetSimUtils
TRT_PAI_Process
src
TRT_PAI_gasMixture.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
TRT_PAI_gasMixture.h
"
7
#include "
TRT_PAI_gasComponent.h
"
8
9
#include <iostream>
10
#include <cmath>
11
12
//____________________________________________________________________________
13
TRT_PAI_gasMixture::TRT_PAI_gasMixture
(
const
std::string& nm) :
14
AthMessaging
(nm),
15
m_name
(nm),
16
m_gasFrozen
(0)
17
{};
18
19
20
//____________________________________________________________________________
21
void
TRT_PAI_gasMixture::addComponent
(
TRT_PAI_gasComponent
* pgc,
double
frac) {
22
if
(
m_gasFrozen
) {
23
ATH_MSG_ERROR
(
"gasMixture::addComponent: cannot add new gasComponent "
24
"- gas already frozen"
);
25
return
;
26
}
27
28
m_compFracs
.push_back(frac);
29
m_pcomp
.push_back(pgc);
30
return
;
31
}
32
33
//____________________________________________________________________________
34
35
void
TRT_PAI_gasMixture::freezeGas
() {
36
if
(
m_gasFrozen
)
return
;
37
38
int
nComp =
m_pcomp
.size();
39
double
wtot = 0.;
40
for
(
int
j=0; j<nComp; j++) {
41
if
(
m_compFracs
[j] <= 0. ) {
42
ATH_MSG_ERROR
(
"gasMixture::freezeGas: "
43
"A gasComponent has non-positive fraction"
);
44
return
;
45
}
46
wtot +=
m_compFracs
[j];
47
}
48
49
if
( std::abs(wtot-1.) > 1e-5 ) {
50
ATH_MSG_WARNING
(
"gasMixture::freezeGas: "
51
"Gas fractions do not add to unity but "
<< wtot
52
<<
". Re-normalizing!!"
);
53
}
54
55
for
(
int
j=0; j<nComp; ++j ) {
56
m_compFracs
[j] /= wtot;
57
}
58
59
m_gasFrozen
= 1;
60
61
// Now, find the composition in terms of elements
62
63
double
w;
64
TRT_PAI_element
* pe;
65
wtot = 0.;
66
for
(
int
j=0; j<nComp; j++) {
67
for
(
int
i=0; i<
m_pcomp
[j]->getNElementTypes(); i++) {
68
pe =
m_pcomp
[j]->getElement(i);
69
w =
m_compFracs
[j] *
m_pcomp
[j]->getElementMultiplicity(i);
70
wtot += w;
71
for
(
unsigned
int
k=0; k<
m_pelem
.size(); k++ ) {
72
if
( pe ==
m_pelem
[k] ) {
73
m_elemWeights
[k] += w;
74
w = -999.;
75
break
;
76
}
77
}
78
if
( w>0. ) {
79
m_elemWeights
.push_back(w);
80
m_pelem
.push_back(pe);
81
}
82
}
83
}
84
return
;
85
}
86
87
//____________________________________________________________________________
88
89
void
TRT_PAI_gasMixture::showStructure
() {
90
91
if
( !
m_gasFrozen
) {
92
ATH_MSG_WARNING
(
"gasMixture::showStructure: Showing structure of non-frozen gas"
);
93
}
94
95
ATH_MSG_INFO
(
"The gas named '"
<<
m_name
<<
"' has the following components:"
);
96
97
for
(
unsigned
int
i=0; i<
m_compFracs
.size(); i++) {
98
msg
(MSG::INFO) <<
" - "
<<
m_compFracs
[i]*100. <<
" percent "
99
<<
m_pcomp
[i]->getName() <<
" consisting of: "
;
100
for
(
int
j=0; j<
m_pcomp
[i]->getNElementTypes(); j++) {
101
if
( j>0 )
msg
(MSG::INFO) <<
","
;
102
msg
(MSG::INFO) <<
" "
<<
m_pcomp
[i]->getElementMultiplicity(j)
103
<<
" atoms "
<<
m_pcomp
[i]->getElement(j)->getName();
104
}
105
msg
(MSG::INFO) <<
endmsg
;
106
}
107
return
;
108
}
109
110
//____________________________________________________________________________
111
112
TRT_PAI_gasComponent
*
TRT_PAI_gasMixture::getComponent
(
unsigned
int
n) {
113
114
if
( n >=
m_pcomp
.size() ) {
115
ATH_MSG_ERROR
(
"gasMixture::getComponent: out of bounds"
);
116
return
m_pcomp
[0];
117
};
118
119
return
m_pcomp
[n];
120
}
121
122
//____________________________________________________________________________
123
124
double
TRT_PAI_gasMixture::getCompFraction
(
unsigned
int
n) {
125
126
if
( n >=
m_compFracs
.size() ) {
127
ATH_MSG_ERROR
(
"gasMixture::getCompFraction: out of bounds"
);
128
return
m_compFracs
[0];
129
}
130
131
return
m_compFracs
[n];
132
}
133
134
//____________________________________________________________________________
135
136
TRT_PAI_element
*
TRT_PAI_gasMixture::getElement
(
unsigned
int
n) {
137
138
if
( n >=
m_pelem
.size() ) {
139
ATH_MSG_ERROR
(
"TRT_PAI_gasMixture::getElement: out of bounds"
);
140
return
m_pelem
[0];
141
};
142
143
return
m_pelem
[n];
144
}
145
146
//____________________________________________________________________________
147
148
double
TRT_PAI_gasMixture::getElemWeight
(
unsigned
int
n) {
149
150
if
( n >=
m_elemWeights
.size() ) {
151
ATH_MSG_ERROR
(
"gasMixture::getElemFraction:Error:out of bounds"
);
152
return
0;
153
};
154
155
return
m_elemWeights
[n];
156
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
TRT_PAI_gasComponent.h
TRT_PAI_gasMixture.h
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition
AthMessaging.h:167
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
TRT_PAI_element
Chemical element.
Definition
TRT_PAI_element.h:14
TRT_PAI_gasComponent
Gas component (molecule).
Definition
TRT_PAI_gasComponent.h:16
TRT_PAI_gasMixture::m_elemWeights
std::vector< double > m_elemWeights
Definition
TRT_PAI_gasMixture.h:89
TRT_PAI_gasMixture::getElement
TRT_PAI_element * getElement(unsigned int n)
Get element no.
Definition
TRT_PAI_gasMixture.cxx:136
TRT_PAI_gasMixture::freezeGas
void freezeGas()
Components can be added to gas mixture before freezeGas is called.
Definition
TRT_PAI_gasMixture.cxx:35
TRT_PAI_gasMixture::m_name
std::string m_name
Definition
TRT_PAI_gasMixture.h:90
TRT_PAI_gasMixture::getCompFraction
double getCompFraction(unsigned int n)
Get fraction of gas component no.
Definition
TRT_PAI_gasMixture.cxx:124
TRT_PAI_gasMixture::addComponent
void addComponent(TRT_PAI_gasComponent *pgc, double frac)
Add gas component to gas mixture.
Definition
TRT_PAI_gasMixture.cxx:21
TRT_PAI_gasMixture::m_pelem
std::vector< TRT_PAI_element * > m_pelem
Definition
TRT_PAI_gasMixture.h:88
TRT_PAI_gasMixture::getElemWeight
double getElemWeight(unsigned int n)
Get weight of element no.
Definition
TRT_PAI_gasMixture.cxx:148
TRT_PAI_gasMixture::showStructure
void showStructure()
Print out of structure of this gas mixture.
Definition
TRT_PAI_gasMixture.cxx:89
TRT_PAI_gasMixture::m_gasFrozen
bool m_gasFrozen
Definition
TRT_PAI_gasMixture.h:91
TRT_PAI_gasMixture::m_pcomp
std::vector< TRT_PAI_gasComponent * > m_pcomp
Definition
TRT_PAI_gasMixture.h:86
TRT_PAI_gasMixture::TRT_PAI_gasMixture
TRT_PAI_gasMixture(const std::string &nm)
Construct gas mixture.
Definition
TRT_PAI_gasMixture.cxx:13
TRT_PAI_gasMixture::m_compFracs
std::vector< double > m_compFracs
Definition
TRT_PAI_gasMixture.h:87
TRT_PAI_gasMixture::getComponent
TRT_PAI_gasComponent * getComponent(unsigned int n)
Get gas component no.
Definition
TRT_PAI_gasMixture.cxx:112
Generated on
for ATLAS Offline Software by
1.17.0