/// Class to hold MM HV spark count information /// at a particular time /// Blair Jamieson (C) 2010 #ifndef TTPCMMSpark_hxx__ #define TTPCMMSpark_hxx__ #include #include #include "ISlowControlDatabase.hxx" #include "TPaveText.h" #include "TList.h" #include "TH2F.h" #include "TMath.h" /// Class to hold TPC MM HV spark count information /// at a particular time /// Blair Jamieson (C) 2010 class ITPCMMSpark { public: /// Initialize TPC MM HV spark properties object using unix time ITPCMMSpark( long autimemin = 1224118800, long autimemax = 1224118800 ); /// Initialize TPC MM HV spark properties object using year, month(0-11), /// day(1-31),... ITPCMMSpark( 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 ~ITPCMMSpark(){}; /// 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(); /// Access method to get current spark count in a particular MM /// returns -1 if no reading is available int GetSpark( int itpc, int irp, int imm ){ if (itpc >=0 && itpc<3 && irp>=0 && irp<2 && imm>=0 && imm<12 && fSparks_isok[itpc][irp][imm] == true ) return fSparks[itpc][irp][imm]; else return -1; } /// Check if readings for current time are valid bool DBReadOK(){ for (int itpc=0; itpc<3; itpc++){ for (int irp=0; irp<2; irp++){ for ( int imm=0; imm<12; imm++){ if ( fSparks_isok[itpc][irp][imm] == false ) return false; } } } return true; } 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 char * fTimeStamp; ///< local time as character array (for titles) /// Spark count read directly from DB sorted into handy array /// index is [TPC][RP][MM] int fSparks[3][2][12]; unsigned int fSparks_idx[3][2][12]; ///< index in fSparks of current time's reading bool fSparks_isok[3][2][12]; ///< check if db query found reading for current time std::vector< std::string > fSparks_names; ///< names of fields to read for spark counts std::vector< std::pair< double, std::vector< double > > > fSparks_vec; ///< DB query results /// Setup vectors of strings for field names /// that will be querried in the database void SetupFieldNames(); /// 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(); ///