ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
void addComponent (TRT_PAI_gasComponent *pgc, double frac)
 Add gas component to gas mixture. More...
 
std::string getName ()
 Get name of gas mixture. More...
 
int getNComponents ()
 Get number of different gas components in this gas mixture. More...
 
TRT_PAI_gasComponentgetComponent (unsigned int n)
 Get gas component no. More...
 
double getCompFraction (unsigned int n)
 Get fraction of gas component no. More...
 
int getNElements ()
 Get number of different element in this gas mixture. More...
 
TRT_PAI_elementgetElement (unsigned int n)
 Get element no. More...
 
double getElemWeight (unsigned int n)
 Get weight of element no. More...
 
void showStructure ()
 Print out of structure of this gas mixture. More...
 
void freezeGas ()
 Components can be added to gas mixture before freezeGas is called. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

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

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. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

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  :
15  m_name(nm),
16  m_gasFrozen(0)
17 {};

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 }

◆ 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;
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 }

◆ 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()

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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ 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 }

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.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
TRT_PAI_gasMixture::m_pcomp
std::vector< TRT_PAI_gasComponent * > m_pcomp
Definition: TRT_PAI_gasMixture.h:86
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TRT_PAI_gasMixture::m_elemWeights
std::vector< double > m_elemWeights
Definition: TRT_PAI_gasMixture.h:89
TRT_PAI_gasMixture::m_name
std::string m_name
Definition: TRT_PAI_gasMixture.h:90
TRT_PAI_gasMixture::m_pelem
std::vector< TRT_PAI_element * > m_pelem
Definition: TRT_PAI_gasMixture.h:88
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
LArG4AODNtuplePlotter.pe
pe
Definition: LArG4AODNtuplePlotter.py:116
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
checkxAOD.frac
frac
Definition: Tools/PyUtils/bin/checkxAOD.py:256
TRT_PAI_gasMixture::m_gasFrozen
bool m_gasFrozen
Definition: TRT_PAI_gasMixture.h:91
TRT_PAI_gasMixture::m_compFracs
std::vector< double > m_compFracs
Definition: TRT_PAI_gasMixture.h:87
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
TRT_PAI_element
Chemical element.
Definition: TRT_PAI_element.h:14
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
fitman.k
k
Definition: fitman.py:528