#ifndef TRuntimeParameters_hxx_seen #define TRuntimeParameters_hxx_seen #include "TString.h" #include #include #include #include #include #include "TUnitsTableParser.hxx" //#include "TND280Log.hxx" //#include /// This class is meant to provide access to a set of parameters /// that are defined in a set of text files; in particular, the text files /// are used to store 'software runtime parameters' in calibration and /// reconstruction algorithms. class TRuntimeParameters { public: ~TRuntimeParameters(); /// Get a reference to the singleton instance of dummy /// database information. If this is first attempt at reference /// then singleton is instantiated and parameters are /// read from text files. static TRuntimeParameters& Get(void) { if (!fTRuntimeParameters) fTRuntimeParameters = new TRuntimeParameters(); return *fTRuntimeParameters; } /// Check if Parameter is stored in database bool HasParameter(std::string); /// Get parameter. Value is returned as integer. int GetParameterI(std::string); /// Get parameter. Value is returned as double. double GetParameterD(std::string); /// Get parameter. Value is returned as string. std::string GetParameterS(std::string); void ClearMapOfTRuntimeParameters(); TUnitsTableParser* GetUnitsTableParser(){ return fUnitsTableParser; } /// This command allows the user to set parameters from the /// command line; the command is different from the standard /// file reading, in that the parameters that are set are 'fixed'. /// Ie, they are immutable and cannot be changed, even if they /// exist in some other parameters file that is read in later. void ReadParamOverrideFile(TString filename); /// Function to parse command line options void ParseOptions(int argc, char* argv[]); /// Function to print out usage for command line options void PrintCommandLineUsage(std::string programName); /// Prints list of saved parameters void PrintListOfParameters(); /// Command line value getters std::string GetInFileName(){return inFileName;}; std::string GetOutZBSFileName(){return outZBSFileName;}; std::string GetOutROOTFileName(){return outROOTFileName;}; std::string GetEventListFileName(){return eventListFileName;}; std::string GetFQParOverrideFileName(){return fqParOverrideFileName;}; std::string GetCopyTreesList(){return copyTreeList;}; std::string GetSCParOverrideFileName(){return scParOverrideFileName;}; std::string GetFQKFileName(){return fqKFileName;}; int GetReadCount(){return readCount;}; int GetSkipCount(){return skipCount;}; int GetWriteHistos(){return writeHistos;}; int GetUseSubEvents(){return useSubEvents;}; int GetCopyTrees(){return copyTrees;}; int GetDoTOFind(){return doTOFind;}; int GetDoMSFit(){return doMSFit;}; private: TRuntimeParameters(); // Add a non-functional private copy constructor. TRuntimeParameters(const TRuntimeParameters &){ std::cout << "TRuntimeParameters copy constructor is private. Shouldn't be called!!!" << std::endl; } /// Reads parameters from input files. /// Function can be used to read in extra parameter files. void ReadInputFile(TString filename, TString dirName="", bool tryFile = false, bool fixParameters = false); /// Helper method to attempt to read parameters file based on parameters name. /// The return value indicates whether we can now find this parameter after /// trying to open this file (return 1 means parameter found). int TryLoadingParametersFile(std::string parameterName); /// map containing list of parameters and their values. std::map > mapOfTRuntimeParameters; typedef std::map >::iterator mapIterator; /// A set of all the 'fixed'. 'Fixed' parameters cannot be changed, even if they reappear /// in a different parameters file. This is used for the parameter override files. std::set fixedParameters; TUnitsTableParser *fUnitsTableParser; std::string inFileName; std::string outZBSFileName; std::string outROOTFileName; std::string eventListFileName; std::string fqParOverrideFileName; std::string copyTreeList; std::string scParOverrideFileName; std::string fqKFileName; int readCount; int skipCount; int writeHistos; int useSubEvents; int copyTrees; int doTOFind; int doMSFit; /// The static pointer to the singleton instance. static TRuntimeParameters* fTRuntimeParameters; }; #endif