From 8ee8d4f3c47e66b6d7bc550e90925ac0a4291709 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <mouginot.baptiste@gmail.com> Date: Tue, 8 Jul 2014 12:02:02 +0000 Subject: [PATCH] git-svn-id: svn+ssh://svn.in2p3.fr/class@313 0e7d625b-0364-4367-a6be-d5be4a48d228 --- .../branches/CLASSV3/include/CLASSLogger.hxx | 4 +- source/branches/CLASSV3/include/Scenario.hxx | 7 +- source/branches/CLASSV3/src/CLASSLogger.cxx | 92 +++++++++++++++++++ source/branches/CLASSV3/src/Scenario.cxx | 56 +++++++++++ 4 files changed, 155 insertions(+), 4 deletions(-) diff --git a/source/branches/CLASSV3/include/CLASSLogger.hxx b/source/branches/CLASSV3/include/CLASSLogger.hxx index 4f8e0f12c..859287e0a 100755 --- a/source/branches/CLASSV3/include/CLASSLogger.hxx +++ b/source/branches/CLASSV3/include/CLASSLogger.hxx @@ -131,9 +131,9 @@ public: \name Constructor/Desctructor */ //@{ + CLASSLogger(); - - CLASSLogger(string CLASSLoggerName = "CLASS_OUTPUT.log", int VerboseLvl = 0, int OutputLvl = 1 ); //!< Normal Constructor + CLASSLogger(string CLASSLoggerName, int VerboseLvl = 0, int OutputLvl = 1 ); //!< Normal Constructor ~CLASSLogger(); //!< Normal Destructor diff --git a/source/branches/CLASSV3/include/Scenario.hxx b/source/branches/CLASSV3/include/Scenario.hxx index 772d2664a..c22f02643 100755 --- a/source/branches/CLASSV3/include/Scenario.hxx +++ b/source/branches/CLASSV3/include/Scenario.hxx @@ -49,15 +49,18 @@ public : \name Constructor/Desctructor */ //@{ + + Scenario(); ///< Normal Constructor. - Scenario(CLASSLogger* Log= new CLASSLogger(), cSecond abstime = 0); ///< Log Constructor. + Scenario(CLASSLogger* Log, cSecond abstime = 0); ///< Log Constructor. /*! Use to load a CLASSLogger \param CLASSLogger: CLASSLogger used for the log... */ + Scenario(cSecond abstime); ///< Time Constructor. - Scenario(cSecond abstime, CLASSLogger* log = new CLASSLogger()); ///< Time Constructor. + Scenario(cSecond abstime, CLASSLogger* log); ///< Time Constructor. /*! Use to set the starting time of the Parc \param abstime: Starting time of the Parc in second diff --git a/source/branches/CLASSV3/src/CLASSLogger.cxx b/source/branches/CLASSV3/src/CLASSLogger.cxx index 7ea892371..7a23f4b49 100755 --- a/source/branches/CLASSV3/src/CLASSLogger.cxx +++ b/source/branches/CLASSV3/src/CLASSLogger.cxx @@ -14,6 +14,98 @@ using namespace std; // // //________________________________________________________________________ +CLASSLogger::CLASSLogger() +{ + string CLASSLoggerName = "CLASS_OUTPUT.log"; + int VerboseLvl = 0; + int OutputLvl = 1; + + + fCLASSLoggerName = CLASSLoggerName; + fOutPutFile.open(CLASSLoggerName.c_str()); + fVerboseLVL = VerboseLvl; + if(!fOutPutFile) + { + cout << "Could not open the CLASSLogger: " << CLASSLoggerName << " !" << endl; + exit(-1); + } + else + cout << "CLASSLogger: " << CLASSLoggerName << " opened." << endl; + fError = 0; + fWarning = 0; + fDebug = 0; + fInfo = 0; + + if (VerboseLvl <= OutputLvl) + fMaxOutPutLVL = OutputLvl; + else + fMaxOutPutLVL = VerboseLvl; + + if(VerboseLvl >= 0) + { + if (!fError) + fError = new LogType(std::cout); + else + fError->SetSecondOutput(std::cout); + } + + if(VerboseLvl >= 1) + { + if (!fWarning) + fWarning = new LogType(std::cout); + else + fWarning->SetSecondOutput(std::cout); + } + if(VerboseLvl >= 2) + { + if (!fInfo) + fInfo = new LogType(std::cout); + else + fInfo->SetSecondOutput(std::cout); + } + if(VerboseLvl >= 3) + { + if (!fDebug) + fDebug = new LogType(std::cout); + else + fDebug->SetSecondOutput(std::cout); + } + + + if(OutputLvl >= 0) + { + if (!fError) + fError = new LogType(fOutPutFile); + else + fError->SetSecondOutput(fOutPutFile); + } + if(OutputLvl >= 1) + { + if (!fWarning) + fWarning = new LogType(fOutPutFile); + else + fWarning->SetSecondOutput(fOutPutFile); + } + if(OutputLvl >= 2) + { + if (!fInfo) + fInfo = new LogType(fOutPutFile); + else + fInfo->SetSecondOutput(fOutPutFile); + } + if(OutputLvl >= 3) + { + if (!fDebug) + fDebug = new LogType(fOutPutFile); + else + fDebug->SetSecondOutput(fOutPutFile); + } + + + +} + + CLASSLogger::CLASSLogger(string CLASSLoggerName, int VerboseLvl, int OutputLvl ) { diff --git a/source/branches/CLASSV3/src/Scenario.cxx b/source/branches/CLASSV3/src/Scenario.cxx index b7424153b..af5d3f838 100755 --- a/source/branches/CLASSV3/src/Scenario.cxx +++ b/source/branches/CLASSV3/src/Scenario.cxx @@ -43,6 +43,62 @@ string dtoa(double num) return os.str(); } +//________________________________________________________________________ +Scenario::Scenario():CLASSObject(new CLASSLogger()) +{ + + fNewTtree = true; + fPrintStep = (cSecond)(3600*24*365.25); // One Step per Year + fAbsoluteTime = 0; + fStartingTime = fAbsoluteTime; + + fStockManagement = true; + + fOutputFileName = "CLASS_Default.root"; + fOutputTreeName = "Data"; + fOutFile = 0; + fOutT = 0; + fParcPower = 0; + + // Warning + + INFO << "!!INFO!! !!!Scenario!!! Parc has been define :" << endl; + INFO << "\t Print set at : " << (double)(fPrintStep/3600/24/365.25) << " year" << endl; + INFO << "\t StockManagement set at : true" << endl; + INFO << "\t OutPut will be in \"" << fOutputFileName << "\" File and \"" << fOutputTreeName << "\" TTree" << endl; + INFO << "\t Log will be in " << GetLog()->GetCLASSLoggerName() << endl; + +} + + +//________________________________________________________________________ +Scenario::Scenario(cSecond abstime):CLASSObject(new CLASSLogger()) +{ + + fNewTtree = true; + fPrintStep = (cSecond)(3600*24*365.25); // One Step per Year + fAbsoluteTime = abstime; + fStartingTime = fAbsoluteTime; + + fStockManagement = true; + + fOutputFileName = "CLASS_Default.root"; + fOutputTreeName = "Data"; + fOutFile = 0; + fOutT = 0; + fParcPower = 0; + + // Warning + + INFO << "!!INFO!! !!!Scenario!!! Parc has been define :" << endl; + INFO << "\t Print set at : " << (double)(fPrintStep/3600/24/365.25) << " year" << endl; + INFO << "\t StockManagement set at : true" << endl; + INFO << "\t OutPut will be in \"" << fOutputFileName << "\" File and \"" << fOutputTreeName << "\" TTree" << endl; + INFO << "\t Log will be in " << GetLog()->GetCLASSLoggerName() << endl; + +} + + //________________________________________________________________________ Scenario::Scenario(CLASSLogger* log, cSecond abstime):CLASSObject(log) { -- GitLab