Skip to content
Snippets Groups Projects
Commit 5276dafd authored by adrien-matta's avatar adrien-matta
Browse files

* Progress on cmake compilation of NPS

parent 46f78ecf
No related branches found
No related tags found
No related merge requests found
Showing
with 300 additions and 85 deletions
...@@ -7,6 +7,11 @@ bin ...@@ -7,6 +7,11 @@ bin
DetectorClassList.txt DetectorClassList.txt
Utility/Makefile Utility/Makefile
Utility/npanalysis Utility/npanalysis
Utility/nptool-libmap Utility/nptool-installer
*.pcm
*Dict*
*rootmap* *rootmap*
*_rflx.cpp *_rflx.cpp
*.dylib
*.so
*.cmake
...@@ -368,13 +368,15 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){ ...@@ -368,13 +368,15 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){
getline(ConfigFile, LineBuffer); getline(ConfigFile, LineBuffer);
// cout << LineBuffer << endl; // cout << LineBuffer << endl;
if (LineBuffer.compare(0, 11, "TiaraInnerBarrel") == 0) if (LineBuffer.find("TiaraInnerBarrel") != std::string::npos)
ReadingStatus = true; ReadingStatus = true;
while (ReadingStatus && !ConfigFile.eof()) { while (ReadingStatus && !ConfigFile.eof()) {
ConfigFile >> DataBuffer ; check_X=true; check_Y=true ; check_Z=true;
// Comment Line // 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? ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////something here?
...@@ -424,17 +426,13 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){ ...@@ -424,17 +426,13 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
// If no Detector Token and no comment, toggle out // If no Detector Token and no comment, toggle out
else { else {
ReadingStatusStrip= false;
cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << endl ;
exit(1);
} }
///////////////////////////////////////////////// /////////////////////////////////////////////////
// If All necessary information there, toggle out // If All necessary information there, toggle out
if (check_X && check_Y && check_Z){ if (check_X && check_Y && check_Z){
ReadingStatus= false;
ReadingStatusStrip= false;
AddDetector(X,Y,Z); AddDetector(X,Y,Z);
// Reinitialisation of Check Boolean // Reinitialisation of Check Boolean
check_X = false ; check_X = false ;
...@@ -690,6 +688,12 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){ ...@@ -690,6 +688,12 @@ void TTiaraBarrelPhysics::BuildPhysicalEvent(){
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetBackEEnergy(i)); return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetBackEEnergy(i));
} }
////////////////////////////////////////////////////////////////////////////
void TTiaraBarrelPhysics::WriteSpectra(){
m_Spectra->WriteSpectra();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory // // Construct Method to be pass to the DetectorFactory //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -122,7 +122,8 @@ class TTiaraBarrelPhysics : public TObject, public NPA::VDetector{ ...@@ -122,7 +122,8 @@ class TTiaraBarrelPhysics : public TObject, public NPA::VDetector{
void CheckSpectra(); void CheckSpectra();
// Used for Online only, clear all the spectra hold by the Spectra class // Used for Online only, clear all the spectra hold by the Spectra class
void ClearSpectra(); void ClearSpectra();
// Write Spectra to file
void WriteSpectra();
public:// Specific to TiaraBarrel Array public:// Specific to TiaraBarrel Array
// Clear The PreTeated object // Clear The PreTeated object
void ClearPreTreatedData() {m_PreTreatedData->Clear();} void ClearPreTreatedData() {m_PreTreatedData->Clear();}
......
...@@ -148,6 +148,9 @@ int main(int argc , char** argv){ ...@@ -148,6 +148,9 @@ int main(int argc , char** argv){
myDetector->StopThread(); myDetector->StopThread();
#endif #endif
ProgressDisplay(begin,end,treated,inter,nentries,mean_rate,displayed); ProgressDisplay(begin,end,treated,inter,nentries,mean_rate,displayed);
if(myOptionManager->GetGenerateHistoOption())
myDetector->WriteSpectra();
RootOutput::getInstance()->Destroy(); RootOutput::getInstance()->Destroy();
RootInput::getInstance()->Destroy(); RootInput::getInstance()->Destroy();
return 0; return 0;
......
add_library(NPSAnnularS1 SHARED AnnularS1.cc)
target_link_libraries(NPSAnnularS1 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPAnnularS1)
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})
add_library(NPSComptonTelescope SHARED ComptonTelescope.cc ComptonTelescopeScorers.cc)
target_link_libraries(NPSComptonTelescope NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPComptonTelescope)
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)
target_link_libraries(NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES})
#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;
}
#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
add_library(NPSDUMMYDetector SHARED DummyDetector.cc)
target_link_libraries(NPSDUMMYDetector NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPDUMMYDetector)
add_library(NPSEurogam SHARED Eurogam.cc)
target_link_libraries(NPSEurogam NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPEurogam)
add_library(NPSFatima SHARED Fatima.cc)
target_link_libraries(NPSFatima NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPFatima)
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)
add_library(NPSHelios SHARED Helios.cc HeliosDetDummyShape.cc HeliosModule.cc HeliosScorers.cc)
target_link_libraries(NPSHelios NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPHelios)
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)
add_library(NPSMUST2 SHARED MUST2Array.cc MUST2Scorers.cc)
target_link_libraries(NPSMUST2 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPMUST2)
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
# $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
add_library(NPSNana SHARED Nana.cc)
target_link_libraries(NPSNana NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPNana)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment