diff --git a/Inputs/DetectorConfiguration/Tiara.detector b/Inputs/DetectorConfiguration/Tiara.detector index 53c11b848480fab074a0486ce8e5abc8b0dcc7f3..72b911acab428b3c66d944ea8bd0b587af0c63cc 100644 --- a/Inputs/DetectorConfiguration/Tiara.detector +++ b/Inputs/DetectorConfiguration/Tiara.detector @@ -43,3 +43,4 @@ Tiara Phi= 300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/Inputs/EventGenerator/30Pdp.reaction b/Inputs/EventGenerator/30Pdp.reaction index a67757c17b035bbd47444625a176a7677d8de174..21711e4be4061d069148c9a02d09a4587bd94248 100644 --- a/Inputs/EventGenerator/30Pdp.reaction +++ b/Inputs/EventGenerator/30Pdp.reaction @@ -21,7 +21,7 @@ TwoBodyReaction Heavy= 31P ExcitationEnergyHeavy= 6.3 ExcitationEnergyLight= 0.0 - CrossSectionPath= al25he3d_5.9_2s1.txt CS + CrossSectionPath= flat.txt CS ShootLight= 1 ShootHeavy= 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/NPAnalysis/TAMU/Analysis.cxx b/NPAnalysis/TAMU/Analysis.cxx index 4a856cb0284c91724eb75bdf470fd41e773dbcd0..e307198ae61172e19fac5eba85e225165e16f14e 100644 --- a/NPAnalysis/TAMU/Analysis.cxx +++ b/NPAnalysis/TAMU/Analysis.cxx @@ -50,6 +50,8 @@ void Analysis::Init(){ ThetaTHSurface = 0; ThetaTBSurface = 0; Si_E_TH = 0 ; + Si_E_InnerTB = 0; + Si_E_OuterTB = 0; Si_E_TB = 0 ; Energy = 0; TargetThickness = m_DetectorManager->GetTargetThickness()*micrometer; @@ -88,7 +90,7 @@ void Analysis::TreatEvent(){ ThetaNormalTarget = 0; if(XTarget>-1000 && YTarget>-1000){ TVector3 BeamImpact(XTarget,YTarget,0); - TVector3 HitDirection = TH -> GetPositionOfInteraction(countTiaraHyball) - BeamImpact ; + TVector3 HitDirection = TH -> GetRandomisedPositionOfInteraction(countTiaraHyball) - BeamImpact ; ThetaLab = HitDirection.Angle( BeamDirection ); ThetaTHSurface = HitDirection.Angle(TVector3(0,0,-1) ); ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; @@ -155,7 +157,7 @@ void Analysis::TreatEvent(){ ThetaNormalTarget = 0; if(XTarget>-1000 && YTarget>-1000){ TVector3 BeamImpact(XTarget,YTarget,0); - TVector3 HitDirection = TB -> GetPositionOfInteraction(countTiaraBarrel) - BeamImpact ; + TVector3 HitDirection = TB -> GetRandomisedPositionOfInteraction(countTiaraBarrel) - BeamImpact ; ThetaLab = HitDirection.Angle( BeamDirection ); ThetaTBSurface = HitDirection.Angle(TVector3(0,0,-1) ); ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; @@ -167,10 +169,16 @@ void Analysis::TreatEvent(){ } /************************************************/ - // Part 2 : Impact Energy + // Part 2 : Impact Energy Energy = ELab = 0; - Si_E_TB = TB->Strip_E[countTiaraBarrel]; - Energy = Si_E_TB; + Si_E_InnerTB = TB->Strip_E[countTiaraBarrel]; + if(TB->Outer_Strip_E[countTiaraBarrel] != -1000){ + Si_E_OuterTB = TB->Outer_Strip_E[countTiaraBarrel]; + Energy = Si_E_InnerTB + Si_E_OuterTB; + } + else { + Energy = Si_E_InnerTB; + } // Evaluate energy using the thickness ELab = proton_Al.EvaluateInitialEnergy( Energy ,0.4*micrometer , ThetaTBSurface); diff --git a/NPAnalysis/TAMU/Analysis.h b/NPAnalysis/TAMU/Analysis.h index c5ebecfdd0d2259b67a334a08a070bcaceee4584..0e2d151448a93ce58bb1322df4dda2db38c650b8 100644 --- a/NPAnalysis/TAMU/Analysis.h +++ b/NPAnalysis/TAMU/Analysis.h @@ -75,6 +75,8 @@ class Analysis: public NPA::VAnalysis{ double ThetaTHSurface ; double ThetaTBSurface ; double Si_E_TH ; + double Si_E_InnerTB; + double Si_E_OuterTB; double Si_E_TB ; double Energy ; double TargetThickness ; diff --git a/NPLib/.gitignore b/NPLib/.gitignore index 171aeb0eb400eabdede91bce8df7c0da7862e131..9c5203f63b06f291582445ac21b60a3f33fec02f 100644 --- a/NPLib/.gitignore +++ b/NPLib/.gitignore @@ -7,6 +7,11 @@ bin DetectorClassList.txt Utility/Makefile Utility/npanalysis -Utility/nptool-libmap +Utility/nptool-installer +*.pcm +*Dict* *rootmap* *_rflx.cpp +*.dylib +*.so +*.cmake diff --git a/NPLib/AnnularS2/CMakeLists.txt b/NPLib/AnnularS2/CMakeLists.txt index 66b43584a7df246add6a85699557c453390007f0..eb3d5acc1f265310c268c6a1035aedb304b3c8de 100644 --- a/NPLib/AnnularS2/CMakeLists.txt +++ b/NPLib/AnnularS2/CMakeLists.txt @@ -1,6 +1,6 @@ add_custom_command(OUTPUT TS2PhysicsDict.cxx TS2PhysicsDict_rdict.pcm TS2Physics.rootmap COMMAND ../scripts/build_dict.sh TS2Physics.h TS2PhysicsDict.cxx TS2Physics.rootmap libNPAnnularS2.dylib DEPENDS TS2Physics.h) add_custom_command(OUTPUT TS2DataDict.cxx TS2DataDict_rdict.pcm TS2Data.rootmap COMMAND ../scripts/build_dict.sh TS2Data.h TS2DataDict.cxx TS2Data.rootmap libNPAnnularS2.dylib DEPENDS TS2Data.h) -add_library(NPS2 SHARED TS2Data.cxx TS2Physics.cxx TS2DataDict.cxx TS2PhysicsDict.cxx ) -target_link_libraries(NPS2 ${ROOT_LIBRARIES} NPCore) +add_library(NPAnnularS2 SHARED TS2Data.cxx TS2Physics.cxx TS2DataDict.cxx TS2PhysicsDict.cxx ) +target_link_libraries(NPAnnularS2 ${ROOT_LIBRARIES} NPCore) install(FILES TS2Data.h TS2Physics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/CMakeLists.txt b/NPLib/CMakeLists.txt index a970430a09459ab19cb5345c3bf655252d98d288..2c88713bb4bb383a9e9ac19fe4f757e0ea0cb913 100644 --- a/NPLib/CMakeLists.txt +++ b/NPLib/CMakeLists.txt @@ -71,17 +71,23 @@ ENDMACRO() # Call the Macro subdirlist(SUB_DIRECTORY ${CMAKE_BINARY_DIR}) set(SUB_DIRECTORY ${SUB_DIRECTORY} Core Physics InitialConditions InteractionCoordinates Utility) -# Add each folder in the include path -#foreach(subdir ${SUB_DIRECTORY}) -# # Allow inclusion of project headers -# include_directories(${subdir}) -#endforeach() include_directories("Core/") # Add each sub folder to the project +set(TARGET_LIST "") foreach(subdir ${SUB_DIRECTORY}) # add the subdirectory - add_subdirectory(${subdir}) + add_subdirectory(${subdir}) + string(COMPARE EQUAL "${subdir}" "Utility" r0) + if(NOT r0) + LIST(APPEND TARGET_LIST NP${subdir}) + endif() endforeach() +export(TARGETS ${TARGET_LIST} FILE NPLibTargets.cmake) +export(PACKAGE NPLib) +file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" "${CMAKE_INCLUDE_OUTPUT_DIRECTORY}") +set(CONF_INCLUDE_DIRS "./" "./") +configure_file(NPLibConfig.cmake.in "${PROJECT_BINARY_DIR}/NPLibConfig.cmake" @ONLY) + install(SCRIPT scripts/post_install.cmake ${DETLIST}) diff --git a/NPLib/Core/NPOptionManager.cxx b/NPLib/Core/NPOptionManager.cxx index 50e1a1f3122edf34f7cc7a5b40d4dcc3acd547bf..5ce4d18f388da6f30a42b6ab93f6aebbae3bb434 100644 --- a/NPLib/Core/NPOptionManager.cxx +++ b/NPLib/Core/NPOptionManager.cxx @@ -32,13 +32,13 @@ NPOptionManager* NPOptionManager::instance = 0 ; //////////////////////////////////////////////////////////////////////////////// NPOptionManager* NPOptionManager::getInstance(int argc, char** argv){ if (instance == 0) instance = new NPOptionManager(argc, argv); - + return instance ; } //////////////////////////////////////////////////////////////////////////////// NPOptionManager* NPOptionManager::getInstance(string arg){ - + if (instance == 0) instance = new NPOptionManager(arg); return instance ; @@ -49,12 +49,14 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ fDefaultReactionFileName = "defaultReaction.reaction"; fDefaultDetectorFileName = "defaultDetector.detector"; fDefaultOutputFileName = "myResult.root"; + fDefaultOutputTreeName = "NPTool_Tree"; fDefaultRunToReadFileName = "defaultRunToTreat.txt"; fDefaultCalibrationFileName = "defaultCalibration.txt"; // Assigned values fReactionFileName = fDefaultReactionFileName; fDetectorFileName = fDefaultDetectorFileName; fOutputFileName = fDefaultOutputFileName; + fOutputTreeName = fDefaultOutputTreeName; fRunToReadFileName = fDefaultRunToReadFileName; fCalibrationFileName = fDefaultCalibrationFileName; fVerboseLevel = 1; @@ -63,43 +65,45 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ fInputPhysicalTreeOption = false; fGenerateHistoOption = false ; fPROOFMode = false; - + for (int i = 0; i < argc; i++) { string argument = argv[i]; if (argument == "-H" || argument == "-h" || argument == "--help") DisplayHelp(); - + else if (argument == "--event-generator" && argc >= i + 1) fReactionFileName = argv[++i] ; - + else if (argument == "-E" && argc >= i + 1) fReactionFileName = argv[++i] ; - + else if (argument == "--detector" && argc >= i + 1) fDetectorFileName = argv[++i] ; - + else if (argument == "-D" && argc >= i + 1) fDetectorFileName = argv[++i] ; - + else if (argument == "--output" && argc >= i + 1) fOutputFileName = argv[++i] ; - + else if (argument == "-O" && argc >= i + 1) fOutputFileName = argv[++i] ; - + + else if (argument == "--tree-name" && argc >= i + 1) fOutputTreeName = argv[++i] ; + else if (argument == "--run" && argc >= i + 1) fRunToReadFileName = argv[++i] ; - + else if (argument == "-R" && argc >= i + 1) fRunToReadFileName = argv[++i] ; - + else if (argument == "--cal" && argc >= i + 1) fCalibrationFileName = argv[++i] ; - + else if (argument == "-C" && argc >= i + 1) fCalibrationFileName = argv[++i] ; - + else if (argument == "-V" && argc >= i + 1) fVerboseLevel = atoi(argv[++i]) ; - + else if (argument == "--verbose" && argc >= i + 1) fVerboseLevel = atoi(argv[++i]) ; - + else if (argument == "--disable-branch") fDisableAllBranchOption = true ; - + else if (argument == "--input-physical") fInputPhysicalTreeOption = true ; - + else if (argument == "-IP") fInputPhysicalTreeOption = true ; - + else if (argument == "-GH") fGenerateHistoOption = true ; - + else if (argument == "-CH") fCheckHistoOption = true ; else if (argument == "-check-histo") fCheckHistoOption = true ; @@ -107,8 +111,17 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ else if (argument == "--generate-histo") fGenerateHistoOption = true ; else if (argument == "--proof") fPROOFMode = true ; - - else if (argument == "-L") fNumberOfEntryToAnalyse= atoi(argv[++i]) ; + + else if (argument == "-L") fNumberOfEntryToAnalyse = atoi(argv[++i]) ; + + else if (argument == "--last-sim") fLastSimFile = true ; + + else if (argument == "--last-phy") fLastPhyFile = true ; + + else if (argument == "--last-res") fLastResFile = true ; + + else if (argument == "--last-any") fLastAnyFile = true ; + //else ; } CheckArguments(); @@ -132,12 +145,12 @@ NPOptionManager::NPOptionManager(string arg) args.push_back(arg); } args.push_back(0); - + ReadTheInputArgument(args.size()-1, &args[0]); for(size_t i = 0; i < args.size(); i++) delete[] args[i]; - + } //////////////////////////////////////////////////////////////////////////////// void NPOptionManager::CheckArguments(){ @@ -148,14 +161,14 @@ void NPOptionManager::CheckArguments(){ //////////////////////////////////////////////////////////////////////////////// void NPOptionManager::CheckEventGenerator(){ bool checkFile = true; - + // NPTool path string GlobalPath = getenv("NPTOOL"); string StandardPath = GlobalPath + "/Inputs/EventGenerator/" + fReactionFileName; - + // ifstream to configfile ifstream ConfigFile; - + // test if config file is in local path ConfigFile.open(fReactionFileName.c_str()); if (!ConfigFile.is_open()) { @@ -170,7 +183,7 @@ void NPOptionManager::CheckEventGenerator(){ if (!checkFile && fReactionFileName != fDefaultReactionFileName) { // if file does not exist SendErrorAndExit("EventGenerator"); } - + // close ConfigFile ConfigFile.close(); } @@ -178,14 +191,14 @@ void NPOptionManager::CheckEventGenerator(){ //////////////////////////////////////////////////////////////////////////////// void NPOptionManager::CheckDetectorConfiguration(){ bool checkFile = true; - + // NPTool path string GlobalPath = getenv("NPTOOL"); string StandardPath = GlobalPath + "/Inputs/DetectorConfiguration/" + fDetectorFileName; - + // ifstream to configfile ifstream ConfigFile; - + // test if config file is in local path ConfigFile.open(fDetectorFileName.c_str()); if (!ConfigFile.is_open()) { @@ -200,7 +213,7 @@ void NPOptionManager::CheckDetectorConfiguration(){ if (!checkFile && fDetectorFileName != fDefaultDetectorFileName) { // if file does not exist SendErrorAndExit("DetectorConfiguration"); } - + // close ConfigFile ConfigFile.close(); } @@ -210,7 +223,7 @@ void NPOptionManager::CheckDetectorConfiguration(){ // This method tests if the input files are the default ones bool NPOptionManager::IsDefault(const char* type) const{ bool result = false; - + string stype = type; if (stype == "EventGenerator") { if (fReactionFileName == fDefaultReactionFileName) result = true; @@ -224,10 +237,16 @@ bool NPOptionManager::IsDefault(const char* type) const{ else if (stype == "RunToTreat") { if (fRunToReadFileName == fDefaultRunToReadFileName) result = true; } + else if (stype == "OutputFileName") { + if (fOutputFileName == fDefaultOutputFileName) result = true; + } + else if (stype == "TreeName") { + if (fOutputTreeName == fDefaultOutputTreeName) result = true; + } else { cout << "NPOptionManager::IsDefault() unkwown keyword" << endl; } - + return result; } @@ -266,21 +285,26 @@ void NPOptionManager::SendErrorAndExit(const char* type) const{ void NPOptionManager::DisplayHelp(){ cout << endl << "----NPOptionManager Help----" << endl << endl ; cout << "List of Option " << endl ; - cout << "\t --help -H -h\t \t \t \t \t \t \t Display this help message" << endl ; - cout << "\t --detector -D <arg>\t \t \t \t \t \t Set arg as the detector configuration file" << endl ; - cout << "\t --event-generator -E <arg>\t \t \t \t \t Set arg as the event generator file" << endl ; - cout << "\t --output -O <arg>\t \t \t \t \t \t Set arg as the Output File Name (output tree)" << endl ; - cout << "\t --verbose -V <arg>\t \t \t \t \t \t Set the verbose level of some of the object, 0 for nothing, 1 for normal printout. Error and warning are not affected" << endl ; + cout << "\t --help -H -h\t \t \t \tDisplay this help message" << endl ; + cout << "\t --detector -D <arg>\t \t \tSet arg as the detector configuration file" << endl ; + cout << "\t --event-generator -E <arg>\t \tSet arg as the event generator file" << endl ; + cout << "\t --output -O <arg>\t \t \tSet arg as the Output File Name (output tree)" << endl ; + cout << "\t --tree-name <arg>\t \t \tSet arg as the Output Tree Name " << endl ; + cout << "\t --verbose -V <arg>\t \t \tSet the verbose level of some of the object, 0 for nothing, 1 for normal printout. Error and warning are not affected" << endl ; cout << endl << "NPAnalysis only:"<<endl; - cout << "\t --run -R <arg>\t \t \t \t \t \t \t Set arg as the run to read file list" << endl ; - cout << "\t --cal -C <arg>\t \t \t \t \t \t \t Set arg as the calibration file list" << endl ; - cout << "\t --disable-branch\t \t \t \t \t \t Disable of branch of Input tree except the one of the detector (faster)" << endl ; - cout << "\t --generate-histo -GH\t \t \t \t \t \t Instantiate the T*Spectra class of each detector" << endl ; - cout << "\t --check-histo -CH\t \t \t \t \t \t Check if the Histogram looks ok and change there color if not" << endl ; - cout << "\t --input-physical -IP\t \t \t \t \t \t Consider the Input file is containing Physics Class instead of Data Class. Output branches associate to the detector are not activated" << endl ; - cout << "\t -L <arg>\t \t \t \t \t \t Limite the number of envent to be analysed to arg" << endl ; + cout << "\t --run -R <arg>\t \t \t \tSet arg as the run to read file list" << endl ; + cout << "\t --cal -C <arg>\t \t \t \tSet arg as the calibration file list" << endl ; + cout << "\t --disable-branch\t \t \tDisable of branch of Input tree except the one of the detector (faster)" << endl ; + cout << "\t --generate-histo -GH\t \t \tInstantiate the T*Spectra class of each detector" << endl ; + cout << "\t --check-histo -CH\t \t \tCheck if the Histogram looks ok and change there color if not" << endl ; + cout << "\t --input-physical -IP\t \t \tConsider the Input file is containing Physics Class instead of Data Class. Output branches associate to the detector are not activated" << endl ; + cout << "\t -L <arg>\t \t \t \tLimite the number of envent to be analysed to arg" << endl ; + cout << "\t --last-sim\t \t \t \tIgnore the list of Run to treat if any and analysed the last simulated file" << endl ; + cout << "\t --last-phy\t \t \t \tIgnore the list of Run to treat if any and analysed the last Physics file" << endl ; + cout << "\t --last-res\t \t \t \tIgnore the list of Run to treat if any and analysed the last Result file" << endl ; + cout << "\t --last-any\t \t \t \tIgnore the list of Run to treat if any and analysed the last root file with a non standard Tree name" << endl ; cout << endl << endl ; - + // exit current program exit(1); } @@ -293,4 +317,22 @@ void NPOptionManager::Destroy(){ instance = 0; } } +//////////////////////////////////////////////////////////////////////////////// +string NPOptionManager::GetLastFile(){ + string path = getenv("NPTOOL"); + if(fLastSimFile) + return (path+"/.last_sim_file"); + + else if(fLastPhyFile) + return (path+"/.last_phy_file"); + + else if(fLastResFile) + return (path+"/.last_res_file"); + else if(fLastAnyFile) + return (path+"/.last_any_file"); + + else + return "VOID"; + +} diff --git a/NPLib/Core/NPOptionManager.h b/NPLib/Core/NPOptionManager.h index 62239fd8508fa45597d0aa9ef8d737f3fd6fe475..fa3b6a20536fa4f6d354654c0ebb2396db108481 100644 --- a/NPLib/Core/NPOptionManager.h +++ b/NPLib/Core/NPOptionManager.h @@ -28,8 +28,7 @@ #include <string> using namespace std; -class NPOptionManager -{ +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 @@ -90,6 +89,7 @@ class NPOptionManager string GetRunToReadFile() {return fRunToReadFileName;} string GetCalibrationFile() {return fCalibrationFileName;} string GetOutputFile() {return fOutputFileName;} + string GetOutputTreeName() {return fOutputTreeName;} bool GetDisableAllBranchOption() {return fDisableAllBranchOption;} bool GetInputPhysicalTreeOption() {return fInputPhysicalTreeOption;} bool GetGenerateHistoOption() {return fGenerateHistoOption;} @@ -97,7 +97,8 @@ class NPOptionManager bool GetPROOF() {return fPROOFMode;} int GetVerboseLevel() {return fVerboseLevel;} int GetNumberOfEntryToAnalyse() {return fNumberOfEntryToAnalyse;} - + string GetLastFile(); + // Setters void SetReactionFile(string name) {fReactionFileName = name;CheckEventGenerator();} void SetDetectorFile(string name) {fDetectorFileName = name;CheckDetectorConfiguration();} @@ -111,17 +112,23 @@ class NPOptionManager string fDefaultRunToReadFileName; string fDefaultCalibrationFileName; string fDefaultOutputFileName; + string fDefaultOutputTreeName; // assigned values string fReactionFileName; string fDetectorFileName; string fRunToReadFileName; string fCalibrationFileName; string fOutputFileName; + string fOutputTreeName; bool fDisableAllBranchOption; bool fInputPhysicalTreeOption; bool fGenerateHistoOption; bool fCheckHistoOption; bool fPROOFMode; // if true, the system run in a pROOF environment + bool fLastSimFile; + bool fLastPhyFile; + bool fLastResFile; + bool fLastAnyFile; int fVerboseLevel; // 0 for not talk, 1 for talking int fNumberOfEntryToAnalyse; // use to limit the number of analysed in NPA }; diff --git a/NPLib/Core/RootInput.cxx b/NPLib/Core/RootInput.cxx index 227c58d8ce4b270405a27168b6985273efccb6de..dc6f7c38cfdc6a8306eff2e43711ef51475adc89 100644 --- a/NPLib/Core/RootInput.cxx +++ b/NPLib/Core/RootInput.cxx @@ -29,7 +29,7 @@ #include "RootInput.h" #include "TAsciiFile.h" - +#include "NPOptionManager.h" #include "TEnv.h" RootInput* RootInput::instance = 0; //////////////////////////////////////////////////////////////////////////////// @@ -53,11 +53,16 @@ void RootInput::Destroy(){ //////////////////////////////////////////////////////////////////////////////// RootInput::RootInput(string configFileName){ + string lastfile= NPOptionManager::getInstance()->GetLastFile(); + if(lastfile!="VOID"){ + configFileName = lastfile; + } + // Setting Root Parameter gEnv->SetValue("TFile.AsyncPrefetching", 1); gEnv->SetValue("TTreeCache.Size",300000000); gEnv->SetValue("TTreeCache.Prefill",1); - + NumberOfFriend = 0; bool CheckTreeName = false; bool CheckRootFileName = false; @@ -66,20 +71,21 @@ RootInput::RootInput(string configFileName){ string lineBuffer, dataBuffer; // Open file + cout << endl; + cout << "/////////// ROOT Input files ///////////" << endl; + cout << "Initializing input TChain" << endl; + ifstream inputConfigFile; inputConfigFile.open(configFileName.c_str()); pRootFile = NULL; pRootChain = new TChain(); - cout << endl; - cout << "/////////// ROOT Input files ///////////" << endl; - cout << "Initializing input TChain" << endl; - - if (!inputConfigFile) { + if (!inputConfigFile.is_open()) { cout << "\033[1;31mError : Run to Read file :" << configFileName << " not found\033[0m" << endl; exit(1); } + else { while (!inputConfigFile.eof()) { getline(inputConfigFile, lineBuffer); @@ -92,23 +98,24 @@ RootInput::RootInput(string configFileName){ CheckTreeName = true ; // If the tree come from a simulation, the InteractionCoordinates // and InitialConditions lib are loaded - + if(dataBuffer=="SimulatedTree"){ #ifdef __linux__ - std::string SHARED_LIB_EXTENSION = ".so"; + std::string SHARED_LIB_EXTENSION = ".so"; #endif #ifdef __FreeBSD__ - std::string SHARED_LIB_EXTENSION = ".so"; + std::string SHARED_LIB_EXTENSION = ".so"; #endif #ifdef __APPLE__ - std::string SHARED_LIB_EXTENSION = ".dylib"; + std::string SHARED_LIB_EXTENSION = ".dylib"; #endif - string libName="libNPInteractionCoordinates"+SHARED_LIB_EXTENSION; - dlopen(libName.c_str(),RTLD_NOW); - libName="libNPInitialConditions"+SHARED_LIB_EXTENSION; - dlopen(libName.c_str(),RTLD_NOW); + string libName="libNPInteractionCoordinates"+SHARED_LIB_EXTENSION; + dlopen(libName.c_str(),RTLD_NOW); + libName="libNPInitialConditions"+SHARED_LIB_EXTENSION; + dlopen(libName.c_str(),RTLD_NOW); + } } // search for token giving the list of Root files to treat @@ -117,7 +124,7 @@ RootInput::RootInput(string configFileName){ while (!inputConfigFile.eof()) { inputConfigFile >> dataBuffer; - + // ignore comment Line if (dataBuffer.compare(0, 1, "%") == 0) { inputConfigFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); @@ -132,7 +139,7 @@ RootInput::RootInput(string configFileName){ } } if( pRootChain->GetEntries() ==0){ - cout << "\033[1;31m ERROR: No entries to analyse\033[0m" << endl; + cout << "\033[1;31m**** ERROR: No entries to analyse ****\033[0m" << endl; exit(1); } else{ @@ -143,7 +150,7 @@ RootInput::RootInput(string configFileName){ if (!CheckRootFileName || !CheckTreeName) cout << "\033[1;33mWARNING: Token not found for InputTree Declaration : Input Tree may not be instantiate properly\033[0m" << endl; - + } //////////////////////////////////////////////////////////////////////////////// diff --git a/NPLib/Core/RootOutput.cxx b/NPLib/Core/RootOutput.cxx index 2a6fe26ac4430c28442f943b5c826b8bf78e1bee..eb75feaea6f63dc103a0930e999c6834e42f77cf 100644 --- a/NPLib/Core/RootOutput.cxx +++ b/NPLib/Core/RootOutput.cxx @@ -21,6 +21,7 @@ *****************************************************************************/ #include <iostream> +#include <fstream> #include <cstdlib> #include "RootOutput.h" @@ -31,49 +32,95 @@ using namespace std; RootOutput* RootOutput::instance = 0; //////////////////////////////////////////////////////////////////////////////// RootOutput* RootOutput::getInstance(TString fileNameBase, TString treeNameBase){ - // A new instance of RootOutput is created if it does not exist: - if (instance == 0) { - instance = new RootOutput(fileNameBase, treeNameBase); - } + // A new instance of RootOutput is created if it does not exist: + if (instance == 0) { + instance = new RootOutput(fileNameBase, treeNameBase); + } - // The instance of RootOutput is returned: - return instance; + // The instance of RootOutput is returned: + return instance; } //////////////////////////////////////////////////////////////////////////////// void RootOutput::Destroy(){ - if (instance != 0) { - delete instance; - instance = 0; - } + if (instance != 0) { + delete instance; + instance = 0; + } } //////////////////////////////////////////////////////////////////////////////// -RootOutput::RootOutput(TString fileNameBase, TString treeNameBase) -{ - TDirectory* currentPath= gDirectory; +RootOutput::RootOutput(TString fileNameBase, TString treeNameBase){ + TDirectory* currentPath= gDirectory; - // The file extension is added to the file name: - TString GlobalPath = getenv("NPTOOL"); - + // The file extension is added to the file name: + TString GlobalPath = getenv("NPTOOL"); - // The ROOT file is created + // The ROOT file is created if(!NPOptionManager::getInstance()->GetPROOF()){ TString fileName = GlobalPath + "/Outputs/"; if (fileNameBase.Contains("root")) fileName += fileNameBase; else fileName += fileNameBase + ".root"; - - pRootFile = new TFile(fileName, "RECREATE"); - } + + pRootFile = new TFile(fileName, "RECREATE"); + + if(treeNameBase=="SimulatedTree"){ + string path = getenv("NPTOOL"); + path+="/.last_sim_file"; + ofstream last_sim_file(path.c_str()); + last_sim_file << "TTreeName" << endl + << " " << treeNameBase <<endl + << "RootFileName" <<endl + << " " << fileName<<endl; + last_sim_file.close(); + } + + else if(treeNameBase=="PhysicsTree"){ + string path = getenv("NPTOOL"); + path+="/.last_phy_file"; + ofstream last_phy_file(path.c_str()); + last_phy_file << "TTreeName" << endl + << " " << treeNameBase <<endl + << "RootFileName" <<endl + << " " << fileName<<endl; + last_phy_file.close(); + } + + + else if(treeNameBase=="ResultTree"){ + string path = getenv("NPTOOL"); + path+="/.last_res_file"; + ofstream last_res_file(path.c_str()); + last_res_file << "TTreeName" << endl + << " " << treeNameBase <<endl + << "RootFileName" <<endl + << " " << fileName<<endl; + last_res_file.close(); + } + else{ + string path = getenv("NPTOOL"); + path+="/.last_any_file"; + ofstream last_any_file(path.c_str()); + last_any_file << "TTreeName" << endl + << " " << treeNameBase <<endl + << "RootFileName" <<endl + << " " << fileName << endl; + last_any_file.close(); + } + + + + } + else{ // the file path must be the current directory // Does not create the Output file at instantiation pRootFile = 0 ; } - + pRootTree = new TTree(treeNameBase, "Data created / analysed with the NPTool package"); pRootList = new TList(); - + // Init TAsciiFile objects InitAsciiFiles(); gDirectory->cd(currentPath->GetPath()); @@ -85,99 +132,97 @@ RootOutput::RootOutput(TString fileNameBase, TString treeNameBase) //////////////////////////////////////////////////////////////////////////////// -void RootOutput::InitAsciiFiles() -{ - // get NPOptionManager pointer - NPOptionManager* OptionManager = NPOptionManager::getInstance(); - - // Event generator - // Get file name from NPOptionManager - TString fileNameEG = OptionManager->GetReactionFile(); - pEventGenerator = new TAsciiFile(); - pEventGenerator->SetNameTitle("EventGenerator", fileNameEG.Data()); - pEventGenerator->Append(fileNameEG.Data()); - - // Detector configuration - // Get file name from NPOptionManager - TString fileNameDC = OptionManager->GetDetectorFile(); - pDetectorConfiguration = new TAsciiFile(); - pDetectorConfiguration->SetNameTitle("DetectorConfiguration", fileNameDC.Data()); - pDetectorConfiguration->Append(fileNameDC.Data()); - - // Run to treat file - // Get file name from NPOptionManager - pRunToTreatFile = new TAsciiFile(); - if (!OptionManager->IsDefault("RunToTreat")) { - TString fileNameRT = OptionManager->GetRunToReadFile(); - pRunToTreatFile->SetNameTitle("RunToTreat", fileNameRT.Data()); - pRunToTreatFile->Append(fileNameRT.Data()); - } - - // Calibration files - pCalibrationFile = new TAsciiFile(); - if (!OptionManager->IsDefault("Calibration")) { - TString fileNameCal = OptionManager->GetCalibrationFile(); - pCalibrationFile->SetNameTitle("Calibration", fileNameCal.Data()); - } - - // Analysis configuration files - pAnalysisConfigFile = new TAsciiFile(); - pAnalysisConfigFile->SetNameTitle("AnalysisConfig", "AnalysisConfig"); +void RootOutput::InitAsciiFiles(){ + // get NPOptionManager pointer + NPOptionManager* OptionManager = NPOptionManager::getInstance(); + + // Event generator + // Get file name from NPOptionManager + TString fileNameEG = OptionManager->GetReactionFile(); + pEventGenerator = new TAsciiFile(); + pEventGenerator->SetNameTitle("EventGenerator", fileNameEG.Data()); + pEventGenerator->Append(fileNameEG.Data()); + + // Detector configuration + // Get file name from NPOptionManager + TString fileNameDC = OptionManager->GetDetectorFile(); + pDetectorConfiguration = new TAsciiFile(); + pDetectorConfiguration->SetNameTitle("DetectorConfiguration", fileNameDC.Data()); + pDetectorConfiguration->Append(fileNameDC.Data()); + + // Run to treat file + // Get file name from NPOptionManager + pRunToTreatFile = new TAsciiFile(); + if (!OptionManager->IsDefault("RunToTreat")) { + TString fileNameRT = OptionManager->GetRunToReadFile(); + pRunToTreatFile->SetNameTitle("RunToTreat", fileNameRT.Data()); + pRunToTreatFile->Append(fileNameRT.Data()); + } + + // Calibration files + pCalibrationFile = new TAsciiFile(); + if (!OptionManager->IsDefault("Calibration")) { + TString fileNameCal = OptionManager->GetCalibrationFile(); + pCalibrationFile->SetNameTitle("Calibration", fileNameCal.Data()); + } + + // Analysis configuration files + pAnalysisConfigFile = new TAsciiFile(); + pAnalysisConfigFile->SetNameTitle("AnalysisConfig", "AnalysisConfig"); } +//////////////////////////////////////////////////////////////////////////////// +RootOutput::~RootOutput(){ + // The data is written to the file and the tree is closed: + if (pRootFile && !NPOptionManager::getInstance()->GetPROOF()) { + TDirectory* currentPath= gDirectory; + gDirectory->cd(pRootFile->GetPath()); + cout << endl; + cout << endl << "Root Output summary" << endl; + cout << " - Number of entries in the Tree: " << pRootTree->GetEntries() << endl; + cout << " - Number of bites written to file: " << pRootTree->Write("", TObject::kOverwrite) << endl; + + // write TAsciiFile if used + // EventGenerator + if (!pEventGenerator->IsEmpty()) pEventGenerator->Write(); + // DetectorConfiguration + if (!pDetectorConfiguration->IsEmpty()) pDetectorConfiguration->Write(); + // CalibrationFile + if (!pCalibrationFile->IsEmpty()) pCalibrationFile->Write(); + // RunToTreatFile + if (!pRunToTreatFile->IsEmpty()) pRunToTreatFile->Write(); + // Analysis ConfigFile + if (!pAnalysisConfigFile->IsEmpty()) pAnalysisConfigFile->Write(); + pRootFile->Flush(); + gDirectory->cd(currentPath->GetPath()); + pRootFile->Close(); + } -RootOutput::~RootOutput() -{ - // The data is written to the file and the tree is closed: - if (pRootFile && !NPOptionManager::getInstance()->GetPROOF()) { - TDirectory* currentPath= gDirectory; - gDirectory->cd(pRootFile->GetPath()); - cout << endl; - cout << endl << "Root Output summary" << endl; - cout << " - Number of entries in the Tree: " << pRootTree->GetEntries() << endl; - cout << " - Number of bites written to file: " << pRootTree->Write("", TObject::kOverwrite) << endl; - - // write TAsciiFile if used - // EventGenerator - if (!pEventGenerator->IsEmpty()) pEventGenerator->Write(); - // DetectorConfiguration - if (!pDetectorConfiguration->IsEmpty()) pDetectorConfiguration->Write(); - // CalibrationFile - if (!pCalibrationFile->IsEmpty()) pCalibrationFile->Write(); - // RunToTreatFile - if (!pRunToTreatFile->IsEmpty()) pRunToTreatFile->Write(); - // Analysis ConfigFile - if (!pAnalysisConfigFile->IsEmpty()) pAnalysisConfigFile->Write(); - pRootFile->Flush(); - gDirectory->cd(currentPath->GetPath()); - pRootFile->Close(); - } - - else if (pRootFile && NPOptionManager::getInstance()->GetPROOF()){ - if (!pEventGenerator->IsEmpty()) pEventGenerator->Write(); - // DetectorConfiguration - if (!pDetectorConfiguration->IsEmpty()) pDetectorConfiguration->Write(); - // CalibrationFile - if (!pCalibrationFile->IsEmpty()) pCalibrationFile->Write(); - // RunToTreatFile - if (!pRunToTreatFile->IsEmpty()) pRunToTreatFile->Write(); - // Analysis ConfigFile - if (!pAnalysisConfigFile->IsEmpty()) pAnalysisConfigFile->Write(); - } - - else if(!pRootFile && NPOptionManager::getInstance()->GetPROOF()){ - - } - - else { - cout << "\033[1;31mNo histograms and Tree !\033[0m" << endl; - } + else if (pRootFile && NPOptionManager::getInstance()->GetPROOF()){ + if (!pEventGenerator->IsEmpty()) pEventGenerator->Write(); + // DetectorConfiguration + if (!pDetectorConfiguration->IsEmpty()) pDetectorConfiguration->Write(); + // CalibrationFile + if (!pCalibrationFile->IsEmpty()) pCalibrationFile->Write(); + // RunToTreatFile + if (!pRunToTreatFile->IsEmpty()) pRunToTreatFile->Write(); + // Analysis ConfigFile + if (!pAnalysisConfigFile->IsEmpty()) pAnalysisConfigFile->Write(); + } + + else if(!pRootFile && NPOptionManager::getInstance()->GetPROOF()){ + + } + + else { + cout << "\033[1;31mNo histograms and Tree !\033[0m" << endl; + } } //////////////////////////////////////////////////////////////////////////////// TFile* RootOutput::InitFile(TString fileNameBase){ - + if(NPOptionManager::getInstance()->GetPROOF()){ TString GlobalPath = getenv("NPTOOL"); TString fileName = GlobalPath + "/Outputs/Analysis/"; @@ -187,7 +232,7 @@ TFile* RootOutput::InitFile(TString fileNameBase){ pRootFile->Flush(); return pRootFile; } - + else{ cout << "ERROR: Do not use RootOutput::InitFile without a proof environment (use --proof option to NPTool)" << endl ; exit(1); diff --git a/NPLib/DummyDetector/CMakeLists.txt b/NPLib/DummyDetector/CMakeLists.txt index 2a4c35b4cf4ad4a4197b046cd170c1410035995a..9c1bcf6ec9a30616ccfc742b102763f0fefb8f06 100644 --- a/NPLib/DummyDetector/CMakeLists.txt +++ b/NPLib/DummyDetector/CMakeLists.txt @@ -1,5 +1,5 @@ add_custom_command(OUTPUT TDUMMYDetectorDataDict.cxx TDUMMYDetectorDataDict_rdict.pcm TDUMMYDetectorData.rootmap COMMAND ../scripts/build_dict.sh TDUMMYDetectorData.h TDUMMYDetectorDataDict.cxx TDUMMYDetectorData.rootmap libNPDummyDetector.dylib DEPENDS TDUMMYDetectorData.h) -add_library(NPDUMMYDetector SHARED TDUMMYDetectorData.cxx TDUMMYDetectorDataDict.cxx ) -target_link_libraries(NPDUMMYDetector ${ROOT_LIBRARIES} NPCore) +add_library(NPDummyDetector SHARED TDUMMYDetectorData.cxx TDUMMYDetectorDataDict.cxx ) +target_link_libraries(NPDummyDetector ${ROOT_LIBRARIES} NPCore) install(FILES TDUMMYDetectorData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/HYDE2/CMakeLists.txt b/NPLib/HYDE2/CMakeLists.txt index fda2baaa3dbece3a13587becdacdb543a33adffb..e83e650871947b45208125eb9fd5e196328f6083 100644 --- a/NPLib/HYDE2/CMakeLists.txt +++ b/NPLib/HYDE2/CMakeLists.txt @@ -1,6 +1,6 @@ add_custom_command(OUTPUT THyde2TrackerPhysicsDict.cxx THyde2TrackerPhysicsDict_rdict.pcm THyde2TrackerPhysics.rootmap COMMAND ../scripts/build_dict.sh THyde2TrackerPhysics.h THyde2TrackerPhysicsDict.cxx THyde2TrackerPhysics.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerPhysics.h) add_custom_command(OUTPUT THyde2TrackerDataDict.cxx THyde2TrackerDataDict_rdict.pcm THyde2TrackerData.rootmap COMMAND ../scripts/build_dict.sh THyde2TrackerData.h THyde2TrackerDataDict.cxx THyde2TrackerData.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerData.h) -add_library(NPHyde2Tracker SHARED Hyde2Tracker.cxx Hyde2TrackerModule.cxx Hyde2TrackerTrapezoid1.cxx Hyde2TrackerTrapezoid2.cxx Hyde2TrackerSquare1.cxx THyde2TrackerData.cxx THyde2TrackerPhysics.cxx THyde2TrackerDataDict.cxx THyde2TrackerPhysicsDict.cxx ) -target_link_libraries(NPHyde2Tracker ${ROOT_LIBRARIES} NPCore) +add_library(NPHYDE2 SHARED Hyde2Tracker.cxx Hyde2TrackerModule.cxx Hyde2TrackerTrapezoid1.cxx Hyde2TrackerTrapezoid2.cxx Hyde2TrackerSquare1.cxx THyde2TrackerData.cxx THyde2TrackerPhysics.cxx THyde2TrackerDataDict.cxx THyde2TrackerPhysicsDict.cxx ) +target_link_libraries(NPHYDE2 ${ROOT_LIBRARIES} NPCore) install(FILES THyde2TrackerData.h THyde2TrackerPhysics.h Hyde2Tracker.h Hyde2TrackerModule.h Hyde2TrackerSquare1.h Hyde2TrackerTrapezoid1.h Hyde2TrackerTrapezoid2.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/HiRA/CMakeLists.txt b/NPLib/HiRA/CMakeLists.txt index 570148ba4ce7f809d18c786bfbab093c3e4405dd..935e8dfa36512747429ed3d47dd1908ebac1b96d 100644 --- a/NPLib/HiRA/CMakeLists.txt +++ b/NPLib/HiRA/CMakeLists.txt @@ -1,5 +1,5 @@ add_custom_command(OUTPUT THiraDataDict.cxx THiraDataDict_rdict.pcm THiraData.rootmap COMMAND ../scripts/build_dict.sh THiraData.h THiraDataDict.cxx THiraData.rootmap libNPHiRA.dylib DEPENDS THiraData.h) -add_library(NPHira SHARED THiraData.cxx THiraDataDict.cxx ) -target_link_libraries(NPHira ${ROOT_LIBRARIES} NPCore) +add_library(NPHiRA SHARED THiraData.cxx THiraDataDict.cxx ) +target_link_libraries(NPHiRA ${ROOT_LIBRARIES} NPCore) install(FILES THiraData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/NPLibConfig.cmake.in b/NPLib/NPLibConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..f2e9b44f39353a89adb8edda37efbdc92ef3059b --- /dev/null +++ b/NPLib/NPLibConfig.cmake.in @@ -0,0 +1,16 @@ +# - Config file for the NPLib package +# It defines the following variables +# NPLib_INCLUDE_DIRS - include directories for NPLib +# NPLib_LIBRARIES - libraries to link against +# NPLib_EXECUTABLE - the bar executable + +# Compute paths +get_filename_component(NPLib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(NPLib_INCLUDE_DIRS "@CMAKE_INCLUDE_OUTPUT_DIRECTORY@") +include_directories("${NPLib_INCLUDE_DIRS}") +set(NPLib_USE_FILE "@CMAKE_BINARY_DIR@/NPLibConfig.cmake") + +set(NPLib_LIBRARIES "-L@CMAKE_BINARY_DIR@/lib -lNPCore -lNPPhysics -lNPInteractionCoordinates -lNPInitialConditions") + +# These are IMPORTED targets created by NPLibTargets.cmake +set(NPLib_EXECUTABLE npanalysis nptool-installer) diff --git a/NPLib/Physics/NPBeam.cxx b/NPLib/Physics/NPBeam.cxx index a6eee4760de9c30176cc569444a7e2254392c093..ce69aa19cb7e4f2788bf444dac1778cda971ea69 100644 --- a/NPLib/Physics/NPBeam.cxx +++ b/NPLib/Physics/NPBeam.cxx @@ -155,7 +155,13 @@ void Beam::ReadConfigurationFile(string Path){ // In case the file is not found in the standard path, the programm try to interpret the file name as an absolute or relative file path. else{ ReactionFile.open( Path.c_str() ); - if(ReactionFile.is_open()) { if(fVerboseLevel==1) cout << "Reading Reaction File " << Path << endl;} + if(ReactionFile.is_open()) { + + if(fVerboseLevel==1) + cout << "\033[1;35m/////////// Beam ///////////" << endl; + + if(fVerboseLevel==1) + cout << "Reading Reaction File " << Path << endl;} else {cout << "Reaction File " << Path << " not found" << endl;exit(1);} } @@ -288,7 +294,7 @@ void Beam::ReadConfigurationFile(string Path){ /////////////////////////////////////////////////// // If no Beam Token and no comment, toggle out else{ - cout << "ERROR : Wrong Token Sequence: Getting out " << endl ; + cout << "\033[1;31mERROR : Wrong Token Sequence: Getting out\033[0m" << endl ; exit(1); } @@ -308,11 +314,12 @@ void Beam::ReadConfigurationFile(string Path){ } if( !check_BeamName || !check_AllEnergy || !check_AllEnergy ){ - cout << "ERROR : Token Sequence Incomplete, Beam definition could not be Fonctionnal" << endl ; + cout << "\033[1;31mERROR : Token Sequence Incomplete, Beam definition could not be Fonctionnal\033[0m" << endl ; exit(1); } - - if(fVerboseLevel==1) cout << "///////////////////////////////////////////////////" << endl << endl ; + + cout << "\033[0m" ; + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPLib/Physics/NPReaction.cxx b/NPLib/Physics/NPReaction.cxx index 5fbf31921899315f239c2be42af46d92bb002a57..af005801ba4ab601e861394d1683813c961b77bd 100644 --- a/NPLib/Physics/NPReaction.cxx +++ b/NPLib/Physics/NPReaction.cxx @@ -383,7 +383,7 @@ void Reaction::ReadConfigurationFile(string Path){ fNuclei1->SetVerboseLevel(0); fNuclei1->ReadConfigurationFile(Path); fBeamEnergy= fNuclei1->GetEnergy(); - if(fVerboseLevel==1) cout << "Beam " << fNuclei1->GetName() << " @ " << fBeamEnergy << " MeV" << endl; + if(fVerboseLevel==1) cout << "\033[1;35mBeam " << fNuclei1->GetName() << " @ " << fBeamEnergy << " MeV" << endl; } else if (DataBuffer=="Target=") { diff --git a/NPLib/Riken/CMakeLists.txt b/NPLib/Riken/CMakeLists.txt index a95e7159cd78f7c0dc9a1cfa077ec7e978e7f38e..0891c32c81c489305f5e3ceba45a175f946fefbd 100644 --- a/NPLib/Riken/CMakeLists.txt +++ b/NPLib/Riken/CMakeLists.txt @@ -1,5 +1,5 @@ add_custom_command(OUTPUT TRIPSDataDict.cxx TRIPSDataDict_rdict.pcm TRIPSData.rootmap COMMAND ../scripts/build_dict.sh TRIPSData.h TRIPSDataDict.cxx TRIPSData.rootmap libNPRiken.dylib DEPENDS TRIPSData.h) -add_library(NPRIPS SHARED TRIPSData.cxx TRIPSDataDict.cxx ) -target_link_libraries(NPRIPS ${ROOT_LIBRARIES} NPCore) +add_library(NPRiken SHARED TRIPSData.cxx TRIPSDataDict.cxx ) +target_link_libraries(NPRiken ${ROOT_LIBRARIES} NPCore) install(FILES TRIPSData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.cxx b/NPLib/Tiara/TTiaraBarrelPhysics.cxx index 88a34893723e99e154e0b0d40800d8073e3ca7b2..67dd8ccbc4974901452a716680726b91d5f5dc07 100644 --- a/NPLib/Tiara/TTiaraBarrelPhysics.cxx +++ b/NPLib/Tiara/TTiaraBarrelPhysics.cxx @@ -393,13 +393,15 @@ for(unsigned int k = 0 ; k < sizeB ; k++){ getline(ConfigFile, LineBuffer); // cout << LineBuffer << endl; - if (LineBuffer.compare(0, 11, "TiaraInnerBarrel") == 0) + if (LineBuffer.find("TiaraInnerBarrel") != std::string::npos) ReadingStatus = true; while (ReadingStatus && !ConfigFile.eof()) { - ConfigFile >> DataBuffer ; + check_X=true; check_Y=true ; check_Z=true; // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + if (DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); + } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////something here? @@ -449,17 +451,13 @@ for(unsigned int k = 0 ; k < sizeB ; k++){ /////////////////////////////////////////////////// // If no Detector Token and no comment, toggle out else { - ReadingStatusStrip= false; - cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << endl ; - exit(1); } ///////////////////////////////////////////////// // If All necessary information there, toggle out if (check_X && check_Y && check_Z){ - - ReadingStatusStrip= false; + ReadingStatus= false; AddDetector(X,Y,Z); // Reinitialisation of Check Boolean check_X = false ; @@ -715,6 +713,12 @@ for(unsigned int k = 0 ; k < sizeB ; k++){ return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetBackEEnergy(i)); } + //////////////////////////////////////////////////////////////////////////// + void TTiaraBarrelPhysics::WriteSpectra(){ + m_Spectra->WriteSpectra(); + } + + //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.h b/NPLib/Tiara/TTiaraBarrelPhysics.h index 69ed35eb19bc840b9f3ee6be0090aa3486a04709..563086238f0bdb7cb9838f7c854d542a95c3bcdf 100644 --- a/NPLib/Tiara/TTiaraBarrelPhysics.h +++ b/NPLib/Tiara/TTiaraBarrelPhysics.h @@ -122,7 +122,8 @@ class TTiaraBarrelPhysics : public TObject, public NPA::VDetector{ void CheckSpectra(); // Used for Online only, clear all the spectra hold by the Spectra class void ClearSpectra(); - + // Write Spectra to file + void WriteSpectra(); public:// Specific to TiaraBarrel Array // Clear The PreTeated object void ClearPreTreatedData() {m_PreTreatedData->Clear();} diff --git a/NPLib/Utility/npanalysis.cxx b/NPLib/Utility/npanalysis.cxx index 1e311068d1bc5f4577f3d7596cf959a1f49c35c7..96ff8bf532615bfd124da3103c85c670fc56234c 100644 --- a/NPLib/Utility/npanalysis.cxx +++ b/NPLib/Utility/npanalysis.cxx @@ -38,7 +38,6 @@ int main(int argc , char** argv){ string name = RootInput::getInstance(inputfilename)->DumpAsciiFile("DetectorConfiguration"); myOptionManager->SetDetectorFile(name); cout << "\033[1;33mWarning: No Detector file given, using Input tree one\033[0m"<<endl;; - } if (myOptionManager->IsDefault("EventGenerator")) { @@ -52,7 +51,28 @@ int main(int argc , char** argv){ string OutputfileName = myOptionManager->GetOutputFile(); // Instantiate RootOutput - RootOutput::getInstance("Analysis/"+OutputfileName, "ResultTree"); + string TreeName="NPTool_Tree"; + + // User decided of the name + if(!myOptionManager->IsDefault("TreeName")){ + TreeName=myOptionManager->GetOutputTreeName(); + } + + // Case of a Physics tree produced + else if(!myOptionManager->GetInputPhysicalTreeOption()){ // + TreeName="PhysicsTree"; + if(myOptionManager->IsDefault("OutputFileName")) + OutputfileName="PhysicsTree"; + } + + // Case of Result tree produced + else{ + TreeName="ResultTree"; + if(myOptionManager->IsDefault("OutputFileName")) + OutputfileName="ResultTree"; + } + + RootOutput::getInstance("Analysis/"+OutputfileName,TreeName); TTree* tree= RootOutput::getInstance()->GetTree(); // Instantiate the detector using a file @@ -148,6 +168,9 @@ int main(int argc , char** argv){ myDetector->StopThread(); #endif ProgressDisplay(begin,end,treated,inter,nentries,mean_rate,displayed); + if(myOptionManager->GetGenerateHistoOption()) + myDetector->WriteSpectra(); + RootOutput::getInstance()->Destroy(); RootInput::getInstance()->Destroy(); return 0; diff --git a/NPSimulation/AnnularS1/AnnularS1.cc b/NPSimulation/AnnularS1/AnnularS1.cc index 120205e107e924ace150af4b1419e8c4330a76f2..4227d77f48667dc2de2e172ab59ae03c806cd81f 100644 --- a/NPSimulation/AnnularS1/AnnularS1.cc +++ b/NPSimulation/AnnularS1/AnnularS1.cc @@ -42,6 +42,7 @@ // NPTool headers #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "AnnularS1.hh" #include "SiliconScorers.hh" #include "TS1Data.h" @@ -230,7 +231,7 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -412,3 +413,26 @@ void AnnularS1::InitializeScorers(){ // Add All Scorer to the Global Scorer Manager G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* AnnularS1::Construct(){ + return (NPS::VDetector*) new AnnularS1(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("AnnularS1","AnnularS1"); + NPS::DetectorFactory::getInstance()->AddDetector("AnnularS1",AnnularS1::Construct); + } +}; + +proxy p; +} + + diff --git a/NPSimulation/AnnularS1/AnnularS1.hh b/NPSimulation/AnnularS1/AnnularS1.hh index b21f2f55fb68df0b9df1a50d787eb8765978afe8..c036da3f03aa8641e5f10646f794c137f9e011a8 100644 --- a/NPSimulation/AnnularS1/AnnularS1.hh +++ b/NPSimulation/AnnularS1/AnnularS1.hh @@ -28,7 +28,7 @@ using namespace std; using namespace CLHEP; // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPTool - ROOT headers #include "TS1Data.h" @@ -37,7 +37,7 @@ using namespace CLHEP; #include "G4MultiFunctionalDetector.hh" #include "G4LogicalVolume.hh" -class AnnularS1 : public VDetector{ +class AnnularS1 : public NPS::VDetector{ //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// //////////////////////////////////////////////////// @@ -103,6 +103,12 @@ private: // Set to true if you want to see Telescope Frame in your visualisation bool m_non_sensitive_part_visiualisation; + + public: + static NPS::VDetector* Construct(); + + + }; @@ -140,6 +146,7 @@ namespace ANNULARS1{ const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness; const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*WaferThickness; const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*WaferThickness + 0.5*AluStripThickness; + } #endif diff --git a/NPSimulation/AnnularS1/CMakeLists.txt b/NPSimulation/AnnularS1/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d92dba83390abf5d2f9cc4b030abebd28289d87a --- /dev/null +++ b/NPSimulation/AnnularS1/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSAnnularS1 SHARED AnnularS1.cc) +target_link_libraries(NPSAnnularS1 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPAnnularS1) diff --git a/NPSimulation/CMakeLists.txt b/NPSimulation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b36553acf95c29eccddb9863f8bf914d649a0b68 --- /dev/null +++ b/NPSimulation/CMakeLists.txt @@ -0,0 +1,93 @@ +cmake_minimum_required (VERSION 2.8) +include("../NPLib/FindROOT.cmake") + +project (NPSimulation) +set (NPSimulation_VERSION_MAJOR 2) +set (NPSimulation_VERSION_MINOR 0) + +set(CMAKE_BUILD_TYPE Release) + +# Finding Geant 4 +find_package(Geant4 REQUIRED ui_all vis_all) +message(${Geant4_USE_FILE}) +include(${Geant4_USE_FILE}) + +# Finding NPLib +find_package(NPLib) +include(${NPLib_USE_FILE}) + +set(DETLIST ${NPLib_DETECTOR_LIST}) + +if("${DETLIST}" MATCHES "") + message("Building all detectors") + else() + message("Building the following detectors ${DETLIST}") +endif() + +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) + +# Add root to the link and include directories +include_directories( ${ROOT_INCLUDE_DIR}) +link_directories( ${ROOT_LIBRARY_DIR}) + +# Get the compilator flag from root to assure consistancy +EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} + ARGS "--cflags" + OUTPUT_VARIABLE root_cflags ) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${root_cflags}") + +# If the compiler is Clang, silence the unrecognised flags +if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -Wno-deprecated-register") +endif() + +set(CMAKE_BINARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) +set(CMAKE_INCLUDE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/include ) + +# A macro that return the list of directory to compile +MACRO(subdirlist result curdir) + FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) + SET(dirlist "") + FOREACH(child ${children}) + IF(IS_DIRECTORY ${curdir}/${child}) + string(COMPARE EQUAL "${child}" ".tmp" r0) + string(COMPARE EQUAL "${child}" "lib" r1) + string(COMPARE EQUAL "${child}" "scripts" r2) + string(COMPARE EQUAL "${child}" "CMakeFiles" r3) + string(COMPARE EQUAL "${child}" "Core" r4) + string(COMPARE EQUAL "${child}" "bin" r5) + string(COMPARE EQUAL "${child}" "macro" r6) + string(COMPARE EQUAL "${child}" "icons" r7) + IF(NOT r0 AND NOT r1 AND NOT r2 AND NOT r3 AND NOT r4 AND NOT r5 AND NOT r6 AND NOT r7) + string(COMPARE EQUAL "${DETLIST}" "" r100) + IF(r100) + LIST(APPEND dirlist ${child}) + ELSEIF(${DETLIST} MATCHES ".*${child}.*" ) + LIST(APPEND dirlist ${child}) + ENDIF() + ENDIF() + ENDIF() + ENDFOREACH() + SET(${result} ${dirlist}) +ENDMACRO() + +# Call the Macro +subdirlist(SUB_DIRECTORY ${CMAKE_BINARY_DIR}) +set(SUB_DIRECTORY ${SUB_DIRECTORY} Core) +include_directories("Core/") + +# Add each sub folder to the project +foreach(subdir ${SUB_DIRECTORY}) +# add the subdirectory + add_subdirectory(${subdir}) + endforeach() + +add_executable(npsimulation Simulation.cc) +target_Link_libraries(npsimulation ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} NPSCore) +configure_file(macro/gui.mac.in macro/gui.mac @ONLY) +configure_file(macro/aliases.mac.in macro/aliases.mac @ONLY) + +install(PROGRAMS npsimulation DESTINATION ${CMAKE_BINARY_OUTPUT_DIRECTORY}) diff --git a/NPSimulation/ComptonTelescope/CMakeLists.txt b/NPSimulation/ComptonTelescope/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d48945290d063a076c2a0cfb855cadd4de59a3df --- /dev/null +++ b/NPSimulation/ComptonTelescope/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSComptonTelescope SHARED ComptonTelescope.cc ComptonTelescopeScorers.cc) +target_link_libraries(NPSComptonTelescope NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPComptonTelescope) diff --git a/NPSimulation/ComptonTelescope/ComptonTelescope.cc b/NPSimulation/ComptonTelescope/ComptonTelescope.cc index c1b14b2fb24ebd52007caf8e0636da94ce1f45a9..5e5acb9ff81b821bd62951cb81a3f88df80969ba 100644 --- a/NPSimulation/ComptonTelescope/ComptonTelescope.cc +++ b/NPSimulation/ComptonTelescope/ComptonTelescope.cc @@ -51,6 +51,7 @@ #include "ComptonTelescopeScorers.hh" #include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" // CLHEP @@ -248,7 +249,7 @@ void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -1023,3 +1024,24 @@ void ComptonTelescope::InitializeScorers() G4SDManager::GetSDMpointer()->AddNewDetector(m_TrackerScorer); G4SDManager::GetSDMpointer()->AddNewDetector(m_CalorimeterScorer); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* ComptonTelescope::Construct(){ + return (NPS::VDetector*) new ComptonTelescope(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("ComptonTelescope","ComptonTelescope"); + NPS::DetectorFactory::getInstance()->AddDetector("ComptonTelescope",ComptonTelescope::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/ComptonTelescope/ComptonTelescope.hh b/NPSimulation/ComptonTelescope/ComptonTelescope.hh index f01b5bee439ec8a5bf707adb272c39aee82c8ce9..a5b7e8a0db08d6981052380f6bbdd42a0e8e78f7 100644 --- a/NPSimulation/ComptonTelescope/ComptonTelescope.hh +++ b/NPSimulation/ComptonTelescope/ComptonTelescope.hh @@ -24,7 +24,7 @@ // NPTool headers -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "TComptonTelescopeData.h" #include "TComptonTelescopeProcessData.h" @@ -40,7 +40,7 @@ using namespace std; -class ComptonTelescope : public VDetector +class ComptonTelescope : public NPS::VDetector //class ComptonTelescope { //////////////////////////////////////////////////// @@ -83,7 +83,7 @@ public: ///////////////////////////////////////// - //// Inherite from VDetector class ///// + //// Inherite from NPS::VDetector class ///// ///////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -178,6 +178,8 @@ private: G4double m_ThicknessOfCalorimeter; G4double m_DistanceTrackerCalorimeter; G4double m_TowerHeight; +public: + static NPS::VDetector* Construct(); }; diff --git a/NPSimulation/ComptonTelescope/ComptonTelescopeScorers.hh b/NPSimulation/ComptonTelescope/ComptonTelescopeScorers.hh index 369bc5b3c821148f44cd6bef0aa6aca9bb4d303f..8a0649095c3789946788b6b1d2a5d1f305212ed3 100644 --- a/NPSimulation/ComptonTelescope/ComptonTelescopeScorers.hh +++ b/NPSimulation/ComptonTelescope/ComptonTelescopeScorers.hh @@ -50,7 +50,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_ProcessName; G4int HCID; G4THitsMap<G4double>* EvtMap; - }; +}; @@ -74,7 +74,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; @@ -98,7 +98,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; @@ -122,7 +122,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4double>* EvtMap; - }; +}; @@ -147,7 +147,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4double>* EvtMap; - }; +}; @@ -171,7 +171,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; @@ -195,7 +195,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; class ComptonTelescopeScorerCalorimeterEnergy : public G4VPrimitiveScorer @@ -218,7 +218,7 @@ namespace COMPTONTELESCOPESCORERS G4String m_VolumeName; G4int HCID; G4THitsMap<G4double>* EvtMap; - }; +}; } diff --git a/NPSimulation/Core/CMakeLists.txt b/NPSimulation/Core/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..376f06e99933eddf6f0826c243c20469ca9d3993 --- /dev/null +++ b/NPSimulation/Core/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSCore SHARED CalorimeterScorers.cc EventAction.cc EventGeneratorParticleDecay.cc ObsoleteGeneralScorers.cc PrimaryGeneratorAction.cc Target.cc Chamber.cc EventGeneratorBeam.cc EventGeneratorTwoBodyReaction.cc Particle.cc PrimaryGeneratorActionMessenger.cc NPSVDetector.cc DetectorConstruction.cc EventGeneratorGammaDecay.cc MaterialManager.cc ParticleStack.cc SiliconScorers.cc VEventGenerator.cc DetectorMessenger.cc EventGeneratorIsotropic.cc MyMagneticField.cc PhysicsList.cc SteppingVerbose.cc NPSDetectorFactory.cc RunAction.cc) +target_link_libraries(NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES}) diff --git a/NPSimulation/src/CalorimeterScorers.cc b/NPSimulation/Core/CalorimeterScorers.cc similarity index 100% rename from NPSimulation/src/CalorimeterScorers.cc rename to NPSimulation/Core/CalorimeterScorers.cc diff --git a/NPSimulation/include/CalorimeterScorers.hh b/NPSimulation/Core/CalorimeterScorers.hh similarity index 100% rename from NPSimulation/include/CalorimeterScorers.hh rename to NPSimulation/Core/CalorimeterScorers.hh diff --git a/NPSimulation/src/Chamber.cc b/NPSimulation/Core/Chamber.cc similarity index 99% rename from NPSimulation/src/Chamber.cc rename to NPSimulation/Core/Chamber.cc index abca1ab9863572aa040ad647905039779c7db1f3..3f70f4160eaf40f5b212e2252299b273a6ed4f9c 100644 --- a/NPSimulation/src/Chamber.cc +++ b/NPSimulation/Core/Chamber.cc @@ -12,7 +12,7 @@ * Last update : 11/03/2010 * *---------------------------------------------------------------------------* * Decription: * - * This class describe standard Chamber. Derived from VDetector* + * This class describe standard Chamber. Derived fromNPS::VDetector* * * *---------------------------------------------------------------------------* * Comment: * diff --git a/NPSimulation/include/Chamber.hh b/NPSimulation/Core/Chamber.hh similarity index 96% rename from NPSimulation/include/Chamber.hh rename to NPSimulation/Core/Chamber.hh index 4d61de321c37cd351a2ffe4c7f7f952665ef2031..e23d8c3f36ba78f596dae6860fe985716fe5a3f4 100644 --- a/NPSimulation/include/Chamber.hh +++ b/NPSimulation/Core/Chamber.hh @@ -15,7 +15,7 @@ *---------------------------------------------------------------------------* * Decription: * * This class describe Cryogenic and standard Chamber. * - * Derived from VDetector * + * Derived fromNPS::VDetector * *---------------------------------------------------------------------------* * Comment: * * @@ -34,12 +34,12 @@ #include "G4LogicalVolume.hh" // NPTool headers -#include "VDetector.hh" +#include "NPSVDetector.hh" using namespace std; using namespace CLHEP; -class Chamber : public VDetector +class Chamber : public NPS::VDetector { public: Chamber(); diff --git a/NPSimulation/Core/DetectorConstruction.cc b/NPSimulation/Core/DetectorConstruction.cc new file mode 100644 index 0000000000000000000000000000000000000000..a9e0916b35052910b83b63e4f86dd065b337bf99 --- /dev/null +++ b/NPSimulation/Core/DetectorConstruction.cc @@ -0,0 +1,297 @@ +/***************************************************************************** + * Copyright (C) 2009-2013 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: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : January 2009 * + * Last update : 26/08/2010 (M. Labiche) * + *---------------------------------------------------------------------------* + * Decription: * + * This Class manage the virtual detector and call their method. * + * Every time a new detector is added to the project, a few line in the * + * ReadConfigurationFile method are needed in order to detect the associate * + * token. * + *---------------------------------------------------------------------------* + * Comment: * + * 15/01/10: Added Chamber (marc.labiche@stfc.ac.uk) * + * 04/12/09: Added PARIS detector (marc.labiche@stfc.ac.uk) * + *****************************************************************************/ + +#include "DetectorConstruction.hh" + +// G4 +#include "G4Material.hh" +#include "G4Box.hh" +#include "G4Tubs.hh" +#include "G4Sphere.hh" +#include "G4LogicalVolume.hh" +#include "G4ThreeVector.hh" +#include "G4PVPlacement.hh" +#include "globals.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4ios.hh" +#include "G4String.hh" +#include "G4RotationMatrix.hh" +#include "MyMagneticField.hh" +#include "G4FieldManager.hh" +#include "G4TransportationManager.hh" +#include "G4ChordFinder.hh" +#include "G4MagIntegratorStepper.hh" +#include "G4SubtractionSolid.hh" +#include "G4GeometryManager.hh" +#include "G4GeometryMessenger.hh" +#include "G4PhysicalVolumeStore.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4VPhysicalVolume.hh" +#include "G4SolidStore.hh" +#include "G4RunManager.hh" +#include "G4SDManager.hh" +// Detector class + +// STL +#include<cstdlib> +#include<fstream> + +// NPL +#include "RootOutput.h" +#include "NPOptionManager.h" + +// NPS +#include "NPSDetectorFactory.hh" +#include "MaterialManager.hh" +#include "DetectorMessenger.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +DetectorConstruction::DetectorConstruction(): world_log(0), world_phys(0){ + m_Target = 0; + m_Chamber = 0 ; + m_Messenger = new DetectorMessenger(this); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +DetectorConstruction::~DetectorConstruction(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4VPhysicalVolume* DetectorConstruction::Construct(){ + return ReadConfigurationFile(); +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){ + // Add new detector to vector + m_Detectors.push_back(NewDetector); + + // Initialize Scorer + NewDetector->InitializeScorers(); + + // Construct new detector + NewDetector->ConstructDetector(world_log); + + // Add Detector to TTree + NewDetector->InitializeRootOutput(); +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ + // Construct the World volume + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + + //------------------------------world volume + G4double world_x = 10.0 * m; + G4double world_y = 10.0 * m; + G4double world_z = 10.0 * m; + + G4Box* world_box + = new G4Box("world_box", world_x, world_y, world_z); + + world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); + world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); + + G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); + world_log->SetVisAttributes(VisAtt); + + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + + string Path = NPOptionManager::getInstance()->GetDetectorFile(); + + ////////General Reading needs//////// + string LineBuffer; + string DataBuffer; + bool cGeneralTarget=false; + bool cGeneralChamber=false; + set<string> check; + + + + + int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); + cout << "\033[1;36m" ; + + // Access the DetectorFactory and ask it to load the Class List + string classlist = getenv("NPTOOL"); + classlist += "/NPLib/DetectorClassList.txt"; + NPS::DetectorFactory* theFactory = NPS::DetectorFactory::getInstance(); + theFactory->ReadClassList(classlist); + + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + if (ConfigFile.is_open()) { // should be always be true + G4cout << " Configuration file " << Path << " loading " << G4endl; + } + else { + G4cout << " Error, no configuration file" << Path << " found" << G4endl; + exit(1); + } + + while (!ConfigFile.eof()) { + //Pick-up next line + getline(ConfigFile, LineBuffer); + //Search for comment Symbol: % + if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/;} + + //////////////////////////////////////////// + //////////// Search for Target ///////////// + //////////////////////////////////////////// + + else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && cGeneralTarget == false) { + cGeneralTarget = true ; + if(VerboseLevel==1) G4cout << G4endl << "////////// Target ///////////" << G4endl << G4endl ; + + // Instantiate the new array as aNPS::VDetector Objects + NPS::VDetector* myDetector = new Target(); + + // Read Position and target specification + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add Target to DetectorConstruction + m_Target = (Target*) myDetector; + + // Add target to theNPS::VDetector Vector + AddDetector(myDetector); + } + + //////////////////////////////////////////// + //////////// Search for Chamber ///////////// + //////////////////////////////////////////// + + else if (LineBuffer.compare(0, 14, "GeneralChamber") == 0 && cGeneralChamber == false) { + cGeneralChamber = true ; + if(VerboseLevel==1) G4cout << G4endl << "////////// Chamber ///////////" << G4endl << G4endl ; + + // Instantiate the new array as aNPS::VDetector Objects + NPS::VDetector* myDetector = new Chamber(); + + // Read Position and target specification + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add Target to DetectorConstruction + m_Chamber = (Chamber*) myDetector; + + // Add target to theNPS::VDetector Vector + AddDetector(myDetector); + } + + else{ + istringstream oss(LineBuffer); + string token; + oss >> token ; + NPS::VDetector* detector = theFactory->Construct(token); + if(detector!=NULL && check.find(token)==check.end()){ + cout << "/////////////////////////////////////////" << endl; + cout << "//// Adding Detector " << token << endl; + detector->ReadConfiguration(Path); + cout << "/////////////////////////////////////////" << endl; + // Add array to the VDetector Vector + AddDetector(detector); + check.insert(token); + } + } + } + + ConfigFile.close(); + cout << "\033[0m" ; + + if(m_Target==NULL){ + G4cout << "\033[1;31mERROR: No target define in detector file. Cannot perform simulation without target\033[0m" << G4endl ; + exit(1); + } + + // Create the Material sample for DEDX tables + MaterialManager::getInstance()->CreateSampleVolumes(world_log); + + return world_phys; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void DetectorConstruction::ReadAllSensitive(const G4Event* event){ + // Before looping on each sub-detector, clear the static variable + // ms_InterCoord + // This is done on the first element of the m_Modules vector. + // This should be done here since this variable (of type TIneractionCoordinates) + // deals with multiplicity of events > 1. + if(m_Detectors.size()>0) + m_Detectors[0]->GetInterCoordPointer()->Clear(); + + unsigned int mysize = m_Detectors.size(); + for (unsigned short i = 0 ; i < mysize ; i++) { + m_Detectors[i]->ReadSensitive(event); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* DetectorConstruction::GetWorldLogic(){ + return world_log; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void DetectorConstruction::ClearGeometry(){ + unsigned int mySize = m_Detectors.size(); + + for (unsigned short i = 0 ; i < mySize ; i++) { + delete m_Detectors[i]; + } + + m_Detectors.clear(); + m_Target = 0; + m_Chamber = 0 ; + world_log=0; + world_phys=0; + + G4GeometryManager::GetInstance()->OpenGeometry(); + G4PhysicalVolumeStore::GetInstance()->Clean(); + G4LogicalVolumeStore::GetInstance()->Clean(); + G4SolidStore::GetInstance()->Clean(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void DetectorConstruction::RedefineGeometry(string file){ + ClearGeometry() ; + + RootOutput::getInstance()->GetTree()->ResetBranchAddresses(); + RootOutput::getInstance()->GetTree()->GetListOfBranches()->Clear(); + + if(file!="") + NPOptionManager::getInstance()->SetDetectorFile(file); + + G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); + G4RunManager::GetRunManager()->GeometryHasBeenModified(); + G4RunManager::GetRunManager()->Initialize(); +} diff --git a/NPSimulation/include/DetectorConstruction.hh b/NPSimulation/Core/DetectorConstruction.hh similarity index 96% rename from NPSimulation/include/DetectorConstruction.hh rename to NPSimulation/Core/DetectorConstruction.hh index f0fb9c103e275dc8c6944f2384882c475912d09f..63c6b1d8b9d2161916049ee6f84cbe8d5b3a4c41 100644 --- a/NPSimulation/include/DetectorConstruction.hh +++ b/NPSimulation/Core/DetectorConstruction.hh @@ -35,7 +35,7 @@ class G4VPhysicalVolume; #include "G4Event.hh" #include "DetectorMessenger.hh" // NPTool headers -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "Target.hh" #include "Chamber.hh" @@ -57,7 +57,7 @@ public: public: G4VPhysicalVolume* ReadConfigurationFile(); - void AddDetector(VDetector*); + void AddDetector(NPS::VDetector*); void ReadAllSensitive(const G4Event*); @@ -71,7 +71,7 @@ private: //G4VPhysicalVolume* Chamber_phys; // Virtual Detector Vector - vector<VDetector*> m_Detectors; + vector<NPS::VDetector*> m_Detectors; private: // Data about the target diff --git a/NPSimulation/src/DetectorMessenger.cc b/NPSimulation/Core/DetectorMessenger.cc similarity index 100% rename from NPSimulation/src/DetectorMessenger.cc rename to NPSimulation/Core/DetectorMessenger.cc diff --git a/NPSimulation/include/DetectorMessenger.hh b/NPSimulation/Core/DetectorMessenger.hh similarity index 100% rename from NPSimulation/include/DetectorMessenger.hh rename to NPSimulation/Core/DetectorMessenger.hh diff --git a/NPSimulation/src/EventAction.cc b/NPSimulation/Core/EventAction.cc similarity index 61% rename from NPSimulation/src/EventAction.cc rename to NPSimulation/Core/EventAction.cc index d8d1316a09d7c6e5c6f8a6b7498a1884dcd5ace9..78195ee83a986d91f3f325b8646d7fab59516932 100644 --- a/NPSimulation/src/EventAction.cc +++ b/NPSimulation/Core/EventAction.cc @@ -35,27 +35,29 @@ #include<iostream> using namespace std; - -#include "G4THitsMap.hh" - +EventAction* EventAction::m_EventAction=0; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -EventAction::EventAction(): m_printModulo(10000){ +EventAction::EventAction(){ + m_EventAction=this; + begin=clock(); + treated=0; + inter=0; + total=0; + mean_rate=0; + displayed=0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - EventAction::~EventAction(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::BeginOfEventAction(const G4Event* event){ - if ((event->GetEventID() + 1) % m_printModulo == 0) - cout << "\rEvent: " << event->GetEventID() + 1 << flush; + treated= event->GetEventID()+1; + ProgressDisplay(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - void EventAction::EndOfEventAction(const G4Event* event){ m_detector->ReadAllSensitive(event) ; RootOutput *pAnalysis = RootOutput::getInstance(); @@ -64,6 +66,46 @@ void EventAction::EndOfEventAction(const G4Event* event){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::SetDetector(DetectorConstruction* detector){ - m_detector = detector ; + m_detector = detector ; } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void EventAction::ProgressDisplay(){ + end = clock(); + if((end-begin)>CLOCKS_PER_SEC||treated>=total ){ + displayed++; + long double elapsed =(long double) (end-begin)/CLOCKS_PER_SEC; + double event_rate = inter/elapsed; + mean_rate += (event_rate-mean_rate)/(displayed); + double percent = 100*treated/total; + double remain = (total-treated)/mean_rate; + + char* timer; + double check; + if(remain>60) + check=asprintf(&timer,"%dmin",(int)(remain/60.)); + else + check=asprintf(&timer,"%ds",(int)(remain)); + + if(treated!=total) + printf("\r \033[1;31m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,mean_rate/1000.,timer); + + else{ + printf("\r "); + printf("\r \033[1;32m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,mean_rate/1000.,timer); + } + fflush(stdout); + inter=0; + begin = clock() ; + } + // treated++; + inter++; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void EventAction::SetRunLength(int length){ + total = length; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +EventAction* EventAction::GetInstance(){ + return m_EventAction; +} diff --git a/NPSimulation/include/EventAction.hh b/NPSimulation/Core/EventAction.hh similarity index 74% rename from NPSimulation/include/EventAction.hh rename to NPSimulation/Core/EventAction.hh index be9ff9baf5666f9527e727a47ebd7595cac315c6..f534b29cd47cb0514d78567a147008393143ea92 100644 --- a/NPSimulation/include/EventAction.hh +++ b/NPSimulation/Core/EventAction.hh @@ -30,24 +30,36 @@ // NPTool header #include "DetectorConstruction.hh" -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -class EventAction : public G4UserEventAction -{ -public: - EventAction(); - virtual ~EventAction(); +// STL +#include<time.h> -public: - void BeginOfEventAction(const G4Event*) ; - void EndOfEventAction(const G4Event*) ; - void SetDetector(DetectorConstruction* detector) ; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +class EventAction : public G4UserEventAction{ + public: + EventAction(); + virtual ~EventAction(); + public: + void BeginOfEventAction(const G4Event*); + void EndOfEventAction(const G4Event*); + void SetDetector(DetectorConstruction* detector); + void ProgressDisplay(); + void SetRunLength(int); + private: // Progress Display + clock_t begin; + clock_t end; + unsigned int treated; + unsigned int inter; + unsigned int total; + double mean_rate; + int displayed; + private: + DetectorConstruction* m_detector; + static EventAction* m_EventAction; -private: - DetectorConstruction* m_detector ; - G4int m_printModulo ; + public: + static EventAction* GetInstance(); }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/src/EventGeneratorBeam.cc b/NPSimulation/Core/EventGeneratorBeam.cc similarity index 100% rename from NPSimulation/src/EventGeneratorBeam.cc rename to NPSimulation/Core/EventGeneratorBeam.cc diff --git a/NPSimulation/include/EventGeneratorBeam.hh b/NPSimulation/Core/EventGeneratorBeam.hh similarity index 100% rename from NPSimulation/include/EventGeneratorBeam.hh rename to NPSimulation/Core/EventGeneratorBeam.hh diff --git a/NPSimulation/src/EventGeneratorGammaDecay.cc b/NPSimulation/Core/EventGeneratorGammaDecay.cc similarity index 100% rename from NPSimulation/src/EventGeneratorGammaDecay.cc rename to NPSimulation/Core/EventGeneratorGammaDecay.cc diff --git a/NPSimulation/include/EventGeneratorGammaDecay.hh b/NPSimulation/Core/EventGeneratorGammaDecay.hh similarity index 100% rename from NPSimulation/include/EventGeneratorGammaDecay.hh rename to NPSimulation/Core/EventGeneratorGammaDecay.hh diff --git a/NPSimulation/src/EventGeneratorIsotropic.cc b/NPSimulation/Core/EventGeneratorIsotropic.cc similarity index 100% rename from NPSimulation/src/EventGeneratorIsotropic.cc rename to NPSimulation/Core/EventGeneratorIsotropic.cc diff --git a/NPSimulation/include/EventGeneratorIsotropic.hh b/NPSimulation/Core/EventGeneratorIsotropic.hh similarity index 100% rename from NPSimulation/include/EventGeneratorIsotropic.hh rename to NPSimulation/Core/EventGeneratorIsotropic.hh diff --git a/NPSimulation/src/EventGeneratorParticleDecay.cc b/NPSimulation/Core/EventGeneratorParticleDecay.cc similarity index 100% rename from NPSimulation/src/EventGeneratorParticleDecay.cc rename to NPSimulation/Core/EventGeneratorParticleDecay.cc diff --git a/NPSimulation/include/EventGeneratorParticleDecay.hh b/NPSimulation/Core/EventGeneratorParticleDecay.hh similarity index 100% rename from NPSimulation/include/EventGeneratorParticleDecay.hh rename to NPSimulation/Core/EventGeneratorParticleDecay.hh diff --git a/NPSimulation/src/EventGeneratorTwoBodyReaction.cc b/NPSimulation/Core/EventGeneratorTwoBodyReaction.cc similarity index 100% rename from NPSimulation/src/EventGeneratorTwoBodyReaction.cc rename to NPSimulation/Core/EventGeneratorTwoBodyReaction.cc diff --git a/NPSimulation/include/EventGeneratorTwoBodyReaction.hh b/NPSimulation/Core/EventGeneratorTwoBodyReaction.hh similarity index 100% rename from NPSimulation/include/EventGeneratorTwoBodyReaction.hh rename to NPSimulation/Core/EventGeneratorTwoBodyReaction.hh diff --git a/NPSimulation/src/MaterialManager.cc b/NPSimulation/Core/MaterialManager.cc similarity index 100% rename from NPSimulation/src/MaterialManager.cc rename to NPSimulation/Core/MaterialManager.cc diff --git a/NPSimulation/include/MaterialManager.hh b/NPSimulation/Core/MaterialManager.hh similarity index 100% rename from NPSimulation/include/MaterialManager.hh rename to NPSimulation/Core/MaterialManager.hh diff --git a/NPSimulation/src/MyMagneticField.cc b/NPSimulation/Core/MyMagneticField.cc similarity index 100% rename from NPSimulation/src/MyMagneticField.cc rename to NPSimulation/Core/MyMagneticField.cc diff --git a/NPSimulation/include/MyMagneticField.hh b/NPSimulation/Core/MyMagneticField.hh similarity index 100% rename from NPSimulation/include/MyMagneticField.hh rename to NPSimulation/Core/MyMagneticField.hh diff --git a/NPSimulation/Core/NPSDetectorFactory.cc b/NPSimulation/Core/NPSDetectorFactory.cc new file mode 100644 index 0000000000000000000000000000000000000000..689c97e2278f98ae8c0dd3f16dbf31bd3ae585dd --- /dev/null +++ b/NPSimulation/Core/NPSDetectorFactory.cc @@ -0,0 +1,132 @@ +#include"NPSDetectorFactory.hh" +using namespace NPS; +#include<dlfcn.h> +#include<fstream> +#include<iostream> +#include<stdlib.h> + +DetectorFactory* DetectorFactory::m_Instance = 0; +#ifdef __linux__ +std::string SHARED_LIB_EXTENSION = ".so"; +#endif + +#ifdef __FreeBSD__ +std::string SHARED_LIB_EXTENSION = ".so"; +#endif + +#ifdef __APPLE__ +std::string SHARED_LIB_EXTENSION = ".dylib"; +#endif + + + +//////////////////////////////////////////////////////////////////////////////// +DetectorFactory::DetectorFactory(){ + +} + +///////////////////////////////////////////////////////////////////////////////// +DetectorFactory::~DetectorFactory(){ + if(m_Instance!=0) + delete m_Instance; + + m_Instance = 0 ; +} + +//////////////////////////////////////////////////////////////////////////////// +DetectorFactory* DetectorFactory::getInstance(){ + if(!m_Instance){ + m_Instance = new DetectorFactory(); + } + + return m_Instance; + +} +//////////////////////////////////////////////////////////////////////////////// +void DetectorFactory::ReadClassList(std::string FileList){ + std::ifstream InFile(FileList.c_str()); + + if(!InFile.is_open()){ + cout << "ERROR: Detector Class List file " << FileList << " Not found" << endl; + exit(1); + } + + string Token, LibName; + while(InFile >> Token >> LibName){ + // Modify LibName from NPLib name to NPSimulation one + LibName = LibName.replace(LibName.find("libNP"), std::string("libNP").length(), "libNPS"); + m_TokenLib[Token] = LibName; + } +} +//////////////////////////////////////////////////////////////////////////////// +void DetectorFactory::CreateClassList(std::string FileList){ + ofstream outFile(FileList.c_str()); + std::map<string,string>::iterator it; + + for(it = m_TokenLib.begin();it!=m_TokenLib.end();it++){ + outFile << it->first << " " << it->second << std::endl; + + } + + +} +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* DetectorFactory::Construct(std::string Token){ + std::map<std::string,ClassDetectorFactoryFn>::iterator it; + + if(m_Construct.find(Token)!=m_Construct.end()) + return m_Construct[Token](); + + else if( m_TokenLib.find(Token)!=m_TokenLib.end()){ + // Add absolute path to library name + std::string path = getenv("NPTOOL"); + std::string libName = path+"NPLib/lib/"+m_TokenLib[Token]; + dlopen(libName.c_str(),RTLD_NOW); + + if(m_Construct.find(Token)!=m_Construct.end()) + return m_Construct[Token](); + + else{ + std::cout << "Warning: Detector with Token " << Token << " has no Constructor or no Library" << std::endl; + return NULL; + } + } + + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////// +void DetectorFactory::AddDetector(std::string Token, ClassDetectorFactoryFn fn){ + m_Construct[Token] = fn; +} +//////////////////////////////////////////////////////////////////////////////// +void DetectorFactory::AddToken(std::string Token, std::string LibName){ + // Make sure the lib name is correct: + // Strip it from lib and NP and extension + std::string remword = "lib"; + size_t pos; + if((pos=LibName.find(remword))!=std::string::npos){ + LibName.swap(LibName.erase(pos,remword.length())); + } + + remword = "NP"; + if((pos=LibName.find(remword))!=std::string::npos){ + LibName.swap(LibName.erase(pos,remword.length())); + } + + remword = ".so"; + if((pos=LibName.find(remword))!=std::string::npos){ + LibName.swap(LibName.erase(pos,remword.length())); + } + + remword = ".dylib"; + if((pos=LibName.find(remword))!=std::string::npos){ + LibName.swap(LibName.erase(pos,remword.length())); + } + + + // Create the full name: + LibName = "libNP"+LibName + SHARED_LIB_EXTENSION; + + m_TokenLib[Token] = LibName; +} diff --git a/NPSimulation/Core/NPSDetectorFactory.hh b/NPSimulation/Core/NPSDetectorFactory.hh new file mode 100644 index 0000000000000000000000000000000000000000..19484638f27699625d62db76f9cd8f4a40bddfa9 --- /dev/null +++ b/NPSimulation/Core/NPSDetectorFactory.hh @@ -0,0 +1,30 @@ +#ifndef _DETECTORFACTORY_ +#define _DETECTORFACTORY_ +#include"NPSVDetector.hh" +#include<map> +#include<string> + +typedef NPS::VDetector* (*ClassDetectorFactoryFn)(); + +namespace NPS{ +class DetectorFactory{ + private: + DetectorFactory(); + ~DetectorFactory(); + + public: + static DetectorFactory* getInstance(); + NPS::VDetector* Construct(std::string Token); + void ReadClassList(std::string FileList); + void AddToken(std::string Token, std::string LibName); + void AddDetector(std::string Token, ClassDetectorFactoryFn fn); + void CreateClassList(string FileName); + private: + static DetectorFactory* m_Instance; + // Map that Match the Token with Constructor, once the lib is loaded + 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; +}; +} +#endif diff --git a/NPSimulation/src/VDetector.cc b/NPSimulation/Core/NPSVDetector.cc similarity index 88% rename from NPSimulation/src/VDetector.cc rename to NPSimulation/Core/NPSVDetector.cc index a1320f9c3d8404704b586b4116664ef739df8b95..6b3ed88227c39555d32b25ca498795481aaf3847 100644 --- a/NPSimulation/src/VDetector.cc +++ b/NPSimulation/Core/NPSVDetector.cc @@ -13,7 +13,7 @@ *---------------------------------------------------------------------------* * Decription: * * All detector added in the project should derive from this virtual class * - * A vector of VDetector object is manage in the DetectorConstruction class * + * A vector ofNPS::VDetector object is manage in the DetectorConstruction class * * and call the virtual method of this class implemented in the daughter * * class object. * * This inheritance insure homogeneity and modularity of the code * @@ -22,26 +22,26 @@ * Comment: * * * *****************************************************************************/ -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "RootOutput.h" #include "G4SDManager.hh" -TInteractionCoordinates* VDetector::ms_InterCoord = 0; +TInteractionCoordinates* NPS::VDetector::ms_InterCoord = 0; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Constructor -VDetector::VDetector(){ +NPS::VDetector::VDetector(){ if (ms_InterCoord == 0) ms_InterCoord = new TInteractionCoordinates(); InitializeRootOutput(); } // Destructor -VDetector::~VDetector(){ +NPS::VDetector::~VDetector(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void VDetector::InitializeRootOutput(){ +void NPS::VDetector::InitializeRootOutput(){ RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); pTree->Branch("InteractionCoordinates", "TInteractionCoordinates", &ms_InterCoord); @@ -50,7 +50,7 @@ void VDetector::InitializeRootOutput(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4MultiFunctionalDetector* VDetector::CheckScorer(string name,bool &exist){ +G4MultiFunctionalDetector* NPS::VDetector::CheckScorer(string name,bool &exist){ exist = true; G4MultiFunctionalDetector* ptr = (G4MultiFunctionalDetector*) G4SDManager::GetSDMpointer()->FindSensitiveDetector(name.c_str(),false); diff --git a/NPSimulation/include/VDetector.hh b/NPSimulation/Core/NPSVDetector.hh similarity index 95% rename from NPSimulation/include/VDetector.hh rename to NPSimulation/Core/NPSVDetector.hh index b97812c6639f1b6bbf7605fa2fcc14ffdc1a41ab..36ff4f488bcc3f97cc5e75a8974f40b00d1875c3 100644 --- a/NPSimulation/include/VDetector.hh +++ b/NPSimulation/Core/NPSVDetector.hh @@ -15,14 +15,14 @@ *---------------------------------------------------------------------------* * Decription: * * All detector added in the project should derive from this virtual class * - * A vector of VDetector object is manage in the DetectorConstruction class * + * A vector ofNPS::VDetector object is manage in the DetectorConstruction class * * and call the virtual method of this class implemented in the daughter * * class object. * * This inheritance insure homogeneity and modularity of the code * * * *---------------------------------------------------------------------------* * Comment: * - * Detector inheriting from VDetector should follow this Naming convention * + * Detector inheriting fromNPS::VDetector should follow this Naming convention * * for logical volume: * * DetectorNameX_SubPart * * * @@ -52,7 +52,7 @@ using namespace std; using namespace CLHEP; - +namespace NPS{ class VDetector{ public: // Default Constructor and destructor @@ -91,5 +91,5 @@ class VDetector{ // Class to store the interaction data (i.e. X,Y,Z,theta,phi) static TInteractionCoordinates* ms_InterCoord; }; - +} #endif diff --git a/NPSimulation/src/ObsoleteGeneralScorers.cc b/NPSimulation/Core/ObsoleteGeneralScorers.cc similarity index 100% rename from NPSimulation/src/ObsoleteGeneralScorers.cc rename to NPSimulation/Core/ObsoleteGeneralScorers.cc diff --git a/NPSimulation/include/ObsoleteGeneralScorers.hh b/NPSimulation/Core/ObsoleteGeneralScorers.hh similarity index 100% rename from NPSimulation/include/ObsoleteGeneralScorers.hh rename to NPSimulation/Core/ObsoleteGeneralScorers.hh diff --git a/NPSimulation/src/Particle.cc b/NPSimulation/Core/Particle.cc similarity index 100% rename from NPSimulation/src/Particle.cc rename to NPSimulation/Core/Particle.cc diff --git a/NPSimulation/include/Particle.hh b/NPSimulation/Core/Particle.hh similarity index 100% rename from NPSimulation/include/Particle.hh rename to NPSimulation/Core/Particle.hh diff --git a/NPSimulation/src/ParticleStack.cc b/NPSimulation/Core/ParticleStack.cc similarity index 100% rename from NPSimulation/src/ParticleStack.cc rename to NPSimulation/Core/ParticleStack.cc diff --git a/NPSimulation/include/ParticleStack.hh b/NPSimulation/Core/ParticleStack.hh similarity index 100% rename from NPSimulation/include/ParticleStack.hh rename to NPSimulation/Core/ParticleStack.hh diff --git a/NPSimulation/src/PhysicsList.cc b/NPSimulation/Core/PhysicsList.cc similarity index 100% rename from NPSimulation/src/PhysicsList.cc rename to NPSimulation/Core/PhysicsList.cc diff --git a/NPSimulation/include/PhysicsList.hh b/NPSimulation/Core/PhysicsList.hh similarity index 100% rename from NPSimulation/include/PhysicsList.hh rename to NPSimulation/Core/PhysicsList.hh diff --git a/NPSimulation/src/PrimaryGeneratorAction.cc b/NPSimulation/Core/PrimaryGeneratorAction.cc similarity index 100% rename from NPSimulation/src/PrimaryGeneratorAction.cc rename to NPSimulation/Core/PrimaryGeneratorAction.cc diff --git a/NPSimulation/include/PrimaryGeneratorAction.hh b/NPSimulation/Core/PrimaryGeneratorAction.hh similarity index 100% rename from NPSimulation/include/PrimaryGeneratorAction.hh rename to NPSimulation/Core/PrimaryGeneratorAction.hh diff --git a/NPSimulation/src/PrimaryGeneratorActionMessenger.cc b/NPSimulation/Core/PrimaryGeneratorActionMessenger.cc similarity index 100% rename from NPSimulation/src/PrimaryGeneratorActionMessenger.cc rename to NPSimulation/Core/PrimaryGeneratorActionMessenger.cc diff --git a/NPSimulation/include/PrimaryGeneratorActionMessenger.hh b/NPSimulation/Core/PrimaryGeneratorActionMessenger.hh similarity index 100% rename from NPSimulation/include/PrimaryGeneratorActionMessenger.hh rename to NPSimulation/Core/PrimaryGeneratorActionMessenger.hh diff --git a/NPSimulation/Core/RunAction.cc b/NPSimulation/Core/RunAction.cc new file mode 100644 index 0000000000000000000000000000000000000000..f5bc177ea012ccf5580fbd1bd5deac19a2fb3653 --- /dev/null +++ b/NPSimulation/Core/RunAction.cc @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (C) 2009-2015 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: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : April 2015 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * A quite Standard Geant4 RunAction class. * + * Use to register the run number in the tree * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// NPS +#include "RunAction.hh" +#include "PrimaryGeneratorAction.hh" +#include "EventAction.hh" +// G4 +#include "G4Run.hh" +#include "G4RunManager.hh" +// NPL +#include "RootOutput.h" +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +RunAction::RunAction(): G4UserRunAction(){ + RootOutput::getInstance()->GetTree()->Branch("Run",&m_RunNumber,"Run/I"); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +RunAction::~RunAction(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void RunAction::BeginOfRunAction(const G4Run* aRun){ + m_RunNumber = aRun->GetRunID()+1; + + //initialize event cumulative quantities + EventAction::GetInstance()->SetRunLength(aRun->GetNumberOfEventToBeProcessed()); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void RunAction::EndOfRunAction(const G4Run* aRun){ + const G4Run* x = aRun; + x=0; +} + diff --git a/NPSimulation/Core/RunAction.hh b/NPSimulation/Core/RunAction.hh new file mode 100644 index 0000000000000000000000000000000000000000..d92ee95070ef869b2f1dce4d32e8527f5d3bec09 --- /dev/null +++ b/NPSimulation/Core/RunAction.hh @@ -0,0 +1,45 @@ +#ifndef RunAction_h +#define RunAction_h 1 +/***************************************************************************** + * Copyright (C) 2009-2015 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: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : April 2015 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * A quite Standard Geant4 RunAction class. * + * Use to register the run number in the tree * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// G4 headers + +#include "G4UserRunAction.hh" +#include "globals.hh" + +class G4Run; + +class RunAction : public G4UserRunAction{ + public: + RunAction(); + virtual ~RunAction(); + + virtual void BeginOfRunAction(const G4Run*); + virtual void EndOfRunAction(const G4Run*); + private: + int m_RunNumber; + +}; + + +#endif + diff --git a/NPSimulation/src/SiliconScorers.cc b/NPSimulation/Core/SiliconScorers.cc similarity index 100% rename from NPSimulation/src/SiliconScorers.cc rename to NPSimulation/Core/SiliconScorers.cc diff --git a/NPSimulation/include/SiliconScorers.hh b/NPSimulation/Core/SiliconScorers.hh similarity index 100% rename from NPSimulation/include/SiliconScorers.hh rename to NPSimulation/Core/SiliconScorers.hh diff --git a/NPSimulation/src/SteppingVerbose.cc b/NPSimulation/Core/SteppingVerbose.cc similarity index 100% rename from NPSimulation/src/SteppingVerbose.cc rename to NPSimulation/Core/SteppingVerbose.cc diff --git a/NPSimulation/include/SteppingVerbose.hh b/NPSimulation/Core/SteppingVerbose.hh similarity index 100% rename from NPSimulation/include/SteppingVerbose.hh rename to NPSimulation/Core/SteppingVerbose.hh diff --git a/NPSimulation/src/Target.cc b/NPSimulation/Core/Target.cc similarity index 99% rename from NPSimulation/src/Target.cc rename to NPSimulation/Core/Target.cc index 30b4429224b553bd60b759629f11353a4698de1b..ac0f327a2e7d1b061c0d92fd296083cd6dd10d09 100644 --- a/NPSimulation/src/Target.cc +++ b/NPSimulation/Core/Target.cc @@ -12,7 +12,7 @@ * Last update : 06/11/2009 * *---------------------------------------------------------------------------* * Decription: * - * This class describe Cryogenic and standard Target. Derived from VDetector* + * This class describe Cryogenic and standard Target. Derived fromNPS::VDetector* * * *---------------------------------------------------------------------------* * Comment: * @@ -68,7 +68,7 @@ Target::Target(){ m_TargetTemperature = 0 ; m_TargetPressure = 0 ; m_EffectiveThickness = 0 ; // effective thickness at 0 deg, compute using angle and thickness - m_TargetNbLayers = 50; // Number of steps by default + m_TargetNbLayers = 5; // Number of steps by default } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -503,9 +503,9 @@ G4double Target::SlowDownBeam(G4ParticleDefinition* Beam, G4double ThicknessBeforeInteraction = abs(ZInteraction - 0.5*m_EffectiveThickness) / cos(m_TargetAngle); G4double dedx,de; + static G4EmCalculator emCalculator; if(m_TargetType){ - G4EmCalculator emCalculator; if(m_TargetThickness!=0){ for (G4int i = 0; i < m_TargetNbLayers; i++){ dedx = emCalculator.ComputeTotalDEDX(IncidentEnergy, Beam, m_TargetMaterial); @@ -516,7 +516,6 @@ G4double Target::SlowDownBeam(G4ParticleDefinition* Beam, } else{ - G4EmCalculator emCalculator; // Windows if(m_WindowsThickness!=0) for (G4int i = 0; i < m_TargetNbLayers; i++){ @@ -533,6 +532,7 @@ G4double Target::SlowDownBeam(G4ParticleDefinition* Beam, IncidentEnergy -= de; } } + return IncidentEnergy; } diff --git a/NPSimulation/include/Target.hh b/NPSimulation/Core/Target.hh similarity index 98% rename from NPSimulation/include/Target.hh rename to NPSimulation/Core/Target.hh index d76dd0efca6b908f401e6ed749b9f4613113b36a..34187522ec1af0257ba8d279b567b9af9fb56c56 100644 --- a/NPSimulation/include/Target.hh +++ b/NPSimulation/Core/Target.hh @@ -14,7 +14,7 @@ * Last update : 06/11/2009 * *---------------------------------------------------------------------------* * Decription: * - * This class describe Cryogenic and standard Target. Derived from VDetector* + * This class describe Cryogenic and standard Target. Derived fromNPS::VDetector* * * *---------------------------------------------------------------------------* * Comment: * @@ -39,12 +39,12 @@ #include "G4LogicalVolume.hh" // NPTool headers -#include "VDetector.hh" +#include "NPSVDetector.hh" using namespace std; using namespace CLHEP; -class Target : public VDetector{ +class Target : public NPS::VDetector{ public: Target(); ~Target(){}; diff --git a/NPSimulation/src/VEventGenerator.cc b/NPSimulation/Core/VEventGenerator.cc similarity index 100% rename from NPSimulation/src/VEventGenerator.cc rename to NPSimulation/Core/VEventGenerator.cc diff --git a/NPSimulation/include/VEventGenerator.hh b/NPSimulation/Core/VEventGenerator.hh similarity index 100% rename from NPSimulation/include/VEventGenerator.hh rename to NPSimulation/Core/VEventGenerator.hh diff --git a/NPSimulation/DUMMYDetector/CMakeLists.txt b/NPSimulation/DUMMYDetector/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9cdb6906fa8544a7e1e3cbc8627a1051b33fee68 --- /dev/null +++ b/NPSimulation/DUMMYDetector/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSDUMMYDetector SHARED DummyDetector.cc) +target_link_libraries(NPSDUMMYDetector NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPDUMMYDetector) diff --git a/NPSimulation/DummyDetector/DummyDetector.cc b/NPSimulation/DUMMYDetector/DummyDetector.cc similarity index 95% rename from NPSimulation/DummyDetector/DummyDetector.cc rename to NPSimulation/DUMMYDetector/DummyDetector.cc index 84849c60ab88203d3aab8490398344bb6e22a94e..b9eac50ec541ec739d11652bae5a28f24c4f5ab8 100644 --- a/NPSimulation/DummyDetector/DummyDetector.cc +++ b/NPSimulation/DUMMYDetector/DummyDetector.cc @@ -42,8 +42,9 @@ #include "G4Colour.hh" // NPTool header -#include "DummyDetector.hh" +#include "DUMMYDetector.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" using namespace OBSOLETEGENERALSCORERS ; @@ -101,7 +102,7 @@ void DUMMYDetector::AddDUMMYDetector( G4double R , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -442,3 +443,24 @@ void DUMMYDetector::InitializeScorers() G4SDManager::GetSDMpointer()->AddNewDetector(m_DUMMYDetectorScorer); } //////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* DUMMYDetector::Construct(){ + return (NPS::VDetector*) new DUMMYDetector(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("DUMMYDetector","DUMMYDetector"); + NPS::DetectorFactory::getInstance()->AddDetector("DUMMYDetector",DUMMYDetector::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/DummyDetector/DummyDetector.hh b/NPSimulation/DUMMYDetector/DummyDetector.hh similarity index 96% rename from NPSimulation/DummyDetector/DummyDetector.hh rename to NPSimulation/DUMMYDetector/DummyDetector.hh index d99d1f50117d5d83d1904ed80561dbd4f6335fa3..75e13f8b5a77a03a974c58c3a0f4900c3b896631 100644 --- a/NPSimulation/DummyDetector/DummyDetector.hh +++ b/NPSimulation/DUMMYDetector/DummyDetector.hh @@ -39,13 +39,13 @@ #include "G4MultiFunctionalDetector.hh" // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "TDUMMYDetectorData.h" using namespace std; using namespace CLHEP; -class DUMMYDetector : public VDetector +class DUMMYDetector : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -68,7 +68,7 @@ public: void VolumeMaker(G4ThreeVector Det_pos, int DetNumber,G4LogicalVolume* world) ; //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -125,5 +125,7 @@ private: vector<G4String> m_Scintillator ; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/Eurogam/CMakeLists.txt b/NPSimulation/Eurogam/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..33f2e2ef962cfe68321f26ccfac98c0a810e145b --- /dev/null +++ b/NPSimulation/Eurogam/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSEurogam SHARED Eurogam.cc) +target_link_libraries(NPSEurogam NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPEurogam) diff --git a/NPSimulation/Eurogam/Eurogam.cc b/NPSimulation/Eurogam/Eurogam.cc index 3ed252e24460d9739a0dc1916410d51486adc186..2502c27a5c8ec34f1e39d9e6594ddcdfe76060f2 100755 --- a/NPSimulation/Eurogam/Eurogam.cc +++ b/NPSimulation/Eurogam/Eurogam.cc @@ -47,6 +47,7 @@ #include "Eurogam.hh" #include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" using namespace OBSOLETEGENERALSCORERS; @@ -665,3 +666,24 @@ void Eurogam::InitializeScorers() // Add All Scorer to the Global Scorer Manager G4SDManager::GetSDMpointer()->AddNewDetector(m_EurogamScorer); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Eurogam::Construct(){ + return (NPS::VDetector*) new Eurogam(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Eurogam","Eurogam"); + NPS::DetectorFactory::getInstance()->AddDetector("Eurogam",Eurogam::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Eurogam/Eurogam.hh b/NPSimulation/Eurogam/Eurogam.hh index b173135673fd3a5eeceea0964f2bd2b4c2e5f066..967e6cbcbc46b85a46f69cbdc722ca91e90899d1 100644 --- a/NPSimulation/Eurogam/Eurogam.hh +++ b/NPSimulation/Eurogam/Eurogam.hh @@ -36,13 +36,13 @@ #include "G4MultiFunctionalDetector.hh" // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "TEurogamData.h" using namespace std; using namespace CLHEP; -class Eurogam : public VDetector +class Eurogam : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -66,7 +66,7 @@ public: //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -127,6 +127,8 @@ private: vector<G4double> m_beta_u; // | vector<G4double> m_beta_v; // > Tilt angle of the detector vector<G4double> m_beta_w; // | +public: + static NPS::VDetector* Construct(); }; diff --git a/NPSimulation/Fatima/CMakeLists.txt b/NPSimulation/Fatima/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..64db645896b7f8af95b017269dcfacf5f5ec7990 --- /dev/null +++ b/NPSimulation/Fatima/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSFatima SHARED Fatima.cc) +target_link_libraries(NPSFatima NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPFatima) diff --git a/NPSimulation/Fatima/Fatima.cc b/NPSimulation/Fatima/Fatima.cc index f2112cefea3ba4069d41640fd1077e54dc068ffc..f89a1269facb538417891c327a3a907e934c0358 100644 --- a/NPSimulation/Fatima/Fatima.cc +++ b/NPSimulation/Fatima/Fatima.cc @@ -42,6 +42,7 @@ using namespace FATIMA; #include "CalorimeterScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" // NPL #include "NPOptionManager.h" #include "RootOutput.h" @@ -112,7 +113,7 @@ void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Fatima::ReadConfiguration(string Path){ @@ -486,3 +487,24 @@ void Fatima::InitializeScorers(){ G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Fatima::Construct(){ + return (NPS::VDetector*) new Fatima(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Fatima","Fatima"); + NPS::DetectorFactory::getInstance()->AddDetector("Fatima",Fatima::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Fatima/Fatima.hh b/NPSimulation/Fatima/Fatima.hh index 254fc3ae16d59a64b4346fec5d3ce5492f85c4ca..47708e0fa0b21165b377485c1faa6920613e5f46 100644 --- a/NPSimulation/Fatima/Fatima.hh +++ b/NPSimulation/Fatima/Fatima.hh @@ -35,14 +35,14 @@ #include "G4MultiFunctionalDetector.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TFatimaData.h" using namespace std; using namespace CLHEP; -class Fatima : public VDetector{ +class Fatima : public NPS::VDetector{ //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// //////////////////////////////////////////////////// @@ -67,7 +67,7 @@ private: // Guarranty that each volume is created only once G4LogicalVolume* m_LogicalDetector; //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -116,6 +116,8 @@ private:/// Visualisation Attribute: G4VisAttributes* m_LaBr3VisAtt; G4VisAttributes* m_DetectorCasingVisAtt ; G4VisAttributes* m_PMTVisAtt; +public: + static NPS::VDetector* Construct(); }; namespace FATIMA{ diff --git a/NPSimulation/GASPARD/CMakeLists.txt b/NPSimulation/GASPARD/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4799f4f45fc9dea1c28b9895492192b89e6be0c1 --- /dev/null +++ b/NPSimulation/GASPARD/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSGASPARD SHARED GaspardScorers.cc GaspardTracker.cc GaspardTrackerAnnular.cc GaspardTrackerDummyShape.cc GaspardTrackerModule.cc GaspardTrackerRectangle.cc GaspardTrackerSquare.cc GaspardTrackerTrapezoid.cc) +target_link_libraries(NPSGASPARD NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPGASPARD) diff --git a/NPSimulation/GASPARD/GaspardTracker.cc b/NPSimulation/GASPARD/GaspardTracker.cc index b993cf0d921323368ccdc868bb880244c5edc799..1724311f349901f39db7a182c45c250a5c066396 100644 --- a/NPSimulation/GASPARD/GaspardTracker.cc +++ b/NPSimulation/GASPARD/GaspardTracker.cc @@ -33,7 +33,7 @@ #include "GaspardTrackerTrapezoid.hh" #include "GaspardTrackerAnnular.hh" #include "GaspardTrackerDummyShape.hh" - +#include "NPSDetectorFactory.hh" using namespace std; @@ -77,7 +77,7 @@ void GaspardTracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store GaspardTrackerSquare "detector" @@ -94,7 +94,7 @@ void GaspardTracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store GaspardTrackerSquare "detector" @@ -111,7 +111,7 @@ void GaspardTracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store GaspardTrackerTrapezoid "detector" @@ -128,7 +128,7 @@ void GaspardTracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store GaspardTrackerTrapezoid "detector" @@ -147,7 +147,7 @@ void GaspardTracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store GaspardTrackerShape "detector" @@ -208,3 +208,24 @@ void GaspardTracker::ReadSensitive(const G4Event* event) int nbDetectors = m_Modules.size(); for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* GaspardTracker::Construct(){ + return (NPS::VDetector*) new GaspardTracker(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("GaspardTracker","GaspardTracker"); + NPS::DetectorFactory::getInstance()->AddDetector("GaspardTracker",GaspardTracker::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/GASPARD/GaspardTracker.hh b/NPSimulation/GASPARD/GaspardTracker.hh index ff730db15eb2af6b907187c33f71a125a373e0bd..5e891e461a8b3a215ae5f91306afe90a83180c66 100644 --- a/NPSimulation/GASPARD/GaspardTracker.hh +++ b/NPSimulation/GASPARD/GaspardTracker.hh @@ -26,7 +26,7 @@ #include <vector> // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "GaspardTrackerModule.hh" using namespace std; @@ -35,7 +35,7 @@ using namespace std; -class GaspardTracker : public VDetector +class GaspardTracker : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -45,7 +45,7 @@ public: virtual ~GaspardTracker(); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -70,5 +70,7 @@ public: private: vector<GaspardTrackerModule*> m_Modules; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/GASPARD/GaspardTrackerAnnular.cc b/NPSimulation/GASPARD/GaspardTrackerAnnular.cc index da76eb36b76eaa204a3077c4fa69ac2d4cdb7aa5..d363c30bca40826958e3523df5936922c04d777c 100644 --- a/NPSimulation/GASPARD/GaspardTrackerAnnular.cc +++ b/NPSimulation/GASPARD/GaspardTrackerAnnular.cc @@ -53,7 +53,7 @@ #include "SiliconScorers.hh" #include "TGaspardTrackerData.h" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -250,7 +250,7 @@ void GaspardTrackerAnnular::VolumeMaker(G4int DetectorNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -412,7 +412,7 @@ void GaspardTrackerAnnular::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void GaspardTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -845,9 +845,9 @@ void GaspardTrackerAnnular::InitializeScorers() { // check whether scorers are already defined bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); if (already_exist) return; diff --git a/NPSimulation/GASPARD/GaspardTrackerAnnular.hh b/NPSimulation/GASPARD/GaspardTrackerAnnular.hh index bb2abde4f9baa7790ad1e934585c2226958c5b46..e2c4f46abbed757508f85ddfb6bbc49efa1545aa 100644 --- a/NPSimulation/GASPARD/GaspardTrackerAnnular.hh +++ b/NPSimulation/GASPARD/GaspardTrackerAnnular.hh @@ -89,9 +89,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -100,7 +100,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/GASPARD/GaspardTrackerDummyShape.cc b/NPSimulation/GASPARD/GaspardTrackerDummyShape.cc index 9bfe8048af2ead7137f7ff1af2cdf98aac2c3175..add19610cccb786f657ee9e4c3da689c29afacac 100644 --- a/NPSimulation/GASPARD/GaspardTrackerDummyShape.cc +++ b/NPSimulation/GASPARD/GaspardTrackerDummyShape.cc @@ -57,7 +57,7 @@ #include "ObsoleteGeneralScorers.hh" #include "GaspardScorers.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -325,7 +325,7 @@ void GaspardTrackerDummyShape::VolumeMaker(G4int DetectorNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -637,7 +637,7 @@ void GaspardTrackerDummyShape::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void GaspardTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -940,9 +940,9 @@ void GaspardTrackerDummyShape::ReadSensitive(const G4Event* event) void GaspardTrackerDummyShape::InitializeScorers() { bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerGPDDummyShape",already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerGPDDummyShape",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDDummyShape",already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDDummyShape",already_exist); if(already_exist) return; // First stage Associate Scorer diff --git a/NPSimulation/GASPARD/GaspardTrackerDummyShape.hh b/NPSimulation/GASPARD/GaspardTrackerDummyShape.hh index d22a9863737b87d7dcb748f8093a0ee3869c3248..3eb12c7527bda25fc7de6343914ef74e00e8ef30 100644 --- a/NPSimulation/GASPARD/GaspardTrackerDummyShape.hh +++ b/NPSimulation/GASPARD/GaspardTrackerDummyShape.hh @@ -104,9 +104,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -115,7 +115,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/GASPARD/GaspardTrackerModule.cc b/NPSimulation/GASPARD/GaspardTrackerModule.cc index 6d460fb4e3f54fcd769d331e545a451a793d7d75..97ed878fd9f9267f9ef770320bd53c7dc8167477 100644 --- a/NPSimulation/GASPARD/GaspardTrackerModule.cc +++ b/NPSimulation/GASPARD/GaspardTrackerModule.cc @@ -21,6 +21,7 @@ #include "GaspardTrackerModule.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" diff --git a/NPSimulation/GASPARD/GaspardTrackerModule.hh b/NPSimulation/GASPARD/GaspardTrackerModule.hh index 60a64ad44bc06c91f3071a235ec7265fc9dc3126..5ba7637ee44fa595fefd9711de63b9f697c1be70 100644 --- a/NPSimulation/GASPARD/GaspardTrackerModule.hh +++ b/NPSimulation/GASPARD/GaspardTrackerModule.hh @@ -63,9 +63,9 @@ public: // Initialize all scorers necessary for each detector virtual void InitializeScorers() = 0; - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; virtual TInteractionCoordinates* GetInterCoordPointer() = 0; diff --git a/NPSimulation/GASPARD/GaspardTrackerRectangle.cc b/NPSimulation/GASPARD/GaspardTrackerRectangle.cc index c2bf95fd0743cb0252acaab99730545421aa2904..b8091e32739c4473e606c0f4c71af1a7fb6010ca 100644 --- a/NPSimulation/GASPARD/GaspardTrackerRectangle.cc +++ b/NPSimulation/GASPARD/GaspardTrackerRectangle.cc @@ -51,8 +51,9 @@ #include "GaspardScorers.hh" #include "SiliconScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -277,7 +278,7 @@ void GaspardTrackerRectangle::VolumeMaker(G4int DetectorNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -631,7 +632,7 @@ void GaspardTrackerRectangle::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void GaspardTrackerRectangle::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -777,9 +778,9 @@ void GaspardTrackerRectangle::InitializeScorers() { // check whether scorers are already defined bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerGPDRectangle", already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerGPDRectangle", already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerGPDRectangle", already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDRectangle", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDRectangle", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDRectangle", already_exist); if (already_exist) return; // First stage scorer diff --git a/NPSimulation/GASPARD/GaspardTrackerRectangle.hh b/NPSimulation/GASPARD/GaspardTrackerRectangle.hh index 51f160cb8175de12bdd6ec7e71cde18b8cb6dd7e..288449f8909a5b64407637df3ed43a7cad16327e 100644 --- a/NPSimulation/GASPARD/GaspardTrackerRectangle.hh +++ b/NPSimulation/GASPARD/GaspardTrackerRectangle.hh @@ -102,18 +102,19 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + //////////////////////////////////////////////////// ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/GASPARD/GaspardTrackerSquare.cc b/NPSimulation/GASPARD/GaspardTrackerSquare.cc index 011527d92d27789f0685508326509a6a53ac3ced..77a31c55f9a3f6b00a713616226af2ae06846e31 100644 --- a/NPSimulation/GASPARD/GaspardTrackerSquare.cc +++ b/NPSimulation/GASPARD/GaspardTrackerSquare.cc @@ -55,8 +55,9 @@ #include "GaspardScorers.hh" #include "SiliconScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -264,7 +265,7 @@ void GaspardTrackerSquare::VolumeMaker(G4int DetectorNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -595,7 +596,7 @@ void GaspardTrackerSquare::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void GaspardTrackerSquare::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -742,9 +743,9 @@ void GaspardTrackerSquare::InitializeScorers() { // check whether scorers are already defined bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerGPDSquare", already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerGPDSquare", already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerGPDSquare", already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDSquare", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDSquare", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDSquare", already_exist); if (already_exist) return; // First stage scorer diff --git a/NPSimulation/GASPARD/GaspardTrackerSquare.hh b/NPSimulation/GASPARD/GaspardTrackerSquare.hh index 836218c9fba8f1eaa204f4b43813128ef7239698..25bfe6aef1fd3abcb6f8c3ca6872d062f3aedab3 100644 --- a/NPSimulation/GASPARD/GaspardTrackerSquare.hh +++ b/NPSimulation/GASPARD/GaspardTrackerSquare.hh @@ -100,9 +100,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -111,7 +111,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/GASPARD/GaspardTrackerTrapezoid.cc b/NPSimulation/GASPARD/GaspardTrackerTrapezoid.cc index 380e5ec77ec434407cfb75becaff851f75d15853..592e96ca65eb6f07c68b031917107f19b24e926b 100644 --- a/NPSimulation/GASPARD/GaspardTrackerTrapezoid.cc +++ b/NPSimulation/GASPARD/GaspardTrackerTrapezoid.cc @@ -51,7 +51,7 @@ #include "ObsoleteGeneralScorers.hh" #include "GaspardScorers.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -288,7 +288,7 @@ void GaspardTrackerTrapezoid::VolumeMaker(G4int DetectorNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -642,7 +642,7 @@ void GaspardTrackerTrapezoid::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void GaspardTrackerTrapezoid::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -937,9 +937,9 @@ void GaspardTrackerTrapezoid::ReadSensitive(const G4Event* event) void GaspardTrackerTrapezoid::InitializeScorers() { bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerGPDTrapezoid", already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerGPDTrapezoid",already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerGPDTrapezoid",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDTrapezoid", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDTrapezoid",already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDTrapezoid",already_exist); if(already_exist) return; diff --git a/NPSimulation/GASPARD/GaspardTrackerTrapezoid.hh b/NPSimulation/GASPARD/GaspardTrackerTrapezoid.hh index 5e564cf44a2ce33d5ed19201ea4c4e4a4e5411df..b677f153ef3c1e454d87949fc7004c18a9b6e778 100644 --- a/NPSimulation/GASPARD/GaspardTrackerTrapezoid.hh +++ b/NPSimulation/GASPARD/GaspardTrackerTrapezoid.hh @@ -102,18 +102,17 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from GaspardTrackerModule - // This is mandatory since the GaspardTracker*** does not derive from VDetector + // This is mandatory since the GaspardTracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; - //////////////////////////////////////////////////// ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/Helios/CMakeLists.txt b/NPSimulation/Helios/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6928bf3e55672a43ab4a04c70fecaaaf55de873b --- /dev/null +++ b/NPSimulation/Helios/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSHelios SHARED Helios.cc HeliosDetDummyShape.cc HeliosModule.cc HeliosScorers.cc) +target_link_libraries(NPSHelios NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPHelios) diff --git a/NPSimulation/Helios/Helios.cc b/NPSimulation/Helios/Helios.cc index 9c1dda8d30fd401c3b785863c063212dcf7b4535..c4eff692df67a10ecd7761ea580e01635ec87a57 100644 --- a/NPSimulation/Helios/Helios.cc +++ b/NPSimulation/Helios/Helios.cc @@ -32,7 +32,7 @@ //#include "HeliosDetTrapezoid.hh" //#include "HeliosDetAnnular.hh" #include "HeliosDetDummyShape.hh" - +#include "NPSDetectorFactory.hh" using namespace std; @@ -76,7 +76,7 @@ void Helios::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store HeliosSquare "detector" @@ -93,7 +93,7 @@ void Helios::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store HeliosTrapezoid "detector" @@ -110,7 +110,7 @@ void Helios::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store HeliosTrapezoid "detector" @@ -131,7 +131,7 @@ void Helios::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store HeliosShape "detector" @@ -192,3 +192,24 @@ void Helios::ReadSensitive(const G4Event* event) int nbDetectors = m_Modules.size(); for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Helios::Construct(){ + return (NPS::VDetector*) new Helios(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Helios","Helios"); + NPS::DetectorFactory::getInstance()->AddDetector("Helios",Helios::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Helios/Helios.hh b/NPSimulation/Helios/Helios.hh index 3ade31aac36a64887786656e71b4260f13ddc71e..5d1886332d81a0a1b4c23db9883d56b8958ffd94 100644 --- a/NPSimulation/Helios/Helios.hh +++ b/NPSimulation/Helios/Helios.hh @@ -27,7 +27,7 @@ #include <vector> // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "HeliosModule.hh" using namespace std; @@ -35,7 +35,7 @@ using namespace std; -class Helios : public VDetector +class Helios : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -45,7 +45,7 @@ public: virtual ~Helios(); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -70,5 +70,7 @@ public: private: vector<HeliosModule*> m_Modules; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/Helios/HeliosDetDummyShape.cc b/NPSimulation/Helios/HeliosDetDummyShape.cc index ef4e3b827a122ecceb36fc378fc53e19c66b8f32..64e07dea73a9d0e70490efe26d3cc2cd76308c6b 100644 --- a/NPSimulation/Helios/HeliosDetDummyShape.cc +++ b/NPSimulation/Helios/HeliosDetDummyShape.cc @@ -46,7 +46,7 @@ // G4 sensitive #include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPTool headers #include "HeliosDetDummyShape.hh" #include "ObsoleteGeneralScorers.hh" @@ -294,7 +294,7 @@ void HeliosDetDummyShape::VolumeMaker(G4int TelescopeNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -609,7 +609,7 @@ void HeliosDetDummyShape::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void HeliosDetDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -853,7 +853,7 @@ void HeliosDetDummyShape::InitializeScorers() { bool already_exist = false; // First stage Associate Scorer - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerHeliosDummyShape",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHeliosDummyShape",already_exist); if(already_exist) return; diff --git a/NPSimulation/Helios/HeliosDetDummyShape.hh b/NPSimulation/Helios/HeliosDetDummyShape.hh index 7afa65fec4ab77a58dfcbbcdb3f84aaa8cc1d064..daca82feb11722ebf8f4d16ad9390f878a1c1639 100644 --- a/NPSimulation/Helios/HeliosDetDummyShape.hh +++ b/NPSimulation/Helios/HeliosDetDummyShape.hh @@ -97,9 +97,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from HeliosModule - // This is mandatory since the Helios*** does not derive from VDetector + // This is mandatory since the Helios*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -108,7 +108,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/Helios/HeliosModule.hh b/NPSimulation/Helios/HeliosModule.hh index 1717514d5a91a508c0eb6571fb3715dd5bb19ff6..38926b0804bb18ff79d86d425748f15149da8849 100644 --- a/NPSimulation/Helios/HeliosModule.hh +++ b/NPSimulation/Helios/HeliosModule.hh @@ -62,9 +62,9 @@ public: // Initialize all scorers necessary for each detector virtual void InitializeScorers() = 0; - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from HeliosModule - // This is mandatory since the Helios*** does not derive from VDetector + // This is mandatory since the Helios*** does not derive from NPS::VDetector virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; virtual TInteractionCoordinates* GetInterCoordPointer() = 0; diff --git a/NPSimulation/Hyde2/CMakeLists.txt b/NPSimulation/Hyde2/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..03fb0db5c51da10e277d250905264ed517e1840f --- /dev/null +++ b/NPSimulation/Hyde2/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSHyde2 SHARED Hyde2Scorers.cc Hyde2Tracker.cc Hyde2TrackerModule.cc Hyde2TrackerSquare1.cc Hyde2TrackerTrapezoid1.cc Hyde2TrackerTrapezoid2.cc) +target_link_libraries(NPSHyde2 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPHyde2) diff --git a/NPSimulation/Hyde2/Hyde2Scorers.cc b/NPSimulation/Hyde2/Hyde2Scorers.cc index 8e55af08e3006efae891cf0c70645c867472aff0..9ae5d284c21e7f32a4c3291e3d8b8f822cae2939 100644 --- a/NPSimulation/Hyde2/Hyde2Scorers.cc +++ b/NPSimulation/Hyde2/Hyde2Scorers.cc @@ -817,4 +817,3 @@ void HYD2ScorerFirstStageBackStripTrapezoid2::PrintAll() G4cout << " PrimitiveScorer " << GetName() << G4endl ; G4cout << " Number of entries " << EvtMap->entries() << G4endl ; } - diff --git a/NPSimulation/Hyde2/Hyde2Tracker.cc b/NPSimulation/Hyde2/Hyde2Tracker.cc index 75cd0a5df4bf6aa77c4d6efc494c4612eb8ad4fe..5e64a6a8c8fcc090dc982bf13c2b94bf6a63221e 100644 --- a/NPSimulation/Hyde2/Hyde2Tracker.cc +++ b/NPSimulation/Hyde2/Hyde2Tracker.cc @@ -31,7 +31,7 @@ #include "Hyde2TrackerSquare1.hh" #include "Hyde2TrackerTrapezoid1.hh" #include "Hyde2TrackerTrapezoid2.hh" - +#include "NPSDetectorFactory.hh" using namespace std; @@ -73,7 +73,7 @@ void Hyde2Tracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store Hyde2TrackerSquare1 "detector" @@ -90,7 +90,7 @@ void Hyde2Tracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store Hyde2TrackerTrapezoid1 "detector" @@ -107,7 +107,7 @@ void Hyde2Tracker::ReadConfiguration(string Path) myDetector->ReadConfiguration(Path); ConfigFile.open(Path.c_str()); - // ms_InterCoord comes from VDetector + // ms_InterCoord comes from NPS::VDetector myDetector->SetInterCoordPointer(ms_InterCoord); // store Hyde2TrackerTrapezoid2 "detector" @@ -168,3 +168,24 @@ void Hyde2Tracker::ReadSensitive(const G4Event* event) int nbDetectors = m_Modules.size(); for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Hyde2Tracker::Construct(){ + return (NPS::VDetector*) new Hyde2Tracker(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Hyde2Tracker","Hyde2Tracker"); + NPS::DetectorFactory::getInstance()->AddDetector("Hyde2Tracker",Hyde2Tracker::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Hyde2/Hyde2Tracker.hh b/NPSimulation/Hyde2/Hyde2Tracker.hh index 98d9573c0232f15e1fd231829df3ca410e2755ef..5f2912260055975172a5f3f93badfc88384794e5 100644 --- a/NPSimulation/Hyde2/Hyde2Tracker.hh +++ b/NPSimulation/Hyde2/Hyde2Tracker.hh @@ -27,7 +27,7 @@ #include <vector> // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "Hyde2TrackerModule.hh" using namespace std; @@ -35,7 +35,7 @@ using namespace std; -class Hyde2Tracker : public VDetector +class Hyde2Tracker : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -45,7 +45,7 @@ public: virtual ~Hyde2Tracker(); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -70,5 +70,7 @@ public: private: vector<Hyde2TrackerModule*> m_Modules; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/Hyde2/Hyde2TrackerModule.cc b/NPSimulation/Hyde2/Hyde2TrackerModule.cc index 9cdf74c80e29b06c217ec348711012b4fe840332..a33fc7cc78fffa314591ae5e958688fce999505d 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerModule.cc +++ b/NPSimulation/Hyde2/Hyde2TrackerModule.cc @@ -21,6 +21,7 @@ #include "Hyde2TrackerModule.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "RootOutput.h" diff --git a/NPSimulation/Hyde2/Hyde2TrackerModule.hh b/NPSimulation/Hyde2/Hyde2TrackerModule.hh index 2b4addf59da7da7eaaf032f0cdbece4aa75ab051..1069b83e588ece0452bcd09451034c659c4673a6 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerModule.hh +++ b/NPSimulation/Hyde2/Hyde2TrackerModule.hh @@ -62,9 +62,9 @@ public: // Initialize all scorers necessary for each detector virtual void InitializeScorers() = 0; - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from Hyde2TrackerModule - // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + // This is mandatory since the Hyde2Tracker*** does not derive from NPS::VDetector virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; virtual TInteractionCoordinates* GetInterCoordPointer() = 0; diff --git a/NPSimulation/Hyde2/Hyde2TrackerSquare1.cc b/NPSimulation/Hyde2/Hyde2TrackerSquare1.cc index a1011fa05e8eefff946058b02508943e793818f4..ac1da838808cd2c6f686e401b886d63e7b8e43dc 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerSquare1.cc +++ b/NPSimulation/Hyde2/Hyde2TrackerSquare1.cc @@ -54,7 +54,7 @@ #include "ObsoleteGeneralScorers.hh" #include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -368,7 +368,7 @@ void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -741,7 +741,7 @@ void Hyde2TrackerSquare1::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -1128,12 +1128,12 @@ void Hyde2TrackerSquare1::ReadSensitive(const G4Event* event) void Hyde2TrackerSquare1::InitializeScorers() { bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerHYD2Square1",already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerHYD2Square1",already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerHYD2Square1",already_exist); - m_FourthStageScorer = VDetector::CheckScorer("FourthStageScorerHYD2Square1",already_exist); - m_FifthStageScorer = VDetector::CheckScorer("FifthStageScorerHYD2Square1",already_exist); - m_SixthStageScorer = VDetector::CheckScorer("SixthStageScorerHYD2Square1",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Square1",already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Square1",already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Square1",already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Square1",already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Square1",already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Square1",already_exist); if(already_exist) return; // First stage Associate Scorer diff --git a/NPSimulation/Hyde2/Hyde2TrackerSquare1.hh b/NPSimulation/Hyde2/Hyde2TrackerSquare1.hh index 8fbb4f9ee0d69a6c35416006a0aef695fe5477a4..460e4d5edd658a72972ae0497a75cc18a3e39a7e 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerSquare1.hh +++ b/NPSimulation/Hyde2/Hyde2TrackerSquare1.hh @@ -110,9 +110,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from Hyde2TrackerModule - // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + // This is mandatory since the Hyde2Tracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -121,7 +121,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.cc b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.cc index f40cdc188bf8cb4013e6ab5312f24ef8136d948f..9f2ede42b84b05aea5a0bee0352d7345b0a01693 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.cc +++ b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.cc @@ -51,7 +51,7 @@ #include "ObsoleteGeneralScorers.hh" #include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -387,7 +387,7 @@ void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -783,7 +783,7 @@ void Hyde2TrackerTrapezoid1::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -1162,12 +1162,12 @@ void Hyde2TrackerTrapezoid1::ReadSensitive(const G4Event* event) void Hyde2TrackerTrapezoid1::InitializeScorers() { bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1",already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1",already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1",already_exist); - m_FourthStageScorer = VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1",already_exist); - m_FifthStageScorer = VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1",already_exist); - m_SixthStageScorer = VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1",already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1",already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1",already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1",already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1",already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1",already_exist); if(already_exist) return; diff --git a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.hh b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.hh index 0a2fe0cab3cd373dd017ee94c096e0de45436ee7..2404cee945bd8b7f830de06eac72cd53d7efbe83 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.hh +++ b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid1.hh @@ -110,9 +110,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from Hyde2TrackerModule - // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + // This is mandatory since the Hyde2Tracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -121,7 +121,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; diff --git a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.cc b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.cc index 4253178c1c26f767466073f448c3fff738208e25..b96656c1ff0c0f491d40650808af6f5afdecdd2d 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.cc +++ b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.cc @@ -51,7 +51,7 @@ #include "ObsoleteGeneralScorers.hh" #include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "VDetector.hh" +#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -387,7 +387,7 @@ void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -783,7 +783,7 @@ void Hyde2TrackerTrapezoid2::InitializeRootOutput() -// Set the TinteractionCoordinates object from VDetector to the present class +// Set the TinteractionCoordinates object from NPS::VDetector to the present class void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; @@ -1162,12 +1162,12 @@ void Hyde2TrackerTrapezoid2::ReadSensitive(const G4Event* event) void Hyde2TrackerTrapezoid2::InitializeScorers() { bool already_exist = false; - m_FirstStageScorer = VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2",already_exist); - m_SecondStageScorer = VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2",already_exist); - m_ThirdStageScorer = VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2",already_exist); - m_FourthStageScorer = VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2",already_exist); - m_FifthStageScorer = VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2",already_exist); - m_SixthStageScorer = VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2",already_exist); + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2",already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2",already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2",already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2",already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2",already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2",already_exist); if(already_exist) return; diff --git a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.hh b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.hh index bb8ce7ca64394822eed40050212885fb2e1c8e33..fd50fae1c53d06f338848d2084e1f42264446a02 100644 --- a/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.hh +++ b/NPSimulation/Hyde2/Hyde2TrackerTrapezoid2.hh @@ -110,9 +110,9 @@ public: // Called at in the EventAction::EndOfEventAvtion void ReadSensitive(const G4Event* event); - // Give the static TInteractionCoordinates from VDetector to the classes + // Give the static TInteractionCoordinates from NPS::VDetector to the classes // deriving from Hyde2TrackerModule - // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + // This is mandatory since the Hyde2Tracker*** does not derive from NPS::VDetector void SetInterCoordPointer(TInteractionCoordinates* interCoord); TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; @@ -121,7 +121,7 @@ public: ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// private: - // Interaction Coordinates coming from VDetector through the + // Interaction Coordinates coming from NPS::VDetector through the // SetInteractionCoordinatesPointer method TInteractionCoordinates* ms_InterCoord; @@ -145,7 +145,6 @@ private: }; - namespace HYD2TRAP2 { // Resolution diff --git a/NPSimulation/MUST2/CMakeLists.txt b/NPSimulation/MUST2/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..575f80c78eafba3c754d20d676dc7e689cd7cca1 --- /dev/null +++ b/NPSimulation/MUST2/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSMUST2 SHARED MUST2Array.cc MUST2Scorers.cc) +target_link_libraries(NPSMUST2 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPMUST2) diff --git a/NPSimulation/MUST2/MUST2Array.cc b/NPSimulation/MUST2/MUST2Array.cc index aeb2a3208dcb01403ec00c667702416edf9bf44c..3595472084638e0da0c1763f26536b5c2060d5ed 100644 --- a/NPSimulation/MUST2/MUST2Array.cc +++ b/NPSimulation/MUST2/MUST2Array.cc @@ -40,6 +40,7 @@ // NPS #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "ObsoleteGeneralScorers.hh" #include "MUST2Scorers.hh" @@ -550,7 +551,7 @@ void MUST2Array::VolumeMaker( G4int TelescopeNumber, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method @@ -1353,3 +1354,24 @@ G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ){ } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* MUST2Array::Construct(){ + return (NPS::VDetector*) new MUST2Array(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("MUST2Array","MUST2Array"); + NPS::DetectorFactory::getInstance()->AddDetector("MUST2Array",MUST2Array::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/MUST2/MUST2Array.hh b/NPSimulation/MUST2/MUST2Array.hh index 552f1e459853a93e6b78697ee952dddc4d8ff61c..33c9bf01892618639bf8366e53934e6f32ce5c71 100644 --- a/NPSimulation/MUST2/MUST2Array.hh +++ b/NPSimulation/MUST2/MUST2Array.hh @@ -24,7 +24,7 @@ * - 16 Si(Li) pad * * - 16 CsI scintillator Crystal * *****************************************************************************/ -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "TMust2Data.h" #include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" @@ -66,7 +66,7 @@ namespace MUST2 const G4double CsI_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*CsIThickness; } -class MUST2Array : public VDetector +class MUST2Array : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -110,7 +110,7 @@ public: //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -204,6 +204,8 @@ private: G4Material* m_MaterialVacuum ; // Mylar G4Material* m_MaterialMyl; +public: + static NPS::VDetector* Construct(); }; extern G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ); diff --git a/NPSimulation/MUST2/MUST2Scorers.hh b/NPSimulation/MUST2/MUST2Scorers.hh index 58ba7d8342711bc394191bd3d3251f56690ef0a1..05725a6055bc90ede8913b5e22dc9da77184a515 100644 --- a/NPSimulation/MUST2/MUST2Scorers.hh +++ b/NPSimulation/MUST2/MUST2Scorers.hh @@ -56,7 +56,7 @@ namespace MUST2 { G4double m_StripPitch; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; @@ -83,7 +83,7 @@ namespace MUST2 { G4double m_StripPitch; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; class PSPadOrCristalNumber : public G4VPrimitiveScorer @@ -106,7 +106,7 @@ namespace MUST2 { private: G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; } diff --git a/NPSimulation/Makefile b/NPSimulation/Makefile deleted file mode 100644 index 5b8bf15b5b6b7f2492e4290c311566833dc00bec..0000000000000000000000000000000000000000 --- a/NPSimulation/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -COPYFILES = CopyIncSrcFiles -DELFILES = DelIncSrcFiles -NPSIM = NPSimulation - -all: $(DELFILES) $(COPYFILES) $(NPSIM) -DelIncSrcFiles: $(NPTOOL)/NPLib/liblist - ./scripts/deletefiles.sh - -CopyIncSrcFiles: DelIncSrcFiles - ./scripts/copyfiles.sh - -NPSimulation: DelIncSrcFiles CopyIncSrcFiles - make -f Makefile.geant4 - -clean: - ./scripts/deletefiles.sh - -distclean: - ./scripts/deletefiles.sh - @echo " + Deleting bin and tmp directories" - rm -rf bin - rm -rf tmp diff --git a/NPSimulation/Makefile.geant4 b/NPSimulation/Makefile.geant4 deleted file mode 100644 index c736721bb6d3561186289373742d8d2f23fa310e..0000000000000000000000000000000000000000 --- a/NPSimulation/Makefile.geant4 +++ /dev/null @@ -1,53 +0,0 @@ -# $Id: GNUmakefile,v 1.1 1999/01/07 16:05:40 gunter Exp $ -# -------------------------------------------------------------- -# GNUmakefile based on examples module by Gabriele Cosmo, 06/04/98. -# -------------------------------------------------------------- - -ROOTCONFIG := root-config -ARCH := $(shell $(ROOTCONFIG) --arch) - -#COPYFILES = CopyIncSrcFiles - -# G4 makefile -name := Simulation -G4TARGET := $(name) -G4EXLIB := true - -ifndef G4INSTALL - G4INSTALL = ../../.. -endif - -# G4 work directory is the path where -# Result of compilation is put in (./$G4WORKDIR/bin/$G4SYSTEM/) -# to execute your programm : ./$G4WORKDIR/bin/$G4SYSTEM/Simulation xx.reaction xx.detector -G4WORKDIR = ./ -G4BIN = ./bin - -CPPFLAGS += $(shell root-config --cflags) -CPPFLAGS += -I$(NPTOOL)/NPLib/include - -ifeq ($(ARCH),linuxx8664gcc) -CPPFLAGS += -Xlinker --no-as-needed -endif - -ifeq ($(ARCH),macosx64) -CPPFLAGS += -Wno-deprecated-register -endif - - -EXTRALIBS = $(shell root-config --glibs) -lMathMore -EXTRALIBS += `$(NPTOOL)/NPLib/liblist` -.PHONY: all -#all: $(COPYFILES) lib bin -all: lib bin - -# copying files associated to selected detectors -#CopyIncSrcFiles: -# ./copyfiles.sh - -cleanVRML: - rm -r *.wrl - -include $(G4INSTALL)/config/architecture.gmk -include $(G4INSTALL)/config/binmake.gmk - diff --git a/NPSimulation/Nana/CMakeLists.txt b/NPSimulation/Nana/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9eaa1f6ef4ceca3bf78d5fe9c8262269c1992a89 --- /dev/null +++ b/NPSimulation/Nana/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSNana SHARED Nana.cc) +target_link_libraries(NPSNana NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPNana) diff --git a/NPSimulation/Nana/Nana.cc b/NPSimulation/Nana/Nana.cc index 3658353edea37e6697ca7c67f9239b48d570d4c3..7138ea487b8b5a4e1a5e663bd5181e98d0037ab2 100644 --- a/NPSimulation/Nana/Nana.cc +++ b/NPSimulation/Nana/Nana.cc @@ -42,6 +42,7 @@ using namespace NANA; #include "CalorimeterScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" // NPL #include "NPOptionManager.h" #include "RootOutput.h" @@ -112,7 +113,7 @@ void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double b } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Nana::ReadConfiguration(string Path){ @@ -485,3 +486,24 @@ void Nana::InitializeScorers(){ G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Nana::Construct(){ + return (NPS::VDetector*) new Nana(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Nana","Nana"); + NPS::DetectorFactory::getInstance()->AddDetector("Nana",Nana::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Nana/Nana.hh b/NPSimulation/Nana/Nana.hh index 2fb54f3d3cd1b174902db507cebda031386db066..14da81021d41ee0570131650cbb6053912f33b2e 100644 --- a/NPSimulation/Nana/Nana.hh +++ b/NPSimulation/Nana/Nana.hh @@ -35,14 +35,14 @@ #include "G4MultiFunctionalDetector.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TNanaData.h" using namespace std; using namespace CLHEP; -class Nana : public VDetector{ +class Nana : public NPS::VDetector{ //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// //////////////////////////////////////////////////// @@ -67,7 +67,7 @@ private: // Guarranty that each volume is created only once G4LogicalVolume* m_LogicalDetector; //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -116,6 +116,8 @@ private:/// Visualisation Attribute: G4VisAttributes* m_LaBr3VisAtt; G4VisAttributes* m_DetectorCasingVisAtt ; G4VisAttributes* m_PMTVisAtt; +public: + static NPS::VDetector* Construct(); }; namespace NANA{ diff --git a/NPSimulation/Paris/CMakeLists.txt b/NPSimulation/Paris/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..618fde020efe606fc43407250c1a9d2f8e99f8d0 --- /dev/null +++ b/NPSimulation/Paris/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSParis SHARED Paris.cc) +target_link_libraries(NPSParis NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPParis) diff --git a/NPSimulation/Paris/Paris.cc b/NPSimulation/Paris/Paris.cc index 4b64c2252447e1a1ada0b8365b6fdbb5369c6f07..f937a5ff1319e16a1c33ebb73d4c9a0c68cc9e01 100644 --- a/NPSimulation/Paris/Paris.cc +++ b/NPSimulation/Paris/Paris.cc @@ -42,6 +42,7 @@ using namespace PARIS; #include "CalorimeterScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" // NPL #include "NPOptionManager.h" #include "RootOutput.h" @@ -162,7 +163,7 @@ void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Paris::ReadConfiguration(string Path){ @@ -609,3 +610,24 @@ void Paris::InitializeScorers(){ G4SDManager::GetSDMpointer()->AddNewDetector(m_NaIScorer) ; } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Paris::Construct(){ + return (NPS::VDetector*) new Paris(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Paris","Paris"); + NPS::DetectorFactory::getInstance()->AddDetector("Paris",Paris::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Paris/Paris.hh b/NPSimulation/Paris/Paris.hh index 77c7d6b336de399c2df5360ef5294dfd1bb4fb17..8729aaaae7d578da0c33445a15ea17c4f2ceeb63 100644 --- a/NPSimulation/Paris/Paris.hh +++ b/NPSimulation/Paris/Paris.hh @@ -35,14 +35,14 @@ #include "G4MultiFunctionalDetector.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TParisData.h" using namespace std; using namespace CLHEP; -class Paris : public VDetector{ +class Paris : public NPS::VDetector{ //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// //////////////////////////////////////////////////// @@ -74,7 +74,7 @@ private: // Guarranty that each volume is created only once G4LogicalVolume* m_LogicalCluster; //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -130,6 +130,8 @@ private:/// Visualisation Attribute: G4VisAttributes* m_PhoswichCasingVisAtt ; G4VisAttributes* m_ClusterCasingVisAtt ; G4VisAttributes* m_PMTVisAtt; +public: + static NPS::VDetector* Construct(); }; namespace PARIS{ diff --git a/NPSimulation/Plastic/CMakeLists.txt b/NPSimulation/Plastic/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d7994b4e9a1e2aecc90c362f28a5ea0458ddaf12 --- /dev/null +++ b/NPSimulation/Plastic/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSPlastic SHARED Plastic.cc) +target_link_libraries(NPSPlastic NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPPlastic) diff --git a/NPSimulation/Plastic/Plastic.cc b/NPSimulation/Plastic/Plastic.cc index 026c48f2dda2884f2cffd88fd67880b9baaa995c..5c967240da198733fd4d6f4129b708f92857522e 100644 --- a/NPSimulation/Plastic/Plastic.cc +++ b/NPSimulation/Plastic/Plastic.cc @@ -45,6 +45,7 @@ #include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" using namespace OBSOLETEGENERALSCORERS ; // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -120,7 +121,7 @@ void Plastic::AddPlastic( G4double R , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -614,3 +615,24 @@ void Plastic::InitializeScorers() { } //////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Plastic::Construct(){ + return (NPS::VDetector*) new Plastic(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Plastic","Plastic"); + NPS::DetectorFactory::getInstance()->AddDetector("Plastic",Plastic::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Plastic/Plastic.hh b/NPSimulation/Plastic/Plastic.hh index 54d30ba232429e7218fcf7440e0b04e343093ea2..7eaf54e320438d9206c69b36c21a12c3059cb145 100644 --- a/NPSimulation/Plastic/Plastic.hh +++ b/NPSimulation/Plastic/Plastic.hh @@ -37,13 +37,13 @@ #include "G4MultiFunctionalDetector.hh" // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" #include "TPlasticData.h" using namespace std; using namespace CLHEP; -class Plastic : public VDetector +class Plastic : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -77,7 +77,7 @@ public: void VolumeMaker(G4ThreeVector Det_pos, int DetNumber,G4LogicalVolume* world) ; //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -132,5 +132,7 @@ private: vector<G4String> m_Scintillator ; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/SSSD/CMakeLists.txt b/NPSimulation/SSSD/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f874cde2faca3de3f6e49b0a880c63e93aa63249 --- /dev/null +++ b/NPSimulation/SSSD/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSSSSD SHARED ThinSi.cc ThinSiScorers.cc) +target_link_libraries(NPSSSSD NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSSSD) diff --git a/NPSimulation/SSSD/ThinSi.cc b/NPSimulation/SSSD/ThinSi.cc index a068f0924528daa10d0c8a033ce21be2ca0922dd..7265b209cc10245bf9b4e0d662fe20e047a43a85 100644 --- a/NPSimulation/SSSD/ThinSi.cc +++ b/NPSimulation/SSSD/ThinSi.cc @@ -44,6 +44,7 @@ // NPTool header #include "ThinSi.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "ObsoleteGeneralScorers.hh" #include "ThinSiScorers.hh" #include "RootOutput.h" @@ -227,7 +228,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -677,3 +678,24 @@ void ThinSi::InitializeMaterial(){ } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* ThinSi::Construct(){ + return (NPS::VDetector*) new ThinSi(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("ThinSi","ThinSi"); + NPS::DetectorFactory::getInstance()->AddDetector("ThinSi",ThinSi::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/SSSD/ThinSi.hh b/NPSimulation/SSSD/ThinSi.hh index 440690054e1ec68d48329473d4a5206da5ef1b48..d47e79d3f43c678d2d423b85573123e2b609b59e 100644 --- a/NPSimulation/SSSD/ThinSi.hh +++ b/NPSimulation/SSSD/ThinSi.hh @@ -33,7 +33,7 @@ #include "G4LogicalVolume.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TSSSDData.h" @@ -63,7 +63,7 @@ namespace THINSI using namespace THINSI ; -class ThinSi : public VDetector +class ThinSi : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -98,7 +98,7 @@ public: //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -167,5 +167,7 @@ private: vector<G4double> m_beta_u ; // | vector<G4double> m_beta_v ; // >Tilt angle of the Telescope vector<G4double> m_beta_w ; // | +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/SSSD/ThinSiScorers.cc b/NPSimulation/SSSD/ThinSiScorers.cc index 2c416d778639c9787dfbf2d2a7b71296af79c762..ba2ba9889d8b2ec9a27cf4f9dc4187b99561934f 100644 --- a/NPSimulation/SSSD/ThinSiScorers.cc +++ b/NPSimulation/SSSD/ThinSiScorers.cc @@ -94,7 +94,3 @@ void PSStripNumber::PrintAll() G4cout << " PrimitiveScorer " << GetName() << G4endl ; G4cout << " Number of entries " << EvtMap->entries() << G4endl ; } - - - - diff --git a/NPSimulation/SSSD/ThinSiScorers.hh b/NPSimulation/SSSD/ThinSiScorers.hh index afb115bfd3d38610fd729c2cf410c2a2d17cb18a..e3d344f12d61f124f32b0979013a0a67b477762b 100644 --- a/NPSimulation/SSSD/ThinSiScorers.hh +++ b/NPSimulation/SSSD/ThinSiScorers.hh @@ -56,7 +56,7 @@ namespace THINSI { G4double m_StripPitch ; G4int HCID; G4THitsMap<G4int>* EvtMap; - }; +}; } diff --git a/NPSimulation/Sharc/CMakeLists.txt b/NPSimulation/Sharc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb358ec9b4fbf130cdae80109056581165bd133d --- /dev/null +++ b/NPSimulation/Sharc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSSharc SHARED Sharc.cc) +target_link_libraries(NPSSharc NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSharc) diff --git a/NPSimulation/Sharc/Sharc.cc b/NPSimulation/Sharc/Sharc.cc index 2a1841c2d82ccce23f38358148cd32764f2a8c7e..2aacfdc7d3cb2581c37c89c6d72e4ac23c1042b9 100644 --- a/NPSimulation/Sharc/Sharc.cc +++ b/NPSimulation/Sharc/Sharc.cc @@ -44,6 +44,7 @@ #include "Sharc.hh" #include "SiliconScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" // NPL #include "NPOptionManager.h" @@ -110,7 +111,7 @@ void Sharc::AddQQQDetector(G4ThreeVector Pos,G4double Thickness){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Sharc::ReadConfiguration(string Path){ @@ -813,3 +814,24 @@ void Sharc::InitializeMaterial(){ } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Sharc::Construct(){ + return (NPS::VDetector*) new Sharc(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Sharc","Sharc"); + NPS::DetectorFactory::getInstance()->AddDetector("Sharc",Sharc::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Sharc/Sharc.hh b/NPSimulation/Sharc/Sharc.hh index 8371d3e8e529e1795747fab247cc2fca24710d56..a0f2d9c121b7383ab6279cb9619e1ea0d9bb28de 100644 --- a/NPSimulation/Sharc/Sharc.hh +++ b/NPSimulation/Sharc/Sharc.hh @@ -35,7 +35,7 @@ #include "G4MultiFunctionalDetector.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TSharcData.h" @@ -141,7 +141,7 @@ namespace SHARC{ } using namespace SHARC ; -class Sharc : public VDetector +class Sharc : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -164,7 +164,7 @@ public: void ConstructQQQDetector(G4LogicalVolume* world); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -237,5 +237,7 @@ private:/// Visualisation Attribute: // Light Grey G4VisAttributes* FrameVisAtt ; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc index 124e87d36dc6cb9bae03916c3503e45b4749df37..80823ef42e444fa032bc105684db521ee70603e2 100644 --- a/NPSimulation/Simulation.cc +++ b/NPSimulation/Simulation.cc @@ -1,4 +1,7 @@ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// STL +#include<cstdlib> + #include "G4RunManager.hh" #include "G4PhysListFactory.hh" // UI @@ -24,7 +27,7 @@ // NPS headers #include "EventAction.hh" -#include "VDetector.hh" +#include "RunAction.hh" //NPL headers #include "NPOptionManager.h" @@ -98,19 +101,35 @@ int main(int argc, char** argv){ event_action->SetDetector(detector) ; runManager->SetUserAction(event_action) ; + /////////////////////////////////////////////////////////////// + /////////////////// Starting the Run Action /////////////////// + /////////////////////////////////////////////////////////////// + RunAction* run_action = new RunAction() ; + runManager->SetUserAction(run_action); #ifdef G4UI_USE #ifdef G4VIS_USE - UImanager->ApplyCommand("/control/execute macro/aliases.mac"); + string Path_Macro = getenv("NPTOOL"); + Path_Macro+="/NPSimulation/macro/"; + + UImanager->ApplyCommand("/control/execute " +Path_Macro+"aliases.mac"); G4VisManager* visManager = new G4VisExecutive("Quiet"); visManager->Initialize(); - UImanager->ApplyCommand("/control/execute macro/vis.mac"); + UImanager->ApplyCommand("/control/execute " +Path_Macro+"vis.mac"); #endif if (ui->IsGUI()){ - UImanager->ApplyCommand("/control/execute macro/gui.mac"); + UImanager->ApplyCommand("/control/execute " +Path_Macro+"gui.mac"); } - +#ifdef __APPLE__ + string command= "osascript "; + command+= getenv("NPTOOL"); + command+="/NPSimulation/scripts/bringtofront.osa & "; + int res =system(command.c_str()); + res =0; +#endif + ui->SessionStart(); + delete ui; #endif diff --git a/NPSimulation/Tiara/CMakeLists.txt b/NPSimulation/Tiara/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa2f6600fef9b85de711db7260a234b725f6715a --- /dev/null +++ b/NPSimulation/Tiara/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSTiara SHARED Tiara.cc) +target_link_libraries(NPSTiara NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPTiara) diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc index 8a5b13b3a8447fe87c265a0b025722e21a51fedf..579bff71e135bd42ba6b7d22f9f632f535c8451d 100644 --- a/NPSimulation/Tiara/Tiara.cc +++ b/NPSimulation/Tiara/Tiara.cc @@ -43,7 +43,9 @@ // NPS #include "Tiara.hh" +#include "NPSDetectorFactory.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "SiliconScorers.hh" // NPL @@ -87,7 +89,7 @@ Tiara::~Tiara(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Tiara::ReadConfiguration(string Path){ @@ -858,6 +860,28 @@ void Tiara::InitializeMaterial(){ m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* Tiara::Construct(){ + return (NPS::VDetector*) new Tiara(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class brlproxy{ + public: + brlproxy(){ + NPS::DetectorFactory::getInstance()->AddToken("TiaraInnerBarrel=","Tiara"); + NPS::DetectorFactory::getInstance()->AddDetector("TiaraInnerBarrel=",Tiara::Construct); + } +}; + +brlproxy brlp; +} + diff --git a/NPSimulation/Tiara/Tiara.hh b/NPSimulation/Tiara/Tiara.hh index 57b9cdc27cb4822a7e7537ea3d0d231a1d0af4e2..9abbc24aa68a80099a73a50b82093eb5995b5495 100644 --- a/NPSimulation/Tiara/Tiara.hh +++ b/NPSimulation/Tiara/Tiara.hh @@ -35,7 +35,7 @@ #include "G4MultiFunctionalDetector.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TTiaraBarrelData.h" @@ -118,7 +118,7 @@ namespace TIARA{ using namespace TIARA; -class Tiara : public VDetector +class Tiara : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -139,7 +139,7 @@ public: void ConstructChamber(G4LogicalVolume* world); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -216,5 +216,10 @@ private:/// Visualisation Attribute: G4VisAttributes* FrameVisAtt ; // Light Blue G4VisAttributes* GuardRingVisAtt ; + + public: + static NPS::VDetector* Construct(); + }; + #endif diff --git a/NPSimulation/Tigress/CMakeLists.txt b/NPSimulation/Tigress/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c93d4e4c1fd9c440c11c5305a7f2044ec9983647 --- /dev/null +++ b/NPSimulation/Tigress/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSTigress SHARED Tigress.cc) +target_link_libraries(NPSTigress NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPTigress) diff --git a/NPSimulation/Tigress/Tigress.cc b/NPSimulation/Tigress/Tigress.cc index 4ab25dba9d0341af209a4028ac87ab095e1d0f13..61d0da3c05a0a38d234d456fc9cd1afacde206bb 100644 --- a/NPSimulation/Tigress/Tigress.cc +++ b/NPSimulation/Tigress/Tigress.cc @@ -56,6 +56,7 @@ #include "Tigress.hh" //#include "TigressScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" // NPL #include "NPOptionManager.h" @@ -129,7 +130,7 @@ Tigress::~Tigress(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of VDetector class +// Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Tigress::ReadConfiguration(string Path){ @@ -947,3 +948,24 @@ void Tigress::InitializeMaterial(){ } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* Tigress::Construct(){ + return (NPS::VDetector*) new Tigress(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("Tigress","Tigress"); + NPS::DetectorFactory::getInstance()->AddDetector("Tigress",Tigress::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/Tigress/Tigress.hh b/NPSimulation/Tigress/Tigress.hh index fa27d7b95961f4c0eeb286cebbaf6dda0a368ddc..74119e3e9f965ffdc647b9fd61f137580cc038c5 100644 --- a/NPSimulation/Tigress/Tigress.hh +++ b/NPSimulation/Tigress/Tigress.hh @@ -35,7 +35,7 @@ #include "G4VSolid.hh" // NPSimulation header -#include "VDetector.hh" +#include "NPSVDetector.hh" // NPLib #include "TTigressData.h" @@ -53,7 +53,7 @@ namespace TIGRESS } using namespace TIGRESS ; -class Tigress : public VDetector +class Tigress : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -94,7 +94,7 @@ public: G4VSolid* ConstructBGO(); //////////////////////////////////////////////////// - ///////// Inherite from VDetector class /////////// + ///////// Inherite from NPS::VDetector class /////////// //////////////////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -165,5 +165,7 @@ private:/// Visualisation Attribute: G4VisAttributes* RedVisAtt; G4VisAttributes* WhiteVisAtt; G4VisAttributes* TrGreyVisAtt; +public: + static NPS::VDetector* Construct(); }; #endif diff --git a/NPSimulation/W1/CMakeLists.txt b/NPSimulation/W1/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..409e428296577f12a03369e83c5463055578edf4 --- /dev/null +++ b/NPSimulation/W1/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSW1 SHARED W1.cc W1Scorers.cc) +target_link_libraries(NPSW1 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPW1) diff --git a/NPSimulation/W1/W1.cc b/NPSimulation/W1/W1.cc index f40c0e47fd6442b86046f139d4fceba9a2434a0c..b8f1026defbdae8d99e410a9daa7fd2919cbbc03 100644 --- a/NPSimulation/W1/W1.cc +++ b/NPSimulation/W1/W1.cc @@ -44,6 +44,7 @@ // NPTool headers #include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" #include "W1.hh" #include "W1Scorers.hh" #include "TW1Data.h" @@ -740,3 +741,24 @@ void W1::InitializeScorers(){ // Add All Scorer to the Global Scorer Manager G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); } + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPS::VDetector* W1::Construct(){ + return (NPS::VDetector*) new W1(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("W1","W1"); + NPS::DetectorFactory::getInstance()->AddDetector("W1",W1::Construct); + } +}; + + proxy p; + } diff --git a/NPSimulation/W1/W1.hh b/NPSimulation/W1/W1.hh index eb6c20057b84e8bb5fc0c115632db06ddf2019c3..5ba59a9ea4d94004688c19bc7210c550c1899aea 100644 --- a/NPSimulation/W1/W1.hh +++ b/NPSimulation/W1/W1.hh @@ -27,7 +27,7 @@ #include <vector> // NPTool header -#include "VDetector.hh" +#include "NPSVDetector.hh" // Geant4 headers #include "G4MultiFunctionalDetector.hh" @@ -40,7 +40,7 @@ using namespace std; -class W1 : public VDetector +class W1 : public NPS::VDetector { //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// @@ -70,7 +70,7 @@ public: ///////////////////////////////////////// - //// Inherite from VDetector class ///// + //// Inherite from NPS::VDetector class ///// ///////////////////////////////////////// public: // Read stream at Configfile to pick-up parameters of detector (Position,...) @@ -148,6 +148,8 @@ private: // Set to true if you want to see Telescope Frame in your visualisation bool m_non_sensitive_part_visiualisation; +public: + static NPS::VDetector* Construct(); }; diff --git a/NPSimulation/include/.gitignore b/NPSimulation/include/.gitignore deleted file mode 100644 index d0fd0137288a79d343f0762898dccc667dcd16db..0000000000000000000000000000000000000000 --- a/NPSimulation/include/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.hh diff --git a/NPSimulation/macro/aliases.mac b/NPSimulation/macro/aliases.mac.in similarity index 78% rename from NPSimulation/macro/aliases.mac rename to NPSimulation/macro/aliases.mac.in index 20e183d8343462a7c6ea6cf39d9f97750fbd0ac2..ad7c40a14b728336263f95ea24849bb9e2ef83a3 100644 --- a/NPSimulation/macro/aliases.mac +++ b/NPSimulation/macro/aliases.mac.in @@ -1,7 +1,7 @@ # Aliases are needed to avoid warning /control/alias gui_beamon "/run/beamOn 1" -/control/alias gui_vis "/control/execute macro/vis.mac" -/control/alias gui_browser "/control/execute macro/browser.mac" +/control/alias gui_vis "/control/execute @CMAKE_BINARY_DIR@/macro/vis.mac" +/control/alias gui_browser "/control/execute @CMAKE_BINARY_DIR@/macro/browser.mac" /control/alias gui_tracking "/tracking/verbose 1" /control/alias gui_surface "/vis/viewer/set/style surface" /control/alias gui_wireframe "/vis/viewer/set/style wireframe" @@ -16,5 +16,5 @@ /control/alias gui_empty "/" /control/alias gui_exit "exit" /control/alias gui_nptool "./scripts/url.sh" -/control/alias gui_update "/control/execute macro/reload.mac" +/control/alias gui_update "/control/execute @CMAKE_BINARY_DIR@/macro/reload.mac" /control/alias gui_open "/det/open" diff --git a/NPSimulation/macro/gui.mac b/NPSimulation/macro/gui.mac deleted file mode 100644 index 5e7afec71b426157748f8d8ed7f9f318ee6b1442..0000000000000000000000000000000000000000 --- a/NPSimulation/macro/gui.mac +++ /dev/null @@ -1,43 +0,0 @@ -# This file permits to customize, with commands, -# the menu bar of the G4UIXm, G4UIQt, G4UIWin32 sessions. -# It has no effect with G4UIterminal. - -# Viewer menu : -/gui/addMenu viewer Viewer -/gui/addButton viewer "New viewer" "{gui_vis}" -/gui/addButton viewer "Set style surface" "{gui_surface}" -/gui/addButton viewer "Set style wireframe" "{gui_wireframe}" - -# Custom visualisation menu -/gui/addMenu custom "Custom View" -/gui/addButton custom "Add axis" "/vis/scene/add/axes" -/gui/addButton custom "Add beam axis" "{gui_beam}" -/gui/addButton custom "Add event ID" "/vis/scene/add/eventID" -/gui/addButton custom "Add step point" "/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true" - -# No hit collection is implemented -#/gui/addButton custom "Add Scorer Hits" "/vis/scene/add/psHits" -#/gui/addButton custom "Add Hits" "/vis/scene/add/hits" - -# NPS tool bar -/gui/addIcon "Follow us on GitHub" user_icon "/gui/system {gui_nptool}" icons/NPToolLogo.png -/gui/addIcon "Exit" user_icon "{gui_exit}" icons/power.png -/gui/addIcon "the star gaze" user_icon "{gui_empty}" icons/empty.png -/gui/addIcon "Update geometry" user_icon "{gui_update}" icons/recycle.png -/gui/addIcon "Update generator" user_icon "/gen/update" icons/bolt.png -/gui/addIcon "Open generator" user_icon "/gen/open" icons/folder.png -/gui/addIcon "the moon beyond the clouds" user_icon "{gui_empty}" icons/empty.png -/gui/addIcon "Run beam on" user_icon "/run/beamOn" icons/rocket.png -/gui/addIcon "One event" user_icon "{gui_beamon}" icons/play.png -/gui/addIcon "Activate tracking verbose" user_icon "{gui_tracking}" icons/shoeprints.png -/gui/addIcon "fill the empty dark" user_icon "{gui_empty}" icons/empty.png -/gui/addIcon "View Browser" user_icon "{gui_browser}" icons/browser.png -/gui/addIcon "Take a screen shot" user_icon "/vis/ogl/printEPS" icons/camera.png -/gui/addIcon "Home" user_icon "{gui_home}" icons/eye.png -/gui/addIcon "Front" user_icon "{gui_front}" icons/arrow-up.png -/gui/addIcon "Back" user_icon "{gui_back}" icons/arrow-down.png -/gui/addIcon "Left" user_icon "{gui_left}" icons/arrow-left.png -/gui/addIcon "Right" user_icon "{gui_right}" icons/arrow-right.png -/gui/addIcon "Zoom in" user_icon "{gui_zoomin}" icons/zoomin.png -/gui/addIcon "Zoom out" user_icon "{gui_zoomout}" icons/zoomout.png - diff --git a/NPSimulation/macro/gui.mac.in b/NPSimulation/macro/gui.mac.in new file mode 100644 index 0000000000000000000000000000000000000000..c69caf9a0212ab02da687ba7d645acce5948c9a2 --- /dev/null +++ b/NPSimulation/macro/gui.mac.in @@ -0,0 +1,43 @@ +# This file permits to customize, with commands, +# the menu bar of the G4UIXm, G4UIQt, G4UIWin32 sessions. +# It has no effect with G4UIterminal. + +# Viewer menu : +/gui/addMenu viewer Viewer +/gui/addButton viewer "New viewer" "{gui_vis}" +/gui/addButton viewer "Set style surface" "{gui_surface}" +/gui/addButton viewer "Set style wireframe" "{gui_wireframe}" + +# Custom visualisation menu +/gui/addMenu custom "Custom View" +/gui/addButton custom "Add axis" "/vis/scene/add/axes" +/gui/addButton custom "Add beam axis" "{gui_beam}" +/gui/addButton custom "Add event ID" "/vis/scene/add/eventID" +/gui/addButton custom "Add step point" "/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true" + +# No hit collection is implemented +#/gui/addButton custom "Add Scorer Hits" "/vis/scene/add/psHits" +#/gui/addButton custom "Add Hits" "/vis/scene/add/hits" + +# NPS tool bar +/gui/addIcon "Follow us on GitHub" user_icon "/gui/system {gui_nptool}" @CMAKE_BINARY_DIR@/icons/NPToolLogo.png +/gui/addIcon "Exit" user_icon "{gui_exit}" @CMAKE_BINARY_DIR@/icons/power.png +/gui/addIcon "the star gaze" user_icon "{gui_empty}" @CMAKE_BINARY_DIR@/icons/empty.png +/gui/addIcon "Update geometry" user_icon "{gui_update}" @CMAKE_BINARY_DIR@/icons/recycle.png +/gui/addIcon "Update generator" user_icon "/gen/update" @CMAKE_BINARY_DIR@/icons/bolt.png +/gui/addIcon "Open generator" user_icon "/gen/open" @CMAKE_BINARY_DIR@/icons/folder.png +/gui/addIcon "the moon beyond the clouds" user_icon "{gui_empty}" @CMAKE_BINARY_DIR@/icons/empty.png +/gui/addIcon "Run beam on" user_icon "/run/beamOn" @CMAKE_BINARY_DIR@/icons/rocket.png +/gui/addIcon "One event" user_icon "{gui_beamon}" @CMAKE_BINARY_DIR@/icons/play.png +/gui/addIcon "Activate tracking verbose" user_icon "{gui_tracking}" @CMAKE_BINARY_DIR@/icons/shoeprints.png +/gui/addIcon "fill the empty dark" user_icon "{gui_empty}" @CMAKE_BINARY_DIR@/icons/empty.png +/gui/addIcon "View Browser" user_icon "{gui_browser}" @CMAKE_BINARY_DIR@/icons/browser.png +/gui/addIcon "Take a screen shot" user_icon "/vis/ogl/printEPS" @CMAKE_BINARY_DIR@/icons/camera.png +/gui/addIcon "Home" user_icon "{gui_home}" @CMAKE_BINARY_DIR@/icons/eye.png +/gui/addIcon "Front" user_icon "{gui_front}" @CMAKE_BINARY_DIR@/icons/arrow-up.png +/gui/addIcon "Back" user_icon "{gui_back}" @CMAKE_BINARY_DIR@/icons/arrow-down.png +/gui/addIcon "Left" user_icon "{gui_left}" @CMAKE_BINARY_DIR@/icons/arrow-left.png +/gui/addIcon "Right" user_icon "{gui_right}" @CMAKE_BINARY_DIR@/icons/arrow-right.png +/gui/addIcon "Zoom in" user_icon "{gui_zoomin}" @CMAKE_BINARY_DIR@/icons/zoomin.png +/gui/addIcon "Zoom out" user_icon "{gui_zoomout}" @CMAKE_BINARY_DIR@/icons/zoomout.png + diff --git a/NPSimulation/scripts/bringtofront.osa b/NPSimulation/scripts/bringtofront.osa new file mode 100644 index 0000000000000000000000000000000000000000..f81cd0c7667ccb1bbc2583ca87ba9567d69e1145 --- /dev/null +++ b/NPSimulation/scripts/bringtofront.osa @@ -0,0 +1,5 @@ +tell application "Finder" + tell process "npsimulation" + set frontmost to true + end tell +end tell diff --git a/NPSimulation/scripts/copyfiles.sh b/NPSimulation/scripts/copyfiles.sh deleted file mode 100755 index b963dec729314bc1767a84c99776ca84f71ab02d..0000000000000000000000000000000000000000 --- a/NPSimulation/scripts/copyfiles.sh +++ /dev/null @@ -1,67 +0,0 @@ -# ***************************************************************************** -# * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * -# * * -# * Creation Date : 26/06/13 * -# * Last update : * -# *---------------------------------------------------------------------------* -# * Decription: This script loops on all subdirectories and make a symbolic * -# * link of headers and source files to the include and src * -# * directories, respectively * -# * Files are copied *only* if the detector has been selected * -# * during the NPLib configuration step * -# * * -# *---------------------------------------------------------------------------* -# * Comment: * -# * * -# * * -# ***************************************************************************** - -#! /bin/bash - -# read .detector_libs file created by the $NPLib/configure script -if [ $# = 0 ] ; then - file="../NPLib/.detector_libs" -fi ; -read -r detectorlibs < "$file" - -# loop on all sub-directories -for dir in * -do - # only treat directories - if [ -d "$dir" ]; then - dir=$(basename "$dir") - # file name in lower case - ldir=$(echo "$dir" | tr '[A-Z]' '[a-z]') - # only copy files associated to defined detector libraries - if echo "$detectorlibs" | grep -q "$ldir" ; then - # print informations - # echo " + Copying files from $ldir directory..." - # enter directory - cd $dir - # loop on files in directory - for file in * - do - # get file extension - ext=${file##*.} - # test if this is a header file - if [ $ext = hh ]; then - path="../$dir/$file" - ln -s $path ../include - # test if this is a source file - elif [ $ext = cc ]; then - path="../$dir/$file" - ln -s $path ../src - fi ; - done - # go back to top directory - cd ../ - fi ; - fi -done diff --git a/NPSimulation/scripts/deletefiles.sh b/NPSimulation/scripts/deletefiles.sh deleted file mode 100755 index 8451236a2dc09a2aebc2a4e2e2a9832921aad890..0000000000000000000000000000000000000000 --- a/NPSimulation/scripts/deletefiles.sh +++ /dev/null @@ -1,69 +0,0 @@ -# ***************************************************************************** -# * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * -# * * -# * Creation Date : 26/06/13 * -# * Last update : * -# *---------------------------------------------------------------------------* -# * Decription: This script is in charge of deleting the headers and source * -# * files associated with any detector found in the $NPS/include * -# * and $NPS/src directories. * -# * * -# *---------------------------------------------------------------------------* -# * Comment: * -# * * -# * * -# ***************************************************************************** - -#! /bin/bash - -incsrcdir="include src" - -# print informations -echo " + Cleaning include directory from detectors' header files..." - -# loop recursively on include files in sub-directories -for file in */*.hh -do - header=$(basename "$file") - dir=$(dirname "$file") - # directory name in lower case - ldir=$(echo "$dir" | tr '[A-Z]' '[a-z]') - # delete files associated to all detector libraries - if ! echo "$incsrcdir" | grep -q "$ldir" ; then - # enter directory - cd include - # delete include files - rm -f $header - # go back to top directory - cd ../ - fi ; -done - - -# print informations -echo " + Cleaning src directory from detectors' source files..." - -# loop recursively on include files in sub-directories -for file in */*.cc -do - src=$(basename "$file") - dir=$(dirname "$file") - # directory name in lower case - ldir=$(echo "$dir" | tr '[A-Z]' '[a-z]') - # only delete files associated to defined detector libraries - if ! echo "$incsrcdir" | grep -q "$ldir" ; then - # enter directory - cd src - # delete include files - rm -f $src - # go back to top directory - cd ../ - fi ; -done diff --git a/NPSimulation/src/.gitignore b/NPSimulation/src/.gitignore deleted file mode 100644 index 283034ca8b41040e2fa9087ba8fc179f0b655e89..0000000000000000000000000000000000000000 --- a/NPSimulation/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.cc diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc deleted file mode 100644 index fbada82053d4b01e51035a29720dc02be6077c21..0000000000000000000000000000000000000000 --- a/NPSimulation/src/DetectorConstruction.cc +++ /dev/null @@ -1,819 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2009-2013 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: Adrien MATTA contact address: matta@ipno.in2p3.fr * - * * - * Creation Date : January 2009 * - * Last update : 26/08/2010 (M. Labiche) * - *---------------------------------------------------------------------------* - * Decription: * - * This Class manage the virtual detector and call their method. * - * Every time a new detector is added to the project, a few line in the * - * ReadConfigurationFile method are needed in order to detect the associate * - * token. * - *---------------------------------------------------------------------------* - * Comment: * - * 15/01/10: Added Chamber (marc.labiche@stfc.ac.uk) * - * 04/12/09: Added PARIS detector (marc.labiche@stfc.ac.uk) * - *****************************************************************************/ - -#include "DetectorConstruction.hh" - -// G4 -#include "G4Material.hh" -#include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Sphere.hh" -#include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" -#include "G4PVPlacement.hh" -#include "globals.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" -#include "G4ios.hh" -#include "G4String.hh" -#include "G4RotationMatrix.hh" -#include "MyMagneticField.hh" -#include "G4FieldManager.hh" -#include "G4TransportationManager.hh" -#include "G4ChordFinder.hh" -#include "G4MagIntegratorStepper.hh" -#include "G4SubtractionSolid.hh" -#include "G4GeometryManager.hh" -#include "G4GeometryMessenger.hh" -#include "G4PhysicalVolumeStore.hh" -#include "G4LogicalVolumeStore.hh" -#include "G4VPhysicalVolume.hh" -#include "G4SolidStore.hh" -#include "G4RunManager.hh" -#include "G4SDManager.hh" -// Detector class -#include "../../NPLib/DetectorList.inc" -#include "Chamber.hh" - -#ifdef INC_ANNULARS1 -#include "AnnularS1.hh" -#endif - -#ifdef INC_COMPTONTELESCOPE -#include "ComptonTelescope.hh" -#endif - -#ifdef INC_DUMMYDETECTOR -#include "DummyDetector.hh" -#endif - -#ifdef INC_EUROGAM -#include "Eurogam.hh" -#endif - -#ifdef INC_FATIMA -#include "Fatima.hh" -#endif - -#ifdef INC_GASPARD -#include "GaspardTracker.hh" -#endif - -#ifdef INC_HELIOS -#include "Helios.hh" -#endif - -#ifdef INC_HYDE2 -#include "Hyde2Tracker.hh" -#endif - -#ifdef INC_MUST2 -#include "MUST2Array.hh" -#endif - -#ifdef INC_NANA -#include "Nana.hh" -#endif - -#ifdef INC_PARIS -#include "Paris.hh" -#endif - -#ifdef INC_PLASTIC -#include "Plastic.hh" -#endif - -#include "Target.hh" - -#ifdef INC_SSSD -#include "ThinSi.hh" -#endif - -#ifdef INC_SHARC -#include "Sharc.hh" -#endif - -#ifdef INC_TIGRESS -#include "Tigress.hh" -#endif - -#ifdef INC_TIARA -#include "Tiara.hh" -#endif - -#ifdef INC_W1 -#include "W1.hh" -#endif - - -// STL -#include<cstdlib> -#include<fstream> - -// NPL -#include "RootOutput.h" -#include "NPOptionManager.h" -#include "MaterialManager.hh" -#include "DetectorMessenger.hh" -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::DetectorConstruction(): world_log(0), world_phys(0){ - m_Target = 0; - m_Chamber = 0 ; - m_Messenger = new DetectorMessenger(this); -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::~DetectorConstruction(){ -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::Construct(){ - return ReadConfigurationFile(); -} - - - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::AddDetector(VDetector* NewDetector){ - // Add new detector to vector - m_Detectors.push_back(NewDetector); - - // Initialize Scorer - NewDetector->InitializeScorers(); - - // Construct new detector - NewDetector->ConstructDetector(world_log); - - // Add Detector to TTree - NewDetector->InitializeRootOutput(); -} - - - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ - // Construct the World volume - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - - //------------------------------world volume - G4double world_x = 10.0 * m; - G4double world_y = 10.0 * m; - G4double world_z = 10.0 * m; - - G4Box* world_box - = new G4Box("world_box", world_x, world_y, world_z); - - world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); - world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); - - G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); - world_log->SetVisAttributes(VisAtt); - - //------------------------------------------------------------------ - - //------------------------------------------------------------------ - - string Path = NPOptionManager::getInstance()->GetDetectorFile(); - - ////////General Reading needs//////// - string LineBuffer; - string DataBuffer; - - - bool cAddThinSi = false; - bool cComptonTelescope = false; - bool cDummy = false; - bool cEurogam = false; - bool cFatima = false; - bool cGeneralTarget = false; - bool cGeneralChamber = false; - bool cGPDTracker = false; - bool cHYD2Tracker = false; - bool cHelios = false; - bool cMUST2 = false; - bool cNana = false; - bool cPlastic = false; - bool cParis = false; - bool cS1 = false; - bool cSharc = false; - bool cTigress = false; - bool cTiara = false; - bool cW1 = false; - - int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); - - ifstream ConfigFile; - ConfigFile.open(Path.c_str()); - - if (ConfigFile.is_open()) { // should be always be true - G4cout << " Configuration file " << Path << " loading " << G4endl; - } - else { - G4cout << " Error, no configuration file" << Path << " found" << G4endl; - exit(1); - } - - while (!ConfigFile.eof()) { - //Pick-up next line - getline(ConfigFile, LineBuffer); - //Search for comment Symbol: % - if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/;} - - //////////////////////////////////////////// - /////// Search for a Dummy Detector //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 16, "TheDUMMYDetector") == 0 && cDummy == false) { - cDummy = true ; -#ifdef INC_DUMMYDETECTOR - if(VerboseLevel==1) G4cout << G4endl << "//////// DUMMY DETECTOR ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new DUMMYDetector() ; - - // Read Position of detector - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - - ///////////////////////////////////////////////////// - //////////// Search for ComptonTelescope //////////// - ///////////////////////////////////////////////////// - else if (LineBuffer.compare(0, 16, "ComptonTelescope") == 0 && cComptonTelescope == false) { -#ifdef INC_COMPTONTELESCOPE - cComptonTelescope = true; - if(VerboseLevel==1) G4cout << "//////// ComptonTelescope ////////" << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new ComptonTelescope(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - - //////////////////////////////////////////// - //////////// Search for Eurogam //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 7, "Eurogam") == 0 && cEurogam == false) { -#ifdef INC_EUROGAM - cEurogam = true; - if(VerboseLevel==1) G4cout << "//////// Eurogam ////////" << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Eurogam(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - //////////////////////////////////////////// - //////////// Search for FATIMA /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 6, "Fatima") == 0 && cFatima == false) { -#ifdef INC_FATIMA - cFatima = true ; - G4cout << "//////// Fatima ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Fatima() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - //////////////////////////////////////////// - //////////// Search for Gaspard //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 14, "GaspardTracker") == 0 && cGPDTracker == false) { -#ifdef INC_GASPARD - cGPDTracker = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Gaspard Tracker ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new GaspardTracker() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - - //////////////////////////////////////////// - //////////// Search for Hyde2 //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && cHYD2Tracker == false) { -#ifdef INC_HYDE2 - cHYD2Tracker = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Hyde2 Tracker ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Hyde2Tracker() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - - //////////////////////////////////////////// - //////////// Search for paris //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 5, "Paris") == 0 && cParis == false) { -#ifdef INC_PARIS - cParis = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Paris ////////" << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Paris() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - //////////////////////////////////////////// - ///// Search for S1 Annular detector ////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "AnnularS1") == 0 && cS1 == false) { -#ifdef INC_ANNULARS1 - cS1 = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// S1 Annular detector ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new AnnularS1() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - //////////////////////////////////////////// - ///// Search for S1 Annular detector ////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 2, "W1") == 0 && cW1 == false) { -#ifdef INC_W1 - cW1 = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// W1 Square detector ////////" << G4endl << G4endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new W1(); - - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - //////////////////////////////////////////// - //////// Search for MUST2 Array //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 10, "MUST2Array") == 0 && cMUST2 == false) { -#ifdef INC_MUST2 - cMUST2 = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// MUST2 Array ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new MUST2Array() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - - //////////////////////////////////////////// - ///////////// Search for Nana ////////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0,4, "Nana") == 0 && cNana == false) { -#ifdef INC_NANA - cNana = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Nana ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Nana() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - - //////////////////////////////////////////// - ////////// Search for ThinSi /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "SSSDArray") == 0 && cAddThinSi == false) { -#ifdef INC_SSSD - cAddThinSi = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// SSSD ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new ThinSi() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - - //////////////////////////////////////////// - ////////// Search for Sharc /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 5, "Sharc") == 0 && cSharc == false) { -#ifdef INC_SHARC - cSharc = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Sharc ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Sharc(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - //////////////////////////////////////////// - ////////// Search for Tigress /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0,7, "Tigress") == 0 && cTigress == false) { -#ifdef INC_TIGRESS - cTigress = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Tigress ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Tigress(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - //////////////////////////////////////////// - ////////// Search for Tiara /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0,5, "Tiara") == 0 && cTiara == false) { -#ifdef INC_TIARA - cTiara = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Tiara ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Tiara(); - - // Read Position of detector - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector(myDetector); -#endif - } - - - //////////////////////////////////////////// - ////////// Search for Plastic /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 19, "ScintillatorPlastic") == 0 && cPlastic == false) { -#ifdef INC_PLASTIC - cPlastic = true ; - if(VerboseLevel==1) G4cout << G4endl << "//////// Plastic ////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Plastic() ; - - // Read Position of detector - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; -#endif - } - //////////////////////////////////////////// - //////////// Search for Helios //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 6, "Helios") == 0 && cHelios == false) { -#ifdef INC_HELIOS - cHelios = true ; - G4cout << "//////// Helios detector ////////" << G4endl ; - - // bool check_MField = false; - double Bz=0.; - - ConfigFile >> DataBuffer ; - if (DataBuffer.compare(0, 7, "MField=") == 0){ - // check_MField = true; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - G4cout << "//////// Magentic Field set at Bz= " << Bz << " ////////" << G4endl ; - } - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Helios() ; - - // Read Position of Telescope - ConfigFile.close() ; - myDetector->ReadConfiguration(Path) ; - ConfigFile.open(Path.c_str()) ; - - // Add array to the VDetector Vector - AddDetector(myDetector) ; - - //------------------------------world volume - // - - // Aluminium material - G4double a= 26.98 * g / mole; - G4double density = 2.7 * g / cm3; - G4double z = 13.; - G4Material* Aluminium = new G4Material("Aluminium", z, a, density); - - - - // Add the Aluminium rod - G4double Al_rod_x = 1. * cm; - G4double Al_rod_y = 1. * cm; - //G4double Al_rod_z = 20.0 * cm; - G4double Al_rod_z = 40.0 * cm; - G4Box* Al_rod_box - = new G4Box("Al_rod_box", Al_rod_x, Al_rod_y, Al_rod_z); - - G4Tubs* Al_rod_tub - = new G4Tubs("Al_rod_tub", 0, 0.5*cm, Al_rod_z+1.*mm, 0.*deg, 360*deg); - - G4SubtractionSolid* Al_rod=new G4SubtractionSolid("Rod",Al_rod_box, Al_rod_tub, 0, G4ThreeVector(0.,0.,0.)); - - G4LogicalVolume* Al_rod_log = new G4LogicalVolume(Al_rod, Aluminium, "Al_rod", 0, 0, 0); - - - new G4PVPlacement(0, G4ThreeVector(0.,0., Al_rod_z + 12.5*cm), Al_rod_log, "Al_rod", world_log, false, 0); - new G4PVPlacement(0, G4ThreeVector(0.,0., -(Al_rod_z + 12.5*cm)), Al_rod_log, "Al_rod", world_log, false, 1); - - - - // Add the Aluminium chamber - G4double Al_chamber_rmin = 50. * cm; - G4double Al_chamber_rmax = 55. * cm; - G4double Al_chamber_z = 100.0 * cm; - - //G4Tubs* Al_chamber_tub - // = new G4Tubs("Al_chamber_tub", Al_chamber_rmin, Al_chamber_rmax, Al_chamber_z, 0.*deg, 180*deg); - G4Tubs* Al_chamber_tub - = new G4Tubs("Al_chamber_tub", Al_chamber_rmin, Al_chamber_rmax, Al_chamber_z, 0.*deg, 360*deg); - - G4LogicalVolume* Al_chamber_log = new G4LogicalVolume(Al_chamber_tub, Aluminium, "Al_chamber", 0, 0, 0); - - G4RotationMatrix* RotZ = new G4RotationMatrix(); - RotZ->rotateZ(-90*deg); - - new G4PVPlacement(RotZ, G4ThreeVector(0.,0.,0.), Al_chamber_log, "Al_chamber", world_log, false, 0); - - - G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.2, 0.5, 0.8)); - Al_rod_log->SetVisAttributes(VisAtt1); - G4VisAttributes* VisAtt2 = new G4VisAttributes(G4Colour(0., 0.5, 0.3)); - Al_chamber_log->SetVisAttributes(VisAtt2); - - - //------------------------------------------------------------------------- - // add also My Magnetic field - //------------------------------------------------------------------------- - - - static G4bool fieldIsInitialized = false; - - if(!fieldIsInitialized) - { - MyMagneticField* myField = new MyMagneticField(G4ThreeVector(0.,0.,Bz)); - - G4FieldManager* fieldMgr - = G4TransportationManager::GetTransportationManager() - ->GetFieldManager(); - fieldMgr->SetDetectorField(myField); - - - /* - G4MagIntegratorStepper *pItsStepper; - G4ChordFinder* pChordFinder= new G4ChordFinder(myField, - 1.0e-2*mm, // stepper size - pItsStepper=0); - fieldMgr->SetChordFinder(pChordFinder); - */ - - fieldMgr->CreateChordFinder(myField); - - fieldIsInitialized = true; - } - -#endif - } - //////////////////////////////////////////// - //////////// Search for Target ///////////// - //////////////////////////////////////////// - - else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && cGeneralTarget == false) { - cGeneralTarget = true ; - if(VerboseLevel==1) G4cout << G4endl << "////////// Target ///////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Objects - VDetector* myDetector = new Target(); - - // Read Position and target specification - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add Target to DetectorConstruction - m_Target = (Target*) myDetector; - - // Add target to the VDetector Vector - AddDetector(myDetector); - } - - //////////////////////////////////////////// - //////////// Search for Chamber ///////////// - //////////////////////////////////////////// - - else if (LineBuffer.compare(0, 14, "GeneralChamber") == 0 && cGeneralChamber == false) { - cGeneralChamber = true ; - if(VerboseLevel==1) G4cout << G4endl << "////////// Chamber ///////////" << G4endl << G4endl ; - - // Instantiate the new array as a VDetector Objects - VDetector* myDetector = new Chamber(); - - // Read Position and target specification - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add Target to DetectorConstruction - m_Chamber = (Chamber*) myDetector; - - // Add target to the VDetector Vector - AddDetector(myDetector); - } - - //Nothing understandable - //else ; - } - - ConfigFile.close(); - - if(m_Target==NULL){ - G4cout << "ERROR: No target define in detector file. Cannot perform simulation without target" << G4endl ; - exit(1); - } - - // Create the Material sample for DEDX tables - MaterialManager::getInstance()->CreateSampleVolumes(world_log); - - return world_phys; -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ReadAllSensitive(const G4Event* event){ - // Before looping on each sub-detector, clear the static variable - // ms_InterCoord - // This is done on the first element of the m_Modules vector. - // This should be done here since this variable (of type TIneractionCoordinates) - // deals with multiplicity of events > 1. - if(m_Detectors.size()>0) - m_Detectors[0]->GetInterCoordPointer()->Clear(); - - unsigned int mysize = m_Detectors.size(); - for (unsigned short i = 0 ; i < mysize ; i++) { - m_Detectors[i]->ReadSensitive(event); - } -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* DetectorConstruction::GetWorldLogic(){ - return world_log; -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ClearGeometry(){ - unsigned int mySize = m_Detectors.size(); - - for (unsigned short i = 0 ; i < mySize ; i++) { - delete m_Detectors[i]; - } - - m_Detectors.clear(); - m_Target = 0; - m_Chamber = 0 ; - world_log=0; - world_phys=0; - - G4GeometryManager::GetInstance()->OpenGeometry(); - G4PhysicalVolumeStore::GetInstance()->Clean(); - G4LogicalVolumeStore::GetInstance()->Clean(); - G4SolidStore::GetInstance()->Clean(); -} - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::RedefineGeometry(string file){ - ClearGeometry() ; - - RootOutput::getInstance()->GetTree()->ResetBranchAddresses(); - RootOutput::getInstance()->GetTree()->GetListOfBranches()->Clear(); - - if(file!="") - NPOptionManager::getInstance()->SetDetectorFile(file); - - G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); - G4RunManager::GetRunManager()->GeometryHasBeenModified(); - G4RunManager::GetRunManager()->Initialize(); -} diff --git a/nptool.sh b/nptool.sh index f6595308dcf911d3d115daae9e7bc3df6fc8f207..b82dd716345809f7097f29e9c50acdb5c6a4b92a 100644 --- a/nptool.sh +++ b/nptool.sh @@ -19,14 +19,14 @@ NPARCH=$(uname) if [ "${NPARCH}" = "Darwin" ] ; then export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$NPTOOL/NPLib/lib + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$NPTOOL/NPSimulation/lib else export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NPTOOL/NPLib/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NPTOOL/NPSimulation/lib fi export PATH=$PATH:$NPLIB/bin - -alias NPSimulation='$NPTOOL/NPSimulation/bin/$G4SYSTEM/Simulation' -alias NPAnalysis='$NPANA/Analysis' +export PATH=$PATH:$NPTOOL/NPSimulation/bin alias NPT='cd $NPTOOL' alias NPL='cd $NPTOOL/NPLib'