/// Class to hold gas system information /// at a particular time /// Blair Jamieson (C) 2009 #ifndef TTPCGas_hxx__ #define TTPCGas_hxx__ #include #include #include "ISlowControlDatabase.hxx" #include "TPaveText.h" #include "TList.h" #include "TH2F.h" #include "TMath.h" const float fParCO2[18] = { -5.4326 , 1.1809 , -0.0002372 , -43.972 , 7.3191 , 0.01324 , -0.032551 , -0.001237 , -0.09917 , -0.02220 , -0.1392 , 0.04847 , -0.003586 , -5.8750e-05 , 4.7685e-05 , 0.0001077 , -3.868e-05 , 1.0860e-06 }; const float fParCF4[8] = { 0.03471045 , -0.8745998 , 1.13897526 , 0.01899379 , 0.11224347 , -0.2499385 , 0.06106793 , -0.0062016 }; //CO2 uncorrection function (x is MFC reading, f(x) is MGA reading) //f(x) = A0 + A1*x + A2*sqrt(x) + A3*II + A4*sqrt(II) + A5*FF + A6*II*FF + A7*sqrt(II)*FF + // A8*II*x + A9*sqrt(II)*x + A10*FF*x + A11*II*FF*x + A12*sqrt(II)*FF*x + // A13*II*sqrt(x) + A14*sqrt(II)*sqrt(x) + A15*FF*sqrt(x) + A16*II*FF*sqrt(x) + // A17*x*x //#chi2= ~350. ndof= 335 const float fUnParCO2[18] = { -0.04875436529, 0.580088430319, 3.49984751656, 31.2007272367, 0.272482162246, 8.03075384474, 0.99185992062, 0.161072765519, -0.04706510951, 0.332506656625, -0.14263580350, -0.06475332948, 0.240082724435, 0.314294464172, -0.34518469949, -0.05425661040, -0.09357137866, 0.000394157939}; //CF4 uncorrection function (x is MFC reading, f(x) is MGA) //f(x) = A0+A1*sqrt(x)+A2*x+A3*x*x+A4*II+A5*II*sqrt(x)+A6*II*x+A7*II*x*x const float fUnParCF4[8] = { 0.0131216591428, 1.60036006049, 0.252353870029, 0.0230248607059, 0.024752004324, 0.0673728461726, 0.0712650145331, -0.00433463061164}; /// Class to hold TPC Gas properties /// at a particular time /// Blair Jamieson (C) 2009 class ITPCGas { public: /// Initialize TPC gas properties object using unix time ITPCGas( long autimemin = 1224118800, long autimemax = 1224118800 ); /// Initialize TPC gas properties object using year, month(0-11), /// day(1-31),... ITPCGas( int ayearmin, int amonthmin, int adaymin, int ahourmin, int aminmin, int asecmin, int ayearmax, int amonthmax, int adaymax, int ahourmax, int aminmax, int asecmax ); /// Destructor does nothing... may leave a histogram /// floating around ~ITPCGas(){}; /// Get time interval this record is valid for void GetTimeInterval(long &start_time, long &end_time); /// Get unix time for this temperature reading long GetTime(){ return fTime; } /// Get time for this reading as year, month(0-11), day(1-31),... void GetTime( int &ayear, int &amonth, int &aday, int &ahour, int &amin, int &asec); /// Set the unix time for this object, and read gas properties closest /// to this time from database void SetTime( long autime ){ fTime=autime; Read(); } /// Get unix time long GetUnixTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0); /// Set the time for this object void SetTimeNoRead( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ); /// Set the time for this object and read gas properties void SetTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ){ SetTimeNoRead(ayear, amonth, aday, ahour, amin, asec); ReadNext(); } /// Read (increment time) and update all /// object gas property readings. Argument passed is the minimum /// time increment to use (default 3 seconds) int ReadNext(int adeltat=3); /// Return timestamp char * GetTimeStamp(){ return fTimeStamp; } /// Print variables to screen void Print(); /// Set Debug output flag void SetDebug( bool aOnOff = true ){ fDebug = aOnOff; } // Access methods float ArFlow (){ return fArFlow; } ///< Argon flow (l/min) float CF4Flow(){ return fCF4Flow;} ///< CF4 flow (l/min) float IbuFlow(){ return fIbuFlow;} ///< isobutane flow (l/min) float Patm (){ return fPatm; } ///< Atmospheric pressure (bar) float PD1 (){ return fPD1; } ///< outer volume to atm dp (mbarg) float PD2 (){ return fPD2; } ///< inner to outer volume dp (mbarg) float P (){ return fP; } ///< inner volume absolute pressure (mbar) float PD4 (){ return fPD4; } ///< pressure near isobutane monitor (mbarg) float H2O (){ return fH2O; } ///< H2O in ~ppm float O2 (){ return fO2; } ///< Inner volume O2 in ppm float IbuMon (){ return fIbuMon; } ///< Isobutane % from safety monitor float IbuAn (){ return fIbuAn; } ///< Isobutane % from MGA3000 (crap) float CO2An (){ return fCO2An; } ///< CO2 ppm from MGA3000 (crap) float CF4An (){ return fCF4An; } ///< CF4 % from MGA3000 (fine but offset) float TO2 (){ return fTO2; } ///< temperture (degC) from O2 monitor float TTPC (int itpc){ if (itpc==1) return fTTPC1; if (itpc==2) return fTTPC2; if (itpc==3) return fTTPC3; return (fTTPC1+fTTPC2+fTTPC3)/3.; } float TTPC1 (){ return fTTPC1; } ///< temperature (degC) from avg of T probes at gas manifolds of TPC1 float TTPC2 (){ return fTTPC2; } ///< temperature (degC) from avg of T probes at gas manifolds of TPC2 float TTPC3 (){ return fTTPC3; } ///< temperature (degC) from avg of T probes at gas manifolds of TPC3 float D0TC1 () { return fD0TC1;} ///< temperture (degC) from normal isobutane flowmeter float D0TC2 () { return fD0TC2;} ///< temperture (degC) from purge isobutane flowmeter float D0TC3 () { return fD0TC3;} ///< temperture (degC) from purge isobutane supply line float D0TC4 () { return fD0TC4;} ///< temperture (degC) from Argon supply line float D0TC5 () { return fD0TC5;} ///< temperture (degC) from normal isobutane supply line // purifier temperatures float P0TC1 () { return fP0TC1;} ///< temperture (degC) from purifier 1 top float P0TC2 () { return fP0TC2;} ///< temperture (degC) from purifier 1 middle float P0TC3 () { return fP0TC3;} ///< temperture (degC) from purifier 1 bottom float P0TC4 () { return fP0TC4;} ///< temperture (degC) from purifier 2 top float P0TC5 () { return fP0TC5;} ///< temperture (degC) from purifier 2 middle float P0TC6 () { return fP0TC6;} ///< temperture (degC) from purifier 2 bottom // isobutane cylinder room temperatures float DXTC1 () { return fDXTC1;} ///< temperture (degC) from isobutane bottle 1 float DXTC2 () { return fDXTC2;} ///< temperture (degC) from isobutane bottle 2 float DXTC3 () { return fDXTC3;} ///< temperture (degC) from isobutane line // monitor chamber drift information float VdIn () { return fVdIn; } ///< Drift speed of input gas ( cm / microseconds ) float VdInUnc () { return fVdInUnc; } ///< Uncertainty in drift speed of input gas ( cm / microseconds ) float VdOut () { return fVdOut; } ///< Drift speed of return gas ( cm / microseconds ) float VdOutUnc() { return fVdOutUnc; } ///< Uncertainty in drift speed of return gas ( cm / microseconds ) float GainIn (){ return fGainIn; } ///< Gain of input gas float GainInUnc (){ return fGainInUnc; } ///< Uncertainty in gain of input gas float GainOut (){ return fGainOut; } ///< Drift speed of return gas float GainOutUnc(){ return fGainOutUnc; } ///< Uncertainty in gain of return gas /// Check if readings for current time are valid bool DBReadOK(){ if ( fPlca_isok==true && fTpc1_isok==true && fTpc2_isok==true && fTpc3_isok==true && fVda_isok==true && fVdb_isok==true && fGa_isok==true && fGb_isok==true ) { return true; } else { return false; } } //x void TimeRange ( int & astart, int &aend ){ astart=fStart; aend=fEnd; } ///< Get time validity of this reading private: long fTime; ///< Unix time for gas readings long fStart; ///< start of validity range for current gas readings long fEnd; ///< end of validity range for current gas readings long fStartTime; ///< start time for intended time range this will be used for long fEndTime; ///< end time for intended time range this will be used for long fIbuCorTime;///< unix time after which isobutane monitor corrections done by PLC long fAnalyzerCorTime;///< unix time after which gas analyzer corrections done by PLC long fAnalyzerCorTime2;///< unix time after which gas analyzer corrections changed in PLC char * fTimeStamp; ///< local time as character array (for titles) float fArFlow; ///< Argon flow (l/min) float fCF4Flow; ///< CF4 flow (l/min) float fIbuFlow; ///< isobutane flow (l/min) float fPatm; ///< Atmospheric pressure (mbar) float fPD1; ///< inner to outer volume dp (mbarg) float fPD2; ///< outer volume to atm dp (mbarg) float fP; ///< inner volume absolute pressure (mbar) float fPD4; ///< pressure near isobutane monitor (mbarg) float fH2O; ///< H2O in ~ppm float fO2; ///< Inner volume O2 in ppm float fIbuMon; ///< Isobutane % from safety monitor float fIbuAn; ///< Isobutane % from MGA3000 (crap) float fCO2An; ///< CO2 ppm from MGA3000 (crap) float fCF4An; ///< CF4 % from MGA3000 (fine but offset) float fTO2; ///< temperture (degC) from O2 monitor float fTTPC1; ///< temperture (degC) from avg of T probes at gas manifolds of TPC1 float fTTPC2; ///< temperture (degC) from avg of T probes at gas manifolds of TPC2 float fTTPC3; ///< temperture (degC) from avg of T probes at gas manifolds of TPC3 float fD0TC1; ///< temperture (degC) from normal isobutane flowmeter float fD0TC2; ///< temperture (degC) from purge isobutane flowmeter float fD0TC3; ///< temperture (degC) from purge isobutane supply line float fD0TC4; ///< temperture (degC) from Argon supply line float fD0TC5; ///< temperture (degC) from normal isobutane supply line float fP0TC1; ///< temperture (degC) from purifier 1 top float fP0TC2; ///< temperture (degC) from purifier 1 middle float fP0TC3; ///< temperture (degC) from purifier 1 bottom float fP0TC4; ///< temperture (degC) from purifier 2 top float fP0TC5; ///< temperture (degC) from purifier 2 middle float fP0TC6; ///< temperture (degC) from purifier 2 bottom // isobutane float fDXTC1; ///< temperture (degC) from isobutane bottle 1 float fDXTC2; ///< temperture (degC) from isobutane bottle 2 float fDXTC3; ///< temperture (degC) from isobutane line // monitor chamber drift information float fVdIn; ///< Drift speed of input gas ( cm / microseconds ) float fVdInUnc; ///< Uncertainty in drift speed of input gas ( cm / microseconds ) float fVdOut; ///< Drift speed of return gas ( cm / microseconds ) float fVdOutUnc; ///< Uncertainty in drift speed of return gas ( cm / microseconds ) float fGainIn; ///< Gain of input gas float fGainInUnc; ///< Uncertainty in gain of input gas float fGainOut; ///< Drift speed of return gas float fGainOutUnc; ///< Uncertainty in gain of return gas bool fDebug; ///< Flag to print debug information to std::cout /// Setup vectors of strings for field names /// that will be querried in the database void SetupFieldNames(); // values used for bulk read from slow control database std::vector< std::string > fPlca_names; ///< names of fields to read from PLCA std::vector< std::string > fTpc1_names; ///< names of fields of Tpc1 temperatures std::vector< std::string > fTpc2_names; ///< names of fields of Tpc2 temperatures std::vector< std::string > fTpc3_names; ///< names of fields of Tpc3 temperatures std::vector< std::string > fVda_names; ///< names of fields of Vdrift A std::vector< std::string > fVdb_names; ///< names of fields of Vdrift B std::vector< std::string > fGa_names; ///< names of fields of Gain A std::vector< std::string > fGb_names; ///< names of fields of Gain B /// Check if anouther chunk of data needs to be read from /// slow control database void CheckReadDB(); // Read another chunk of data from slow control database void ReadSlowDB_Plca(); /// > > fPlca_vec; ///< db query result for read from PLCA std::vector< std::pair< double, std::vector< double > > > fTpc1_vec; ///< db query result for Tpc1 temperatures std::vector< std::pair< double, std::vector< double > > > fTpc2_vec; ///< db query result for Tpc2 temperatures std::vector< std::pair< double, std::vector< double > > > fTpc3_vec; ///< db query result for Tpc3 temperatures std::vector< std::pair< double, std::vector< double > > > fVda_vec; ///< db query result for Vdrift A std::vector< std::pair< double, std::vector< double > > > fVdb_vec; ///< db query result for Vdrift B std::vector< std::pair< double, std::vector< double > > > fGa_vec; ///< db query result for Gain A std::vector< std::pair< double, std::vector< double > > > fGb_vec; ///< db query result for Gain B /// Get index into each of the vectors of database query /// results for the current time void UpdateVectorTimeIdx(); unsigned int fPlca_idx; ///< time idx for current PLCA unsigned int fTpc1_idx; ///< time idx for current Tpc1 temperatures unsigned int fTpc2_idx; ///< time idx for current Tpc2 temperatures unsigned int fTpc3_idx; ///< time idx for current Tpc3 temperatures unsigned int fVda_idx; ///< time idx for current Vdrift A unsigned int fVdb_idx; ///< time idx for current Vdrift B unsigned int fGa_idx; ///< time idx for current Gain A unsigned int fGb_idx; ///< time idx for current Gain B bool fPlca_isok; ///< db read ok for current PLCA bool fTpc1_isok; ///< db read ok for current Tpc1 temperatures bool fTpc2_isok; ///< db read ok for current Tpc2 temperatures bool fTpc3_isok; ///< db read ok for current Tpc3 temperatures bool fVda_isok; ///< db read ok for current Vdrift A bool fVdb_isok; ///< db read ok for current Vdrift B bool fGa_isok; ///< db read ok for current Gain A bool fGb_isok; ///< db read ok for current Gain B /// Set character timestamp from integer unix timestamp void SetupTimeStamp(); /// Read the gas system readings void Read(); /// Initialize gas system object Sets offsets, makes histogram, /// reads properties, and fills histogram? void Init(); /// Note aCF4 is MGA3000 reading, aC4H10 should be true value float CorrectCF4(float aCF4,float aC4H10); /// Note aCO2 is MGA3000 reading, aC4H10 and aCF4 should be true values float CorrectCO2(float aCO2,float aC4H10,float aCF4); /// Note aCF4 is "true" reading, aC4H10 should be true value float UnCorrectCF4(float aCF4,float aC4H10); /// Note aCO2 is "true" reading, aC4H10 and aCF4 should be true values float UnCorrectCO2(float aCO2,float aC4H10,float aCF4); /// Apply temperature corrections, and gas cross term Corrections void ApplyCorrections(); }; #endif //TTPCGas_hxx__