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

Matrix Plotter #187

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions .github/workflows/CIValidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
test_4: empty
test_5: empty
test_6: empty
test_7: empty

- name: Covariance Validations
test_1: ./CIValidations/CovarianceValidations
Expand All @@ -36,6 +37,7 @@ jobs:
test_4: empty
test_5: empty
test_6: empty
test_7: empty

- name: Fitter Validations
test_1: ./CIValidations/FitterValidations
Expand All @@ -44,10 +46,11 @@ jobs:
test_4: ./bin/RHat 10 MCMC_Test.root MCMC_Test.root MCMC_Test.root MCMC_Test.root
test_5: ./bin/CombineMaCh3Chains -o MergedChain.root MCMC_Test.root MCMC_Test.root MCMC_Test.root MCMC_Test.root
test_6: ./bin/GetPenaltyTerm MCMC_Test.root bin/TutorialDiagConfig.yaml
test_7: ./bin/MatrixPlotter bin/TutorialDiagConfig.yaml MCMC_Test_drawCorr.root
# TODO
#need fixing config
#test_7: bin/GetPostfitParamPlots -o MCMC_Test_Process.root -c Inputs/PlottingConfig.yaml
#test_8: bin/PlotLLH -o MCMC_Test.root -c Inputs/PlottingConfig.yaml
#test_8: bin/GetPostfitParamPlots -o MCMC_Test_drawCorr.root -c Inputs/PlottingConfig.yaml
#test_9: bin/PlotLLH -o MCMC_Test.root -c Inputs/PlottingConfig.yaml

- name: NuMCMC Tools Validations
test_1: ./CIValidations/NuMCMCvalidations.sh
Expand All @@ -56,6 +59,7 @@ jobs:
test_4: empty
test_5: empty
test_6: empty
test_7: empty

container:
image: ghcr.io/mach3-software/mach3:alma9latest
Expand Down Expand Up @@ -118,3 +122,9 @@ jobs:
echo "Performing test 6"
${{ matrix.test_6 }}
fi

if [[ "${{ matrix.test_7 }}" != "empty" ]]; then
echo " "
echo "Performing test 7"
${{ matrix.test_7 }}
fi
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ else()
target_compile_options(MaCh3CompilerOptions INTERFACE
-O3 # Optimize code for maximum speed
-finline-limit=100000000 # Increase the limit for inlining functions to improve performance
#-fstrict-aliasing # Assume that pointers of different types do not point to the same memory location
# KS: After benchmarking below didn't in fact worse performance, leave it for future tests and documentation
#-funroll-loops # Unroll loops where possible for performance
#--param=max-vartrack-size=100000000 # Set maximum size of variable tracking data to avoid excessive memory usage
Expand Down
14 changes: 7 additions & 7 deletions covariance/covarianceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void covarianceBase::init(std::string name, std::string file) {
}

// Should put in a
TMatrixDSym *CovMat = (TMatrixDSym*)(infile->Get(name.c_str()));
TMatrixDSym *CovMat = static_cast<TMatrixDSym*>(infile->Get(name.c_str()));
if (CovMat == nullptr) {
MACH3LOG_ERROR("Could not find covariance matrix name {} in file {}", name, file);
MACH3LOG_ERROR("Are you really sure {} exists in the file?", name);
Expand Down Expand Up @@ -348,7 +348,7 @@ void covarianceBase::setCovMatrix(TMatrixDSym *cov) {
throw MaCh3Exception(__FILE__ , __LINE__ );
}
covMatrix = cov;
invCovMatrix = (TMatrixDSym*)cov->Clone();
invCovMatrix = static_cast<TMatrixDSym*>(cov->Clone());
invCovMatrix->Invert();
//KS: ROOT has bad memory management, using standard double means we can decrease most operation by factor 2 simply due to cache hits
for (int i = 0; i < _fNumPar; i++)
Expand Down Expand Up @@ -899,7 +899,7 @@ void covarianceBase::SetBranches(TTree &tree, bool SaveProposal) {
// When running PCA, also save PCA parameters
if (pca) {
for (int i = 0; i < _fNumParPCA; ++i) {
tree.Branch(Form("%s_PCA", _fNames[i].c_str()), (double*)&(fParCurr_PCA.GetMatrixArray()[i]), Form("%s_PCA/D", _fNames[i].c_str()));
tree.Branch(Form("%s_PCA", _fNames[i].c_str()), static_cast<double*>(&fParCurr_PCA.GetMatrixArray()[i]), Form("%s_PCA/D", _fNames[i].c_str()));
}
}

Expand All @@ -912,7 +912,7 @@ void covarianceBase::SetBranches(TTree &tree, bool SaveProposal) {
// When running PCA, also save PCA parameters
if (pca) {
for (int i = 0; i < _fNumParPCA; ++i) {
tree.Branch(Form("%s_PCA_Prop", _fNames[i].c_str()), (double*)&(fParProp_PCA.GetMatrixArray()[i]), Form("%s_PCA_Prop/D", _fNames[i].c_str()));
tree.Branch(Form("%s_PCA_Prop", _fNames[i].c_str()), static_cast<double*>(&fParProp_PCA.GetMatrixArray()[i]), Form("%s_PCA_Prop/D", _fNames[i].c_str()));
}
}
}
Expand Down Expand Up @@ -1155,7 +1155,7 @@ void covarianceBase::setThrowMatrix(TMatrixDSym *cov){
throw MaCh3Exception(__FILE__ , __LINE__ );
}

throwMatrix = (TMatrixDSym*)cov->Clone();
throwMatrix = static_cast<TMatrixDSym*>(cov->Clone());
if(use_adaptive && AdaptiveHandler.AdaptionUpdate()) makeClosestPosDef(throwMatrix);
else MakePosDef(throwMatrix);

Expand Down Expand Up @@ -1274,11 +1274,11 @@ void covarianceBase::makeClosestPosDef(TMatrixDSym *cov) {
throw MaCh3Exception(__FILE__ , __LINE__ );
}

TMatrixD cov_sym_v = (TMatrixD)cov_sym_svd.GetV();
TMatrixD cov_sym_v = static_cast<TMatrixD>(cov_sym_svd.GetV());
TMatrixD cov_sym_vt = cov_sym_v;
cov_sym_vt.T();
//SVD returns as vector (grrr) so need to get into matrix form for multiplying!
TVectorD cov_sym_sigvect = (TVectorD)cov_sym_svd.GetSig();
TVectorD cov_sym_sigvect = static_cast<TVectorD>(cov_sym_svd.GetSig());
const Int_t nCols = cov_sym_v.GetNcols(); //square so only need rows hence lack of cols
TMatrixDSym cov_sym_sig(nCols);
TMatrixDDiag cov_sym_sig_diag(cov_sym_sig);
Expand Down
Loading