/// Class to hold TPC MM spark count for /// a range of times, and calculate /// spark rate. Uses TTPCSpark to /// read the values at a particular time. /// /// Blair Jamieson (C) 2010 #ifndef TTPCSparkCounter_hxx__ #define TTPCSparkCounter_hxx__ #include #include #include #include #include #include #include "ILiveTime.hxx" #include "ITPCMMSpark.hxx" #include "IAvgRMSPlot.hxx" class ITPCSparkCounter { public: /// Initialize TPC MM spark count object using unix time /// default time interval is 100 hours (expect only ~10 sparks/mm) ITPCSparkCounter( long autimemin = 1224118800, long autimemax = 1224118800, int adt=360000, bool verbose=false, bool makeplots=false); /// Initialize TPC MM spark count object using year, month(0-11), /// day(1-31),... ITPCSparkCounter( int ayearmin, int amonthmin, int adaymin, int ahourmin, int aminmin, int asecmin, int ayearmax, int amonthmax, int adaymax, int ahourmax, int aminmax, int asecmax, int adt=360000, bool verbose=false, bool makeplots=false); /// Destructor does nothing... may leave a histogram /// floating around ~ITPCSparkCounter(){}; private: long fStart; ///< start unix time of validity range long fEnd; ///< end unix time of validity range bool fVerbose; ///< flag to say if should print lots bool fMakePlots; ///< flag to say if plots should be saved to png files int fDT; ///< Time interval to do count over /// Update the graph values for graphs that will be saved at end void SaveGraphValues( ITPCMMSpark &sparks, bool lastflag ); // values saved for graphs: IAvgRMSPlot fSparkCount[3][2][12];///< Spark count (counts in time interval) [TPC][RP][MM] IAvgRMSPlot fSparkFreq[3][2][12]; ///< Spark frequency (counts per time interval) [TPC][RP][MM] IAvgRMSPlot fSparkCountEP[3][2]; ///< Spark count per endplate (counts in time interval) [TPC][RP] IAvgRMSPlot fSparkFreqEP[3][2]; ///< Spark frequency per endplate (counts per time interval) [TPC][RP] IAvgRMSPlot fSparkCountTPC[3]; ///< Spark count per tpc (counts in time interval) [TPC][RP] IAvgRMSPlot fSparkFreqTPC[3]; ///< Spark frequency per tpc (counts per time interval) [TPC][RP] IAvgRMSPlot fSparkCnt;///< Spark count (counts in time interval) mms IAvgRMSPlot fSparkFrq; ///< Spark frequency (counts per time interval) mms IAvgRMSPlot fSparkCntAll;///< Spark count (counts in time interval) all mms IAvgRMSPlot fSparkFrqAll; ///< Spark frequency (counts per time interval) all mms // current count for loop over time interval long fLastTime; ///< time of last reading int fLastCount[3][2][12]; ///< last reading from DB to compare/see if reset was done int fCount[3][2][12]; ///< current spark count for time interval fTimeSum int fTimeSum; ///< current time interval counted so far /// Initialize livetime and status objects void Init(); /// Collect all of the TGraphs, and save them to file. void SavePlotsToFile(); }; #endif //TTPCSparkCounter_hxx__