diff --git a/cmake/c++CompilerSetup.cmake b/cmake/c++CompilerSetup.cmake
index 89a51eb..266b708 100644
--- a/cmake/c++CompilerSetup.cmake
+++ b/cmake/c++CompilerSetup.cmake
@@ -1,108 +1,109 @@
# 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 .
################################################################################
if(USE_OMP)
LIST(APPEND EXTRA_CXX_FLAGS -fopenmp)
endif()
if(USE_DYNSAMPLES)
LIST(APPEND EXTRA_LIBS dl)
LIST(APPEND EXTRA_CXX_FLAGS -D__USE_DYNSAMPLES__)
endif()
set(CXX_WARNINGS -Wall )
cmessage(DEBUG "EXTRA_CXX_FLAGS: ${EXTRA_CXX_FLAGS}")
string(REPLACE ";" " " STR_EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STR_EXTRA_CXX_FLAGS} ${CXX_WARNINGS}")
-
+ set(CMAKE_Fortran_FLAGS_RELEASE "-fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
if(USE_DYNSAMPLES)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC")
+ set(CMAKE_Fortran_FLAGS_DEBUG "-fPIC")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CURRENT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
elseif(CMAKE_BUILD_TYPE MATCHES RELEASE)
set(CURRENT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
else()
cmessage(FATAL_ERROR "[ERROR]: Unknown CMAKE_BUILD_TYPE (\"${CMAKE_BUILD_TYPE}\"): Should be \"DEBUG\" or \"RELEASE\".")
endif()
SET(STR_EXTRA_LINK_DIRS)
if(NOT EXTRA_LINK_DIRS STREQUAL "")
string(REPLACE ";" " -L" STR_EXTRA_LINK_DIRS "-L${EXTRA_LINK_DIRS}")
endif()
SET(STR_EXTRA_LIBS)
if(NOT EXTRA_LIBS STREQUAL "")
string(REPLACE ";" " -l" STR_EXTRA_LIBS "-l${EXTRA_LIBS}")
endif()
SET(STR_EXTRA_SHAREDOBJS)
if(NOT EXTRA_SHAREDOBJS STREQUAL "")
string(REPLACE ";" " " STR_EXTRA_SHAREDOBJS "${EXTRA_SHAREDOBJS}")
endif()
SET(STR_EXTRA_LINK_FLAGS)
if(NOT EXTRA_LINK_FLAGS STREQUAL "")
string(REPLACE ";" " " STR_EXTRA_LINK_FLAGS "${EXTRA_LINK_FLAGS}")
endif()
cmessage(DEBUG "EXTRA_LINK_DIRS: ${STR_EXTRA_LINK_DIRS}")
cmessage(DEBUG "EXTRA_LIBS: ${STR_EXTRA_LIBS}")
cmessage(DEBUG "EXTRA_SHAREDOBJS: ${STR_EXTRA_SHAREDOBJS}")
cmessage(DEBUG "EXTRA_LINK_FLAGS: ${STR_EXTRA_LINK_FLAGS}")
if(NOT STR_EXTRA_LINK_DIRS STREQUAL "" AND NOT STR_EXTRA_LIBS STREQUAL "")
SET(CMAKE_DEPENDLIB_FLAGS "${STR_EXTRA_LINK_DIRS} ${STR_EXTRA_LIBS}")
endif()
if(NOT EXTRA_SHAREDOBJS STREQUAL "")
if(NOT STR_EXTRA_LINK_FLAGS STREQUAL "")
SET(STR_EXTRA_LINK_FLAGS "${STR_EXTRA_SHAREDOBJS} ${STR_EXTRA_LINK_FLAGS}")
else()
SET(STR_EXTRA_LINK_FLAGS "${STR_EXTRA_SHAREDOBJS}")
endif()
endif()
if(NOT EXTRA_LINK_FLAGS STREQUAL "")
if(NOT CMAKE_LINK_FLAGS STREQUAL "")
SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} ${STR_EXTRA_LINK_FLAGS}")
else()
SET(CMAKE_LINK_FLAGS "${STR_EXTRA_LINK_FLAGS}")
endif()
endif()
if(USE_OMP)
cmessage(FATAL_ERROR "No OMP features currently enabled so this is a FATAL_ERROR to let you know that you don't gain anything with this declaration.")
endif()
if (VERBOSE)
cmessage (STATUS "C++ Compiler : ${CXX_COMPILER_NAME}")
cmessage (STATUS " flags : ${CMAKE_CXX_FLAGS}")
cmessage (STATUS " Release flags : ${CMAKE_CXX_FLAGS_RELEASE}")
cmessage (STATUS " Debug flags : ${CMAKE_CXX_FLAGS_DEBUG}")
cmessage (STATUS " Link Flags : ${CMAKE_LINK_FLAGS}")
cmessage (STATUS " Lib Flags : ${CMAKE_DEPENDLIB_FLAGS}")
endif()
diff --git a/src/InputHandler/InputTypes.h b/src/InputHandler/InputTypes.h
index 89215cd..7a78145 100644
--- a/src/InputHandler/InputTypes.h
+++ b/src/InputHandler/InputTypes.h
@@ -1,164 +1,160 @@
// 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 INPUTTYPES_SEEN_H
#define INPUTTYPES_SEEN_H
/// Global Enum to define generator type being read with FitEvent
/// Have to define kNORM as if its a generator for the time being.
enum generator_event_type {
kUNKNOWN = 999,
kNEUT = 0,
kNIWG = 1,
kNUWRO = 2,
kT2K = 3,
kCUSTOM = 4,
kGENIE = 5,
kEVTSPLINE = 6,
kNUANCE = 7,
kGiBUU = 8,
kNORM = 9,
- kMODENORM = 10,
- kEMPTY = 11,
- kINPUTFITEVENT = 12,
- kNEWSPLINE = 13,
- kLIKEWEIGHT = 14,
- kSPLINEPARAMETER = 15,
- kHEPMC = 16,
- kHISTO = 17,
- kSIGMAQ0HIST = 18,
+ kEMPTY = 10,
+ kINPUTFITEVENT = 11,
+ kNEWSPLINE = 12,
+ kLIKEWEIGHT = 13,
+ kSPLINEPARAMETER = 14,
+ kHEPMC = 15,
+ kHISTO = 16,
+ kSIGMAQ0HIST = 17,
kLast_generator_event_type
};
namespace InputUtils {
enum InputType {
kNEUT_Input = 0,
kNUWRO_Input = 1,
kGENIE_Input = 2,
kGiBUU_Input,
kNUANCE_Input,
kEVSPLN_Input,
kEMPTY_Input,
kFEVENT_Input,
kJOINT_Input,
kSIGMAQ0HIST_Input,
kHISTO_Input,
kInvalid_Input,
kBNSPLN_Input, // Not sure if this are currently used.
};
}
inline std::ostream& operator<<(std::ostream& os,
generator_event_type const& gs) {
switch (gs) {
case kUNKNOWN: {
return os << "kUNKNOWN";
}
case kNEUT: {
return os << "kNEUT";
}
case kNIWG: {
return os << "kNIWG";
}
case kNUWRO: {
return os << "kNUWRO";
}
case kT2K: {
return os << "kT2K";
}
case kCUSTOM: {
return os << "kCUSTOM";
}
case kGENIE: {
return os << "kGENIE";
}
case kEVTSPLINE: {
return os << "kEVTSPLINE";
}
case kNUANCE: {
return os << "kNUANCE";
}
case kGiBUU: {
return os << "kGiBUU";
}
case kNORM: {
return os << "kNORM";
}
- case kMODENORM: {
- return os << "kMODENORM";
- }
case kHEPMC: {
return os << "kHEPMC";
}
case kSIGMAQ0HIST: {
return os << "kSIGMAQ0HIST";
}
case kHISTO: {
return os << "kHISTO";
}
default: { return os << "kUNKNOWN"; }
}
}
inline std::ostream &operator<<(std::ostream &os, InputUtils::InputType it) {
switch (it) {
case InputUtils::kNEUT_Input: {
return os << "kNEUT_Input";
}
case InputUtils::kNUWRO_Input: {
return os << "kNUWRO_Input";
}
case InputUtils::kGENIE_Input: {
return os << "kGENIE_Input";
}
case InputUtils::kGiBUU_Input: {
return os << "kGiBUU_Input";
}
case InputUtils::kNUANCE_Input: {
return os << "kNUANCE_Input";
}
case InputUtils::kEVSPLN_Input: {
return os << "kEVSPLN_Input";
}
case InputUtils::kEMPTY_Input: {
return os << "kEMPTY_Input";
}
case InputUtils::kFEVENT_Input: {
return os << "kFEVENT_Input";
}
case InputUtils::kJOINT_Input: {
return os << "kJOINT_Input";
}
case InputUtils::kSIGMAQ0HIST_Input: {
return os << "kSIGMAQ0HIST_Input";
}
case InputUtils::kHISTO_Input: {
return os << "kHISTO_Input";
}
case InputUtils::kInvalid_Input:
case InputUtils::kBNSPLN_Input:
default: { return os << "kInvalid_Input"; }
}
}
#endif
diff --git a/src/Reweight/FitWeight.cxx b/src/Reweight/FitWeight.cxx
index 84fab8e..56939c4 100644
--- a/src/Reweight/FitWeight.cxx
+++ b/src/Reweight/FitWeight.cxx
@@ -1,303 +1,273 @@
#include "FitWeight.h"
+#include "GENIEWeightEngine.h"
+#include "LikelihoodWeightEngine.h"
+#include "ModeNormEngine.h"
+#include "NEUTWeightEngine.h"
+#include "NIWGWeightEngine.h"
+#include "NUISANCEWeightEngine.h"
+#include "NuWroWeightEngine.h"
#include "OscWeightEngine.h"
+#include "SampleNormEngine.h"
+#include "SplineWeightEngine.h"
+#include "T2KWeightEngine.h"
void FitWeight::AddRWEngine(int type) {
switch (type) {
case kNEUT:
fAllRW[type] = new NEUTWeightEngine("neutrw");
break;
case kNUWRO:
fAllRW[type] = new NuWroWeightEngine("nuwrorw");
break;
case kGENIE:
fAllRW[type] = new GENIEWeightEngine("genierw");
break;
case kNORM:
fAllRW[type] = new SampleNormEngine("normrw");
break;
case kLIKEWEIGHT:
fAllRW[type] = new LikelihoodWeightEngine("likerw");
break;
case kT2K:
fAllRW[type] = new T2KWeightEngine("t2krw");
break;
case kCUSTOM:
fAllRW[type] = new NUISANCEWeightEngine("nuisrw");
break;
case kSPLINEPARAMETER:
fAllRW[type] = new SplineWeightEngine("splinerw");
break;
case kNIWG:
fAllRW[type] = new NIWGWeightEngine("niwgrw");
break;
case kOSCILLATION:
fAllRW[type] = new OscWeightEngine();
break;
+ case kMODENORM:
+ fAllRW[type] = new ModeNormEngine();
default:
THROW("CANNOT ADD RW Engine for unknown dial type: " << type);
break;
}
}
WeightEngineBase* FitWeight::GetRWEngine(int type) {
- switch (type) {
- case kNEUT:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kNUWRO:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kGENIE:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kNORM:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kLIKEWEIGHT:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kT2K:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kCUSTOM:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kSPLINEPARAMETER:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kNIWG:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- case kOSCILLATION:
- if (fAllRW.count(type)) {
- return fAllRW[type];
- }
- default: { THROW("CANNOT get RW Engine for dial type: " << type); }
+ if (HasRWEngine(type)) {
+ return fAllRW[type];
}
+ THROW("CANNOT get RW Engine for dial type: " << type);
}
-bool FitWeight::HasRWEngine(int type){
-switch (type) {
+bool FitWeight::HasRWEngine(int type) {
+ switch (type) {
case kNEUT:
case kNUWRO:
case kGENIE:
case kNORM:
case kLIKEWEIGHT:
case kT2K:
case kCUSTOM:
case kSPLINEPARAMETER:
case kNIWG:
- case kOSCILLATION:{
+ case kOSCILLATION: {
return fAllRW.count(type);
}
default: { THROW("CANNOT get RW Engine for dial type: " << type); }
}
}
void FitWeight::IncludeDial(std::string name, std::string type, double val) {
// Should register the dial here.
int typeenum = Reweight::ConvDialType(type);
IncludeDial(name, typeenum, val);
}
void FitWeight::IncludeDial(std::string name, int dialtype, double val) {
// Get the dial enum
int nuisenum = Reweight::ConvDial(name, dialtype);
if (nuisenum == -1) {
THROW("NUISENUM == " << nuisenum << " for " << name);
}
// Setup RW Engine Pointer
if (fAllRW.find(dialtype) == fAllRW.end()) {
AddRWEngine(dialtype);
}
WeightEngineBase* rw = fAllRW[dialtype];
// Include the dial
rw->IncludeDial(name, val);
// Set Dial Value
if (val != -9999.9) {
rw->SetDialValue(name, val);
}
// Sort Maps
fAllEnums[name] = nuisenum;
fAllValues[nuisenum] = val;
// Sort Lists
fNameList.push_back(name);
fEnumList.push_back(nuisenum);
fValueList.push_back(val);
}
void FitWeight::Reconfigure(bool silent) {
// Reconfigure all added RW engines
for (std::map::iterator iter = fAllRW.begin();
iter != fAllRW.end(); iter++) {
(*iter).second->Reconfigure(silent);
}
}
void FitWeight::SetDialValue(std::string name, double val) {
// Add extra check, if name not found look for one with name in it.
int nuisenum = fAllEnums[name];
SetDialValue(nuisenum, val);
}
// Allow for name aswell using GlobalList to determine sample name.
void FitWeight::SetDialValue(int nuisenum, double val) {
// Conv dial type
- int dialtype = int(nuisenum - (nuisenum % 1000)) / 1000;
+ int dialtype = Reweight::GetDialType(nuisenum);
if (fAllRW.find(dialtype) == fAllRW.end()) {
THROW("Cannot find RW Engine for dialtype = "
- << dialtype << " " << nuisenum << " "
- << (nuisenum - (nuisenum % 1000)) / 1000);
+ << dialtype << ", " << Reweight::RemoveDialType(nuisenum));
}
// Get RW Engine for this dial
fAllRW[dialtype]->SetDialValue(nuisenum, val);
fAllValues[nuisenum] = val;
// Update ValueList
for (size_t i = 0; i < fEnumList.size(); i++) {
if (fEnumList[i] == nuisenum) {
fValueList[i] = val;
}
}
}
void FitWeight::SetAllDials(const double* x, int n) {
for (size_t i = 0; i < (UInt_t)n; i++) {
int rwenum = fEnumList[i];
SetDialValue(rwenum, x[i]);
}
Reconfigure();
}
double FitWeight::GetDialValue(std::string name) {
// Add extra check, if name not found look for one with name in it.
int nuisenum = fAllEnums[name];
return GetDialValue(nuisenum);
}
double FitWeight::GetDialValue(int nuisenum) { return fAllValues[nuisenum]; }
int FitWeight::GetDialPos(std::string name) {
int rwenum = fAllEnums[name];
return GetDialPos(rwenum);
}
int FitWeight::GetDialPos(int nuisenum) {
for (size_t i = 0; i < fEnumList.size(); i++) {
if (fEnumList[i] == nuisenum) {
return i;
}
}
ERR(FTL) << "No Dial Found! " << std::endl;
throw;
return -1;
}
bool FitWeight::DialIncluded(std::string name) {
return (fAllEnums.find(name) != fAllEnums.end());
}
bool FitWeight::DialIncluded(int rwenum) {
return (fAllValues.find(rwenum) != fAllValues.end());
}
double FitWeight::CalcWeight(BaseFitEvt* evt) {
double rwweight = 1.0;
for (std::map::iterator iter = fAllRW.begin();
iter != fAllRW.end(); iter++) {
double w = (*iter).second->CalcWeight(evt);
- // LOG(FIT) << "Iter " << (*iter).second->fCalcName << " = " << w <<
- // std::endl;
rwweight *= w;
}
return rwweight;
}
void FitWeight::UpdateWeightEngine(const double* x) {
size_t count = 0;
for (std::vector::iterator iter = fEnumList.begin();
iter != fEnumList.end(); iter++) {
SetDialValue((*iter), x[count]);
count++;
}
}
void FitWeight::GetAllDials(double* x, int n) {
for (int i = 0; i < n; i++) {
x[i] = GetDialValue(fEnumList[i]);
}
}
-bool FitWeight::NeedsEventReWeight(const double* x) {
- bool haschange = false;
- size_t count = 0;
-
- // Compare old to new and decide if RW needed.
- for (std::vector::iterator iter = fEnumList.begin();
- iter != fEnumList.end(); iter++) {
- int nuisenum = (*iter);
- int type = (nuisenum / 1000) - (nuisenum % 1000);
-
- // Compare old to new
- double oldval = GetDialValue(nuisenum);
- double newval = x[count];
- if (oldval != newval) {
- if (fAllRW[type]->NeedsEventReWeight()) {
- haschange = true;
- }
- }
-
- count++;
- }
-
- return haschange;
-}
+// bool FitWeight::NeedsEventReWeight(const double* x) {
+// bool haschange = false;
+// size_t count = 0;
+
+// // Compare old to new and decide if RW needed.
+// for (std::vector::iterator iter = fEnumList.begin();
+// iter != fEnumList.end(); iter++) {
+// int nuisenum = (*iter);
+// int type = (nuisenum / 1000) - (nuisenum % 1000);
+
+// // Compare old to new
+// double oldval = GetDialValue(nuisenum);
+// double newval = x[count];
+// if (oldval != newval) {
+// if (fAllRW[type]->NeedsEventReWeight()) {
+// haschange = true;
+// }
+// }
+
+// count++;
+// }
+
+// return haschange;
+// }
double FitWeight::GetSampleNorm(std::string name) {
if (name.empty()) return 1.0;
// Find norm dial
if (fAllEnums.find(name + "_norm") != fAllEnums.end()) {
if (fAllValues.find(fAllEnums[name + "_norm"]) != fAllValues.end()) {
return fAllValues[fAllEnums[name + "_norm"]];
} else {
return 1.0;
}
} else {
return 1.0;
}
}
void FitWeight::Print() {
LOG(REC) << "Fit Weight State: " << std::endl;
for (size_t i = 0; i < fNameList.size(); i++) {
LOG(REC) << " -> Par " << i << ". " << fNameList[i] << " " << fValueList[i]
<< std::endl;
}
}
diff --git a/src/Reweight/FitWeight.h b/src/Reweight/FitWeight.h
index 8393e16..0829ce8 100644
--- a/src/Reweight/FitWeight.h
+++ b/src/Reweight/FitWeight.h
@@ -1,74 +1,65 @@
#ifndef FITWEIGHT2_H
#define FITWEIGHT2_H
#include "WeightUtils.h"
#include "WeightEngineBase.h"
-#include "NEUTWeightEngine.h"
-#include "GENIEWeightEngine.h"
-#include "NuWroWeightEngine.h"
-#include "SampleNormEngine.h"
-#include "LikelihoodWeightEngine.h"
-#include "SplineWeightEngine.h"
-#include "NUISANCEWeightEngine.h"
-#include "T2KWeightEngine.h"
-#include "NIWGWeightEngine.h"
#include