/*! * @file ISAlgorithm.h * @author Dan Saunders, on behalf of the SoLid collaboration. * @date 17 Feb 2016 */ #ifndef ISAlgorithm_h_ #define ISAlgorithm_h_ #include #include #include #include #include "TFile.h" #include "TH1F.h" #include "TH2D.h" #include "TTree.h" #include "TChain.h" #include "SClipboard/SClipboard.h" #include "SDetector/SDetector.h" #include "SRunStatus/SRunStatus.h" #include "containerHeaders.h" //______________________________________________________________________________ class ISOption { public: std::string m_name; ISOption(std::string name) : m_name(name) {} virtual void processStrVal(std::string) {}; std::string name() {return m_name;} }; class SOptionInt : public ISOption{ public: int * m_val; SOptionInt(std::string name, int * val) : m_val(val), ISOption(name) {} void processStrVal(std::string strVal) {(*m_val) = std::stoi(strVal);} }; class SOptionStr : public ISOption{ public: std::string * m_val; SOptionStr(std::string name, std::string * val) : m_val(val), ISOption(name) {} void processStrVal(std::string strVal) {(*m_val) = strVal;} }; class SOptionDouble : public ISOption{ public: double * m_val; SOptionDouble(std::string name, double * val) : m_val(val), ISOption(name) {} void processStrVal(std::string strVal) {(*m_val) = atof(strVal.c_str());} }; //______________________________________________________________________________ //! Virtual class for base of all SAlgorithms. class ISAlgorithm { private: //! See runStopped() bool m_runStopped; //! See name() std::string m_name; //! See dtr() SDetector * m_detector; //! See cb() SClipboard * m_clipboard; //! See hcycleExecutionTime() TH1F * h_cycleExecutionTime; public: //! Option list. std::vector m_options; ISAlgorithm(SDetector * dtr, SClipboard * cb, std::string name); ~ISAlgorithm(); // Virtual functions. virtual void initialize() { std::cout<<"[Error]: Default initilizer."< * initPerChannelPlots1D(std::string name, std::string title, unsigned int nBins, double xLow, double xUp); SRunStatus * successfulRunStatus(); // Setters and getters _______________________________________________________ //! Name of the inheriting algorithm. std::string name() {return m_name;} //! Pointer to the saffron clipboard - passed in via the constructor. SClipboard * cb() {return m_clipboard;} //! Pointer to the detector configuration - passed in via the constructor. SDetector * dtr() {return m_detector;} //! Distribution of algorithm execution time. TH1F * hCycleExecutionTime() {return h_cycleExecutionTime;} //! Flag to terminate the curent cycle execution loop (e.g. eof). bool runStopped() {return m_runStopped;} void setRunStopped(bool runStopped) {m_runStopped = runStopped;} std::vector options() {return m_options;} }; #endif /* ISAlgorithm_h_ */