diff --git a/NPAnalysis/10He_Riken/src/Analysis.cc b/NPAnalysis/10He_Riken/src/Analysis.cc index c58c1c4d44fbf0d4d84ce522b5550c32d3c7d9dd..0ecb75fb46c4132d713e56b315180cc2fe24680e 100644 --- a/NPAnalysis/10He_Riken/src/Analysis.cc +++ b/NPAnalysis/10He_Riken/src/Analysis.cc @@ -1,21 +1,26 @@ #include "ObjectManager.hh" - +#include "NPOptionManager.h" using namespace std; int main(int argc,char** argv) { - if(argc!=4) - { - cout << - "you need to specify both a Reaction file and a Detector file such as : Analysis myReaction.reaction myDetector.detector runToRead.run" - << endl; - return 0; - } +// if(argc!=4) +// { +// cout << +// "you need to specify both a Reaction file and a Detector file such as : Analysis myReaction.reaction myDetector.detector runToRead.run" +// << endl; +// return 0; +// } +// +// string detectorfileName = argv[1] ; +// string calibrationfileName = argv[2] ; +// string runToReadfileName = argv[3] ; - string detectorfileName = argv[1] ; - string calibrationfileName = argv[2] ; - string runToReadfileName = argv[3] ; + NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); + string detectorfileName = myOptionManager->GetDetectorFilePath() ; + string calibrationfileName = myOptionManager->GetCalibrationFilePath() ; + string runToReadfileName = myOptionManager->GetRunToReadFilePath() ; // First of All instantiate RootInput and Output // Detector will be attached later diff --git a/NPLib/Makefile b/NPLib/Makefile index df066bf01732dd87d54b0a49fd61a26281030d2a..2a608be0d967c64f5f8f1381c6b69edd08a4facf 100644 --- a/NPLib/Makefile +++ b/NPLib/Makefile @@ -270,7 +270,7 @@ INCLUDE = -I$(CLHEP_BASE_DIR)/include #------------------------------------------------------------------------------ SHARELIB = CalibManager Vdetec InputOutputRoot InitCond InterCoord \ Must2All GaspardData AnnularS1Data PlasticData DummyDetectorData SSSDData\ - Reaction EnergyLoss TagManager ParisData ShieldData + Reaction EnergyLoss TagManager OptionManager ParisData ShieldData all: $(SHARELIB) rm -f ./include/*Dict.h @@ -418,6 +418,13 @@ TagManager: ifeq ($(ARCH),macosx) cd lib; ln -sf libTagManager.so libTagManager.dylib endif + +OptionManager: + make libOptionManager.so -C ./Tools + cp ./Tools/*.so ./lib ; cp ./Tools/*.h ./include +ifeq ($(ARCH),macosx) + cd lib; ln -sf libOptionManager.so libOptionManager.dylib +endif ####################################### diff --git a/NPLib/Tools/Makefile b/NPLib/Tools/Makefile index fea81d80e6f279a9f9964b9a8d9b106a7ac94dc1..1f724348fe42dfa23975538b7eb14db2d1381ded 100644 --- a/NPLib/Tools/Makefile +++ b/NPLib/Tools/Makefile @@ -268,7 +268,7 @@ GLIBS = $(ROOTGLIBS) $(SYSLIBS) INCLUDE = -I$(CLHEP_BASE_DIR)/include #------------------------------------------------------------------------------ -SHARELIB = libReaction.so libEnergyLoss.so libTagManager.so +SHARELIB = libReaction.so libEnergyLoss.so libTagManager.so libOptionManager.so all: $(SHARELIB) #------------------------------------------------------------------------------ @@ -288,12 +288,17 @@ libTagManager.so: NPTagManager.o NPTagManagerDict.o NPTagManagerDict.cxx: NPTagManager.h rootcint -f $@ -c $^ + +## OptionManager ## +libOptionManager.so: NPOptionManager.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ # dependances NPReaction.o:NPReaction.cxx NPReaction.h NPNucleus.o: NPNucleus.cxx NPNucleus.h NPEnergyLoss.o:NPEnergyLoss.cxx NPEnergyLoss.h NPTagManager.o:NPTagManager.cxx NPTagManager.h +NPOptionManager.o:NPOptionManager.cxx NPOptionManager.h ####################################### ############# Clean and More ########## diff --git a/NPLib/Tools/NPOptionManager.cxx b/NPLib/Tools/NPOptionManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..18cf752ae7786dd1b899c2c03c314dee549c1fcb --- /dev/null +++ b/NPLib/Tools/NPOptionManager.cxx @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: A. MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : 21/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is a singleton class which deals with input * + * arguments of the different NPTool programm (NPS and NPA) * + *---------------------------------------------------------------------------* + * Comment: The singleton form allow users to call the object from anywhere * + * in the code * + * * + * * + *****************************************************************************/ + +#include "NPOptionManager.h" + + +NPOptionManager* NPOptionManager::instance = 0 ; + +NPOptionManager* NPOptionManager::getInstance(int argc,char** argv) + { + if( instance == 0 ) instance = new NPOptionManager(argc,argv); + + return instance ; + } + + +////////////////////////////////////////////////////// +NPOptionManager::NPOptionManager(int argc,char** argv) + { + // Default Setting + fReactionFileName = "myReaction.reaction" ; + fDetectorFileName = "myDetector.detector" ; + fOutputFileName = "myResult.root" ; + fRunToReadFileName = "RunToRead.txt" ; + fCalibrationFileName = "Calibration.txt" ; + + for (int i = 0 ; i < argc ; i++) + { + string argument = argv[i]; + + if(argument == "-H" || argument == "-h" || argument == "-help") + DisplayHelp(); + + else if(argument == "-R" && argc>=i+1 ) fReactionFileName = argv[i+1] ; + + else if(argument == "-C" && argc>=i+1 ) fDetectorFileName = argv[i+1] ; + + else if(argument == "-O" && argc>=i+1 ) fOutputFileName = argv[i+1] ; + + else if(argument == "-run" && argc>=i+1 ) fRunToReadFileName = argv[i+1] ; + + else if(argument == "-cal" && argc>=i+1 ) fCalibrationFileName = argv[i+1] ; + + else ; + } + + } + +/////////////////////////////////////////////////// +void NPOptionManager::DisplayHelp() + { + cout << "----NPOptionManager Help----" << endl ; + cout << "List of Option " << endl ; + cout << "\t -C <arg>\t \t \t \t \t Set arg as the detector configuration file" << endl ; + cout << "\t -cal <arg>\t \t \t \t \t Set arg as the calibration file list" << endl ; + cout << "\t -H -h -help\t \t \t \t \t Display this help message" << endl ; + cout << "\t -O <arg>\t \t \t \t \t Set arg as the Output File Name (output tree)" << endl ; + cout << "\t -run <arg>\t \t \t \t \t Set arg as the run to read file list" << endl ; + cout << endl << endl ; + } diff --git a/NPLib/Tools/NPOptionManager.h b/NPLib/Tools/NPOptionManager.h new file mode 100644 index 0000000000000000000000000000000000000000..1c638a3e4b2842aac107470fc0164a8a8bd11c0e --- /dev/null +++ b/NPLib/Tools/NPOptionManager.h @@ -0,0 +1,80 @@ +#ifndef NPOPTIONMANAGER_HH +#define NPOPTIONMANAGER_HH + +/***************************************************************************** + * Copyright (C) 2009-2010 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: A. MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : 21/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is a singleton class which deals with input * + * arguments of the different NPTool programm (NPS and NPA) * + *---------------------------------------------------------------------------* + * Comment: The singleton form allow users to call the object from anywhere * + * in the code * + * * + * * + *****************************************************************************/ + +// STL headers +#include <iostream> +#include <string> +using namespace std; + +class NPOptionManager + { + public: + // The analysis class is designed to be a singleton (i.e. only one instance + // can exist). A member function called Instance is defined, which allows + // the user to get a pointer to the existing instance or to create it if + // it does not yet exist: + // (see the constructor for an explanation of the arguments) + static NPOptionManager* getInstance(int argc=0,char** argv=NULL); + + // The analysis class instance can be deleted by calling the Destroy + // method (NOTE: The class destructor is protected, and can thus not be + // called directly): + static void Destroy(); + + protected: + // Constructor (protected) + NPOptionManager(int argc,char** argv); + + // Destructor (protected) + ~NPOptionManager() {}; + + // Prevent copying + NPOptionManager(const NPOptionManager& only); + const NPOptionManager& operator=(const NPOptionManager& only); + + private: + // The static instance of the NPOptionManager class: + static NPOptionManager* instance; + + private: + void DisplayHelp(); + + public: + string GetReactionFilePath() { return fReactionFileName ; } ; + string GetDetectorFilePath() { return fDetectorFileName ; } ; + string GetRunToReadFilePath() { return fRunToReadFileName ; } ; + string GetCalibrationFilePath() { return fCalibrationFileName ; } ; + string GetOutputFilePath() { return fOutputFileName ; } ; + + private: + string fReactionFileName ; + string fDetectorFileName ; + string fRunToReadFileName ; + string fCalibrationFileName ; + string fOutputFileName ; + + }; + +#endif diff --git a/NPLib/liblist b/NPLib/liblist index 166329173f1d2f8d0c4666c1a4504fa0168c639d..a15ada49ab7f45fa317fc0613356c531843c0185 100755 --- a/NPLib/liblist +++ b/NPLib/liblist @@ -1,10 +1,25 @@ -echo -L$NPLIB/lib -lVDetector -lDetectorManager -lCalibrationManager -lIORoot -lReaction -lEnergyLoss -lTagManager\ - -lMust2Data -lMust2Physics \ - -lSSSDData -lSSSDPhysics \ - -lPlasticData -lPlasticPhysics \ - -lAnnularS1Data \ - -lGaspardData -lGaspardPhysics \ - -lDUMMYDetectorData \ - -lParisData -lParisPhysics\ - -lShieldData -lShieldPhysics\ - -lInitialConditions -lInteractionCoordinates +echo -L/home/Adrien/Desktop/NPTool.dev/NPLib/lib \ + -lAnnularS1Data \ + -lCalibrationManager \ + -lDetectorManager \ + -lDUMMYDetectorData \ + -lEnergyLoss \ + -lGaspardData \ + -lGaspardPhysics \ + -lInitialConditions \ + -lInteractionCoordinates \ + -lIORoot \ + -lMust2Data \ + -lMust2Physics \ + -lParisData \ + -lParisPhysics \ + -lPlasticData \ + -lPlasticPhysics \ + -lReaction \ + -lShieldData \ + -lShieldPhysics \ + -lSSSDData \ + -lSSSDPhysics \ + -lTagManager \ + -lOptionManager \ + -lVDetector \