Skip to content

Commit

Permalink
Merge pull request #98 from mach3-software/feature_NoThrowParms
Browse files Browse the repository at this point in the history
Remove ThrowParms
  • Loading branch information
KSkwarczynski authored Sep 5, 2024
2 parents 83543bb + 06e1b8c commit 3ad5848
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 247 deletions.
2 changes: 1 addition & 1 deletion Diagnostics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Plotting and Diagnostic
### Diagnostic
**ProcessMCMC** - The main app you want to use for analysing the ND280 chain. It prints posterior distribution after burn-in the cut. Moreover, you can compare two/three different chains. There are a few options you can modify easily inside the app like selection, burn-in cut, and whether to plot xse+flux or only flux. Other functionality
<ol>
<li> Produce a covariance matrix with multithreading (which requires lots of RAM due to caching) </li>
Expand Down
1 change: 0 additions & 1 deletion covariance/AdaptiveMCMCHandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

// MaCh3 Includes
#include "manager/MaCh3Logger.h"
#include "manager/manager.h"
#include "covariance/CovarianceUtils.h"

Expand Down
2 changes: 0 additions & 2 deletions covariance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(HEADERS
ThrowParms.h
CovarianceUtils.h
covarianceBase.h
covarianceOsc.h
Expand All @@ -9,7 +8,6 @@ set(HEADERS
)

add_library(Covariance SHARED
ThrowParms.cpp
covarianceBase.cpp
covarianceOsc.cpp
covarianceXsec.cpp
Expand Down
1 change: 0 additions & 1 deletion covariance/PCAHandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

// MaCh3 Includes
#include "manager/MaCh3Logger.h"
#include "manager/manager.h"
#include "covariance/CovarianceUtils.h"

Expand Down
104 changes: 0 additions & 104 deletions covariance/ThrowParms.cpp

This file was deleted.

38 changes: 0 additions & 38 deletions covariance/ThrowParms.h

This file was deleted.

59 changes: 3 additions & 56 deletions covariance/covarianceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,57 +531,6 @@ std::vector<double> covarianceBase::getProposed() const {
return props;
}

// Throw nominal values
void covarianceBase::throwNominal(bool nomValues, int seed) {
TVectorD* vec = new TVectorD(_fNumPar);
for (int i = 0; i < _fNumPar; i++) {
(*vec)(i) = 1.0;
}

ThrowParms* nom_throws = new ThrowParms(*vec, (*covMatrix));
nom_throws->SetSeed(seed);
std::vector<double> nominal = getNominalArray();
nominal.clear();
nominal.resize(_fNumPar);

// If we want to put the nominals somewhere else than user specified
// Don't fully understand this though: won't we have to reweight the MC somehow?
// nominal[i] is used in GetLikelihood() as the penalty term, so we're essentially setting a random parameter penalty term?
if (!nomValues)
{
bool throw_again = true;

while(throw_again == true)
{
throw_again = false;
MACH3LOG_INFO("Setting {} nominal values to random throws.", getName());
nom_throws->ThrowSet(nominal);

for (int i = 0; i < _fNumPar; i++)
{
// if parameter is fixed, dont throw
if (_fError[i] < 0) {
nominal[i] = 1.0;
continue;
}

if (nominal[i] < 0) {
nominal[i] = 0.0;
throw_again = true;
}
}
}
} else {
// If we want nominal values, set all entries to 1 (defined as nominal in MaCh3)
for (int i = 0; i < int(nominal.size()); i++) {
nominal[i] = 1.0;
}
}

delete nom_throws;
delete vec;
}

// *************************************
// Throw the parameters according to the covariance matrix
// This shouldn't be used in MCMC code ase it can break Detailed Balance;
Expand Down Expand Up @@ -995,16 +944,15 @@ 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(isnan(pars[i])) {
//Make sure that you are actually passing a number to set the parameter to
if(std::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];
}
}
}

// And if pca make the transfer
if (pca) {
TransferToPCA();
Expand Down Expand Up @@ -1199,8 +1147,7 @@ void covarianceBase::printIndivStepScale() {
std::cout << "============================================================" << std::endl;
}
// ********************************************
//Makes sure that matrix is positive-definite (so no error is thrown when
//throwNominal() is called) by adding a small number to on-diagonal elements
//Makes sure that matrix is positive-definite by adding a small number to on-diagonal elements
void covarianceBase::MakePosDef(TMatrixDSym *cov) {
// ********************************************
//DB Save original warning state and then increase it in this function to suppress 'matrix not positive definite' messages
Expand Down
2 changes: 0 additions & 2 deletions covariance/covarianceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
#include "manager/manager.h"
#include "samplePDF/Structs.h"
#include "covariance/CovarianceUtils.h"
#include "covariance/ThrowParms.h"
#include "covariance/AdaptiveMCMCHandler.h"
#include "covariance/PCAHandler.h"


#ifndef _LARGE_LOGL_
/// Large Likelihood is used it parameter go out of physical boundary, this indicates in MCMC that such step should eb removed
#define _LARGE_LOGL_ 1234567890.0
Expand Down
3 changes: 0 additions & 3 deletions covariance/covarianceXsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
// MaCh3 includes
#include "covariance/covarianceBase.h"
#include "samplePDF/Structs.h"
#include "manager/YamlHelper.h"

#include "yaml-cpp/yaml.h"

/// @brief Class responsible for handling of systematic error parameters with different types defined in the config. Like spline, normalisation parameters etc.
/// @see For more details, visit the [Wiki](https://github.com/mach3-software/MaCh3/wiki/02.-Implementation-of-Systematic).
Expand Down
12 changes: 0 additions & 12 deletions manager/manager.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#pragma once

// C++ includes
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>

// ROOT include
#include "TTree.h"
#include "TBranch.h"
#include "TMacro.h"

// MaCh3 Includes
#include "manager/MaCh3Logger.h"
#include "samplePDF/Structs.h"
Expand Down
6 changes: 3 additions & 3 deletions plotting/plottingUtils/plottingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TH1D TGraphToTH1D(TGraph graph, std::string newName, std::string newTitle) {
}

// get the bin edges
Double_t binEdges[nPoints + 1];
std::vector<double> binEdges(nPoints + 1);
binEdges[0] = pointsX[0] - (pointsX[1] - pointsX[0]) / 2.0;
binEdges[nPoints] = pointsX[nPoints - 1] + (pointsX[nPoints - 1] - pointsX[nPoints - 2]) / 2.0;

Expand All @@ -46,7 +46,7 @@ TH1D TGraphToTH1D(TGraph graph, std::string newName, std::string newTitle) {
binEdges[pointId] = (pointsX[pointId] + pointsX[pointId - 1]) / 2.0;
}

TH1D retHist = TH1D(name.c_str(), title.c_str(), nPoints, binEdges);
TH1D retHist = TH1D(name.c_str(), title.c_str(), nPoints, binEdges.data());

for (int binId = 0; binId < nPoints; binId++)
{
Expand Down Expand Up @@ -80,4 +80,4 @@ std::vector<std::vector<float>> TGraphToVector(TGraph graph) {
return ret;
}

} // namespace MaCh3Plotting
} // namespace MaCh3Plotting
2 changes: 1 addition & 1 deletion samplePDF/ShiftFunctors.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "samplePDFFDBase.h"
#include "samplePDF/Structs.h"

class BaseFuncPar{
public:
Expand Down
2 changes: 1 addition & 1 deletion samplePDF/Structs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Structs.h"
#include "samplePDF/Structs.h"

#include "TList.h"
#include "TObjArray.h"
Expand Down
6 changes: 0 additions & 6 deletions samplePDF/samplePDFBase.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#pragma once

//C++ includes
#include <iostream>
#include <vector>
#include <assert.h>
#include <stdexcept>

//ROOT includes
#include "TTree.h"
Expand All @@ -13,11 +10,8 @@
#include "TMath.h"
#include "TFile.h"
#include "TROOT.h"
#include "TRandom.h"
#include "TSpline.h"
#include "TRandom3.h"
#include "TString.h"
#include "TMath.h"

//MaCh3 includes
#include "samplePDF/Structs.h"
Expand Down
Loading

0 comments on commit 3ad5848

Please sign in to comment.