ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_PAI_gasMixture Class Reference

Gas mixture = mixture of gas components. More...

#include <TRT_PAI_gasMixture.h>

Inheritance diagram for TRT_PAI_gasMixture:
Collaboration diagram for TRT_PAI_gasMixture:

Public Member Functions

 TRT_PAI_gasMixture (const std::string &nm)
 Construct gas mixture.
void addComponent (TRT_PAI_gasComponent *pgc, double frac)
 Add gas component to gas mixture.
const std::string & getName ()
 Get name of gas mixture.
int getNComponents ()
 Get number of different gas components in this gas mixture.
TRT_PAI_gasComponentgetComponent (unsigned int n)
 Get gas component no.
double getCompFraction (unsigned int n)
 Get fraction of gas component no.
int getNElements ()
 Get number of different element in this gas mixture.
TRT_PAI_elementgetElement (unsigned int n)
 Get element no.
double getElemWeight (unsigned int n)
 Get weight of element no.
void showStructure ()
 Print out of structure of this gas mixture.
void freezeGas ()
 Components can be added to gas mixture before freezeGas is called.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::vector< TRT_PAI_gasComponent * > m_pcomp
std::vector< double > m_compFracs
std::vector< TRT_PAI_element * > m_pelem
std::vector< double > m_elemWeights
std::string m_name
bool m_gasFrozen
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Gas mixture = mixture of gas components.

Definition at line 18 of file TRT_PAI_gasMixture.h.

Constructor & Destructor Documentation

◆ TRT_PAI_gasMixture()

TRT_PAI_gasMixture::TRT_PAI_gasMixture ( const std::string & nm)

Construct gas mixture.

Parameters
nmmixture name

Definition at line 13 of file TRT_PAI_gasMixture.cxx.

13 :
14 AthMessaging(nm),
15 m_name(nm),
17{};
AthMessaging()
Default constructor:

Member Function Documentation

◆ addComponent()

void TRT_PAI_gasMixture::addComponent ( TRT_PAI_gasComponent * pgc,
double frac )

Add gas component to gas mixture.

Parameters
pgcpointer to gas component to be added
fracfraction of this component in gas

Definition at line 21 of file TRT_PAI_gasMixture.cxx.

21 {
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}
#define ATH_MSG_ERROR(x)
std::vector< TRT_PAI_gasComponent * > m_pcomp
std::vector< double > m_compFracs

◆ freezeGas()

void TRT_PAI_gasMixture::freezeGas ( )

Components can be added to gas mixture before freezeGas is called.

After call, gas is frozen, and no more components can be added.

Definition at line 35 of file TRT_PAI_gasMixture.cxx.

35 {
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}
#define ATH_MSG_WARNING(x)
std::vector< double > m_elemWeights
std::vector< TRT_PAI_element * > m_pelem

◆ getCompFraction()

double TRT_PAI_gasMixture::getCompFraction ( unsigned int n)

Get fraction of gas component no.

n of this gas mixture

Parameters
ngas component number

Definition at line 124 of file TRT_PAI_gasMixture.cxx.

124 {
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}

◆ getComponent()

TRT_PAI_gasComponent * TRT_PAI_gasMixture::getComponent ( unsigned int n)

Get gas component no.

n of this gas mixture

Parameters
ngas component number

Definition at line 112 of file TRT_PAI_gasMixture.cxx.

112 {
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}

◆ getElement()

TRT_PAI_element * TRT_PAI_gasMixture::getElement ( unsigned int n)

Get element no.

n in this gas mixture

Parameters
nelement number

Definition at line 136 of file TRT_PAI_gasMixture.cxx.

136 {
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}

◆ getElemWeight()

double TRT_PAI_gasMixture::getElemWeight ( unsigned int n)

Get weight of element no.

n in this gas mixture

Parameters
nelement number

Definition at line 148 of file TRT_PAI_gasMixture.cxx.

148 {
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}

◆ getName()

const std::string & TRT_PAI_gasMixture::getName ( )
inline

Get name of gas mixture.

Definition at line 38 of file TRT_PAI_gasMixture.h.

38{ return m_name; };

◆ getNComponents()

int TRT_PAI_gasMixture::getNComponents ( )
inline

Get number of different gas components in this gas mixture.

Definition at line 43 of file TRT_PAI_gasMixture.h.

43{return m_compFracs.size();}

◆ getNElements()

int TRT_PAI_gasMixture::getNElements ( )
inline

Get number of different element in this gas mixture.

Definition at line 60 of file TRT_PAI_gasMixture.h.

60{return m_elemWeights.size();}

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ showStructure()

void TRT_PAI_gasMixture::showStructure ( )

Print out of structure of this gas mixture.

Definition at line 89 of file TRT_PAI_gasMixture.cxx.

89 {
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}
#define endmsg
#define ATH_MSG_INFO(x)
MsgStream & msg
Definition testRead.cxx:32

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_compFracs

std::vector<double> TRT_PAI_gasMixture::m_compFracs
private

Definition at line 87 of file TRT_PAI_gasMixture.h.

◆ m_elemWeights

std::vector<double> TRT_PAI_gasMixture::m_elemWeights
private

Definition at line 89 of file TRT_PAI_gasMixture.h.

◆ m_gasFrozen

bool TRT_PAI_gasMixture::m_gasFrozen
private

Definition at line 91 of file TRT_PAI_gasMixture.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string TRT_PAI_gasMixture::m_name
private

Definition at line 90 of file TRT_PAI_gasMixture.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_pcomp

std::vector<TRT_PAI_gasComponent*> TRT_PAI_gasMixture::m_pcomp
private

Definition at line 86 of file TRT_PAI_gasMixture.h.

◆ m_pelem

std::vector<TRT_PAI_element*> TRT_PAI_gasMixture::m_pelem
private

Definition at line 88 of file TRT_PAI_gasMixture.h.


The documentation for this class was generated from the following files: