/// Class to calculate livetimes /// for a particular component /// /// Blair Jamieson (C) 2010 #ifndef TLiveTime_hxx__ #define TLiveTime_hxx__ #include #include #include #include #include #include #include #include #include #include class ILiveTime { public: /// Initialization /// Requires name of component whose livetime is being checked, and /// time interval in seconds that live fraction is calculated over /// (default time interval is 8 hour = 28800 seconds) ILiveTime(char * aname, int atinterval = 28800); /// Destructor, should cleanup? but does nothing ~ILiveTime(){}; /// Add another status value that is valid /// Status = 0 for good, and anything else for bad /// from time atimestart to atimeend void AddStatus( long atimestart, long atimeend, long astatus ); /// Build vector of time pairs when the status is good or bad void BuildGoodBad(); /// Build vector of live fraction from lists of times and status void BuildLiveFraction(); // Methods to print and get the results // Each checks if results computed yet -- // if not then computation is done /// Get the TGraph of Status vs time TGraph* GraphStatVsTime(); /// Get the TGraph of Live fraction TGraph* GraphLiveFraction(); /// Print List of Good and Bad Time intervals void Print(); /// Process list of times and status to build graphs, and output them /// to a png file, and print status to screen void Process(bool verbose = false, bool makeplots = false); /// Get TGraph time offset due to day light savings time /// messing things up int GetDSTOffset( long atime ); /// Write log file in format needed for detector status database entries void WriteLog( char * aauthor, char * acomment, char * aname ); private: char * fName; ///< Name of component whose livetime is being checked std::vector fTimes; ///< Unix time (of reading) offset by fAxisX0 for TGraphing std::vector fTimesRed; ///< Unix time (of reading) offset by fAxisX0 for TGraphing std::vector fStartTimes; ///< Start unix times for status std::vector fEndTimes; ///< End unix times for status std::vector fStatus; ///< Status for time / time interval std::vector fStatusRed; ///< Status for time / time interval TGraph * fStatVsTime; ///< Graph status vs time std::vector< std::pair > fGoodTimes; ///< Vector of unix time intervals that status is good std::vector< std::pair > fBadTimes; ///< Vector of unix time intervals that status is bad std::vector< long > fBadStatus; ///< Keep list of status for bad status // redundant list sorted in time std::vector< std::pair > fAllTimes; ///< Vector of unix time intervals with status AllStatus std::vector< long > fAllStatus; ///< Keep list of status for bad status long fTimeInterval; ///< Time interval over which to calculate live fractions std::vector fLiveTimes; ///< Time boundaries for live fraction calculation offset by fAxisX0 for TGraphing std::vector fLiveFraction; ///< Live fractions at each time boundary TGraph * fGrLiveFraction; ///< Live fraction plot TDatime * fAxisT0; ///< relative time for root TAxis time axis nonsense int fAxisX0; ///< relative axis offset for root TAxis time axis nonsense }; #endif //TLiveTime_hxx__