diff --git a/Inputs/DetectorConfiguration/e628.detector b/Inputs/DetectorConfiguration/e628.detector index cada95eea565c463827ddfb020671f11d0d45365..4892f6d01fcd8ec27112d56dd6f62003800a264d 100644 --- a/Inputs/DetectorConfiguration/e628.detector +++ b/Inputs/DetectorConfiguration/e628.detector @@ -76,7 +76,7 @@ VIS= all %%%%%%%%%%%%%%%%%%%%%%%%%%% -TiaraHyball +Tiara TiaraHyballWedge Z= -147 R= 0 diff --git a/NPLib/CMakeLists.txt b/NPLib/CMakeLists.txt index 2c88713bb4bb383a9e9ac19fe4f757e0ea0cb913..38d17a052c2f77322e1a3b127bcc4ecf6b49321c 100644 --- a/NPLib/CMakeLists.txt +++ b/NPLib/CMakeLists.txt @@ -1,9 +1,15 @@ cmake_minimum_required (VERSION 2.8) include("FindROOT.cmake") -project (NPLib) -set (NPLIB_VERSION_MAJOR 2) -set (NPLIB_VERSION_MINOR 0) +project(NPLib) +# Major change in the Core/Physics (affecting the detector/analysis/simulation) +set(NPLIB_VERSION_MAJOR 2) +# Minor change in the Core/Physics (not affecting any other part) +set(NPLIB_VERSION_MINOR 0) +# Change any of the detector in NPA +set(NPLIB_VERSION_DETA 35) + +configure_file(Core/NPLibVersion.h.in Core/NPLibVersion.h @ONLY) set(CMAKE_BUILD_TYPE Release) diff --git a/NPLib/Core/NPLibVersion.h.in b/NPLib/Core/NPLibVersion.h.in new file mode 100644 index 0000000000000000000000000000000000000000..0e483b4c86e4cd2fa12c7931e93a06ace57a6a2f --- /dev/null +++ b/NPLib/Core/NPLibVersion.h.in @@ -0,0 +1,5 @@ +namespace NPL{ + std::string version_major="@NPLIB_VERSION_MAJOR@"; + std::string version_minor="@NPLIB_VERSION_MINOR@"; + std::string version_deta="@NPLIB_VERSION_DETA@"; +} diff --git a/NPLib/Core/NPOptionManager.cxx b/NPLib/Core/NPOptionManager.cxx index 5ce4d18f388da6f30a42b6ab93f6aebbae3bb434..1b41946d4efe91e7232a20d3a296d886b39f3c98 100644 --- a/NPLib/Core/NPOptionManager.cxx +++ b/NPLib/Core/NPOptionManager.cxx @@ -21,7 +21,7 @@ *****************************************************************************/ #include "NPOptionManager.h" - +#include "NPLibVersion.h" #include <fstream> #include <sstream> #include <cstdlib> @@ -125,13 +125,28 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ //else ; } CheckArguments(); + DisplayVersion(); } +//////////////////////////////////////////////////////////////////////////////// +void NPOptionManager::DisplayVersion(){ + if(fVerboseLevel>0){ + string line; + line.resize(80,'*'); + cout << line << endl; + cout << "*********************************** NPTool ***********************************"<< endl; + cout << line << endl; + cout << "NPLib version: nplib-"<< NPL::version_major <<"-" << NPL::version_minor << "-" << NPL::version_deta <<endl; + cout << " Copyright: NPTool Collaboration "<<endl; + cout << " GitHub: http://github.com/adrien-matta/nptool"<<endl; ; + cout << line << endl; - + } +} +//////////////////////////////////////////////////////////////////////////////// NPOptionManager::NPOptionManager(int argc, char** argv){ ReadTheInputArgument(argc,argv); } - +//////////////////////////////////////////////////////////////////////////////// NPOptionManager::NPOptionManager(string arg) { vector<char *> args; @@ -283,6 +298,7 @@ void NPOptionManager::SendErrorAndExit(const char* type) const{ //////////////////////////////////////////////////////////////////////////////// void NPOptionManager::DisplayHelp(){ + DisplayVersion(); cout << endl << "----NPOptionManager Help----" << endl << endl ; cout << "List of Option " << endl ; cout << "\t --help -H -h\t \t \t \tDisplay this help message" << endl ; diff --git a/NPLib/Core/NPOptionManager.h b/NPLib/Core/NPOptionManager.h index fa3b6a20536fa4f6d354654c0ebb2396db108481..599fae3e2d53045c9adead830db51332dad95dd3 100644 --- a/NPLib/Core/NPOptionManager.h +++ b/NPLib/Core/NPOptionManager.h @@ -67,6 +67,7 @@ class NPOptionManager{ private: void DisplayHelp(); + void DisplayVersion(); void CheckArguments(); void CheckEventGenerator(); void CheckDetectorConfiguration(); diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.cxx b/NPLib/Tiara/TTiaraBarrelPhysics.cxx index 67dd8ccbc4974901452a716680726b91d5f5dc07..af95b28f031ec5e7ad49f197c7c6d0c3c4f5f487 100644 --- a/NPLib/Tiara/TTiaraBarrelPhysics.cxx +++ b/NPLib/Tiara/TTiaraBarrelPhysics.cxx @@ -733,8 +733,8 @@ for(unsigned int k = 0 ; k < sizeB ; k++){ class brlproxy{ public: brlproxy(){ - NPA::DetectorFactory::getInstance()->AddToken("TiaraInnerBarrel=","Tiara"); - NPA::DetectorFactory::getInstance()->AddDetector("TiaraInnerBarrel=",TTiaraBarrelPhysics::Construct); + NPA::DetectorFactory::getInstance()->AddToken("Tiara","Tiara"); + NPA::DetectorFactory::getInstance()->AddDetector("Tiara",TTiaraBarrelPhysics::Construct); } }; diff --git a/NPLib/Tiara/TTiaraHyballPhysics.cxx b/NPLib/Tiara/TTiaraHyballPhysics.cxx index 55a620cc36fbab676bf5015d352329b2c75819e7..17860efd3373619f8d4db6855d5939ec5de0ef27 100644 --- a/NPLib/Tiara/TTiaraHyballPhysics.cxx +++ b/NPLib/Tiara/TTiaraHyballPhysics.cxx @@ -786,8 +786,8 @@ extern "C"{ class proxy{ public: proxy(){ - NPA::DetectorFactory::getInstance()->AddToken("TiaraHyballWedge","Tiara"); - NPA::DetectorFactory::getInstance()->AddDetector("TiaraHyballWedge",TTiaraHyballPhysics::Construct); + NPA::DetectorFactory::getInstance()->AddToken("Tiara","Tiara"); + NPA::DetectorFactory::getInstance()->AddDetector("Tiara",TTiaraHyballPhysics::Construct); } }; diff --git a/NPSimulation/CMakeLists.txt b/NPSimulation/CMakeLists.txt index b36553acf95c29eccddb9863f8bf914d649a0b68..19d2c83244fc03fb58c6eda9b52687b0ab135483 100644 --- a/NPSimulation/CMakeLists.txt +++ b/NPSimulation/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required (VERSION 2.8) include("../NPLib/FindROOT.cmake") project (NPSimulation) -set (NPSimulation_VERSION_MAJOR 2) -set (NPSimulation_VERSION_MINOR 0) +set (NPSIM_VERSION_MAJOR 2) +set (NPSIM_VERSION_MINOR 0) +set (NPSIM_VERSION_DETS 17) set(CMAKE_BUILD_TYPE Release) @@ -16,6 +17,8 @@ include(${Geant4_USE_FILE}) find_package(NPLib) include(${NPLib_USE_FILE}) +configure_file(Core/NPSimulationVersion.hh.in Core/NPSimulationVersion.hh @ONLY) + set(DETLIST ${NPLib_DETECTOR_LIST}) if("${DETLIST}" MATCHES "") diff --git a/NPSimulation/Core/NPSDetectorFactory.cc b/NPSimulation/Core/NPSDetectorFactory.cc index da823e94def76c8e9bceb828fe614e98587f5eca..dc04247933a3622a096a75fd2b6be55f5b365112 100644 --- a/NPSimulation/Core/NPSDetectorFactory.cc +++ b/NPSimulation/Core/NPSDetectorFactory.cc @@ -85,7 +85,12 @@ NPS::VDetector* DetectorFactory::Construct(std::string Token){ if(m_Construct.find(Token)!=m_Construct.end()) return m_Construct[Token](); - + + // Test for an alternative token + else if(m_TokenAlternative.find(Token)!=m_TokenAlternative.end()){ + return m_Construct[m_TokenAlternative[Token]](); + } + else{ std::cout << "Warning: Detector with Token " << Token << " has no Constructor or no Library" << std::endl; return NULL; @@ -130,3 +135,16 @@ void DetectorFactory::AddToken(std::string Token, std::string LibName){ m_TokenLib[Token] = LibName; } +//////////////////////////////////////////////////////////////////////////////// + void DetectorFactory::AddTokenAlternative(std::string MainToken, std::string TokenAlternative){ + // Make sure the main token exit: + if(m_TokenLib.find(MainToken)==m_TokenLib.end()){ + cout << "\033[1;33m **** ERROR: Cannot add Alternative token " << TokenAlternative << " to main token " + << MainToken << " because main token does not exist\033[0m" << endl ; + exit(1); + } + + else{ + m_TokenAlternative[TokenAlternative] = MainToken; + } + } diff --git a/NPSimulation/Core/NPSDetectorFactory.hh b/NPSimulation/Core/NPSDetectorFactory.hh index 19484638f27699625d62db76f9cd8f4a40bddfa9..85929df1d5bc458a1abe25f9ebb245e083c55156 100644 --- a/NPSimulation/Core/NPSDetectorFactory.hh +++ b/NPSimulation/Core/NPSDetectorFactory.hh @@ -17,6 +17,7 @@ class DetectorFactory{ NPS::VDetector* Construct(std::string Token); void ReadClassList(std::string FileList); void AddToken(std::string Token, std::string LibName); + void AddTokenAlternative(std::string mainToken, std::string Alternative); void AddDetector(std::string Token, ClassDetectorFactoryFn fn); void CreateClassList(string FileName); private: @@ -25,6 +26,8 @@ class DetectorFactory{ std::map<std::string,ClassDetectorFactoryFn> m_Construct; // Map that Match the Token with the Lib to be loaded std::map<std::string,std::string> m_TokenLib; + // Map of alternative token + std::map<std::string,std::string> m_TokenAlternative; }; } #endif diff --git a/NPSimulation/Core/NPSimulationVersion.hh.in b/NPSimulation/Core/NPSimulationVersion.hh.in new file mode 100644 index 0000000000000000000000000000000000000000..c895436376e6f274e9ca3357ccb1e38742895e5a --- /dev/null +++ b/NPSimulation/Core/NPSimulationVersion.hh.in @@ -0,0 +1,5 @@ +namespace NPS{ + std::string version_major="@NPSIM_VERSION_MAJOR@"; + std::string version_minor="@NPSIM_VERSION_MINOR@"; + std::string version_dets="@NPSIM_VERSION_DETS@"; +} diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc index 80823ef42e444fa032bc105684db521ee70603e2..313def029600285bb0052d05e5f3551f98783ef9 100644 --- a/NPSimulation/Simulation.cc +++ b/NPSimulation/Simulation.cc @@ -28,7 +28,7 @@ // NPS headers #include "EventAction.hh" #include "RunAction.hh" - +#include "NPSimulationVersion.hh" //NPL headers #include "NPOptionManager.h" #include "RootOutput.h" @@ -36,6 +36,18 @@ int main(int argc, char** argv){ // Initialize NPOptionManager object NPOptionManager* OptionManager = NPOptionManager::getInstance(argc, argv); + if(OptionManager->GetVerboseLevel() > 0){ + string line; + line.resize(80,'*'); + cout << endl << line << endl; + cout << "******************************** NPSimulation ********************************"<< endl; + cout << line << endl; + cout << "NPSimulation version: npsimulation-"<< NPS::version_major <<"-" << NPS::version_minor << "-" << NPS::version_dets <<endl; + cout << " Copyright: NPTool Collaboration "<<endl; + cout << " GitHub: http://github.com/adrien-matta/nptool"<<endl; ; + cout << line << endl; + } + // Test if input files are found. If not, exit if (OptionManager->IsDefault("EventGenerator")) OptionManager->SendErrorAndExit("EventGenerator"); @@ -68,8 +80,6 @@ int main(int argc, char** argv){ //physListFactory->GetReferencePhysList("QGSP_BERT"); runManager->SetUserInitialization(physicsList); - - PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector); // Initialize Geant4 kernel diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc index 579bff71e135bd42ba6b7d22f9f632f535c8451d..29b69712f7ed1e9c6b7ed0e6c4f12f6610800fa6 100644 --- a/NPSimulation/Tiara/Tiara.cc +++ b/NPSimulation/Tiara/Tiara.cc @@ -874,8 +874,8 @@ extern "C"{ class brlproxy{ public: brlproxy(){ - NPS::DetectorFactory::getInstance()->AddToken("TiaraInnerBarrel=","Tiara"); - NPS::DetectorFactory::getInstance()->AddDetector("TiaraInnerBarrel=",Tiara::Construct); + NPS::DetectorFactory::getInstance()->AddToken("Tiara","Tiara"); + NPS::DetectorFactory::getInstance()->AddDetector("Tiara",Tiara::Construct); } };