Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature flexible binning #89

Merged
merged 48 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2e6b307
Flexible sample binning, get variable from a string and get x_var and…
EdAtkin Apr 22, 2024
e16e742
removing pot in constructor argument, this can be just be grabbed fro…
EdAtkin Apr 22, 2024
28776e0
removing binning opt. We now pass the number of dimensions expected b…
EdAtkin Apr 24, 2024
11e2d39
changes to AddSample call to pass the strings for the spline axes. Al…
EdAtkin Apr 24, 2024
c212768
Tidying up and adding in some logger information
EdAtkin Apr 25, 2024
0763cf1
tiny changes to sort out merge conflicts with develop
EdAtkin Apr 25, 2024
c4e98f5
fixing a problem with spdlog not likeing converting TString into a ba…
EdAtkin Apr 25, 2024
5374620
fixing a redefinition of the constructor
EdAtkin Apr 25, 2024
9e7177d
minor fix to spline interpolation, now assign default TSpline3 for FD…
EdAtkin Apr 26, 2024
984b132
adding in a dummy y value to fill y_var with in the case that you are…
EdAtkin May 1, 2024
4e26c34
adding a simple map to go from spline index to the global systematic …
EdAtkin May 23, 2024
d789ac3
Tidying up spline FD base a little bit and sorting out the spline vs …
EdAtkin May 23, 2024
66c73b5
change default C++ version to 17
EdAtkin May 23, 2024
7899b53
whoops, added some extra brackets
EdAtkin May 23, 2024
7ea2f8a
adding in counter for different sytematics types to make maps so the …
EdAtkin May 29, 2024
5a34f79
fixing a bug in the spline evaluation. Previously could accidentally …
EdAtkin May 29, 2024
961d209
this might be risky but I think the check that bin is within the rang…
EdAtkin May 29, 2024
ca7bb7c
changing so that the GetName function is consistent across ND and FD …
EdAtkin May 31, 2024
72aa729
changing so that covarianceOsc is now a member of samplePDFFDBase, th…
EdAtkin Jun 3, 2024
e25a37e
getting rid of not on Minuit2 flag, it is ENABLED not DISABLED. This …
EdAtkin Jun 28, 2024
be90b32
some simple debug messages for setting parameter values
EdAtkin Aug 20, 2024
a61c37c
Add a GetError function and also remove calcReweight as we can just u…
EdAtkin Aug 20, 2024
65e9a94
minor changes to status printouts and some spline sanity checking
EdAtkin Aug 20, 2024
15d417a
Adding another function to return the relative spline index and also …
EdAtkin Aug 20, 2024
0e3e697
minor changes, using getTEstLLH(data,mc) as defulat poisson likelihoo…
EdAtkin Aug 21, 2024
a0dd30d
changing name of SplineParIndex to be clear that this is a global ind…
EdAtkin Aug 21, 2024
5cb7e0e
tidying some small couts to use logger
EdAtkin Aug 22, 2024
e3731a8
teeny tiny tidy up
EdAtkin Aug 22, 2024
e1b197f
minor tidy ups, mainly removing ifs on null osc objects for calling r…
EdAtkin Aug 22, 2024
22ef7a0
another place where we no longer need to check on the osc being null
EdAtkin Aug 22, 2024
47bfc5c
fixing merge conflicts
EdAtkin Aug 22, 2024
64cbb46
minor changes to get things to compile properly, mainly removing dupl…
EdAtkin Aug 22, 2024
578a6c6
accidentally added samplePDFInterface.h back in
EdAtkin Aug 22, 2024
bbe8200
changing throw; to throw MaCh3Exception(__FILE__, __LINE)
EdAtkin Aug 27, 2024
9fe02ee
removing stretch, I accidentally added it back in
EdAtkin Aug 27, 2024
3d65023
changing c++ version to be 14 as the minimum as some ROOT 6 versions …
EdAtkin Aug 27, 2024
6c62fb7
removing initialistion in header for nDimesions and fixing typo
EdAtkin Aug 27, 2024
33df6c0
inline was causing problems so just removed it
EdAtkin Aug 28, 2024
d01e295
Stop killing all jobs if one get's killed
KSkwarczynski Aug 28, 2024
1e4ee49
Also update CD workflow
KSkwarczynski Aug 28, 2024
f4d0496
in the merge I messed up removing this function, separate function to…
EdAtkin Aug 28, 2024
7b2daa2
Merge branch 'feature_FlexibleBinning' of github.com:mach3-software/M…
EdAtkin Aug 28, 2024
d51d553
fix c++14 compatibility and new methrod to dump matrix for backward c…
KSkwarczynski Aug 30, 2024
97113b4
another try with c++14
KSkwarczynski Aug 30, 2024
75ad0d5
making loading in spline parameters optional, you still need a covari…
EdAtkin Aug 30, 2024
30e9f87
Merge branch 'feature_FlexibleBinning' of github.com:mach3-software/M…
EdAtkin Aug 30, 2024
438e945
minor tweaks
KSkwarczynski Aug 30, 2024
9e0485f
Merge branch 'feature_FlexibleBinning' of https://github.com/mach3-so…
KSkwarczynski Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CDImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails
matrix:
include:
- os: Ubuntu22.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/CIBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails
matrix:
include:
- os: Ubuntu22.04
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/MaCh3Dependencies.cmake)

############################ C++ Compiler ####################################
if (NOT DEFINED CMAKE_CXX_STANDARD OR "${CMAKE_CXX_STANDARD} " STREQUAL " ")
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD 14)
endif()

# KS: If C++ standard is lower than C++ standard used for ROOT compilation things will go terribly wrong
Expand Down
14 changes: 7 additions & 7 deletions OscClass/OscClass_CUDAProb3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,11 @@ void Oscillator::Reset(int NeutrinoSignIndex, int InitialNeutrinoIndex, int Fina

}

bool Oscillator::isAlreadyCalculated(double* oscpar, double prodH, double Yp_Val) {
bool Oscillator::isAlreadyCalculated(const double** oscpar, double prodH, double Yp_Val) {

bool fAlreadyCalculated = true;
for (int i=0;i<nOscpars;i++) {
if (oscpar[i]!=foscpar[i]) {
if (*oscpar[i]!=foscpar[i]) {
fAlreadyCalculated = false;
}
}
Expand All @@ -940,9 +940,9 @@ bool Oscillator::isAlreadyCalculated(double* oscpar, double prodH, double Yp_Val
return fAlreadyCalculated;
}

void Oscillator::SaveParams(double* oscpar, double prodH, double Yp_Val) {
void Oscillator::SaveParams(const double** oscpar, double prodH, double Yp_Val) {
for (int i=0;i<nOscpars;i++) {
foscpar[i] = oscpar[i];
foscpar[i] = *oscpar[i];
}
fprodH = prodH;
fYp_Val = Yp_Val;
Expand All @@ -952,7 +952,7 @@ void Oscillator::SaveParams(double* oscpar, double prodH, double Yp_Val) {
fBinning[3] = nFineEnergy;
}

void Oscillator::FillOscillogram(double* oscpar, double prodH, double Yp_Val) {
void Oscillator::FillOscillogram(const double** oscpar, double prodH, double Yp_Val) {
if (isAlreadyCalculated(oscpar,prodH,Yp_Val)) {
return;
}
Expand All @@ -961,8 +961,8 @@ void Oscillator::FillOscillogram(double* oscpar, double prodH, double Yp_Val) {

//DB oscpar, as given from MaCh3, expresses the mixing angles in sin^2(theta). The propagator expects them in theta
for (int iOscPar=0;iOscPar<3;iOscPar++) {
if (oscpar[iOscPar] < 0) {
std::cerr << "Invalid oscillation parameter (Can not sqrt this value)!:" << oscpar[iOscPar] << std::endl;
if (*oscpar[iOscPar] < 0) {
std::cerr << "Invalid oscillation parameter (Can not sqrt this value)!:" << *oscpar[iOscPar] << std::endl;
throw;
}
}
Expand Down
6 changes: 3 additions & 3 deletions OscClass/OscClass_CUDAProb3.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Oscillator {

int GetOscillogramNBins(int Switcher);

void FillOscillogram(double* oscpar, double prodH, double Yp_Val=0.468);
void FillOscillogram(const double** oscpar, double prodH, double Yp_Val=0.468);
double ReturnProb(double NeutrinoEnergy, double Cosz, int InitialFlavour, int FinalFlavour);

void RebinOscillogram(int Switcher, std::vector<double> NewBinning);
Expand Down Expand Up @@ -103,8 +103,8 @@ class Oscillator {
void FillSecondaryHistograms(int NeutrinoSignIndex, int InitialNeutrinoIndex, int FinalNeutrinoIndex);
void FillPrimaryHistograms(int NeutrinoSignIndex, int InitialNeutrinoIndex, int FinalNeutrinoIndex);

bool isAlreadyCalculated(double* oscpar, double prodH, double Yp_Val);
void SaveParams(double* oscpar, double prodH, double Yp_Val);
bool isAlreadyCalculated(const double** oscpar, double prodH, double Yp_Val);
void SaveParams(const double** oscpar, double prodH, double Yp_Val);
void ResetSavedParams();

void PrintBox(Box Box1);
Expand Down
20 changes: 13 additions & 7 deletions covariance/covarianceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,17 +681,15 @@ void covarianceBase::setSingleParameter(const int parNo, const double parVal) {
// *************************************
_fPropVal[parNo] = parVal;
_fCurrVal[parNo] = parVal;
MACH3LOG_DEBUG("Setting {}(parameter {}) to {}", GetParName(parNo), parNo, parVal);

MACH3LOG_DEBUG("Setting {} (parameter {}) to {})" GetParName(parNo), parNo, parVal);
if (pca) TransferToPCA();
}
// ********************************************
void covarianceBase::setParCurrProp(const int parNo, const double parVal) {
// ********************************************
_fPropVal[parNo] = parVal;
_fCurrVal[parNo] = parVal;
MACH3LOG_DEBUG("Setting {}(parameter {}) to {}", GetParName(parNo), parNo, parVal);

MACH3LOG_DEBUG("Setting {} (parameter {}) to {})" GetParName(parNo), parNo, parVal);
if (pca) TransferToPCA();
}

Expand Down Expand Up @@ -997,16 +995,22 @@ void covarianceBase::setParameters(const std::vector<double>& pars) {

unsigned int parsSize = pars.size();
for (unsigned int i = 0; i < parsSize; i++) {
//Make sure that you are actually passing a number to set the parameter to
if(std::isnan(pars[i])) {
std::cerr << "Error: trying to set parameter value to a nan for parameter " << GetParName(i) << " in matrix " << matrixName << ". This will not go well!" << std::endl;
//Make sure that you are actually passing a number to set the parameter to
if(isnan(pars[i])) {
MACH3LOG_ERROR("Error: trying to set parameter value to a nan for parameter {} in matrix {}. This will not go well!", GetParName(i), matrixName);
throw;
} else {
_fPropVal[i] = pars[i];
}
}
}

MACH3LOG_DEBUG("Set parameters to:");
std::cout << "Set parameters to: " << std::endl;
for(int par_i = 0 ; par_i < pars.size() ; ++par_i){
MACH3LOG_DEBUG("{} : {}", par_i, _fPropVal[par_i]);
}

// And if pca make the transfer
if (pca) {
TransferToPCA();
Expand All @@ -1029,6 +1033,7 @@ void covarianceBase::SetBranches(TTree &tree, bool SaveProposal) {
tree.Branch(Form("%s_PCA", _fNames[i].c_str()), (double*)&(fParCurr_PCA.GetMatrixArray()[i]), Form("%s_PCA/D", _fNames[i].c_str()));
}
}

if(SaveProposal)
{
// loop over parameters and set a branch
Expand All @@ -1043,6 +1048,7 @@ void covarianceBase::SetBranches(TTree &tree, bool SaveProposal) {
}
}
}

// ********************************************
void covarianceBase::setStepScale(const double scale) {
// ********************************************
Expand Down
16 changes: 3 additions & 13 deletions covariance/covarianceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ class covarianceBase {
/// @brief Get diagonal error for ith parameter
/// @param i Parameter index
inline double getDiagonalError(const int i) { return std::sqrt((*covMatrix)(i,i)); }
/// @brief Get the error for the ith parameter
/// @param i Parameter index
inline double GetError(const int i) {return _fError[i];}

/// @brief Adaptive Step Tuning Stuff
void resetIndivStepScale();
Expand Down Expand Up @@ -175,19 +178,6 @@ class covarianceBase {
/// @brief KS: Convert covariance matrix to correlation matrix and return TH2D which can be used for fancy plotting
TH2D* GetCorrelationMatrix();

/// @brief What parameter Gets reweighted by what amount according to MCMC
/// @param bin simply parameter index
inline double calcReWeight(const int bin) {
if (bin >= 0 && bin < _fNumPar) {
return _fPropVal[bin];
} else {
MACH3LOG_WARN("Specified bin is <= 0 OR bin > npar!");
MACH3LOG_WARN("bin = {}, npar = {}", bin, _fNumPar);
MACH3LOG_WARN("This won't ruin much that this step in the MCMC, but does indicate something wrong in memory!");
return 1.0;
}
return 1.0;
}
//========
//ETA - This might be a bit squiffy? If the vector gots moved from say a
//push_back then the pointer is no longer valid... maybe need a better
Expand Down
Loading
Loading