diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7bf32c..e198417 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,190 +1,196 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
project(NUISANCE)
include(ExternalProject)
enable_language(Fortran)
set (NUISANCE_VERSION_MAJOR 2)
set (NUISANCE_VERSION_MINOR 7)
set (NUISANCE_VERSION_REVISION 0)
set (NUISANCE_VERSION_STRING "v${NUISANCE_VERSION_MAJOR}r${NUISANCE_VERSION_MINOR}")
if(${NUISANCE_VERSION_REVISION} STRGREATER "0")
set (NUISANCE_VERSION_STRING "${NUISANCE_VERSION_STRING}p${NUISANCE_VERSION_REVISION}")
endif()
#Set this to TRUE to enable build debugging messages
set(BUILD_DEBUG_MSGS TRUE)
include(${CMAKE_SOURCE_DIR}/cmake/cmessage.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/cacheVariables.cmake)
cmessage(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"")
cmessage(STATUS "CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"")
################################################################################
# Check Dependencies
################################################################################
################################## ROOT ######################################
include(${CMAKE_SOURCE_DIR}/cmake/ROOTSetup.cmake)
################################# HEPMC ######################################
include(${CMAKE_SOURCE_DIR}/cmake/HepMC.cmake)
############################ Reweight Engines ################################
include(${CMAKE_SOURCE_DIR}/cmake/ReweightEnginesSetup.cmake)
############################ Other Generators ################################
include(${CMAKE_SOURCE_DIR}/cmake/GiBUUSetup.cmake)
if(USE_NUANCE)
LIST(APPEND EXTRA_CXX_FLAGS -D__NUANCE_ENABLED__)
endif()
################################# Pythia6/8 ####################################
include(${CMAKE_SOURCE_DIR}/cmake/pythia6Setup.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pythia8Setup.cmake)
################################# gperftools ###################################
include(${CMAKE_SOURCE_DIR}/cmake/gperfSetup.cmake)
if(NOT NOTEST)
enable_testing()
endif()
SET(GENERATOR_SUPPORT)
foreach(gen NEUT;NuWro;GENIE;GiBUU;NUANCE)
if(USE_${gen})
SET(GENERATOR_SUPPORT "${GENERATOR_SUPPORT}${gen} ")
endif()
endforeach(gen)
cmessage(STATUS "Generator Input Support: ${GENERATOR_SUPPORT}")
set(MINCODE
Routines
FCN)
set(CORE
MCStudies
Genie
FitBase
+ Config
+ Logger
InputHandler
Splines
- Reweight
+ Reweight
Utils
+ Statistical
#Devel
Smearceptance
)
LIST(APPEND ALLEXPERIMENTS
ANL
ArgoNeuT
BEBC
BNL
Electron
FNAL
GGM
K2K
MINERvA
MiniBooNE
SciBooNE
T2K)
foreach(exp ${ALLEXPERIMENTS})
if(NOT NO_${exp})
LIST(APPEND EXPERIMENTS_TO_BUILD ${exp})
else()
LIST(REVERSE EXTRA_CXX_FLAGS)
LIST(APPEND EXTRA_CXX_FLAGS -D__NO_${exp}__)
LIST(REVERSE EXTRA_CXX_FLAGS)
endif()
endforeach()
################################## COMPILER ####################################
include(${CMAKE_SOURCE_DIR}/cmake/c++CompilerSetup.cmake)
################################### doxygen ###################################
include(${CMAKE_SOURCE_DIR}/cmake/docsSetup.cmake)
################################################################################
set(MINIMUM_INCLUDE_DIRECTORIES)
LIST(APPEND MINIMUM_INCLUDE_DIRECTORIES
${RWENGINE_INCLUDE_DIRECTORIES}
${CMAKE_SOURCE_DIR}/src/FitBase
${CMAKE_SOURCE_DIR}/src/Reweight
${CMAKE_SOURCE_DIR}/src/InputHandler
+ ${CMAKE_SOURCE_DIR}/src/Config
+ ${CMAKE_SOURCE_DIR}/src/Logger
+ ${CMAKE_SOURCE_DIR}/src/Statistical
${CMAKE_SOURCE_DIR}/src/Splines
${CMAKE_SOURCE_DIR}/src/Utils
${CMAKE_SOURCE_DIR}/src/Genie)
cmessage(DEBUG "Base include directories: ${MINIMUM_INCLUDE_DIRECTORIES}")
set(EXP_INCLUDE_DIRECTORIES)
foreach(edir ${EXPERIMENTS_TO_BUILD})
LIST(APPEND EXP_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src/${edir})
endforeach()
cmessage(DEBUG "Included experiments: ${EXP_INCLUDE_DIRECTORIES}")
foreach(mdir ${MINCODE})
cmessage (DEBUG "Configuring directory: src/${mdir}")
add_subdirectory(src/${mdir})
endforeach()
foreach(edir ${EXPERIMENTS_TO_BUILD})
cmessage (DEBUG "Configuring directory: src/${edir}")
add_subdirectory(src/${edir})
endforeach()
foreach(cdir ${CORE})
cmessage (DEBUG "Configuring directory: src/${cdir}")
add_subdirectory(src/${cdir})
endforeach()
cmessage(DEBUG "Module targets: ${MODULETargets}")
add_subdirectory(app)
add_subdirectory(src/Tests)
configure_file(cmake/setup.sh.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" DESTINATION
${CMAKE_INSTALL_PREFIX})
install(PROGRAMS
"${PROJECT_SOURCE_DIR}/scripts/nuiscardgen" DESTINATION
bin)
install(PROGRAMS
"${PROJECT_SOURCE_DIR}/scripts/nuissamples" DESTINATION
bin)
diff --git a/VERSION b/VERSION
index f3677eb..8f6d685 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-Fitter Version Tag: v2r7
\ No newline at end of file
+Fitter Version Tag: v2r8
\ No newline at end of file
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index c260ba6..1d488e3 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,192 +1,217 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
set(TARGETS_TO_BUILD)
if(USE_MINIMIZER)
add_executable(nuismin nuismin.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuismin)
target_link_libraries(nuismin ${MODULETargets})
target_link_libraries(nuismin ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuismin ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuismin PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
add_executable(nuissplines nuissplines.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissplines)
target_link_libraries(nuissplines ${MODULETargets})
target_link_libraries(nuissplines ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuissplines ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuissplines PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
include_directories(${RWENGINE_INCLUDE_DIRECTORIES})
include_directories(${CMAKE_SOURCE_DIR}/src/Routines)
include_directories(${CMAKE_SOURCE_DIR}/src/InputHandler)
include_directories(${CMAKE_SOURCE_DIR}/src/Genie)
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
+include_directories(${CMAKE_SOURCE_DIR}/src/Statistical)
include_directories(${CMAKE_SOURCE_DIR}/src/Utils)
+include_directories(${CMAKE_SOURCE_DIR}/src/Config)
+include_directories(${CMAKE_SOURCE_DIR}/src/Logger)
include_directories(${CMAKE_SOURCE_DIR}/src/Splines)
include_directories(${CMAKE_SOURCE_DIR}/src/Reweight)
include_directories(${CMAKE_SOURCE_DIR}/src/FCN)
include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies)
include_directories(${CMAKE_SOURCE_DIR}/src/Smearceptance)
include_directories(${EXP_INCLUDE_DIRECTORIES})
if (USE_NuWro AND NOT NUWRO_BUILT_FROM_FILE)
add_executable(nuwro_nuisance nuwro_NUISANCE.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuwro_nuisance)
target_link_libraries(nuwro_nuisance ${MODULETargets})
target_link_libraries(nuwro_nuisance ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuwro_nuisance ${ROOT_LIBS})
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuwro_nuisance PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
if (USE_NEUT)
add_executable(neut_nuisance neut_NUISANCE.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};neut_nuisance)
target_link_libraries(neut_nuisance ${MODULETargets})
target_link_libraries(neut_nuisance ${CMAKE_DEPENDLIB_FLAGS})
target_link_libraries(neut_nuisance ${ROOT_LIBS})
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(neut_nuisance PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
if (BUILD_GEVGEN)
add_executable(gevgen_nuisance gEvGen_NUISANCE.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};gevgen_nuisance)
target_link_libraries(gevgen_nuisance ${MODULETargets})
target_link_libraries(gevgen_nuisance ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(gevgen_nuisance ${ROOT_LIBS})
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
include_directories(${GENIE_INCLUDES}/Apps)
include_directories(${GENIE_INCLUDES}/FluxDrivers)
include_directories(${GENIE_INCLUDES}/EVGDrivers)
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(gevgen_nuisance PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
add_executable(gevgen_nuisance_mixed gEvGen_NUISANCE_MIXED.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};gevgen_nuisance_mixed)
target_link_libraries(gevgen_nuisance_mixed ${MODULETargets})
target_link_libraries(gevgen_nuisance_mixed ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(gevgen_nuisance_mixed ${ROOT_LIBS})
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
include_directories(${GENIE_INCLUDES}/Apps)
include_directories(${GENIE_INCLUDES}/FluxDrivers)
include_directories(${GENIE_INCLUDES}/EVGDrivers)
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(gevgen_nuisance_mixed PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
if (USE_GiBUU)
add_executable(DumpGiBUUEvents DumpGiBUUEvents.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};DumpGiBUUEvents)
target_link_libraries(DumpGiBUUEvents ${MODULETargets})
target_link_libraries(DumpGiBUUEvents ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(DumpGiBUUEvents ${ROOT_LIBS})
include_directories(${CMAKE_SOURCE_DIR}/src/FitBase)
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(DumpGiBUUEvents PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
add_executable(nuiscomp nuiscomp.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuiscomp)
target_link_libraries(nuiscomp ${MODULETargets})
target_link_libraries(nuiscomp ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuiscomp ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuiscomp PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
add_executable(nuisflat nuisflat.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuisflat)
target_link_libraries(nuisflat ${MODULETargets})
target_link_libraries(nuisflat ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuisflat ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuisflat PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
add_executable(nuissmear nuissmear.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissmear)
target_link_libraries(nuissmear ${MODULETargets})
target_link_libraries(nuissmear ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuissmear ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuissmear PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
add_executable(nuissyst nuissyst.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissyst)
target_link_libraries(nuissyst ${MODULETargets})
target_link_libraries(nuissyst ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(nuissyst ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(nuissyst PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
+add_executable(nuisbayes nuisbayes.cxx)
+set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuisbayes)
+target_link_libraries(nuisbayes ${MODULETargets})
+target_link_libraries(nuisbayes ${CMAKE_DEPENDLIB_FLAGS})
+# target_link_libraries(nuisbayes ${ROOT_LIBS})
+if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
+ set_target_properties(nuisbayes PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
+endif()
+
if(USE_GENIE)
add_executable(PrepareGENIE PrepareGENIE.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareGENIE)
target_link_libraries(PrepareGENIE ${MODULETargets})
target_link_libraries(PrepareGENIE ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(PrepareGENIE ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(PrepareGENIE PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
if(USE_NEUT)
add_executable(PrepareNEUT PrepareNEUT.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareNEUT)
target_link_libraries(PrepareNEUT ${MODULETargets})
target_link_libraries(PrepareNEUT ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(PrepareNEUT ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(PrepareNEUT PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
# PREPARE NUWRO
# Commented out for the time being until it is finished..
if(USE_NuWro)
add_executable(PrepareNuwro PrepareNuwroEvents.cxx)
set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareNuwro)
target_link_libraries(PrepareNuwro ${MODULETargets})
target_link_libraries(PrepareNuwro ${CMAKE_DEPENDLIB_FLAGS})
# target_link_libraries(PrepareNuwro ${ROOT_LIBS})
if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "")
set_target_properties(PrepareNuwro PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
endif()
endif()
install(TARGETS ${TARGETS_TO_BUILD} DESTINATION bin)
+
+#add_executable(DumpROOTClassesFromVector DumpROOTClassesFromVector.cxx)
+# #Strip out -lNuWro_event1
+# string(REPLACE "-lNuWro_event1" "" NWEVSTRIPPED_CDF ${CMAKE_DEPENDLIB_FLAGS})
+# cmessage(DEBUG "Attempted to strip out nuwro library: \"${CMAKE_DEPENDLIB_FLAGS}\" -> \"${NWEVSTRIPPED_CDF}\"")
+# add_executable(PrepareNEUT PrepareNEUT.cxx)
+# target_link_libraries(DumpROOTClassesFromVector ${MODULETargets})
+# target_link_libraries(DumpROOTClassesFromVector ${NWEVSTRIPPED_CDF})
+# if(NOT CMAKE_LINK_FLAGS STREQUAL "")
+# set_target_properties(DumpROOTClassesFromVector PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
+# endif()
+#install(TARGETS DumpROOTClassesFromVector DESTINATION bin)
+
diff --git a/src/Utils/DumpROOTClassesFromVector.cxx b/app/DumpROOTClassesFromVector.cxx
similarity index 100%
rename from src/Utils/DumpROOTClassesFromVector.cxx
rename to app/DumpROOTClassesFromVector.cxx
diff --git a/app/PrepareNEUT.cxx b/app/PrepareNEUT.cxx
index a4c31ed..3b37e40 100644
--- a/app/PrepareNEUT.cxx
+++ b/app/PrepareNEUT.cxx
@@ -1,237 +1,238 @@
#include
#include
#include "TFile.h"
#include "TH1D.h"
#include "TTree.h"
#include "PlotUtils.h"
+#include "StatUtils.h"
#include "FitLogger.h"
// If you don't have NEUT enabled, you shouldn't compile this...
#include "neutpart.h"
#include "neutvect.h"
std::string fInputFiles = "";
std::string fOutputFile = "";
std::string fFluxFile = "";
bool fFluxInGeV = false;
void PrintOptions();
void ParseOptions(int argc, char* argv[]);
void CreateRateHistogram(std::string inputList, std::string flux, std::string output);
//*******************************
int main(int argc, char* argv[]){
//*******************************
LOG_VERB(FitPar::Config().GetParI("VERBOSITY"));
ERR_VERB(FitPar::Config().GetParI("ERROR"));
ParseOptions(argc, argv);
LOG(FIT) << "Running PrepareNEUT" << std::endl;
CreateRateHistogram(fInputFiles, fFluxFile, fOutputFile);
};
//*******************************
void CreateRateHistogram(std::string inputList, std::string flux, std::string output){
//*******************************
// Need to allow for more than one file... will do soon
TChain* tn = new TChain("neuttree");
std::vector inputs = GeneralUtils::ParseToStr(inputList,",");
for (std::vector::iterator it = inputs.begin();
it != inputs.end(); ++it){
LOG(FIT) << "Adding " << *it << " to the output" << std::endl;
tn->AddFile((*it).c_str());
}
if (inputs.size() > 1 && output.empty()){
ERR(FTL) << "You must provide a new output file name if you want to have more than 1 input file!" << std::endl;
throw;
}
int nevts = tn->GetEntries();
if (!nevts){
ERR(FTL) << "Either the input file is not from NEUT, or it's empty..." <SetBranchAddress("vectorbranch", &fNeutVect);
// Get Flux Hist
std::vector fluxvect = GeneralUtils::ParseToStr(flux,",");
TH1D* fluxHist = NULL;
if (fluxvect.size() > 1){
TFile* fluxfile = new TFile(fluxvect[0].c_str(),"READ");
fluxHist = (TH1D*) fluxfile->Get(fluxvect[1].c_str());
fluxHist->SetDirectory(0);
} else {
ERR(FTL) << "NO FLUX SPECIFIED" << std::endl;
throw;
}
// Decide what type of flux was given
if (fFluxInGeV) LOG(FIT) << "Assuming flux histogram is in GeV" << std::endl;
else LOG(FIT) << "Assuming flux histogram is in MeV" << std::endl;
// Make Event Hist
TH1D* xsecHist = (TH1D*)fluxHist->Clone();
xsecHist->Reset();
// Make a total cross section hist for shits and giggles
TH1D* entryHist = (TH1D*) xsecHist->Clone();
for (int i = 0; i < nevts; ++i){
tn->GetEntry(i);
NeutPart* part = fNeutVect->PartInfo(0);
double E = part->fP.E();
double xsec = fNeutVect->Totcrs;
// Unit conversion
if (fFluxInGeV) E*=1E-3;
xsecHist ->Fill(E, xsec);
entryHist->Fill(E);
if (i % (nevts/20) == 0){
LOG(FIT) << "Processed " << i << "/" << nevts << " NEUT events." << std::endl;
}
}
LOG(FIT) << "Processed all events" << std::endl;
xsecHist ->Divide(entryHist);
// This will be the evtrt histogram
TH1D* evtHist = NULL;
// If the integral of xsecHist is 0 the input file used a really old version of NEUT without Totcrs
if (!xsecHist->Integral(0, -1)){
ERR(WRN) << "Old NEUT input file: events will not be correctly normalized" << std::endl;
evtHist = (TH1D*)entryHist->Clone();
if (evtHist->Integral() != 0)
evtHist ->Scale(fluxHist->Integral()/float(evtHist->Integral()));
} else {
evtHist = (TH1D*)xsecHist->Clone();
evtHist ->Multiply(fluxHist);
}
// Check whether the overflow is empty. If not, advise that either the wrong flux histogram or units were used...
// If the events were generated with a limited range of the flux histogram, this may be benign
if (evtHist->Integral(0, -1) != evtHist->Integral() || evtHist->Integral(0, -1) == 0){
ERR(WRN) << "The input file and flux histogram provided do not match... " << std::endl;
ERR(WRN) << "Are the units correct? Did you provide the correct flux file?" << std::endl;
ERR(WRN) << "Use output with caution..." << std::endl;
}
// Pick where the output should go
TFile *outFile = NULL;
if (!output.empty()){
LOG(FIT) << "Saving histograms in " << output << std::endl;
outFile = new TFile(output.c_str(), "RECREATE");
} else {
LOG(FIT) << "Saving histograms in " << inputs[0] << std::endl;
outFile = new TFile(inputs[0].c_str(), "UPDATE");
}
outFile->cd();
std::string xsec_name = "xsec_PrepareNeut";
std::string flux_name = "flux_PrepareNeut";
std::string rate_name = "evtrt_PrepareNeut";
if (output.empty()){
// Check whether we should overwrite existing histograms
std::string input_xsec = PlotUtils::GetObjectWithName(outFile, "xsec");
std::string input_flux = PlotUtils::GetObjectWithName(outFile, "flux");
std::string input_rate = PlotUtils::GetObjectWithName(outFile, "evtrt");
if (!input_xsec.empty()) {
LOG(FIT) << "Updating histogram: " << input_xsec << std::endl;
xsec_name = input_xsec;
}
if (!input_flux.empty()) {
LOG(FIT) << "Updating histogram: " << input_flux << std::endl;
flux_name = input_flux;
}
if (!input_rate.empty()) {
LOG(FIT) << "Updating histogram: " << input_rate << std::endl;
rate_name = input_rate;
}
} else {
LOG(FIT) << "Cloning neuttree into output file." << std::endl;
StopTalking();
TTree* newtree = (TTree*)tn->CloneTree(-1, "fast");
StartTalking();
newtree->Write();
}
xsecHist->Write(xsec_name.c_str(), TObject::kOverwrite);
fluxHist->Write(flux_name.c_str(), TObject::kOverwrite);
evtHist ->Write(rate_name.c_str(), TObject::kOverwrite);
outFile ->Close();
return;
}
void PrintOptions(){
std::cout << "PrepareNEUT NUISANCE app. " << std::endl
<< "Produces or recalculates evtrt and flux histograms necessary for NUISANCE normalization." << std::endl;
std::cout << "PrepareNEUT: " << std::endl;
std::cout << " [-h,-help,--h,--help]" << std::endl;
std::cout << " -i inputfile1.root,inputfile2.root,inputfile3.root,..." << std::endl;
std::cout << " Takes any number of files, but assumes all are produced with a single flux" << std::endl;
std::cout << " -f flux_root_file.root,flux_hist_name" << std::endl;
std::cout << " Path to root file containing the flux histogram used when generating the NEUT files" << std::endl;
std::cout << " [-o outputfile.root] " << std::endl;
std::cout << " If an output file is not given, the input file will be used" << std::endl;
std::cout << " If more than one input file is given, an output file must be given" << std::endl;
std::cout << " [-G]" << std::endl;
std::cout << " Flux is assumed to be in MeV. This switch indicates the input flux is in GeV" << std::endl << std::endl;
}
void ParseOptions(int argc, char* argv[]){
bool flagopt = false;
// If No Arguments print commands
for (int i = 1; i< argc; ++i){
if (!std::strcmp(argv[i], "-h")) { flagopt = true; break; }
else if (!std::strcmp(argv[i], "-G")) { fFluxInGeV = true; }
if (i+1 != argc){
// Cardfile
if (!std::strcmp(argv[i], "-h")) { flagopt = true; break; }
else if (!std::strcmp(argv[i], "-i")) { fInputFiles = argv[i+1]; ++i; }
else if (!std::strcmp(argv[i], "-o")) { fOutputFile = argv[i+1]; ++i; }
else if (!std::strcmp(argv[i], "-f")) { fFluxFile = argv[i+1]; ++i; }
else {
ERR(FTL) << "ERROR: unknown command line option given! - '"
<.
+*******************************************************************************/
+
+// Author: Patrick Stowell 09/2016
+/*
+ Usage: ./nuissyst -c card file -o output file, where the results of the throws are stored
+ where:
+*/
+
+#include "BayesianRoutines.h"
+
+//*******************************
+void printInputCommands(){
+//*******************************
+
+ exit(-1);
+
+};
+
+//*******************************
+int main(int argc, char* argv[]){
+//*******************************
+
+ // Program status;
+ int status = 0;
+
+ // If No Arguments print commands
+ if (argc == 1) printInputCommands();
+
+ for (int i = 1; i< argc; ++i){
+ // Cardfile
+ if (!std::strcmp(argv[i], "-h")) printInputCommands();
+ else break;
+ }
+
+ // Read input arguments such as card file, parameter arguments, and fit routines
+ LOG(FIT)<<"Starting nuissyst"<Run();
+
+
+ // Show Final Status
+ LOG(FIT)<<"-------------------------------------"<.
*******************************************************************************/
#include "ComparisonRoutines.h"
#include "InputUtils.h"
#include "MeasurementBase.h"
#include "GenericFlux_Tester.h"
#include "Smearceptance_Tester.h"
// Global Arguments
std::string gOptInputFile = "";
std::string gOptFormat = "";
std::string gOptOutputFile = "";
std::string gOptType = "DEFAULT";
std::string gOptNumberEvents = "NULL";
std::string gOptCardInput = "";
std::string gOptOptions = "";
//*******************************
void PrintSyntax() {
//*******************************
std::cout << "nuisflat -i input -f format [-o outfile] [-n nevents] [-t "
"options] [-q con=val] \n";
std::cout
<< "\n Arguments : "
<< "\n\t -i input : Path to input vector of events to flatten"
<< "\n\t"
<< "\n\t This should be given in the same format a normal "
"input file"
<< "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}."
<< "\n\t"
<< "\n\t -f format : FlatTree format to output:"
<< "\n\t\t GenericFlux : Standard event summary format."
<< "\n\t "
<< "\n\t[-c crd.xml]: Input card file to override configs or set dial values."
<< "\n\t "
<< "\n\t[-o outfile]: Optional output file path. "
<< "\n\t "
<< "\n\t If none given, input.format.root is chosen."
<< "\n\t"
<< "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is "
"all."
<< "\n\t"
<< "\n\t[-t options]: Pass OPTION to the FlatTree sample. "
<< "\n\t Similar to type field in comparison xml configs."
<< "\n\t"
<< "\n\t[-q con=val]: Configuration overrides." << std::endl;
exit(-1);
};
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char** argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if ((!std::string(argv[i]).compare("-h")) ||
(!std::string(argv[i]).compare("-?")) ||
(!std::string(argv[i]).compare("--help")))
PrintSyntax();
}
// Format is nuwro -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
// Parse input file
ParserUtils::ParseArgument(args, "-i", gOptInputFile, false);
if (gOptInputFile == "") {
THROW("Need to provide a valid input file to nuisflat using -i flag!");
} else {
LOG(FIT) << "Reading Input File = " << gOptInputFile << std::endl;
}
// Get Output Format
ParserUtils::ParseArgument(args, "-f", gOptFormat, false);
if (gOptFormat == "") {
THROW("Need to provide a valid output format to nuisflat!");
} else {
LOG(FIT) << "Saving flattree in format = " << gOptFormat << std::endl;
}
// Get Output File
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile == "") {
gOptOutputFile = gOptInputFile + "." + gOptFormat + ".root";
LOG(FIT) << "No output file given so saving nuisflat output to:"
<< gOptOutputFile << std::endl;
} else {
LOG(FIT) << "Saving nuisflat output to " << gOptOutputFile << std::endl;
}
// Get N Events and Configs
nuisconfig configuration = Config::Get();
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents.compare("NULL")) {
configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents);
}
std::vector configargs;
ParserUtils::ParseArgument(args, "-q", configargs);
for (size_t i = 0; i < configargs.size(); i++) {
configuration.OverrideConfig(configargs[i]);
}
ParserUtils::ParseArgument(args, "-c", gOptCardInput, false);
if (gOptCardInput != "") {
QLOG(FIT, "Reading cardfile: " << gOptCardInput);
- configuration.LoadConfig(gOptCardInput, "");
+ configuration.LoadSettings(gOptCardInput, "");
}
ParserUtils::ParseArgument(args, "-t", gOptOptions, false);
if (gOptOptions != "") {
QLOG(FIT, "Read options: \"" << gOptOptions << "\'");
}
return;
}
//*******************************
int main(int argc, char* argv[]) {
//*******************************
// Parse
GetCommandLineArgs(argc, argv);
// Make output file
TFile* f = new TFile(gOptOutputFile.c_str(), "RECREATE");
if (f->IsZombie()) {
THROW("Cannot create output file!");
}
f->cd();
FitPar::Config().out = f;
// Create a new measurementbase class depending on the Format
MeasurementBase* flattreecreator = NULL;
// Make a new sample key for the format of interest.
nuiskey samplekey = Config::CreateKey("sample");
if (!gOptFormat.compare("GenericFlux")) {
- samplekey.AddS("name", "FlatTree");
- samplekey.AddS("input", gOptInputFile);
- samplekey.AddS("type", gOptType);
+ samplekey.Set("name", "FlatTree");
+ samplekey.Set("input", gOptInputFile);
+ samplekey.Set("type", gOptType);
flattreecreator = new GenericFlux_Tester("FlatTree", gOptInputFile,
FitBase::GetRW(), gOptType, "");
} else {
ERR(FTL) << "Unknown FlatTree format!" << std::endl;
}
// Make the FlatTree reconfigure
flattreecreator->Reconfigure();
f->cd();
flattreecreator->Write();
f->Close();
// Show Final Status
LOG(FIT) << "-------------------------------------" << std::endl;
LOG(FIT) << "Flattree Generation Complete." << std::endl;
LOG(FIT) << "-------------------------------------" << std::endl;
return 0;
}
diff --git a/app/nuissmear.cxx b/app/nuissmear.cxx
index 878f0d5..c558d1f 100644
--- a/app/nuissmear.cxx
+++ b/app/nuissmear.cxx
@@ -1,222 +1,223 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "ComparisonRoutines.h"
#include "InputUtils.h"
#include "Smearceptance_Tester.h"
// Global Arguments
std::string gOptInputFile = "";
std::string gOptOutputFile = "";
std::string gOptType = "DEFAULT";
std::string gOptNumberEvents = "NULL";
std::string gOptCardInput = "";
std::string gOptOptions = "";
//*******************************
void PrintSyntax() {
//*******************************
std::cout << "nuisflat -i input [-o outfile] [-n nevents] [-t "
"options] [-q con=val] \n";
std::cout
<< "\n Arguments : "
<< "\n\t -i input : Path to input vector of events to flatten"
<< "\n\t"
<< "\n\t This should be given in the same format a normal "
"input file"
<< "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}."
<< "\n\t"
<< "\n\t[-c crd.xml]: Input card file to override configs or define "
"smearcepters."
<< "\n\t "
<< "\n\t[-o outfile]: Optional output file path. "
<< "\n\t "
<< "\n\t If none given, input.smear.root is chosen."
<< "\n\t"
<< "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is "
"all."
<< "\n\t"
<< "\n\t[-t options]: Pass OPTION to the smearception sample. "
<< "\n\t Similar to type field in comparison xml configs."
<< "\n\t"
<< "\n\t[-q con=val]: Configuration overrides." << std::endl;
exit(-1);
};
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char** argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if ((!std::string(argv[i]).compare("-h")) ||
(!std::string(argv[i]).compare("-?")) ||
(!std::string(argv[i]).compare("--help")))
PrintSyntax();
}
// Format is nuwro -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
// Parse input file
ParserUtils::ParseArgument(args, "-i", gOptInputFile, false);
if (gOptInputFile == "") {
THROW("Need to provide a valid input file to nuisflat using -i flag!");
} else {
LOG(FIT) << "Reading Input File = " << gOptInputFile << std::endl;
gOptInputFile = InputUtils::PrependGuessedInputTypeToName(gOptInputFile);
}
// Get Output File
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile == "") {
gOptOutputFile = gOptInputFile + ".smear.root";
LOG(FIT) << "No output file given so saving nuisflat output to:"
<< gOptOutputFile << std::endl;
} else {
LOG(FIT) << "Saving nuisflat output to " << gOptOutputFile << std::endl;
}
// Get N Events and Configs
nuisconfig configuration = Config::Get();
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents.compare("NULL")) {
configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents);
}
std::vector configargs;
ParserUtils::ParseArgument(args, "-q", configargs);
for (size_t i = 0; i < configargs.size(); i++) {
configuration.OverrideConfig(configargs[i]);
}
ParserUtils::ParseArgument(args, "-c", gOptCardInput, false);
if (gOptCardInput != "") {
QLOG(FIT, "Reading cardfile: " << gOptCardInput);
- configuration.LoadConfig(gOptCardInput, "");
+ configuration.LoadSettings(gOptCardInput, "");
}
ParserUtils::ParseArgument(args, "-t", gOptOptions, false);
if (gOptOptions != "") {
QLOG(FIT, "Read options: \"" << gOptOptions << "\'");
}
return;
}
void SetupRW() {
std::vector parkeys = Config::QueryKeys("parameter");
if (!parkeys.empty()) {
LOG(FIT) << "Number of parameters : " << parkeys.size() << std::endl;
}
std::vector Params;
std::map TypeVals;
std::map CurrVals;
for (size_t i = 0; i < parkeys.size(); i++) {
nuiskey key = parkeys.at(i);
// Check for type,name,nom
if (!key.Has("type")) {
ERR(FTL) << "No type given for parameter " << i << std::endl;
ERR(FTL) << "type='PARAMETER_TYPE'" << std::endl;
throw;
} else if (!key.Has("name")) {
ERR(FTL) << "No name given for parameter " << i << std::endl;
ERR(FTL) << "name='SAMPLE_NAME'" << std::endl;
throw;
} else if (!key.Has("nominal")) {
ERR(FTL) << "No nominal given for parameter " << i << std::endl;
ERR(FTL) << "nominal='NOMINAL_VALUE'" << std::endl;
throw;
}
// Get Inputs
std::string partype = key.GetS("type");
std::string parname = key.GetS("name");
double parnom = key.GetD("nominal");
// Push into vectors
Params.push_back(parname);
TypeVals[parname] = FitBase::ConvDialType(partype);
CurrVals[parname] = parnom;
}
for (UInt_t i = 0; i < Params.size(); i++) {
FitBase::GetRW()->IncludeDial(Params[i], TypeVals[Params[i]]);
FitBase::GetRW()->SetDialValue(Params[i], CurrVals[Params[i]]);
}
FitBase::GetRW()->Reconfigure();
}
//*******************************
int main(int argc, char* argv[]) {
//*******************************
// Parse
GetCommandLineArgs(argc, argv);
// Make output file
TFile* f = new TFile(gOptOutputFile.c_str(), "RECREATE");
if (f->IsZombie()) {
THROW("Cannot create output file!");
}
f->cd();
- FitPar::Config().out = f;
+ Config::Get().out = f;
// Create a new measurementbase class depending on the Format
MeasurementBase* flattreecreator = NULL;
// Make a new sample key for the format of interest.
nuiskey samplekey = Config::CreateKey("sample");
- samplekey.SetS("name", std::string("FlatTree_") + gOptOptions);
- samplekey.SetS("input", gOptInputFile);
- samplekey.SetS("type", gOptType);
+ samplekey.Set("name", "FlatTree");
+ samplekey.Set("smearceptor", gOptOptions);
+ samplekey.Set("input", gOptInputFile);
+ samplekey.Set("type", gOptType);
if (gOptOptions == "") {
THROW(
"Attempting to flatten with Smearceptor, but no Smearceptor given. "
"Please supply a -t option.");
}
if (gOptCardInput == "") {
THROW(
"Attempting to flatten with Smearceptor, but no card passed with "
"Smearceptors configured. Please supply a -c option.");
}
SetupRW();
flattreecreator = new Smearceptance_Tester(samplekey);
// Make the FlatTree reconfigure
flattreecreator->Reconfigure();
f->cd();
flattreecreator->Write();
f->Close();
// Show Final Status
LOG(FIT) << "-------------------------------------" << std::endl;
LOG(FIT) << "Flattree Generation Complete." << std::endl;
LOG(FIT) << "-------------------------------------" << std::endl;
return 0;
}
diff --git a/cmake/GENIESetup.cmake b/cmake/GENIESetup.cmake
index 148d685..7c0b2c5 100644
--- a/cmake/GENIESetup.cmake
+++ b/cmake/GENIESetup.cmake
@@ -1,155 +1,157 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
# TODO
# check system for libxml2
# check whether we need the includes
# check if we can use a subset of the GENIE libraries
################################################################################
# Check Dependencies
################################################################################
################################# GENIE ######################################
if(GENIE STREQUAL "")
cmessage(FATAL_ERROR "Variable GENIE is not defined. "
"The location of a pre-built GENIE install must be defined either as"
" $ cmake -DGENIE=/path/to/GENIE or as and environment vairable"
" $ export GENIE=/path/to/GENIE")
endif()
if (BUILD_GEVGEN)
cmessage(STATUS "Building custom gevgen")
LIST(APPEND EXTRA_CXX_FLAGS -D__GEVGEN_ENABLED__)
endif()
# Extract GENIE VERSION
-execute_process (COMMAND ${CMAKE_SOURCE_DIR}/cmake/getgenieversion.sh ${GENIE}
- OUTPUT_VARIABLE GENIE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+if (GENIE_VERSION STREQUAL "AUTO")
+ execute_process (COMMAND ${CMAKE_SOURCE_DIR}/cmake/getgenieversion.sh ${GENIE}
+ OUTPUT_VARIABLE GENIE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
execute_process (COMMAND genie-config
--libs OUTPUT_VARIABLE GENIE_LD_FLAGS_STR OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND genie-config
--topsrcdir OUTPUT_VARIABLE GENIE_INCLUDES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "-L\([^ ]+\) \(.*\)$" PARSE_GENIE_LIBS_MATCH ${GENIE_LD_FLAGS_STR})
cmessage(DEBUG "genie-config --libs: ${GENIE_LD_FLAGS_STR}")
if(NOT PARSE_GENIE_LIBS_MATCH)
cmessage(FATAL_ERROR "Expected to be able to parse the result of genie-config --libs to a lib directory and a list of libraries to include, but got: \"${GENIE_LD_FLAGS_STR}\"")
endif()
set(GENIE_LIB_DIR ${CMAKE_MATCH_1})
set(GENIE_LIBS_RAW ${CMAKE_MATCH_2})
string(REPLACE "-l" "" GENIE_LIBS_STRIPED "${GENIE_LIBS_RAW}")
cmessage(STATUS "GENIE version : ${GENIE_VERSION}")
cmessage(STATUS "GENIE libdir : ${GENIE_LIB_DIR}")
cmessage(STATUS "GENIE libs : ${GENIE_LIBS_STRIPED}")
string(REGEX MATCH "ReinSeghal" WASMATCHED ${GENIE_LIBS_STRIPED})
if(WASMATCHED AND GENIE_VERSION STREQUAL "210")
set(GENIE_SEHGAL ${GENIE_LIBS_STRIPED})
STRING(REPLACE "ReinSeghal" "ReinSehgal" GENIE_LIBS_STRIPED ${GENIE_SEHGAL})
cmessage(DEBUG "Fixed inconsistency in library naming: ${GENIE_LIBS_STRIPED}")
endif()
string(REGEX MATCH "ReWeight" WASMATCHED ${GENIE_LIBS_STRIPED})
if(NOT WASMATCHED)
set(GENIE_LIBS_STRIPED "GReWeight ${GENIE_LIBS_STRIPED}")
cmessage(DEBUG "Force added ReWeight library: ${GENIE_LIBS_STRIPED}")
endif()
string(REPLACE " " ";" GENIE_LIBS_LIST "${GENIE_LIBS_STRIPED}")
cmessage(DEBUG "genie-config --libs -- MATCH1: ${CMAKE_MATCH_1}")
cmessage(DEBUG "genie-config --libs -- MATCH2: ${CMAKE_MATCH_2}")
cmessage(DEBUG "genie-config --libs -- libs stripped: ${GENIE_LIBS_STRIPED}")
cmessage(DEBUG "genie-config --libs -- libs list: ${GENIE_LIBS_LIST}")
################################ LHAPDF ######################################
if(LHAPDF_LIB STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPDF_LIB is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_LIB=/path/to/LHAPDF_libraries or as and environment vairable $ export LHAPDF_LIB=/path/to/LHAPDF_libraries")
endif()
if(LHAPDF_INC STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPDF_INC is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_INC=/path/to/LHAPDF_includes or as and environment vairable $ export LHAPDF_INC=/path/to/LHAPDF_includes")
endif()
if(LHAPATH STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPATH is not defined. The location of a the LHAPATH directory must be defined either as $ cmake -DLHAPATH=/path/to/LHAPATH or as and environment variable $ export LHAPATH=/path/to/LHAPATH")
endif()
################################ LIBXML ######################################
if(LIBXML2_LIB STREQUAL "")
cmessage(FATAL_ERROR "Variable LIBXML2_LIB is not defined. The location of a pre-built libxml2 install must be defined either as $ cmake -DLIBXML2_LIB=/path/to/LIBXML2_libraries or as and environment vairable $ export LIBXML2_LIB=/path/to/LIBXML2_libraries")
endif()
if(LIBXML2_INC STREQUAL "")
cmessage(FATAL_ERROR "Variable LIBXML2_INC is not defined. The location of a pre-built libxml2 install must be defined either as $ cmake -DLIBXML2_INC=/path/to/LIBXML2_includes or as and environment vairable $ export LIBXML2_INC=/path/to/LIBXML2_includes")
endif()
############################### log4cpp ######################################
if(LOG4CPP_LIB STREQUAL "")
cmessage(FATAL_ERROR "Variable LOG4CPP_LIB is not defined. The location of a pre-built log4cpp install must be defined either as $ cmake -DLOG4CPP_LIB=/path/to/LOG4CPP_libraries or as and environment vairable $ export LOG4CPP_LIB=/path/to/LOG4CPP_libraries")
endif()
if(LOG4CPP_INC STREQUAL "")
cmessage(FATAL_ERROR "Variable LOG4CPP_INC is not defined. The location of a pre-built log4cpp install must be defined either as $ cmake -DGENIE_LOG4CPP_INC=/path/to/LOG4CPP_includes or as and environment vairable $ export LOG4CPP_INC=/path/to/LOG4CPP_includes")
endif()
################################################################################
LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_ENABLED__ -D__GENIE_VERSION__=${GENIE_VERSION})
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES
${GENIE_INCLUDES_DIR}
${GENIE_INCLUDES_DIR}/GHEP
${GENIE_INCLUDES_DIR}/Ntuple
${GENIE_INCLUDES_DIR}/ReWeight
${GENIE_INCLUDES_DIR}/Apps
${GENIE_INCLUDES_DIR}/FluxDrivers
${GENIE_INCLUDES_DIR}/EVGDrivers
${LHAPDF_INC}
${LIBXML2_INC}
${LOG4CPP_INC})
SAYVARS()
LIST(APPEND EXTRA_LINK_DIRS
${GENIE_LIB_DIR}
${LHAPDF_LIB}
${LIBXML2_LIB}
${LOG4CPP_LIB})
#LIST(REVERSE EXTRA_LIBS)
#LIST(REVERSE GENIE_LIBS_LIST)
LIST(APPEND EXTRA_LIBS ${GENIE_LIBS_LIST})
#LIST(REVERSE EXTRA_LIBS)
LIST(APPEND EXTRA_LIBS LHAPDF xml2 log4cpp)
if(USE_PYTHIA8)
set(NEED_PYTHIA8 TRUE)
set(NEED_ROOTPYTHIA8 TRUE)
else()
set(NEED_PYTHIA6 TRUE)
set(NEED_ROOTPYTHIA6 TRUE)
endif()
set(NEED_ROOTEVEGEN TRUE)
SET(USE_GENIE TRUE CACHE BOOL "Whether to enable GENIE (reweight) support. Requires external libraries. " FORCE)
diff --git a/cmake/cacheVariables.cmake b/cmake/cacheVariables.cmake
index 1c75a96..9aa2f08 100644
--- a/cmake/cacheVariables.cmake
+++ b/cmake/cacheVariables.cmake
@@ -1,208 +1,209 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
function(CheckAndSetDefaultEnv VARNAME DEFAULT CACHETYPE DOCSTRING ENVNAME)
#cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.")
if(NOT DEFINED ${VARNAME})
if(DEFINED ENV{${ENVNAME}} AND NOT $ENV{${ENVNAME}} STREQUAL "")
set(${VARNAME} $ENV{${ENVNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
cmessage(DEBUG " Read ${VARNAME} from ENVVAR ${ENVNAME} as $ENV{${ENVNAME}}.")
else()
set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING})
endif()
else()
set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
unset(${VARNAME})
endif()
cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.")
endfunction()
function(CheckAndSetDefaultCache VARNAME DEFAULT CACHETYPE DOCSTRING)
# cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.")
if(NOT DEFINED ${VARNAME})
set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING})
else()
set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
unset(${VARNAME})
endif()
cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.")
endfunction()
function(CheckAndSetDefault VARNAME DEFAULT)
# cmessage(DEBUG "Trying to assign variable ${VARNAME}.")
if(NOT DEFINED ${VARNAME})
set(${VARNAME} ${DEFAULT} PARENT_SCOPE)
set(${VARNAME} ${DEFAULT})
endif()
cmessage(CACHE "--Set variable: \"${VARNAME}\" to \"${${VARNAME}}\".")
endfunction()
CheckAndSetDefaultCache(VERBOSE TRUE BOOL "Whether to configure loudly.")
set (CMAKE_SKIP_BUILD_RPATH TRUE)
#Changes default install path to be a subdirectory of the build dir.
#Can set build dir at configure time with -DCMAKE_INSTALL_PREFIX=/install/path
if(CMAKE_INSTALL_PREFIX STREQUAL "" OR CMAKE_INSTALL_PREFIX STREQUAL
"/usr/local")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
elseif(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE DEBUG)
elseif(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE DEBUG)
endif()
CheckAndSetDefaultCache(USE_MINIMIZER TRUE INTERNAL "Whether we are using the ROOT minimization libraries. ")
CheckAndSetDefaultCache(USE_HEPMC FALSE BOOL "Whether to enable HepMC input support. ")
CheckAndSetDefaultEnv(HEPMC "" PATH "Path to HepMC source tree root directory. Overrides environment variable \$HEPMC <>" HEPMC)
CheckAndSetDefaultCache(HEPMC_MOMUNIT "GEV" STRING "HepMC momentum units [MEV|GEV]. ")
CheckAndSetDefaultCache(HEPMC_LENUNIT "CM" STRING "HepMC momentum units [MM|CM]. ")
CheckAndSetDefaultCache(HEPMC_USED_EP FALSE INTERNAL "Whether we built HepMC or not. ")
CheckAndSetDefaultCache(USE_NEUT FALSE BOOL "Whether to enable NEUT (reweight) support. Requires external libraries. ")
CheckAndSetDefaultEnv(NEUT_ROOT "" PATH "Path to NEUT source tree root directory. Overrides environment variable \$NEUT_ROOT <>" NEUT_ROOT)
CheckAndSetDefaultEnv(CERN "" PATH "Path to CERNLIB source tree root directory that NEUT was built against. Overrides environment variable \$CERN <>" CERN)
CheckAndSetDefaultEnv(CERN_LEVEL "" STRING "CERNLIB Library version. Overrides environment variable \$CERN_LEVEL <>" CERN_LEVEL)
CheckAndSetDefaultCache(USE_NuWro FALSE BOOL "Whether to enable NuWro support. ")
CheckAndSetDefaultEnv(NUWRO "" PATH "Path to NuWro source tree root directory. Overrides environment variable \$NUWRO <>" NUWRO)
CheckAndSetDefaultEnv(NUWRO_INC "" PATH "Path to NuWro installed includes directory, needs to contain \"params_all.h\". Overrides environment variable \$NUWRO_INC <>" NUWRO_INC)
CheckAndSetDefaultCache(NUWRO_INPUT_FILE "" FILEPATH "Path to an input NuWro event vector, which can be used to build NuWro i/o libraries. <>")
CheckAndSetDefaultCache(NUWRO_BUILT_FROM_FILE FALSE INTERNAL "Whether the NuWro libraries were built by NUISANCE. ")
CheckAndSetDefaultCache(USE_NuWro_RW FALSE BOOL "Whether to try and build support for NuWro reweighting. ")
CheckAndSetDefaultCache(USE_NuWro_SRW_Event FALSE BOOL "Whether to use cut down NuWro reweight event format. Requires NuWro reweight. ")
CheckAndSetDefaultCache(USE_GENIE FALSE BOOL "Whether to enable GENIE (reweight) support. Requires external libraries. ")
+CheckAndSetDefaultCache(GENIE_VERSION "AUTO" STRING "GENIE Version ")
CheckAndSetDefaultEnv(GENIE "" PATH "Path to GENIE source tree root directory. Overrides environment variable \$GENIE <>" GENIE)
CheckAndSetDefaultEnv(LHAPDF_LIB "" PATH "Path to pre-built LHAPDF libraries. Overrides environment variable \$LHAPDF_LIB. <>" LHAPDF_LIB)
CheckAndSetDefaultEnv(LHAPDF_INC "" PATH "Path to installed LHAPDF headers. Overrides environment variable \$LHAPDF_INC. <>" LHAPDF_INC)
CheckAndSetDefaultEnv(LHAPATH "" PATH "Path to LHA PDF inputs. Overrides environment variable \$LHAPATH. <>" LHAPATH)
CheckAndSetDefaultEnv(LIBXML2_LIB "" PATH "Path to pre-built LIBXML2 libraries. Overrides environment variable \$LIBXML2_LIB. <>" LIBXML2_LIB)
CheckAndSetDefaultEnv(LIBXML2_INC "" PATH "Path to installed LIBXML2 headers. Overrides environment variable \$LIBXML2_INC. <>" LIBXML2_INC)
CheckAndSetDefaultEnv(LOG4CPP_LIB "" PATH "Path to pre-built LOG4CPP libraries. Overrides environment variable \$LOG4CPP_LIB. <>" LOG4CPP_LIB)
CheckAndSetDefaultEnv(LOG4CPP_INC "" PATH "Path to installed LOG4CPP headers. Overrides environment variable \$LOG4CPP_INC. <>" LOG4CPP_INC)
CheckAndSetDefaultCache(BUILD_GEVGEN FALSE BOOL "Whether to build nuisance_gevgen app.")
CheckAndSetDefaultCache(USE_T2K FALSE BOOL "Whether to enable T2KReWeight support. Requires external libraries. ")
CheckAndSetDefaultEnv(T2KREWEIGHT "" PATH "Path to installed T2KREWEIGHTReWeight. Overrides environment variable \$T2KREWEIGHT. <>" T2KREWEIGHT)
CheckAndSetDefaultCache(USE_NIWG FALSE BOOL "Whether to enable (T2K) NIWG ReWeight support. Requires external libraries. ")
CheckAndSetDefaultEnv(NIWG_ROOT "" PATH "Path to installed NIWGReWeight. Overrides environment variable \$NIWG. <>" NIWG)
CheckAndSetDefaultCache(USE_MINERvA_RW FALSE BOOL "Whether to enable MINERvA ReWeight support. ")
CheckAndSetDefaultEnv(PYTHIA6 "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>" PYTHIA6)
CheckAndSetDefaultEnv(PYTHIA8 "" PATH "Path to directory containing libPythia8.so. Overrides environment variable \$PYTHIA8 <>" PYTHIA8)
CheckAndSetDefaultCache(USE_PYTHIA8 FALSE BOOL "Whether to enable PYTHIA8 event support. ")
CheckAndSetDefaultCache(USE_GiBUU TRUE BOOL "Whether to enable GiBUU event support. ")
CheckAndSetDefaultCache(BUILD_GiBUU FALSE BOOL "Whether to build supporting GiBUU event tools along with a patched version of GiBUU. ")
CheckAndSetDefaultCache(USE_NUANCE TRUE BOOL "Whether to enable NUANCE event support. ")
CheckAndSetDefaultCache(USE_PROB3PP FALSE BOOL "Whether to download and compile in Prob3++ support. ")
CheckAndSetDefaultCache(NO_EXTERNAL_UPDATE TRUE BOOL "Whether to perform the update target for external dependencies. ")
CheckAndSetDefaultCache(USE_GPERFTOOLS FALSE BOOL "Whether to compile in google performance tools. ")
CheckAndSetDefault(NEED_PYTHIA6 FALSE)
CheckAndSetDefault(NEED_PYTHIA8 FALSE)
CheckAndSetDefault(NEED_ROOTEVEGEN FALSE)
CheckAndSetDefault(NEED_ROOTPYTHIA6 FALSE)
CheckAndSetDefaultCache(USE_OMP FALSE BOOL "Whether to enable multicore features (there currently are none...). ")
CheckAndSetDefault(NO_EXPERIMENTS FALSE)
cmessage(STATUS "NO_EXPERIMENTS: ${NO_EXPERIMENTS}")
CheckAndSetDefaultCache(NO_ANL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ANL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_ArgoNeuT ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ArgoNeuT samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_BEBC ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BEBC samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_BNL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BNL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_FNAL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build FNAL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_GGM ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build GGM samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_K2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build K2K samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_MINERvA ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MINERvA samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_MiniBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MiniBooNE samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_T2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build T2K samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_SciBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build SciBooNE samples. <-DNO_EXPERIMENTS=FALSE>")
function(SAYVARS)
LIST(APPEND VARS
USE_HEPMC
HEPMC
HEPMC_MOMUNIT
HEPMC_LENUNIT
HEPMC_USED_EP
USE_NEUT
NEUT_ROOT
CERN
CERN_LEVEL
USE_NuWro
NUWRO
NUWRO_INC
NUWRO_INPUT_FILE
NUWRO_BUILT_FROM_FILE
USE_GENIE
GENIE
LHAPDF_LIB
LHAPDF_INC
LIBXML2_LIB
LIBXML2_INC
LOG4CPP_LIB
GENIE_LOG4CPP_INC
BUILD_GEVGEN
USE_T2K
USE_NIWG
USE_GiBUU
BUILD_GiBUU
USE_NUANCE
NO_EXTERNAL_UPDATE
USE_GPERFTOOLS
NO_ANL
NO_ArgoNeuT
NO_BEBC
NO_BNL
NO_FNAL
NO_GGM
NO_K2K
NO_MINERvA
NO_MiniBooNE
NO_T2K
NO_SciBooNE)
foreach(v ${VARS})
if(DEFINED ${v})
cmessage(DEBUG "VARIABLE: \"${v}\" = \"${${v}}\"")
endif()
endforeach(v)
endfunction()
diff --git a/parameters/config.xml b/parameters/config.xml
index 8ad5bc2..4e103d0 100644
--- a/parameters/config.xml
+++ b/parameters/config.xml
@@ -1,200 +1,214 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/dumpgenieconfig.py b/scripts/dumpgenieconfig.py
new file mode 100644
index 0000000..b5c98c3
--- /dev/null
+++ b/scripts/dumpgenieconfig.py
@@ -0,0 +1,35 @@
+from ROOT import TFile, TFolder, TObjString
+import sys
+
+def PrintKey(obj, indent):
+ splitkey = obj.GetName().split(";")
+ keydict = {}
+ for val in reversed(splitkey):
+ splitval = val.split(":")
+ if (len(splitval) < 2): splitval = val.split("=")
+ keydict[splitval[0].strip()] = ''.join(splitval[1:]).strip()
+
+ print indent, keydict
+
+def ExpandKeys(keydir, indent):
+ for obj in keydir.GetListOfFolders():
+ if "TFolder" in str(type(obj)):
+ print indent, obj.GetName()
+ ExpandKeys(obj, indent + " -> ")
+ if "TObjString" in str(type(obj)):
+ PrintKey(obj, indent )
+
+def ExpandGlobalList(keydir):
+ for obj in keydir.GetListOfFolders():
+ if str(obj.GetName()) != "GlobalParameterList": continue
+ print "GLOBAL : ", obj.GetName()
+ ExpandKeys(obj,"GLOBAL : ")
+
+if __name__=="__main__":
+
+ myfile = TFile(sys.argv[1],"READ")
+ configs = myfile.Get("gconfig")
+ ExpandKeys(configs,"")
+
+ print "\n# Global List #\n"
+ ExpandGlobalList(configs)
diff --git a/scripts/nuissamples b/scripts/nuissamples
index a80432a..7721fe5 100755
--- a/scripts/nuissamples
+++ b/scripts/nuissamples
@@ -1,20 +1,19 @@
#!/bin/sh
-for line in $(grep compare $NUISANCE/src/FCN/SampleList.cxx)
-do
- if [[ $line != *"compare"* ]];
- then
- continue
- fi
- line=${line//\!name\.compare\(/}
- line=${line//\(/}
- line=${line//\)/}
- line=${line//\"/}
+for line in $(grep compare $NUISANCE/src/FCN/SampleList.cxx); do
+ if [[ $line != *"compare"* ]]; then
+ continue
+ fi
+ line=${line//\!name\.compare\(/}
+ line=${line//\(/}
+ line=${line//\)/}
+ line=${line//\"/}
+ line=${line//\{}
- if [[ $line != *"$1"* ]];
- then
- continue
- fi
+ if [[ $line != *"$1"* ]];
+ then
+ continue
+ fi
- echo ${2}${line}${3}
+ echo ${2}${line}${3}
done
diff --git a/src/Routines/CMakeLists.txt b/src/Config/CMakeLists.txt
similarity index 79%
copy from src/Routines/CMakeLists.txt
copy to src/Config/CMakeLists.txt
index 2c5cf1c..7577b9d 100644
--- a/src/Routines/CMakeLists.txt
+++ b/src/Config/CMakeLists.txt
@@ -1,66 +1,52 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
-set(IMPLFILES
-ComparisonRoutines.cxx
-SystematicRoutines.cxx
-SplineRoutines.cxx
-)
-
-if(USE_MINIMIZER)
- set(IMPLFILES ${IMPLFILES};MinimizerRoutines.cxx)
-endif()
-
set(HEADERFILES
-ComparisonRoutines.h
-SystematicRoutines.h
-SplineRoutines.h
+NuisConfig.h
+NuisKey.h
)
-if(USE_MINIMIZER)
- set(HEADERFILES ${HEADERFILES};MinimizerRoutines.h)
-endif()
+set(IMPLFILES
+NuisConfig.cxx
+NuisKey.cxx
+)
-set(LIBNAME Routines)
+set(LIBNAME Config)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_library(${LIBNAME} STATIC ${IMPLFILES})
else(CMAKE_BUILD_TYPE MATCHES RELEASE)
add_library(${LIBNAME} SHARED ${IMPLFILES})
endif()
-include_directories(${EXP_INCLUDE_DIRECTORIES})
-
include_directories(${MINIMUM_INCLUDE_DIRECTORIES})
-include_directories(${CMAKE_SOURCE_DIR}/src/FCN)
-include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies)
-
set_target_properties(${LIBNAME} PROPERTIES VERSION
"${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}")
+
#set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS})
if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES)
add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES})
endif()
install(TARGETS ${LIBNAME} DESTINATION lib)
#Can uncomment this to install the headers... but is it really neccessary?
#install(FILES ${HEADERFILES} DESTINATION include)
set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE)
diff --git a/src/Config/NuisConfig.cxx b/src/Config/NuisConfig.cxx
new file mode 100644
index 0000000..f1f1033
--- /dev/null
+++ b/src/Config/NuisConfig.cxx
@@ -0,0 +1,802 @@
+// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+
+/*******************************************************************************
+* This file is part of NUISANCE.
+*
+* NUISANCE is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* NUISANCE is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with NUISANCE. If not, see .
+*******************************************************************************/
+#include "NuisConfig.h"
+
+#include "FitLogger.h"
+#include "GeneralUtils.h"
+#include "TXMLEngine.h"
+
+namespace Config {
+
+nuisconfig &Get() { return nuisconfig::GetConfig(); };
+std::string GetPar(std::string const &name) { return Get().GetConfig(name); }
+bool HasPar(std::string const &name) { return Get().HasConfig(name); }
+std::string GetParS(std::string const &name) { return Get().GetConfigS(name); }
+int GetParI(std::string const &name) { return Get().GetConfigI(name); }
+bool GetParB(std::string const &name) { return Get().GetConfigB(name); }
+float GetParF(std::string const &name) { return Get().GetConfigF(name); }
+double GetParD(std::string const &name) { return Get().GetConfigD(name); }
+void SetPar(std::string const &name, std::string const &val) {
+ Get().SetConfig(name, val);
+}
+void SetPar(std::string const &name, char const *val) {
+ Get().SetConfig(name, val);
+}
+void SetPar(std::string const &name, bool val) { Get().SetConfig(name, val); }
+void SetPar(std::string const &name, int val) { Get().SetConfig(name, val); }
+void SetPar(std::string const &name, float val) { Get().SetConfig(name, val); }
+void SetPar(std::string const &name, double val) { Get().SetConfig(name, val); }
+}
+
+namespace FitPar {
+std::string GetDataBase() { return GeneralUtils::GetTopLevelDir() + "/data/"; };
+nuisconfig &Config() { return Config::Get(); };
+}
+
+nuisconfig *nuisconfig::m_nuisconfigInstance = NULL;
+nuisconfig &nuisconfig::GetConfig(void) {
+ if (!m_nuisconfigInstance) m_nuisconfigInstance = new nuisconfig;
+ return *m_nuisconfigInstance;
+};
+
+// Main Class Definition
+nuisconfig::nuisconfig() {
+ // Load default Parameters
+ std::string filename =
+ (GeneralUtils::GetTopLevelDir() + "/parameters/config.xml");
+ std::cout << "[ NUISANCE ]: Loading DEFAULT settings from : " << filename;
+
+ // Create XML Engine
+ fXML = new TXMLEngine;
+ fXML->SetSkipComments(true);
+
+ // Load in documents
+ fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000));
+ if (!fXMLDocs[0]) {
+ THROW("Cannot Read Parameters File!");
+ }
+
+ // Setup Main XML Node to be the first file read
+ fMainNode = fXML->DocGetRootElement(fXMLDocs[0]);
+
+ // Print result
+ std::cout << " -> DONE." << std::endl;
+}
+
+nuisconfig::~nuisconfig() {
+ // Should really delete XML objects here but we don't
+}
+
+void nuisconfig::LoadSettings(std::string const &filename,
+ std::string const &state) {
+ // Open file and see if its XML
+ std::cout << "[ NUISANCE ]: Trying to parse file : " << filename;
+ StopTalking();
+ XMLDocPointer_t readdoc = fXML->ParseFile(filename.c_str(), 1000000);
+ StartTalking();
+
+ // If it is parse it as a nice XML config file
+ if (readdoc) {
+ std::cout << " -> Found XML file." << std::endl;
+ LoadXMLSettings(filename, state);
+
+ // Otherwise its an old simple card file
+ } else {
+ std::cout << " -> Assuming its a simple card file." << std::endl;
+ LoadCardSettings(filename, state);
+ }
+}
+
+void nuisconfig::LoadXMLSettings(std::string const &filename,
+ std::string const &state) {
+ std::cout << "[ NUISANCE ]: Loading XML settings from : " << filename
+ << std::endl;
+
+ // Add new file to xml docs list
+ fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000));
+
+ if (!fXMLDocs.back()) {
+ THROW("Failed to read: " << filename);
+ }
+
+ // Loop over children and add
+ XMLNodePointer_t child =
+ fXML->GetChild(fXML->DocGetRootElement(fXMLDocs.back()));
+
+ // // Here we manually load all the children from the card file into our root
+ // node
+ if (!child) {
+ THROW("CANNOT Find child inside settings file!");
+ }
+
+ while (child) {
+ // SPECIAL CONFIG CASE
+ // If its a config node, then remove previous attributes, overriding old
+ // value
+ if (!std::string(fXML->GetNodeName(child)).compare("config")) {
+ // Loop over attribues
+ XMLAttrPointer_t attr1 = fXML->GetFirstAttr(child);
+ while (attr1) {
+ // If a valid attribute name is given then compare
+ if (!GetConfigS(fXML->GetAttrName(attr1)).empty()) {
+ // Get full list of present configs
+ std::vector confignodes = GetNodes("config");
+
+ // Loop over present configs and compare
+ for (size_t i = 0; i < confignodes.size(); i++) {
+ // If we already have this config, free the old attribute
+ if (fXML->HasAttr(confignodes[i], fXML->GetAttrName(attr1))) {
+ fXML->FreeAttr(confignodes[i], fXML->GetAttrName(attr1));
+ break;
+ }
+ }
+ }
+
+ // Move onto next config attribute
+ attr1 = fXML->GetNextAttr(attr1);
+ }
+ }
+
+ TString nodeStr;
+
+ fXML->SaveSingleNode(child, &nodeStr);
+
+ XMLNodePointer_t copyNode = fXML->ReadSingleNode(nodeStr.Data());
+
+ // Add this child to the main config list
+ fXML->AddChild(fMainNode, copyNode);
+
+ // Get Next Child
+ child = fXML->GetNext(child);
+ }
+ std::cout << " -> DONE." << std::endl;
+}
+
+void nuisconfig::LoadCardSettings(std::string const &filename,
+ std::string const &state) {
+ std::cout << "[ NUISANCE ]: Loading simple config from : " << filename;
+
+ // Build XML Config from the card file by parsing each line
+ std::vector cardlines =
+ GeneralUtils::ParseFileToStr(filename, "\n");
+ int linecount = 0;
+
+ // Loop over all input lines
+ for (std::vector::iterator iter = cardlines.begin();
+ iter != cardlines.end(); iter++) {
+ std::string line = (*iter);
+ linecount++;
+
+ // Skip Comments
+ if (line.empty()) continue;
+ if (line.c_str()[0] == '#') continue;
+
+ // Parse whitespace
+ std::vector strvct = GeneralUtils::ParseToStr(line, " ");
+ if (strvct.empty()) continue;
+
+ // Get Identifier
+ std::string id = strvct[0];
+
+ // Build backwards compatible xml configs
+
+ // Sample structure
+ if (!id.compare("sample")) {
+ CreateSampleNodeFromLine(line);
+ }
+
+ // Any parameter structure
+ if (id.find("_parameter") != std::string::npos) {
+ CreateParameterNodeFromLine(line);
+ }
+
+ // Any covar structure
+ if (!id.compare("covar") || !id.compare("pull") || !id.compare("throw")) {
+ CreatePullNodeFromLine(line);
+ }
+
+ // Any config structure
+ if (!id.compare("config")) {
+ CreateOldConfigNodeFromLine(line);
+ }
+ }
+ std::cout << " -> DONE." << std::endl;
+}
+
+XMLNodePointer_t nuisconfig::CreateSampleNodeFromLine(std::string const &line) {
+ // Create new node entry
+ XMLNodePointer_t samplenode = CreateNode("sample");
+
+ // Parse line
+ std::vector strvct = GeneralUtils::ParseToStr(line, " ");
+
+ // Add line elements to the node
+ // name input type norm
+ if (strvct.size() > 1) Set(samplenode, "name", strvct[1]);
+ if (strvct.size() > 2) Set(samplenode, "input", strvct[2]);
+ if (strvct.size() > 3) Set(samplenode, "type", strvct[3]);
+ if (strvct.size() > 4) Set(samplenode, "norm", strvct[4]);
+
+ return samplenode;
+}
+
+XMLNodePointer_t nuisconfig::CreateParameterNodeFromLine(
+ std::string const &line) {
+ // Create new node entry
+ XMLNodePointer_t parnode = CreateNode("parameter");
+
+ // Parse line
+ std::vector strvct = GeneralUtils::ParseToStr(line, " ");
+
+ // Add line elements to the node
+ // type name nominal [low] [high] [step] state
+ if (strvct.size() > 0) Set(parnode, "type", strvct[0]);
+ if (strvct.size() > 1) Set(parnode, "name", strvct[1]);
+ if (strvct.size() > 2) Set(parnode, "nominal", strvct[2]);
+
+ // If free structure
+ if (strvct.size() == 7) {
+ Set(parnode, "low", strvct[3]);
+ Set(parnode, "high", strvct[4]);
+ Set(parnode, "step", strvct[5]);
+ Set(parnode, "state", strvct[6]);
+
+ // Fixed param structure
+ } else if (strvct.size() == 3) {
+ Set(parnode, "state", "FIX");
+ } else if (strvct.size() == 4) {
+ Set(parnode, "state", strvct[3]);
+ }
+
+ return parnode;
+}
+
+XMLNodePointer_t nuisconfig::CreatePullNodeFromLine(std::string const &line) {
+ // Create new node entry
+ XMLNodePointer_t parnode = CreateNode("covar");
+
+ // Parse line
+ std::vector strvct = GeneralUtils::ParseToStr(line, " ");
+
+ // Add line elements to the node
+ // name input type
+ if (strvct.size() > 1) Set(parnode, "name", strvct[1]);
+ if (strvct.size() > 2) Set(parnode, "input", strvct[2]);
+ if (strvct.size() > 3) Set(parnode, "type", strvct[3]);
+
+ return parnode;
+}
+
+XMLNodePointer_t nuisconfig::CreateOldConfigNodeFromLine(
+ std::string const &line) {
+ // Create new node entry
+ XMLNodePointer_t confignode = CreateNode("config");
+
+ // Parse line
+ std::vector strvct = GeneralUtils::ParseToStr(line, " ");
+
+ // Add line elements to the node
+ // name value
+ if (strvct.size() > 2) Set(confignode, strvct[1], strvct[2]);
+
+ return confignode;
+}
+
+void nuisconfig::FinaliseSettings(std::string const &name) {
+ std::cout << "[ NUISANCE ]: Finalising run settings";
+
+ WriteSettings(name);
+
+ // Save full config to file
+ RemoveEmptyNodes();
+ RemoveIdenticalNodes();
+
+ std::cout << " -> DONE." << std::endl;
+}
+
+void nuisconfig::WriteSettings(std::string const &outputname) {
+ // Create a New XML Doc
+ XMLDocPointer_t newxmldoc = fXML->NewDoc();
+ fXML->DocSetRootElement(newxmldoc, fMainNode);
+
+ // Save document to file
+ if (GetConfigB("SaveParsedXMLFile")) {
+ fXML->SaveDoc(newxmldoc, outputname.c_str());
+ }
+}
+
+void nuisconfig::PrintXML(XMLNodePointer_t node, int indent) {
+ std::stringstream ss("");
+ for (int i = 0; i < indent; ++i) {
+ ss << " ";
+ }
+
+ std::cout << ss.str() << "<" << fXML->GetNodeName(node) << std::flush;
+
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ while (attr) {
+ std::cout << " " << fXML->GetAttrName(attr) << "=\""
+ << fXML->GetAttrValue(attr) << "\"" << std::flush;
+ attr = fXML->GetNextAttr(attr);
+ }
+ if (!fXML->GetChild(node)) {
+ std::cout << " />" << std::endl;
+ return;
+ }
+ std::cout << " >" << std::endl;
+
+ XMLNodePointer_t child = fXML->GetChild(node);
+ while (child) {
+ PrintXML(child, indent + 1);
+ child = fXML->GetNext(child);
+ }
+
+ std::cout << ss.str() << "" << fXML->GetNodeName(node) << ">" << std::endl;
+}
+
+XMLNodePointer_t nuisconfig::CreateNode(std::string const &name) {
+ return fXML->NewChild(fMainNode, 0, name.c_str());
+}
+
+XMLNodePointer_t nuisconfig::CreateNode(XMLNodePointer_t node,
+ std::string const &name) {
+ return fXML->NewChild(node, 0, name.c_str());
+}
+
+XMLNodePointer_t nuisconfig::GetNode(XMLNodePointer_t node,
+ std::string const &type) {
+ /// Loop over all children
+ XMLNodePointer_t child = fXML->GetChild(node);
+ while (child != 0) {
+ /// Get nodes for given type (if type empty return all)
+ if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) {
+ return child;
+ }
+
+ // Next child
+ child = fXML->GetNext(child);
+ }
+
+ // Child not found
+ return 0;
+}
+
+void nuisconfig::RemoveEmptyNodes() {
+ std::vector nodelist = Config::Get().GetNodes();
+ for (size_t i = 0; i < nodelist.size(); i++) {
+ if (fXML->IsEmptyNode(nodelist[i])) {
+ RemoveNode(nodelist[i]);
+ }
+ }
+}
+
+void nuisconfig::RemoveIdenticalNodes() {
+ std::vector removed;
+
+ // Loop over all nodes and check for identical nodes
+ std::vector nodelist = Config::Get().GetNodes();
+ for (size_t i = 0; i < nodelist.size(); i++) {
+ for (size_t j = 0; j < nodelist.size(); j++) {
+ if (i == j) continue;
+
+ XMLNodePointer_t node1 = nodelist[i];
+ XMLNodePointer_t node2 = nodelist[j];
+
+ // Check node already removed.
+ if (std::find(removed.begin(), removed.end(), node1) != removed.end()) {
+ continue;
+ }
+ if (std::find(removed.begin(), removed.end(), node2) != removed.end()) {
+ continue;
+ }
+
+ // Check matching
+ if (!MatchingNodes(node1, node2)) {
+ continue;
+ }
+
+ if (std::string(fXML->GetNodeName(node1)).compare("config") and
+ fXML->IsEmptyNode(node1)) {
+ // Matching so print out warning
+ std::cout << "Matching nodes given! Removing node1!" << std::endl
+ << "Node 1" << std::endl;
+ PrintNode(node1);
+
+ std::cout << "Node 2" << std::endl;
+ PrintNode(node2);
+ }
+
+ // Remove node
+ removed.push_back(node1);
+ }
+ }
+
+ // Now go through and remove this node.
+ for (size_t i = 0; i < removed.size(); i++) {
+ RemoveNode(removed.at(i));
+ }
+
+ return;
+}
+
+void nuisconfig::RemoveNode(XMLNodePointer_t node) {
+ fXML->FreeAllAttr(node);
+ fXML->CleanNode(node);
+ fXML->FreeNode(node);
+ fXML->UnlinkNode(node);
+}
+
+void nuisconfig::PrintNode(XMLNodePointer_t node) {
+ // Print Node Name
+ std::cout << fXML->GetNodeName(node) << std::endl;
+
+ // Loop and print all attributes
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ while (attr != 0) {
+ std::cout << " -> " << fXML->GetAttrName(attr) << " : "
+ << fXML->GetAttrValue(attr) << std::endl;
+ attr = fXML->GetNextAttr(attr);
+ }
+}
+
+bool nuisconfig::MatchingNodes(XMLNodePointer_t node1, XMLNodePointer_t node2) {
+ bool matching = true;
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node1);
+ while (attr != 0) {
+ if (GetS(node2, fXML->GetAttrName(attr)) != fXML->GetAttrValue(attr))
+ matching = false;
+ attr = fXML->GetNextAttr(attr);
+ }
+ return matching;
+}
+
+XMLNodePointer_t nuisconfig::GetNode(std::string const &type) {
+ return GetNode(fMainNode, type);
+}
+
+std::vector nuisconfig::GetNodes(XMLNodePointer_t node,
+ std::string const &type) {
+ // Create new vector for nodes
+ std::vector nodelist;
+
+ /// Loop over all children
+ XMLNodePointer_t child = fXML->GetChild(node);
+ while (child != 0) {
+ /// Get nodes for given type (if type empty return all)
+ if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) {
+ nodelist.push_back(child);
+ }
+
+ // Next child
+ child = fXML->GetNext(child);
+ }
+
+ // return list
+ return nodelist;
+}
+
+std::vector nuisconfig::GetNodes(std::string const &type) {
+ return GetNodes(fMainNode, type);
+}
+
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
+ std::string const &val) {
+ // Remove and re-add attribute
+ if (fXML->HasAttr(node, name.c_str())) {
+ fXML->FreeAttr(node, name.c_str());
+ }
+
+ fXML->NewAttr(node, 0, name.c_str(), val.c_str());
+}
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
+ char const *val) {
+ Set(node, name, std::string(val));
+}
+
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, bool val) {
+ Set(node, name, GeneralUtils::BoolToStr(val));
+}
+
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, int val) {
+ Set(node, name, GeneralUtils::IntToStr(val));
+}
+
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
+ float val) {
+ Set(node, name, GeneralUtils::DblToStr(val));
+}
+
+void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
+ double val) {
+ Set(node, name, GeneralUtils::DblToStr(val));
+}
+
+void nuisconfig::SetS(XMLNodePointer_t node, std::string const &name,
+ std::string const &val) {
+ Set(node, name, val);
+}
+
+void nuisconfig::SetB(XMLNodePointer_t node, std::string const &name,
+ bool val) {
+ Set(node, name, GeneralUtils::BoolToStr(val));
+}
+
+void nuisconfig::SetI(XMLNodePointer_t node, std::string const &name, int val) {
+ Set(node, name, GeneralUtils::IntToStr(val));
+}
+
+void nuisconfig::SetF(XMLNodePointer_t node, std::string const &name,
+ float val) {
+ Set(node, name, GeneralUtils::DblToStr(val));
+}
+
+void nuisconfig::SetD(XMLNodePointer_t node, std::string const &name,
+ double val) {
+ Set(node, name, GeneralUtils::DblToStr(val));
+}
+
+bool nuisconfig::Has(XMLNodePointer_t node, std::string const &name) {
+ // If node empty return empty
+ if (node == 0) return false;
+
+ // Search attributes
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ bool found = false;
+
+ // Loop over all attributes
+ while (attr != 0) {
+ // Find value of correct name
+ if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
+ found = true;
+ break;
+ }
+
+ // Next Attribute
+ attr = fXML->GetNextAttr(attr);
+ }
+
+ return found;
+}
+
+std::string nuisconfig::Get(XMLNodePointer_t node, std::string const &name) {
+ // If node empty return empty
+ if (node == 0) return "";
+
+ // Get Attribute from child with name
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ std::string temp = "";
+
+ // Loop over all attributes
+ while (attr != 0) {
+ // If valid match then save
+ if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
+ temp = fXML->GetAttrValue(attr);
+ }
+
+ // Next Attribute
+ attr = fXML->GetNextAttr(attr);
+ }
+
+ return temp;
+}
+
+std::string nuisconfig::GetS(XMLNodePointer_t node, std::string const &name) {
+ return Get(node, name);
+}
+
+bool nuisconfig::GetB(XMLNodePointer_t node, std::string const &name) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::StrToBool(tempattr);
+}
+
+int nuisconfig::GetI(XMLNodePointer_t node, std::string const &name) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::StrToInt(tempattr);
+}
+
+float nuisconfig::GetF(XMLNodePointer_t node, std::string const &name) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::StrToDbl(tempattr);
+}
+
+double nuisconfig::GetD(XMLNodePointer_t node, std::string const &name) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::StrToDbl(tempattr);
+}
+
+std::vector nuisconfig::GetVS(XMLNodePointer_t node,
+ std::string const &name,
+ const char *del) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::ParseToStr(tempattr, del);
+}
+
+// std::vector nuisconfig::GetVB(XMLNodePointer_t node,
+// std::string name,
+// const char* del) {
+// std::string tempattr = Get(node, name);
+// return GeneralUtils::ParseToBool(tempattr, del);
+// }
+
+std::vector nuisconfig::GetVI(XMLNodePointer_t node,
+ std::string const &name, const char *del) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::ParseToInt(tempattr, del);
+}
+
+// std::vector nuisconfig::GetVF(XMLNodePointer_t node,
+// std::string name,
+// const char* del) {
+// std::string tempattr = Get(node, name);
+// return GeneralUtils::ParseToDouble(tempattr, del);
+// }
+
+std::vector nuisconfig::GetVD(XMLNodePointer_t node,
+ std::string const &name,
+ char const *del) {
+ std::string tempattr = Get(node, name);
+ return GeneralUtils::ParseToDbl(tempattr, del);
+}
+
+std::vector nuisconfig::GetAllKeysForNode(XMLNodePointer_t node) {
+ bool matching = true;
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ std::vector keys;
+ while (attr != 0) {
+ if (!std::string(fXML->GetAttrName(attr)).empty()) {
+ keys.push_back(std::string(fXML->GetAttrName(attr)));
+ }
+ attr = fXML->GetNextAttr(attr);
+ }
+
+ return keys;
+}
+
+XMLNodePointer_t nuisconfig::GetConfigNode(std::string const &name) {
+ // Loop over children and look for name
+ XMLNodePointer_t child = fXML->GetChild(fMainNode);
+ while (child != 0) {
+ // Select only config parameters
+ if (!std::string(fXML->GetNodeName(child)).compare("config")) {
+ // Loop over config attributes and search for name
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(child);
+ while (attr != 0) {
+ // Save name value
+ if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
+ return child;
+ }
+
+ // Get Next Attribute
+ attr = fXML->GetNextAttr(attr);
+ }
+ }
+
+ // Next Child
+ child = fXML->GetNext(child);
+ }
+
+ return 0;
+}
+
+void nuisconfig::SetConfig(std::string const &name, std::string const &val) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) node = CreateNode("config");
+ Set(node, name, val);
+}
+void nuisconfig::SetConfig(std::string const &name, char const *val) {
+ SetConfig(name, std::string(val));
+}
+
+void nuisconfig::SetConfig(std::string const &name, bool val) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) node = CreateNode("config");
+ Set(node, name, val);
+}
+
+void nuisconfig::SetConfig(std::string const &name, int val) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) node = CreateNode("config");
+ Set(node, name, val);
+}
+
+void nuisconfig::SetConfig(std::string const &name, float val) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) node = CreateNode("config");
+ Set(node, name, val);
+}
+
+void nuisconfig::SetConfig(std::string const &name, double val) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) node = CreateNode("config");
+ Set(node, name, val);
+}
+
+void nuisconfig::OverrideConfig(std::string const &conf) {
+ std::vector opts = GeneralUtils::ParseToStr(conf, "=");
+ SetConfig(opts[0], opts[1]);
+}
+
+std::string nuisconfig::GetConfig(std::string const &name) {
+ XMLNodePointer_t node = GetConfigNode(name);
+ if (!node) return "";
+
+ XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
+ std::string temp = "";
+
+ // Loop config attributes
+ while (attr != 0) {
+ // Find match
+ if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
+ temp = fXML->GetAttrValue(attr);
+ }
+
+ // Get Next Attribute
+ attr = fXML->GetNextAttr(attr);
+ }
+ return temp;
+}
+
+bool nuisconfig::HasConfig(std::string const &name) {
+ return bool(GetConfigNode(name));
+}
+
+std::string nuisconfig::GetConfigS(std::string const &name) {
+ return GetConfig(name);
+}
+
+bool nuisconfig::GetConfigB(std::string const &name) {
+ std::string pars = GetConfig(name);
+ return GeneralUtils::StrToBool(pars);
+}
+
+int nuisconfig::GetConfigI(std::string const &name) {
+ std::string pars = GetConfig(name);
+ return GeneralUtils::StrToInt(pars);
+}
+
+float nuisconfig::GetConfigF(std::string const &name) {
+ std::string pars = GetConfig(name);
+ return GeneralUtils::StrToDbl(pars);
+}
+
+double nuisconfig::GetConfigD(std::string const &name) {
+ std::string pars = GetConfig(name);
+ return GeneralUtils::StrToDbl(pars);
+}
+
+std::string nuisconfig::GetParDIR(std::string const &parName) {
+ std::string outstr = this->GetParS(parName);
+
+ // Make replacements in the string
+ const int nfiletypes = 2;
+ const std::string filetypes[nfiletypes] = {"@data", "@nuisance"};
+ std::string filerepl[nfiletypes] = {FitPar::GetDataBase(),
+ FitPar::GetDataBase() + "/../"};
+
+ for (int i = 0; i < nfiletypes; i++) {
+ std::string findstring = filetypes[i];
+ std::string replstring = filerepl[i];
+ if (outstr.find(findstring) != std::string::npos) {
+ outstr.replace(outstr.find(findstring), findstring.size(), filerepl[i]);
+ break;
+ }
+ }
+
+ return outstr;
+};
diff --git a/src/Config/NuisConfig.h b/src/Config/NuisConfig.h
new file mode 100644
index 0000000..d95795e
--- /dev/null
+++ b/src/Config/NuisConfig.h
@@ -0,0 +1,193 @@
+// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+
+/*******************************************************************************
+* This file is part of NUISANCE.
+*
+* NUISANCE is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* NUISANCE is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with NUISANCE. If not, see .
+*******************************************************************************/
+#ifndef NUISCONFIG_H_SEEN
+#define NUISCONFIG_H_SEEN
+
+#include
+#include