TPCCondData
GasConditions.cc
Go to the documentation of this file.
1 /* GasConditions.cc
2  * $Id$
3  */
4 
5 #include "GasConditions.h"
6 
7 namespace tpcconddata{
8 
10  return std::string("$Rev: 1592 $");
11 }
12 
14  return std::string("TPCGasConditions");
15 }
16 
18  createObj=true;
19  myObj = new IMPL::LCGenericObjectImpl();
20 
21  setTemperature( 0 );
22  setPressure( 0 );
23  setOverPressure( 0 );
24  setFlow( 0 );
25  setWaterContent( 0 );
26  setOxygenContent( 0 );
27 
28 }
29 
30 GasConditions::GasConditions(EVENT::LCObject* Obj){
31  createObj=false;
32  myObj = dynamic_cast<IMPL::LCGenericObjectImpl*>( Obj );
33 
34  if (myObj ==0){
35  //could be an GasConditions
36  GasConditions* dummyObj = dynamic_cast<GasConditions*>( Obj );
37  if (dummyObj != 0){
38  myObj=dummyObj->obj();
39  }
40  }
41 }
42 
44  if (createObj) delete myObj;
45 }
46 
47 float GasConditions::getMixture( int Content ) const {
48  for (int iContent = 0; iContent < getNMixtureContents(); iContent++){
49  if ( getContent( iContent ) == Content ){
50  return getFraction( iContent );
51  }
52  }
53  return 0.0;
54 }
55 
57  return myObj->getFloatVal( 0 ) ;
58 }
59 
61  return myObj->getFloatVal( 1 ) ;
62 }
63 
65  return myObj->getFloatVal( 2 ) ;
66 }
67 
68 float GasConditions::getFlow() const {
69  return myObj->getFloatVal( 3 ) ;
70 }
71 
73  return myObj->getFloatVal( 4 ) ;
74 }
75 
77  return myObj->getFloatVal( 5 ) ;
78 }
79 
80 void GasConditions::setMixture( int Content, float Value ){
81  for (int iContent = 0; iContent < getNMixtureContents(); iContent++){
82  if ( getContent( iContent ) == Content ){
83  setFraction( iContent, Value );
84  return;
85  }
86  }
87  addMixtureContents( Content, Value );
88 }
89 
90 void GasConditions::setTemperature( float Value ) {
91  myObj->setFloatVal( 0 , Value ) ;
92 }
93 
94 void GasConditions::setPressure( float Value ) {
95  myObj->setFloatVal( 1 , Value ) ;
96 }
97 
98 void GasConditions::setOverPressure( float Value ) {
99  myObj->setFloatVal( 2 , Value ) ;
100 }
101 
102 void GasConditions::setFlow( float Value ) {
103  myObj->setFloatVal( 3 , Value ) ;
104 }
105 
106 void GasConditions::setWaterContent( float Value ) {
107  myObj->setFloatVal( 4 , Value ) ;
108 }
109 
110 void GasConditions::setOxygenContent( float Value ) {
111  myObj->setFloatVal( 5 , Value ) ;
112 }
113 
114 void GasConditions::print( std::ostream& os ) const {
115 
116  if (getNMixtureContents() > 0 ){
117  std::streamsize WidthBefore = os.width();
118  os.width( 7 );
119  os<<"mixtrue: ";
120  for (int iMix = 0; iMix < getNMixtureContents(); iMix++){
121  os<<getContent( iMix )<<":";
122  }
123  os<<std::endl;
124  os<<" ";
125  for (int iMix = 0; iMix < getNMixtureContents(); iMix++){
126  os<<getFraction( iMix )<<":";
127  }
128  os.width( WidthBefore );
129  }
130  else{
131  os<<"no mixture defined";
132  }
133  os<<std::endl;
134  os<<"temprature: "<<getTemperature()<<" C"<<std::endl;
135  os<<"presure: "<<getPressure()<<" hPa"<<std::endl;
136  os<<"overpresure: "<<getOverPressure()<<" mbar"<<std::endl;
137  os<<"flow: "<<getFlow()<<" l/h"<<std::endl;
138  os<<"water content: "<<getWaterContent()<<" ppmV"<<std::endl;
139  os<<"oxygen content: "<<getOxygenContent()<<" ppmV"<<std::endl;
140 }
141 
142 std::ostream &operator<<(std::ostream &os, const GasConditions &gc) {
143  gc.print(os);
144  return os;
145 }
146 
148  return myObj->getNInt();
149 }
150 int GasConditions::getContent( int Index ) const {
151  if (Index < getNMixtureContents() ){
152  return myObj->getIntVal( Index );
153  }
154  return -1;
155 }
156 float GasConditions::getFraction( int Index ) const {
157  if (Index < getNMixtureContents() ){
158  return myObj->getFloatVal( 6+Index );
159  }
160  return 0.0;
161 }
162 void GasConditions::setFraction( int Index, float Fraction ){
163  if (Index < getNMixtureContents() ){
164  myObj->setFloatVal( 6+Index, Fraction );
165  }
166 }
167 void GasConditions::addMixtureContents( int Content, float Fraction ){
168  myObj->setIntVal( getNMixtureContents(), Content );
169  myObj->setFloatVal( 6+getNMixtureContents(), Fraction );
170 }
171 
172 int GasConditions::getNInt() const { return myObj->getNInt();}//myObj->getNInt(); }
173 int GasConditions::getNFloat() const { return myObj->getNFloat(); }
174 int GasConditions::getNDouble() const { return 0; }
175 
176 int GasConditions::getIntVal(int index) const {
177  return myObj->getIntVal( index ) ;
178 }
179 float GasConditions::getFloatVal(int index) const {
180  return myObj->getFloatVal( index ) ;
181 }
182 double GasConditions::getDoubleVal(int index) const {
183  return 0.0;//myObj->getDoubleVal( index ) ;
184 }
185 
186 }
IMPL::LCGenericObjectImpl * obj()
Definition: GasConditions.h:69
void setTemperature(float Value)
float getTemperature() const
return the temperature of the gas in C
virtual ~GasConditions()
Important for memory handling.
float getOxygenContent() const
return the oxygen content in the gas in ppmV
float getFloatVal(int index) const
void setFlow(float Value)
void setOxygenContent(float Value)
GasConditions()
constructor wich only sets channel
void setPressure(float Value)
float getFlow() const
return the flow of the gas in l/h
float getFraction(int Index) const
std::ostream & operator<<(std::ostream &os, const ADCChannelMapping &acm)
void setMixture(int Content, float Value)
void print(std::ostream &os=std::cout) const
float getOverPressure() const
return the over pressure of the sytem (to the athmosphere) in mbar
void setWaterContent(float Value)
static std::string getDefaultColName()
void addMixtureContents(int Content, float Fraction)
double getDoubleVal(int index) const
void setOverPressure(float Value)
int getIntVal(int index) const
void setFraction(int Index, float Fraction)
class to store the condition of the gas in a gaseous detector (e.g.
Definition: GasConditions.h:19
float getWaterContent() const
return the water content in the gas in ppmV
static std::string getRevision()
Definition: GasConditions.cc:9
float getPressure() const
return the pressure of the gas in hPa
IMPL::LCGenericObjectImpl * myObj
Definition: GasConditions.h:97
float getMixture(int Content) const
return fraction of the mixtrue of the gas in of the following contents
int getContent(int Index) const