From 935d291eaa92cc443bfa5c4814eb6ef7738827bf Mon Sep 17 00:00:00 2001 From: KSkwarczynski Date: Fri, 26 Jul 2024 14:29:17 +0000 Subject: [PATCH] deploy: 3d74fdc42a4e904aa5d0cba556b16b81920d3f7a --- AdaptiveMCMCHandler_8cpp.html | 98 + AdaptiveMCMCHandler_8cpp_source.html | 368 ++ ...uct_8h.html => AdaptiveMCMCHandler_8h.html | 24 +- AdaptiveMCMCHandler_8h_source.html | 173 + CombineMaCh3Chains_8cpp.html | 14 +- CombineMaCh3Chains_8cpp_source.html | 14 +- CovarianceUtils_8h.html | 3 - CovarianceUtils_8h_source.html | 226 +- DiagMCMC_8cpp.html | 10 +- DiagMCMC_8cpp_source.html | 10 +- FDMCStruct_8h_source.html | 2 +- FitterBase_8cpp_source.html | 82 +- FitterBase_8h_source.html | 275 +- GetPenaltyTerm_8cpp.html | 14 +- GetPenaltyTerm_8cpp_source.html | 14 +- GetPostfitParamPlots_8cpp.html | 4 +- GetPostfitParamPlots_8cpp_source.html | 4 +- LikelihoodFit_8cpp_source.html | 34 +- LikelihoodFit_8h_source.html | 4 +- MCMCProcessor_8cpp_source.html | 24 +- MCMCProcessor_8h_source.html | 6 +- MaCh3Exception_8h_source.html | 68 +- MaCh3Factory_8cpp.html | 6 +- MaCh3Factory_8cpp_source.html | 6 +- MaCh3Factory_8h_source.html | 2 +- MaCh3Logger_8h.html | 94 +- MaCh3Logger_8h_source.html | 123 +- MaCh3Modes_8cpp_source.html | 32 +- MaCh3Modes_8h.html | 2 +- MaCh3Modes_8h_source.html | 147 +- MinuitFit_8cpp_source.html | 10 +- MinuitFit_8h_source.html | 2 +- Monitor_8cpp_source.html | 6 +- Monitor_8h_source.html | 6 +- OscClass__CUDAProb3_8cpp_source.html | 2 +- OscClass__CUDAProb3_8h_source.html | 2 +- PSO_8cpp_source.html | 84 +- PSO_8h_source.html | 431 +- PlotAutoCorrelations_8C.html | 2 +- PlotAutoCorrelations_8C_source.html | 2 +- PlotLLH_8cpp.html | 4 +- PlotLLH_8cpp_source.html | 4 +- PlotMCMC__Diagnosis_8cpp.html | 2 +- PlotMCMC__Diagnosis_8cpp_source.html | 2 +- ProcessMCMC_8cpp.html | 10 +- ProcessMCMC_8cpp_source.html | 10 +- RHat_8cpp.html | 16 +- RHat_8cpp_source.html | 16 +- SECURITY_8md.html | 83 + SampleSummary_8cpp_source.html | 4 +- SampleSummary_8h_source.html | 4 +- ShiftFunctors_8h_source.html | 2 +- SplineMonolith_8cpp_source.html | 30 +- SplineMonolith_8h_source.html | 4 +- SplineStructs_8h.html | 12 +- SplineStructs_8h_source.html | 14 +- StatisticalUtils_8h.html | 4 +- StatisticalUtils_8h_source.html | 4 +- Structs_8cpp.html | 2 +- Structs_8cpp_source.html | 2 +- Structs_8h.html | 8 +- Structs_8h_source.html | 22 +- ThrowParms_8cpp_source.html | 2 +- ThrowParms_8h_source.html | 2 +- YamlHelper_8h.html | 213 +- YamlHelper_8h_source.html | 318 +- adaptiveMCMCStruct_8h_source.html | 153 - annotated.html | 4 +- classBaseFuncPar.html | 2 +- classFitterBase.html | 144 +- classLikelihoodFit.html | 34 +- classMCMCProcessor-members.html | 2 +- classMCMCProcessor.html | 36 +- classMaCh3Exception.html | 34 +- classMaCh3Modes-members.html | 2 +- classMaCh3Modes.html | 68 +- classMinuitFit.html | 10 +- classOscillator.html | 2 +- classPSO.html | 224 +- classSMonolith.html | 26 +- classSampleSummary.html | 4 +- classTF1__red.html | 2 +- classTSpline3__red.html | 2 +- classThrowParms.html | 2 +- classTruncated__Spline.html | 2 +- classXSecStruct.html | 2 +- ...__mcmc_1_1AdaptiveMCMCHandler-members.html | 107 + ...adaptive__mcmc_1_1AdaptiveMCMCHandler.html | 822 ++++ classcovarianceBase-members.html | 245 +- classcovarianceBase.html | 3639 +++++++-------- classcovarianceOsc-members.html | 287 +- classcovarianceOsc.html | 57 +- classcovarianceXsec-members.html | 309 +- classcovarianceXsec.html | 211 +- classes.html | 2 +- classmanager.html | 12 +- classmcmc.html | 42 +- classparticle.html | 116 +- classsamplePDFBase.html | 6 +- classsamplePDFFDBase.html | 14 +- classsplineFDBase.html | 8 +- covarianceBase_8cpp_source.html | 4071 ++++++++--------- covarianceBase_8h.html | 2 +- covarianceBase_8h_source.html | 904 ++-- covarianceOsc_8cpp_source.html | 34 +- covarianceOsc_8h_source.html | 4 +- covarianceXsec_8cpp_source.html | 90 +- covarianceXsec_8h.html | 3 +- covarianceXsec_8h_source.html | 223 +- dir_ad7582af392f69120f12d3a638849ade.html | 4 +- files.html | 157 +- functions_a.html | 13 +- functions_c.html | 2 +- functions_e.html | 2 +- functions_func.html | 1 + functions_func_c.html | 2 +- functions_func_g.html | 6 +- functions_func_i.html | 1 + functions_func_p.html | 2 +- functions_func_s.html | 5 +- functions_func_u.html | 1 + functions_func_~.html | 1 + functions_g.html | 6 +- functions_i.html | 3 +- functions_p.html | 4 +- functions_s.html | 11 +- functions_u.html | 1 + functions_vars_a.html | 10 +- functions_vars_e.html | 2 +- functions_vars_p.html | 2 +- functions_vars_s.html | 4 +- functions_~.html | 1 + gpuMCMCProcessorUtils_8cu.html | 56 +- gpuMCMCProcessorUtils_8cu_source.html | 2 +- gpuMCMCProcessorUtils_8cuh.html | 56 +- gpuMCMCProcessorUtils_8cuh_source.html | 82 +- gpuSplineUtils_8cu.html | 1209 ++--- gpuSplineUtils_8cu_source.html | 1600 ++++--- gpuUtils_8cu.html | 26 +- gpuUtils_8cu_source.html | 2 +- gpuUtils_8cuh.html | 30 +- gpuUtils_8cuh_source.html | 36 +- hierarchy.html | 2 +- kdeGpu2_8cu.html | 2 +- kdeGpu2_8cu_source.html | 2 +- kdeGpu_8cu.html | 2 +- kdeGpu_8cu_source.html | 2 +- manager_8cpp_source.html | 12 +- manager_8h_source.html | 8 +- mcmc_8cpp_source.html | 42 +- mcmc_8h_source.html | 6 +- ...ithub_2workspace_2Diagnostics_2README.html | 2 +- md__2github_2workspace_2SECURITY.html | 93 + namespaceMaCh3Utils.html | 174 +- namespaceadaptive__mcmc.html | 59 +- namespacemembers.html | 1 - namespacemembers_func.html | 1 - namespaces.html | 4 +- pages.html | 3 +- probGpu_8cu.html | 17 +- probGpu_8cu_source.html | 2 +- samplePDFBase_8cpp_source.html | 4 +- samplePDFBase_8h_source.html | 6 +- samplePDFFDBase_8cpp_source.html | 16 +- samplePDFFDBase_8h_source.html | 4 +- search/all_10.js | 80 +- search/all_12.js | 91 +- search/all_13.js | 347 +- search/all_15.js | 2 +- search/all_16.js | 14 +- search/all_1a.js | 51 +- search/all_2.js | 76 +- search/all_4.js | 2 +- search/all_6.js | 2 +- search/all_8.js | 6 +- search/all_a.js | 79 +- search/all_e.js | 4 +- search/all_f.js | 4 +- search/classes_0.js | 2 +- search/files_0.js | 3 +- search/files_b.js | 25 +- search/functions_1.js | 25 +- search/functions_11.js | 8 +- search/functions_13.js | 2 +- search/functions_18.js | 51 +- search/functions_3.js | 2 +- search/functions_7.js | 6 +- search/functions_8.js | 51 +- search/functions_e.js | 63 +- search/pages_7.js | 3 +- search/pages_9.js | 3 +- search/variables_1.js | 10 +- search/variables_11.js | 4 +- search/variables_5.js | 2 +- search/variables_d.js | 4 +- search/variables_e.js | 4 +- search/variables_f.js | 4 +- splineFDBase_8cpp_source.html | 10 +- splineFDBase_8h_source.html | 4 +- structMaCh3ModeInfo.html | 22 +- ...e__mcmc_1_1AdaptiveMCMCStruct-members.html | 98 - ...tadaptive__mcmc_1_1AdaptiveMCMCStruct.html | 275 -- 202 files changed, 10655 insertions(+), 9775 deletions(-) create mode 100644 AdaptiveMCMCHandler_8cpp.html create mode 100644 AdaptiveMCMCHandler_8cpp_source.html rename adaptiveMCMCStruct_8h.html => AdaptiveMCMCHandler_8h.html (67%) create mode 100644 AdaptiveMCMCHandler_8h_source.html create mode 100644 SECURITY_8md.html delete mode 100644 adaptiveMCMCStruct_8h_source.html create mode 100644 classadaptive__mcmc_1_1AdaptiveMCMCHandler-members.html create mode 100644 classadaptive__mcmc_1_1AdaptiveMCMCHandler.html create mode 100644 md__2github_2workspace_2SECURITY.html delete mode 100644 structadaptive__mcmc_1_1AdaptiveMCMCStruct-members.html delete mode 100644 structadaptive__mcmc_1_1AdaptiveMCMCStruct.html diff --git a/AdaptiveMCMCHandler_8cpp.html b/AdaptiveMCMCHandler_8cpp.html new file mode 100644 index 000000000..541b72647 --- /dev/null +++ b/AdaptiveMCMCHandler_8cpp.html @@ -0,0 +1,98 @@ + + + + + + + +MaCh3: /github/workspace/covariance/AdaptiveMCMCHandler.cpp File Reference + + + + + + + + + +
+
+ + + + + + + +
+
MaCh3 1.1.0 +
+
Reference Guide
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+ +
AdaptiveMCMCHandler.cpp File Reference
+
+
+ +

Go to the source code of this file.

+ + + + +

+Namespaces

namespace  adaptive_mcmc
 
+
+ + + + diff --git a/AdaptiveMCMCHandler_8cpp_source.html b/AdaptiveMCMCHandler_8cpp_source.html new file mode 100644 index 000000000..d6cd4cabe --- /dev/null +++ b/AdaptiveMCMCHandler_8cpp_source.html @@ -0,0 +1,368 @@ + + + + + + + +MaCh3: /github/workspace/covariance/AdaptiveMCMCHandler.cpp Source File + + + + + + + + + +
+
+ + + + + + + +
+
MaCh3 1.1.0 +
+
Reference Guide
+
+
+ + + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
AdaptiveMCMCHandler.cpp
+
+
+Go to the documentation of this file.
+
2
+
+
3namespace adaptive_mcmc{
+
4
+
5// ********************************************
+
+ +
7// ********************************************
+ + + + +
12
+
13 par_means = {};
+
14 adaptive_covariance = nullptr;
+
15}
+
+
16
+
17// ********************************************
+
+ +
19// ********************************************
+
20 if(adaptive_covariance != nullptr) {
+ +
22 }
+
23}
+
+
24
+
25
+
26// ********************************************
+
+
27void AdaptiveMCMCHandler::InitFromConfig(const YAML::Node& adapt_manager, const std::string& matrix_name_str, const int Npars) {
+
28// ********************************************
+
29 // setAdaptionDefaults();
+
30 if(GetFromManager<std::string>(adapt_manager["AdaptionOptions"]["Covariance"][matrix_name_str], "")==""){
+
31 MACH3LOG_WARN("Adaptive Settings not found for {}, this is fine if you don't want adaptive MCMC", matrix_name_str);
+
32 return;
+
33 }
+
34
+
35 // We"re going to grab this info from the YAML manager
+
36 if(GetFromManager<bool>(adapt_manager["AdaptionOptions"]["Covariance"][matrix_name_str]["DoAdaption"], false)) {
+
37 MACH3LOG_WARN("Not using adaption for {}", matrix_name_str);
+
38 return;
+
39 }
+
40
+
41 start_adaptive_throw = GetFromManager<int>(adapt_manager["AdaptionOptions"]["Settings"]["AdaptionStartThrow"], 10);
+
42 start_adaptive_update = GetFromManager<int>(adapt_manager["AdaptionOptions"]["Settings"]["AdaptionStartUpdate"], 0);
+
43 end_adaptive_update = GetFromManager<int>(adapt_manager["AdaptionOptions"]["Settings"]["AdaptionEndUpdate"], 10000);
+
44 adaptive_update_step = GetFromManager<int>(adapt_manager["AdaptionOptions"]["Settings"]["AdaptionUpdateStep"], 100);
+
45
+
46
+
47 // We also want to check for "blocks" by default all parameters "know" about each other
+
48 // but we can split the matrix into independent block matrices
+
49
+
50 // We"ll set a dummy variable here
+
51 auto matrix_blocks = GetFromManager<std::vector<std::vector<int>>>(adapt_manager["AdaptionOptions"]["Settings"][matrix_name_str]["AdaptionUpdateStep"], {{}});
+
52
+ +
54}
+
+
55
+
56// ********************************************
+
+ +
58// ********************************************
+ +
60 adaptive_covariance->Zero();
+
61 par_means = std::vector<double>(Npars, 0);
+
62}
+
+
63
+
64
+
65// ********************************************
+
+
66void AdaptiveMCMCHandler::SetAdaptiveBlocks(std::vector<std::vector<int>> block_indices, const int Npars) {
+
67// ********************************************
+
68 /*
+
69 * In order to adapt efficient we want to setup our throw matrix to be a serious of block-diagonal (ish) matrices
+
70 *
+
71 * To do this we set sub-block in the config by parameter index. For example having
+
72 * [[0,4],[4, 6]] in your config will set up two blocks one with all indices 0<=i<4 and the other with 4<=i<6
+
73 */
+
74 // Set up block regions
+
75 adapt_block_matrix_indices = std::vector<int>(Npars, 0);
+
76
+
77 // Should also make a matrix of block sizes
+
78 adapt_block_sizes = std::vector<int>((int)block_indices.size()+1, 0);
+ +
80
+
81 if(block_indices.size()==0 || block_indices[0].size()==0) return;
+
82
+
83 // Now we loop over our blocks
+
84 for(int iblock=0; iblock<(int)block_indices.size(); iblock++){
+
85 // Loop over blocks in the block
+ + + +
89
+
90 //std::cout<<block_lb<<" "<<block_ub<<std::endl;
+
91 if(block_lb > Npars || block_ub > Npars){
+
92 MACH3LOG_ERROR("Cannot set matrix block with edges {}, {} for matrix of size {}",
+ + +
95 }
+
96 for(int ipar = block_lb; ipar < block_ub; ipar++){
+ + +
99 adapt_block_sizes[0] -= 1;
+
100 }
+
101 }
+
102 }
+
103}
+
+
104
+
105
+
106// ********************************************
+
107//HW: Truly adaptive MCMC!
+
+ +
109// ********************************************
+
110 TFile* outFile = new TFile(outFileName, "UPDATE");
+
111 if(outFile->IsZombie()){
+
112 MACH3LOG_ERROR("Couldn't find {}", outFileName);
+
113 throw;
+
114 }
+
115 TVectorD* outMeanVec = new TVectorD((int)par_means.size());
+
116 for(int i = 0; i < (int)par_means.size(); i++){
+
117 (*outMeanVec)(i) = par_means[i];
+
118 }
+
119 outFile->cd();
+
120 adaptive_covariance->Write(systematicName+"_postfit_matrix");
+
121 outMeanVec->Write(systematicName+"_mean_vec");
+
122 outFile->Close();
+
123 delete outMeanVec;
+
124 delete outFile;
+
125}
+
+
126
+
127// ********************************************
+
128// HW : I would like this to be less painful to use!
+
129// First things first we need setters
+
+ +
131 const std::string& matrix_name,
+
132 const std::string& means_name,
+
133 bool& use_adaptive,
+
134 const int Npars) {
+
135// ********************************************
+
136 // Lets you set the throw matrix externally
+
137 // Open file
+
138 std::unique_ptr<TFile>matrix_file(new TFile(matrix_file_name.c_str()));
+
139 use_adaptive = true;
+
140
+
141 if(matrix_file->IsZombie()){
+
142 MACH3LOG_ERROR("Couldn't find {}", matrix_file_name);
+
143 throw;
+
144 }
+
145
+
146 // Next we grab our matrix
+
147 adaptive_covariance = static_cast<TMatrixDSym*>(matrix_file->Get(matrix_name.c_str()));
+ +
149 MACH3LOG_ERROR("Couldn't find {} in {}", matrix_name, matrix_file_name);
+
150 throw;
+
151 }
+
152
+
153 // Finally we grab the means vector
+
154 TVectorD* means_vector = static_cast<TVectorD*>(matrix_file->Get(means_name.c_str()));
+
155
+
156 // This is fine to not exist!
+
157 if(means_vector){
+
158 // Yay our vector exists! Let's loop and fill it
+
159 // Should check this is done
+
160 if(means_vector->GetNrows()){
+
161 MACH3LOG_ERROR("External means vec size ({}) != matrix size ({})", means_vector->GetNrows(), Npars);
+ +
163 }
+
164
+
165 par_means = std::vector<double>(Npars);
+
166 for(int i = 0; i < Npars; i++){
+
167 par_means[i] = (*means_vector)(i);
+
168 }
+
169 MACH3LOG_INFO("Found Means in External File, Will be able to adapt");
+
170 }
+
171 // Totally fine if it doesn't exist, we just can't do adaption
+
172 else{
+
173 // We don't need a means vector, set the adaption=false
+
174 MACH3LOG_WARN("Cannot find means vector in {}, therefore I will not be able to adapt!", matrix_file_name);
+
175 use_adaptive = false;
+
176 }
+
177
+
178 matrix_file->Close();
+
179 MACH3LOG_INFO("Set up matrix from external file");
+
180}
+
+
181
+
182
+
183// ********************************************
+
+
184void AdaptiveMCMCHandler::UpdateAdaptiveCovariance(const std::vector<double>& _fCurrVal, const int steps_post_burn, const int Npars) {
+
185// ********************************************
+
186 std::vector<double> par_means_prev = par_means;
+
187
+
188 #ifdef MULTITHREAD
+
189 #pragma omp parallel for
+
190 #endif
+
191 for(int iRow = 0; iRow < Npars; iRow++) {
+ +
193 }
+
194
+
195 //Now we update the covariances using cov(x,y)=E(xy)-E(x)E(y)
+
196 #ifdef MULTITHREAD
+
197 #pragma omp parallel for
+
198 #endif
+
199 for(int irow = 0; irow < Npars; irow++){
+ +
201 // int scale_factor = 5.76/double(adapt_block_sizes[block]);
+
202 for(int icol = 0; icol <= irow; icol++){
+
203 double cov_val=0;
+
204 // Not in the same blocks
+ +
206 // Calculate Covariance for block
+
207 // https://projecteuclid.org/journals/bernoulli/volume-7/issue-2/An-adaptive-Metropolis-algorithm/bj/1080222083.full
+
208 cov_val = (*adaptive_covariance)(irow, icol)*Npars/5.6644;
+
209 cov_val += par_means_prev[irow]*par_means_prev[icol]; //First we remove the current means
+
210 cov_val = (cov_val*steps_post_burn+_fCurrVal[irow]*_fCurrVal[icol])/(steps_post_burn+1); //Now get mean(iRow*iCol)
+ +
212 cov_val*=5.6644/Npars;
+
213 }
+
214 (*adaptive_covariance)(icol, irow) = cov_val;
+
215 (*adaptive_covariance)(irow, icol) = cov_val;
+
216 }
+
217 }
+
218}
+
+
219
+
220// ********************************************
+
+ +
222// ********************************************
+
223 MACH3LOG_INFO("Adaptive MCMC Info:");
+
224 MACH3LOG_INFO("Throwing from New Matrix from Step : {}", start_adaptive_throw);
+
225 MACH3LOG_INFO("Adaption Matrix Start Update : {}", start_adaptive_update);
+
226 MACH3LOG_INFO("Adaption Matrix Ending Updates : {}", end_adaptive_update);
+
227 MACH3LOG_INFO("Steps Between Updates : {}", adaptive_update_step);
+
228}
+
+
229
+
230
+
231} //end adaptive_mcmc
+
+ +
int size
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Custom exception class for MaCh3 errors.
+
std::vector< double > par_means
Mean values for all parameters.
+
std::vector< int > adapt_block_matrix_indices
Indices for block-matrix adaption.
+
void Print()
Print all class members.
+
int start_adaptive_update
When do we stop update the adaptive matrix.
+
std::vector< int > adapt_block_sizes
Size of blocks for adaption.
+ +
void SaveAdaptiveToFile(const TString &outFileName, const TString &systematicName)
HW: Save adaptive throw matrix to file.
+ + +
int end_adaptive_update
Steps between changing throw matrix.
+
void UpdateAdaptiveCovariance(const std::vector< double > &_fCurrVal, const int steps_post_burn, const int Npars)
Method to update adaptive MCMC.
+
int adaptive_update_step
Steps between changing throw matrix.
+
void SetAdaptiveBlocks(std::vector< std::vector< int > > block_indices, const int Npars)
HW: sets adaptive block matrix.
+
void CreateNewAdaptiveCovariance(const int Npars)
If we don't have a covariance matrix to start from for adaptive tune we need to make one!
+
void InitFromConfig(const YAML::Node &adapt_manager, const std::string &matrix_name_str, const int Npars)
Read initial values from config file.
+
void SetThrowMatrixFromFile(const std::string &matrix_file_name, const std::string &matrix_name, const std::string &means_name, bool &use_adaptive, const int Npars)
sets throw matrix from a file
+
TMatrixDSym * adaptive_covariance
Full adaptive covariance matrix.
+ +
+ + + + diff --git a/adaptiveMCMCStruct_8h.html b/AdaptiveMCMCHandler_8h.html similarity index 67% rename from adaptiveMCMCStruct_8h.html rename to AdaptiveMCMCHandler_8h.html index d20065f0e..8fb98aaee 100644 --- a/adaptiveMCMCStruct_8h.html +++ b/AdaptiveMCMCHandler_8h.html @@ -5,7 +5,7 @@ -MaCh3: /github/workspace/covariance/adaptiveMCMCStruct.h File Reference +MaCh3: /github/workspace/covariance/AdaptiveMCMCHandler.h File Reference @@ -77,34 +77,26 @@
-
adaptiveMCMCStruct.h File Reference
+Namespaces
+
AdaptiveMCMCHandler.h File Reference
#include "manager/MaCh3Logger.h"
-#include "TMatrixDSym.h"
-#include <vector>
+#include "manager/manager.h"
+#include "covariance/CovarianceUtils.h"
-

Go to the source code of this file.

+

Go to the source code of this file.

- - + +

Classes

struct  adaptive_mcmc::AdaptiveMCMCStruct
 struct encapsulating all adaptive MCMC information More...
class  adaptive_mcmc::AdaptiveMCMCHandler
 Contains information about adaptive covariance matrix. More...
 
- -

Namespaces

namespace  adaptive_mcmc
 Contains information about adaptive covariance matrix.
 
- - - -

-Functions

void adaptive_mcmc::print_adaptive_struct (AdaptiveMCMCStruct adaptive_struct)
 Basic printer method for AMCMC struct.
 
diff --git a/AdaptiveMCMCHandler_8h_source.html b/AdaptiveMCMCHandler_8h_source.html new file mode 100644 index 000000000..d8bc737d1 --- /dev/null +++ b/AdaptiveMCMCHandler_8h_source.html @@ -0,0 +1,173 @@ + + + + + + + +MaCh3: /github/workspace/covariance/AdaptiveMCMCHandler.h Source File + + + + + + + + + +
+
+ + + + + + + +
+
MaCh3 1.1.0 +
+
Reference Guide
+
+
+ + + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
AdaptiveMCMCHandler.h
+
+
+Go to the documentation of this file.
1#pragma once
+
2
+
3// MaCh3 Includes
+ +
5#include "manager/manager.h"
+ +
7
+
8namespace adaptive_mcmc{
+
9
+
+ +
14 public:
+
15
+ +
18
+ +
21
+
23 void Print();
+
24
+
27 void InitFromConfig(const YAML::Node& adapt_manager, const std::string& matrix_name_str, const int Npars);
+
28
+
30 void CreateNewAdaptiveCovariance(const int Npars);
+
31
+
34 void SetAdaptiveBlocks(std::vector<std::vector<int>> block_indices, const int Npars);
+
35
+ +
38
+
43 void SetThrowMatrixFromFile(const std::string& matrix_file_name,
+
44 const std::string& matrix_name,
+
45 const std::string& means_name,
+
46 bool& use_adaptive,
+
47 const int Npars);
+
48
+
49
+
50
+
51
+
55 void UpdateAdaptiveCovariance(const std::vector<double>& _fCurrVal, const int steps_post_burn, const int Npars);
+
56
+ +
60
+ +
63
+ +
66
+ +
69
+ +
72
+
74 std::vector<int> adapt_block_sizes;
+
75
+
76 // Variables directedly linked to adaption
+
78 std::vector<double> par_means;
+
79
+ +
82};
+
+
83
+
84} // adaptive_mcmc namespace
+ + +
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Contains information about adaptive covariance matrix.
+
std::vector< double > par_means
Mean values for all parameters.
+
std::vector< int > adapt_block_matrix_indices
Indices for block-matrix adaption.
+
void Print()
Print all class members.
+
int start_adaptive_update
When do we stop update the adaptive matrix.
+
std::vector< int > adapt_block_sizes
Size of blocks for adaption.
+ +
void SaveAdaptiveToFile(const TString &outFileName, const TString &systematicName)
HW: Save adaptive throw matrix to file.
+ + +
int end_adaptive_update
Steps between changing throw matrix.
+
void UpdateAdaptiveCovariance(const std::vector< double > &_fCurrVal, const int steps_post_burn, const int Npars)
Method to update adaptive MCMC.
+
int adaptive_update_step
Steps between changing throw matrix.
+
void SetAdaptiveBlocks(std::vector< std::vector< int > > block_indices, const int Npars)
HW: sets adaptive block matrix.
+
void CreateNewAdaptiveCovariance(const int Npars)
If we don't have a covariance matrix to start from for adaptive tune we need to make one!
+
void InitFromConfig(const YAML::Node &adapt_manager, const std::string &matrix_name_str, const int Npars)
Read initial values from config file.
+
void SetThrowMatrixFromFile(const std::string &matrix_file_name, const std::string &matrix_name, const std::string &means_name, bool &use_adaptive, const int Npars)
sets throw matrix from a file
+
TMatrixDSym * adaptive_covariance
Full adaptive covariance matrix.
+ + +
+ + + + diff --git a/CombineMaCh3Chains_8cpp.html b/CombineMaCh3Chains_8cpp.html index 6ed649db5..45e893ff0 100644 --- a/CombineMaCh3Chains_8cpp.html +++ b/CombineMaCh3Chains_8cpp.html @@ -191,10 +191,10 @@

51 }
53}
-
#define MACH3LOG_DEBUG
Definition MaCh3Logger.h:12
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
#define MACH3LOG_DEBUG
Definition MaCh3Logger.h:15
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
@@ -324,8 +324,8 @@

bool forceOverwrite
int targetCompression
std::vector< std::string > inpFileList
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
Custom exception class for MaCh3 errors.
@@ -419,7 +419,7 @@

275}
void ParseArg(int argc, char *argv[])
void CombineChain()
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
diff --git a/CombineMaCh3Chains_8cpp_source.html b/CombineMaCh3Chains_8cpp_source.html index 893051c1e..4095eceb6 100644 --- a/CombineMaCh3Chains_8cpp_source.html +++ b/CombineMaCh3Chains_8cpp_source.html @@ -379,13 +379,13 @@
int targetCompression
std::vector< std::string > inpFileList
void CombineChain()
-
#define MACH3LOG_DEBUG
Definition MaCh3Logger.h:12
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_DEBUG
Definition MaCh3Logger.h:15
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Custom exception class for MaCh3 errors.
diff --git a/CovarianceUtils_8h.html b/CovarianceUtils_8h.html index ef337c872..9e31a7758 100644 --- a/CovarianceUtils_8h.html +++ b/CovarianceUtils_8h.html @@ -85,15 +85,12 @@ #include "TMatrixDSym.h"
#include "TVectorT.h"
#include "TVectorD.h"
-#include "TCanvas.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TTree.h"
#include "TFile.h"
-#include "TAxis.h"
#include "TRandom3.h"
#include "TMath.h"
-#include "math.h"
#include "TDecompChol.h"
#include "TStopwatch.h"
#include "TMatrix.h"
diff --git a/CovarianceUtils_8h_source.html b/CovarianceUtils_8h_source.html index ed8708d7e..d71e3dd42 100644 --- a/CovarianceUtils_8h_source.html +++ b/CovarianceUtils_8h_source.html @@ -90,127 +90,123 @@
5#include "TMatrixDSym.h"
6#include "TVectorT.h"
7#include "TVectorD.h"
-
8#include "TCanvas.h"
-
9#include "TH1D.h"
-
10#include "TH2D.h"
-
11#include "TTree.h"
-
12#include "TFile.h"
-
13#include "TAxis.h"
-
14#include "TRandom3.h"
-
15#include "TMath.h"
-
16#include "math.h"
-
17#include "TDecompChol.h"
-
18#include "TStopwatch.h"
-
19#include "TMatrix.h"
-
20#include "TMatrixDSymEigen.h"
-
21#include "TMatrixDEigen.h"
-
22#include "TDecompSVD.h"
-
23
+
8#include "TH1D.h"
+
9#include "TH2D.h"
+
10#include "TTree.h"
+
11#include "TFile.h"
+
12#include "TRandom3.h"
+
13#include "TMath.h"
+
14#include "TDecompChol.h"
+
15#include "TStopwatch.h"
+
16#include "TMatrix.h"
+
17#include "TMatrixDSymEigen.h"
+
18#include "TMatrixDEigen.h"
+
19#include "TDecompSVD.h"
+
20
+
21#ifdef MULTITHREAD
+
22#include "omp.h"
+
23#endif
24
-
25#ifdef MULTITHREAD
-
26#include "omp.h"
-
27#endif
-
28
-
29namespace MaCh3Utils
-
30{
-
-
32 inline int GetNThreads()
-
33 {
-
34 #ifdef MULTITHREAD
- -
36 #else
-
37 int nThreads = 1;
-
38 #endif
-
39
-
40 return nThreads;
-
41 }
+
25namespace MaCh3Utils
+
26{
+
+
28 inline int GetNThreads()
+
29 {
+
30 #ifdef MULTITHREAD
+ +
32 #else
+
33 int nThreads = 1;
+
34 #endif
+
35
+
36 return nThreads;
+
37 }
-
42
-
-
44 inline double* MatrixMult(double *A, double *B, int n) {
-
45 //CW: First transpose to increse cache hits
-
46 double *BT = new double[n*n];
-
47 #ifdef MULTITHREAD
-
48 #pragma omp parallel for
-
49 #endif
-
50 for (int i = 0; i < n; i++) {
-
51 for (int j = 0; j < n; j++) {
-
52 BT[j*n+i] = B[i*n+j];
-
53 }
-
54 }
-
55
-
56 // Now multiply
-
57 double *C = new double[n*n];
-
58 #ifdef MULTITHREAD
-
59 #pragma omp parallel for
-
60 #endif
-
61 for (int i = 0; i < n; i++) {
-
62 for (int j = 0; j < n; j++) {
-
63 double sum = 0;
-
64 for (int k = 0; k < n; k++) {
-
65 sum += A[i*n+k]*BT[j*n+k];
-
66 }
-
67 C[i*n+j] = sum;
-
68 }
-
69 }
-
70 delete BT;
-
71
-
72 return C;
-
73 }
+
38
+
+
40 inline double* MatrixMult(double *A, double *B, int n) {
+
41 //CW: First transpose to increse cache hits
+
42 double *BT = new double[n*n];
+
43 #ifdef MULTITHREAD
+
44 #pragma omp parallel for
+
45 #endif
+
46 for (int i = 0; i < n; i++) {
+
47 for (int j = 0; j < n; j++) {
+
48 BT[j*n+i] = B[i*n+j];
+
49 }
+
50 }
+
51
+
52 // Now multiply
+
53 double *C = new double[n*n];
+
54 #ifdef MULTITHREAD
+
55 #pragma omp parallel for
+
56 #endif
+
57 for (int i = 0; i < n; i++) {
+
58 for (int j = 0; j < n; j++) {
+
59 double sum = 0;
+
60 for (int k = 0; k < n; k++) {
+
61 sum += A[i*n+k]*BT[j*n+k];
+
62 }
+
63 C[i*n+j] = sum;
+
64 }
+
65 }
+
66 delete BT;
+
67
+
68 return C;
+
69 }
-
74
-
-
76 inline double** MatrixMult(double **A, double **B, int n) {
-
77 // First make into monolithic array
-
78 double *A_mon = new double[n*n];
-
79 double *B_mon = new double[n*n];
-
80
-
81 #ifdef MULTITHREAD
-
82 #pragma omp parallel for
-
83 #endif
-
84 for (int i = 0; i < n; ++i) {
-
85 for (int j = 0; j < n; ++j) {
-
86 A_mon[i*n+j] = A[i][j];
-
87 B_mon[i*n+j] = B[i][j];
-
88 }
-
89 }
-
90 //CW: Now call the monolithic calculator
-
91 double *C_mon = MatrixMult(A_mon, B_mon, n);
-
92 delete A_mon;
-
93 delete B_mon;
-
94
-
95 // Return the double pointer
-
96 double **C = new double*[n];
-
97 #ifdef MULTITHREAD
-
98 #pragma omp parallel for
-
99 #endif
-
100 for (int i = 0; i < n; ++i) {
-
101 C[i] = new double[n];
-
102 for (int j = 0; j < n; ++j) {
-
103 C[i][j] = C_mon[i*n+j];
-
104 }
-
105 }
-
106 delete C_mon;
-
107
-
108 return C;
-
109 }
+
70
+
+
72 inline double** MatrixMult(double **A, double **B, int n) {
+
73 // First make into monolithic array
+
74 double *A_mon = new double[n*n];
+
75 double *B_mon = new double[n*n];
+
76
+
77 #ifdef MULTITHREAD
+
78 #pragma omp parallel for
+
79 #endif
+
80 for (int i = 0; i < n; ++i) {
+
81 for (int j = 0; j < n; ++j) {
+
82 A_mon[i*n+j] = A[i][j];
+
83 B_mon[i*n+j] = B[i][j];
+
84 }
+
85 }
+
86 //CW: Now call the monolithic calculator
+
87 double *C_mon = MatrixMult(A_mon, B_mon, n);
+
88 delete A_mon;
+
89 delete B_mon;
+
90
+
91 // Return the double pointer
+
92 double **C = new double*[n];
+
93 #ifdef MULTITHREAD
+
94 #pragma omp parallel for
+
95 #endif
+
96 for (int i = 0; i < n; ++i) {
+
97 C[i] = new double[n];
+
98 for (int j = 0; j < n; ++j) {
+
99 C[i][j] = C_mon[i*n+j];
+
100 }
+
101 }
+
102 delete C_mon;
+
103
+
104 return C;
+
105 }
-
110
-
- -
113 {
-
114 double *C_mon = MatrixMult(A.GetMatrixArray(), B.GetMatrixArray(), A.GetNcols());
-
115 TMatrixD C;
-
116 C.Use(A.GetNcols(), A.GetNrows(), C_mon);
-
117 return C;
-
118 }
+
106
+
+ +
109 {
+
110 double *C_mon = MatrixMult(A.GetMatrixArray(), B.GetMatrixArray(), A.GetNcols());
+
111 TMatrixD C;
+
112 C.Use(A.GetNcols(), A.GetNrows(), C_mon);
+
113 return C;
+
114 }
-
119
-
120}
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
115
+
116}
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
-
double * MatrixMult(double *A, double *B, int n)
CW: Multi-threaded matrix multiplication.
-
int GetNThreads()
number of threads which we need for example for TRandom3
+
double * MatrixMult(double *A, double *B, int n)
CW: Multi-threaded matrix multiplication.
+
int GetNThreads()
number of threads which we need for example for TRandom3
48}
YAML::Node config
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
@@ -193,9 +193,9 @@

20 return 0;
21}
void DiagMCMC(std::string inputFile, std::string config)
Definition DiagMCMC.cpp:24
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
Custom exception class for MaCh3 errors.
diff --git a/DiagMCMC_8cpp_source.html b/DiagMCMC_8cpp_source.html index d195bdde5..4baee6e4a 100644 --- a/DiagMCMC_8cpp_source.html +++ b/DiagMCMC_8cpp_source.html @@ -141,12 +141,12 @@
void DiagMCMC(std::string inputFile, std::string config)
Definition DiagMCMC.cpp:24
YAML::Node config
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
-
Custom exception class for MaCh3 errors.
+
Custom exception class for MaCh3 errors.
diff --git a/FDMCStruct_8h_source.html b/FDMCStruct_8h_source.html index 4d6ee8871..eb7c29fbc 100644 --- a/FDMCStruct_8h_source.html +++ b/FDMCStruct_8h_source.html @@ -155,7 +155,7 @@
73#endif
74};
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
Bin-by-bin class calculating response for spline parameters.
constructors are same for all three so put in here
Definition FDMCStruct.h:5
std::string flavourName
Definition FDMCStruct.h:12
diff --git a/FitterBase_8cpp_source.html b/FitterBase_8cpp_source.html index 686178467..b9cc34af7 100644 --- a/FitterBase_8cpp_source.html +++ b/FitterBase_8cpp_source.html @@ -1195,7 +1195,7 @@
1081 //KS: this is only relevant if PlotByMode is turned on
1082 //Checking each mode is time consuming so we only consider one which are relevant for particular analysis
1083 const int nRelevantModes = 2;
- +
1085 bool DoByMode = GetFromManager<int>(fitMan->raw()["General"]["DoByMode"], false);
1086
1087 //KS: If true it will make additional plots with LLH sample contribution in each bin, should make it via config file...
@@ -1564,66 +1564,66 @@
std::vector< TString > BranchNames
-
#define MACH3LOG_CRITICAL
Definition MaCh3Logger.h:16
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
-
int MaCh3Modes_t
Enumerator of MaCh3Mode.
Definition MaCh3Modes.h:13
+
#define MACH3LOG_CRITICAL
Definition MaCh3Logger.h:19
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
int MaCh3Modes_t
Enumerator of MaCh3Mode.
Definition MaCh3Modes.h:14
TH1D * PolyProjectionX(TObject *poly, std::string TempName, std::vector< double > xbins, bool computeErrors)
WP: Poly Projectors.
Definition Structs.cpp:156
TH1D * PolyProjectionY(TObject *poly, std::string TempName, std::vector< double > ybins, bool computeErrors)
WP: Poly Projectors.
Definition Structs.cpp:227
#define _int_
Definition Structs.h:12
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
MaCh3Modes * Modes
MaCh3 Modes.
Definition FitterBase.h:95
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
MaCh3Modes * Modes
MaCh3 Modes.
Definition FitterBase.h:96
void RunLLHScan()
Perform a 1D likelihood scan.
-
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:125
+
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:126
void addSystObj(covarianceBase *cov)
This function adds a Covariance object to the analysis framework. The Covariance object will be utili...
void ProcessMCMC()
Process MCMC output.
-
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:132
-
covarianceOsc * osc2
handles oscillation parameters
Definition FitterBase.h:127
-
int accCount
counts accepted steps
Definition FitterBase.h:106
-
TRandom3 * random
Random number.
Definition FitterBase.h:137
+
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:133
+
covarianceOsc * osc2
handles oscillation parameters
Definition FitterBase.h:128
+
int accCount
counts accepted steps
Definition FitterBase.h:107
+
TRandom3 * random
Random number.
Definition FitterBase.h:138
FitterBase(manager *const fitMan)
Constructor.
-
virtual std::string GetName() const
Get name of class.
Definition FitterBase.h:70
-
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:122
-
bool OutputPrepared
Checks if output prepared not repeat some operations.
Definition FitterBase.h:160
+
virtual std::string GetName() const
Get name of class.
Definition FitterBase.h:71
+
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:123
+
bool OutputPrepared
Checks if output prepared not repeat some operations.
Definition FitterBase.h:161
void SaveOutput()
Save output and close files.
-
TFile * outputFile
Output.
Definition FitterBase.h:140
+
TFile * outputFile
Output.
Definition FitterBase.h:141
void SaveSettings()
Save the settings that the MCMC was run with.
-
bool SaveProposal
Save proposal at each step.
Definition FitterBase.h:153
-
manager * fitMan
The manager.
Definition FitterBase.h:92
-
unsigned int step
current state
Definition FitterBase.h:98
+
bool SaveProposal
Save proposal at each step.
Definition FitterBase.h:154
+
manager * fitMan
The manager.
Definition FitterBase.h:93
+
unsigned int step
current state
Definition FitterBase.h:99
void PrepareOutput()
Prepare the output file.
-
bool SettingsSaved
Checks if setting saved not repeat some operations.
Definition FitterBase.h:158
-
double accProb
current acceptance prob
Definition FitterBase.h:104
+
bool SettingsSaved
Checks if setting saved not repeat some operations.
Definition FitterBase.h:159
+
double accProb
current acceptance prob
Definition FitterBase.h:105
void GetStepScaleBasedOnLLHScan()
LLH scan is good first estimate of step scale.
-
bool FileSaved
Checks if file saved not repeat some operations.
Definition FitterBase.h:156
+
bool FileSaved
Checks if file saved not repeat some operations.
Definition FitterBase.h:157
void RunSigmaVar()
Perform a 2D and 1D sigma var for all samples.
-
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:112
-
double stepTime
Time of single step.
Definition FitterBase.h:134
-
TDirectory * CovFolder
Output cov folder.
Definition FitterBase.h:142
-
TStopwatch * clock
tells global time how long fit took
Definition FitterBase.h:130
+
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:113
+
double stepTime
Time of single step.
Definition FitterBase.h:135
+
TDirectory * CovFolder
Output cov folder.
Definition FitterBase.h:143
+
TStopwatch * clock
tells global time how long fit took
Definition FitterBase.h:131
void addOscHandler(covarianceOsc *oscf)
Adds an oscillation handler for covariance objects.
TGraphAsymmErrors * MakeAsymGraph(TH1D *sigmaArrayLeft, TH1D *sigmaArrayCentr, TH1D *sigmaArrayRight, std::string title)
Used by sigma variation, check how 1 sigma changes spectra.
void DragRace(const int NLaps=100)
Calculates the required time for each sample or covariance object in a drag race simulation....
void Run2DLLHScan()
Perform a 2D likelihood scan.
void addSamplePDF(samplePDFBase *sample)
This function adds a sample PDF object to the analysis framework. The sample PDF object will be utili...
-
unsigned int TotalNSamples
Total number of samples used.
Definition FitterBase.h:119
-
double logLCurr
current likelihood
Definition FitterBase.h:100
-
double osc_llh
Definition FitterBase.h:110
-
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:114
-
int auto_save
auto save every N steps
Definition FitterBase.h:146
-
bool fTestLikelihood
Necessary for some fitting algorithms like PSO.
Definition FitterBase.h:149
+
unsigned int TotalNSamples
Total number of samples used.
Definition FitterBase.h:120
+
double logLCurr
current likelihood
Definition FitterBase.h:101
+
double osc_llh
Definition FitterBase.h:111
+
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:115
+
int auto_save
auto save every N steps
Definition FitterBase.h:147
+
bool fTestLikelihood
Necessary for some fitting algorithms like PSO.
Definition FitterBase.h:150
virtual ~FitterBase()
Destructor for the FitterBase class.
-
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:144
-
bool save_nominal
save nominal matrix info or not
Definition FitterBase.h:151
-
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:117
+
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:145
+
bool save_nominal
save nominal matrix info or not
Definition FitterBase.h:152
+
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:118
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
-
Custom exception class for MaCh3 errors.
+
Custom exception class for MaCh3 errors.
+
MaCh3Modes_t GetMode(const std::string &name)
KS: Get mode number based on name, if mode not known you will get UNKNOWN_BAD.
std::string GetMaCh3ModeName(const int Index)
KS: Get normal name of mode, if mode not known you will get UNKNOWN_BAD.
-
MaCh3Modes_t GetMode(std::string name)
KS: Get mode number based on name, if mode not known you will get UNKNOWN_BAD.
-
Base class responsible for handling of systematic error parameters. Capable of using PCA or using ada...
-
void SetBranches(TTree &tree, bool SaveProposal=false)
set branches for output file
-
virtual std::vector< double > getNominalArray()
+
Base class responsible for handling of systematic error parameters. Capable of using PCA or using ada...
+
void SetBranches(TTree &tree, bool SaveProposal=false)
set branches for output file
+
virtual std::vector< double > getNominalArray()
Class responsible for handling of neutrino oscillation parameters.
The manager class is responsible for managing configurations and settings.
Definition manager.h:28
void SaveSettings(TFile *const OutputFile)
Add manager useful information's to TFile, in most cases to Fitter.
Definition manager.cpp:58
diff --git a/FitterBase_8h_source.html b/FitterBase_8h_source.html index 03225331d..63472f105 100644 --- a/FitterBase_8h_source.html +++ b/FitterBase_8h_source.html @@ -85,160 +85,161 @@
Go to the documentation of this file.
1#pragma once
2
-
3#include <iostream>
-
4#include <fstream>
-
5#include <sstream>
-
6
- - - -
10
-
11#include "manager/manager.h"
-
12#include "mcmc/MCMCProcessor.h"
-
13
-
14//KS: Joy of forward declaration https://gieseanw.wordpress.com/2018/02/25/the-joys-of-forward-declarations-results-from-the-real-world/
-
15class TRandom3;
-
16class TStopwatch;
-
17class TTree;
- -
19class TDirectory;
-
20
-
- -
24 public:
-
27 FitterBase(manager * const fitMan);
-
29 virtual ~FitterBase();
-
30
- -
34
- -
38
- -
42
- -
47
-
49 virtual void runMCMC() = 0;
-
50
-
53 void DragRace(const int NLaps = 100);
-
54
-
56 void RunLLHScan();
-
57
- -
60
-
63 void Run2DLLHScan();
-
64
-
67 void RunSigmaVar();
-
68
-
70 virtual inline std::string GetName()const {return "FitterBase";};
-
71 protected:
-
73 void ProcessMCMC();
-
74
-
76 void PrepareOutput();
-
77
-
79 void SaveOutput();
-
80
-
82 void SaveSettings();
-
83
- -
90
- -
93
- -
96
-
98 unsigned int step;
-
100 double logLCurr;
-
102 double logLProp;
-
104 double accProb;
- -
107
-
110 double osc_llh;
-
112 double *sample_llh;
-
114 double *syst_llh;
-
115
-
117 std::vector<samplePDFBase*> samples;
-
119 unsigned int TotalNSamples;
-
120
-
122 std::vector<covarianceBase*> systematics;
-
123
- - -
128
- - -
134 double stepTime;
-
135
- -
138
- - - - -
147
- - - -
154
- - - -
161
-
162 #ifdef DEBUG
-
164 bool debug;
-
166 std::ofstream debugFile;
-
167 #endif
-
168};
+
3// C++ includes
+
4#include <iostream>
+
5#include <fstream>
+
6#include <sstream>
+
7
+
8// MaCh3 Includes
+ + + +
12#include "manager/manager.h"
+
13#include "mcmc/MCMCProcessor.h"
+
14
+
15//KS: Joy of forward declaration https://gieseanw.wordpress.com/2018/02/25/the-joys-of-forward-declarations-results-from-the-real-world/
+
16class TRandom3;
+
17class TStopwatch;
+
18class TTree;
+ +
20class TDirectory;
+
21
+
+ +
25 public:
+
28 FitterBase(manager * const fitMan);
+
30 virtual ~FitterBase();
+
31
+ +
35
+ +
39
+ +
43
+ +
48
+
50 virtual void runMCMC() = 0;
+
51
+
54 void DragRace(const int NLaps = 100);
+
55
+
57 void RunLLHScan();
+
58
+ +
61
+
64 void Run2DLLHScan();
+
65
+
68 void RunSigmaVar();
+
69
+
71 virtual inline std::string GetName()const {return "FitterBase";};
+
72 protected:
+
74 void ProcessMCMC();
+
75
+
77 void PrepareOutput();
+
78
+
80 void SaveOutput();
+
81
+
83 void SaveSettings();
+
84
+ +
91
+ +
94
+ +
97
+
99 unsigned int step;
+
101 double logLCurr;
+
103 double logLProp;
+
105 double accProb;
+ +
108
+
111 double osc_llh;
+
113 double *sample_llh;
+
115 double *syst_llh;
+
116
+
118 std::vector<samplePDFBase*> samples;
+
120 unsigned int TotalNSamples;
+
121
+
123 std::vector<covarianceBase*> systematics;
+
124
+ + +
129
+ + +
135 double stepTime;
+
136
+ +
139
+ + + + +
148
+ + + +
155
+ + + +
162
+
163 #ifdef DEBUG
+
165 bool debug;
+
167 std::ofstream debugFile;
+
168 #endif
+
169};
-
169
+
170
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Base class for implementing fitting algorithms.
Definition FitterBase.h:23
-
MaCh3Modes * Modes
MaCh3 Modes.
Definition FitterBase.h:95
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Base class for implementing fitting algorithms.
Definition FitterBase.h:24
+
MaCh3Modes * Modes
MaCh3 Modes.
Definition FitterBase.h:96
void RunLLHScan()
Perform a 1D likelihood scan.
-
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:125
-
double logLProp
proposed likelihood
Definition FitterBase.h:102
+
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:126
+
double logLProp
proposed likelihood
Definition FitterBase.h:103
virtual void runMCMC()=0
The specific fitting algorithm implemented in this function depends on the derived class....
void addSystObj(covarianceBase *cov)
This function adds a Covariance object to the analysis framework. The Covariance object will be utili...
void ProcessMCMC()
Process MCMC output.
-
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:132
-
covarianceOsc * osc2
handles oscillation parameters
Definition FitterBase.h:127
-
int accCount
counts accepted steps
Definition FitterBase.h:106
-
TRandom3 * random
Random number.
Definition FitterBase.h:137
-
virtual std::string GetName() const
Get name of class.
Definition FitterBase.h:70
-
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:122
-
bool OutputPrepared
Checks if output prepared not repeat some operations.
Definition FitterBase.h:160
+
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:133
+
covarianceOsc * osc2
handles oscillation parameters
Definition FitterBase.h:128
+
int accCount
counts accepted steps
Definition FitterBase.h:107
+
TRandom3 * random
Random number.
Definition FitterBase.h:138
+
virtual std::string GetName() const
Get name of class.
Definition FitterBase.h:71
+
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:123
+
bool OutputPrepared
Checks if output prepared not repeat some operations.
Definition FitterBase.h:161
void SaveOutput()
Save output and close files.
-
TFile * outputFile
Output.
Definition FitterBase.h:140
+
TFile * outputFile
Output.
Definition FitterBase.h:141
void SaveSettings()
Save the settings that the MCMC was run with.
-
bool SaveProposal
Save proposal at each step.
Definition FitterBase.h:153
-
manager * fitMan
The manager.
Definition FitterBase.h:92
-
unsigned int step
current state
Definition FitterBase.h:98
+
bool SaveProposal
Save proposal at each step.
Definition FitterBase.h:154
+
manager * fitMan
The manager.
Definition FitterBase.h:93
+
unsigned int step
current state
Definition FitterBase.h:99
void PrepareOutput()
Prepare the output file.
-
bool SettingsSaved
Checks if setting saved not repeat some operations.
Definition FitterBase.h:158
-
double accProb
current acceptance prob
Definition FitterBase.h:104
+
bool SettingsSaved
Checks if setting saved not repeat some operations.
Definition FitterBase.h:159
+
double accProb
current acceptance prob
Definition FitterBase.h:105
void GetStepScaleBasedOnLLHScan()
LLH scan is good first estimate of step scale.
-
bool FileSaved
Checks if file saved not repeat some operations.
Definition FitterBase.h:156
+
bool FileSaved
Checks if file saved not repeat some operations.
Definition FitterBase.h:157
void RunSigmaVar()
Perform a 2D and 1D sigma var for all samples.
-
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:112
-
double stepTime
Time of single step.
Definition FitterBase.h:134
-
TDirectory * CovFolder
Output cov folder.
Definition FitterBase.h:142
-
TStopwatch * clock
tells global time how long fit took
Definition FitterBase.h:130
+
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:113
+
double stepTime
Time of single step.
Definition FitterBase.h:135
+
TDirectory * CovFolder
Output cov folder.
Definition FitterBase.h:143
+
TStopwatch * clock
tells global time how long fit took
Definition FitterBase.h:131
void addOscHandler(covarianceOsc *oscf)
Adds an oscillation handler for covariance objects.
TGraphAsymmErrors * MakeAsymGraph(TH1D *sigmaArrayLeft, TH1D *sigmaArrayCentr, TH1D *sigmaArrayRight, std::string title)
Used by sigma variation, check how 1 sigma changes spectra.
void DragRace(const int NLaps=100)
Calculates the required time for each sample or covariance object in a drag race simulation....
void Run2DLLHScan()
Perform a 2D likelihood scan.
void addSamplePDF(samplePDFBase *sample)
This function adds a sample PDF object to the analysis framework. The sample PDF object will be utili...
-
unsigned int TotalNSamples
Total number of samples used.
Definition FitterBase.h:119
-
double logLCurr
current likelihood
Definition FitterBase.h:100
-
double osc_llh
Definition FitterBase.h:110
-
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:114
-
int auto_save
auto save every N steps
Definition FitterBase.h:146
-
bool fTestLikelihood
Necessary for some fitting algorithms like PSO.
Definition FitterBase.h:149
+
unsigned int TotalNSamples
Total number of samples used.
Definition FitterBase.h:120
+
double logLCurr
current likelihood
Definition FitterBase.h:101
+
double osc_llh
Definition FitterBase.h:111
+
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:115
+
int auto_save
auto save every N steps
Definition FitterBase.h:147
+
bool fTestLikelihood
Necessary for some fitting algorithms like PSO.
Definition FitterBase.h:150
virtual ~FitterBase()
Destructor for the FitterBase class.
-
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:144
-
bool save_nominal
save nominal matrix info or not
Definition FitterBase.h:151
-
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:117
-
KS: Class describing MaCh3 modes used in the analysis, it is being initialised from config.
Definition MaCh3Modes.h:32
-
Base class responsible for handling of systematic error parameters. Capable of using PCA or using ada...
+
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:145
+
bool save_nominal
save nominal matrix info or not
Definition FitterBase.h:152
+
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:118
+
KS: Class describing MaCh3 modes used in the analysis, it is being initialised from config.
Definition MaCh3Modes.h:33
+
Base class responsible for handling of systematic error parameters. Capable of using PCA or using ada...
Class responsible for handling of neutrino oscillation parameters.
The manager class is responsible for managing configurations and settings.
Definition manager.h:28
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
diff --git a/GetPenaltyTerm_8cpp.html b/GetPenaltyTerm_8cpp.html index 0a473b198..9fd1f816a 100644 --- a/GetPenaltyTerm_8cpp.html +++ b/GetPenaltyTerm_8cpp.html @@ -413,8 +413,8 @@

std::vector< TString > BranchNames

void ReadXSecFile(std::string inputFile)
std::vector< bool > isFlat
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
void PrintProgressBar(const int Done, const int All)
KS: Simply print progress bar.
Definition Monitor.cpp:193
@@ -462,9 +462,9 @@

60}
void GetPenaltyTerm(std::string inputFile, std::string configFile)
YAML::Node config
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
-
Custom exception class for MaCh3 errors.
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
Custom exception class for MaCh3 errors.
@@ -568,8 +568,8 @@

394 TempFile->Close();
395 delete TempFile;
396}
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:144
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:147
void PrintConfig(const YAML::Node &node)
KS: Print Yaml config using logger.
Definition Monitor.cpp:279
diff --git a/GetPenaltyTerm_8cpp_source.html b/GetPenaltyTerm_8cpp_source.html index 972a32bc2..a360d70c1 100644 --- a/GetPenaltyTerm_8cpp_source.html +++ b/GetPenaltyTerm_8cpp_source.html @@ -495,13 +495,13 @@
void ReadXSecFile(std::string inputFile)
std::vector< bool > isFlat
YAML::Node config
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:144
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:147
+
Custom exception class for MaCh3 errors.
void PrintProgressBar(const int Done, const int All)
KS: Simply print progress bar.
Definition Monitor.cpp:193
void PrintConfig(const YAML::Node &node)
KS: Print Yaml config using logger.
Definition Monitor.cpp:279
diff --git a/GetPostfitParamPlots_8cpp.html b/GetPostfitParamPlots_8cpp.html index 2b87de188..28fa8a0f5 100644 --- a/GetPostfitParamPlots_8cpp.html +++ b/GetPostfitParamPlots_8cpp.html @@ -273,7 +273,7 @@

105 blockHist->GetXaxis()->LabelsOption("v");
106 }
107}
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
@@ -981,7 +981,7 @@

985}
void GetViolinPlots(std::string FileName1="", std::string FileName2="")
void GetPostfitParamPlots()
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
diff --git a/GetPostfitParamPlots_8cpp_source.html b/GetPostfitParamPlots_8cpp_source.html index 98aac6c4e..fd2f523dd 100644 --- a/GetPostfitParamPlots_8cpp_source.html +++ b/GetPostfitParamPlots_8cpp_source.html @@ -1150,8 +1150,8 @@
void setTH1Style(TH1 *hist, std::string styleName)
TPad * p2
void MakeFDDetPlots()
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
diff --git a/LikelihoodFit_8cpp_source.html b/LikelihoodFit_8cpp_source.html index cdafb7513..20dbdf9d1 100644 --- a/LikelihoodFit_8cpp_source.html +++ b/LikelihoodFit_8cpp_source.html @@ -246,25 +246,25 @@
154
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Base class for implementing fitting algorithms.
Definition FitterBase.h:23
-
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:125
-
double logLProp
proposed likelihood
Definition FitterBase.h:102
-
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:132
-
int accCount
counts accepted steps
Definition FitterBase.h:106
-
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:122
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Base class for implementing fitting algorithms.
Definition FitterBase.h:24
+
covarianceOsc * osc
handles oscillation parameters
Definition FitterBase.h:126
+
double logLProp
proposed likelihood
Definition FitterBase.h:103
+
TStopwatch * stepClock
tells how long single step/fit iteration took
Definition FitterBase.h:133
+
int accCount
counts accepted steps
Definition FitterBase.h:107
+
std::vector< covarianceBase * > systematics
Systematic holder.
Definition FitterBase.h:123
void SaveSettings()
Save the settings that the MCMC was run with.
-
unsigned int step
current state
Definition FitterBase.h:98
+
unsigned int step
current state
Definition FitterBase.h:99
void PrepareOutput()
Prepare the output file.
-
double accProb
current acceptance prob
Definition FitterBase.h:104
-
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:112
-
double stepTime
Time of single step.
Definition FitterBase.h:134
-
double logLCurr
current likelihood
Definition FitterBase.h:100
-
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:114
-
int auto_save
auto save every N steps
Definition FitterBase.h:146
-
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:144
-
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:117
+
double accProb
current acceptance prob
Definition FitterBase.h:105
+
double * sample_llh
store the llh breakdowns
Definition FitterBase.h:113
+
double stepTime
Time of single step.
Definition FitterBase.h:135
+
double logLCurr
current likelihood
Definition FitterBase.h:101
+
double * syst_llh
systematic llh breakdowns
Definition FitterBase.h:115
+
int auto_save
auto save every N steps
Definition FitterBase.h:147
+
TTree * outTree
Output tree with posteriors.
Definition FitterBase.h:145
+
std::vector< samplePDFBase * > samples
Sample holder.
Definition FitterBase.h:118
int NParsPCA
Number of all parameters from all covariances in PCA base.
LikelihoodFit(manager *const fitMan)
Constructor.
virtual ~LikelihoodFit()
Destructor.
diff --git a/LikelihoodFit_8h_source.html b/LikelihoodFit_8h_source.html index b783c8b49..b7fe56343 100644 --- a/LikelihoodFit_8h_source.html +++ b/LikelihoodFit_8h_source.html @@ -108,8 +108,8 @@
33
-
Base class for implementing fitting algorithms.
Definition FitterBase.h:23
-
manager * fitMan
The manager.
Definition FitterBase.h:92
+
Base class for implementing fitting algorithms.
Definition FitterBase.h:24
+
manager * fitMan
The manager.
Definition FitterBase.h:93
Implementation of base Likelihood Fit class, it is mostly responsible for likelihood calculation whil...
int NParsPCA
Number of all parameters from all covariances in PCA base.
int GetNPars()
Get total number of params, this sums over all covariance objects.
diff --git a/MCMCProcessor_8cpp_source.html b/MCMCProcessor_8cpp_source.html index acee56ced..6e3a3b234 100644 --- a/MCMCProcessor_8cpp_source.html +++ b/MCMCProcessor_8cpp_source.html @@ -3151,7 +3151,7 @@
2998// ***************
2999// Find Param Index based on name
-
3000int MCMCProcessor::GetParamIndexFromName(const std::string Name){
+
3000int MCMCProcessor::GetParamIndexFromName(const std::string& Name){
3001// **************************
3002 int ParamNo = _UNDEF_;
3003 for (int i = 0; i < nDraw; ++i)
@@ -3217,7 +3217,7 @@
3059 for(unsigned int k = 0; k < ParNames.size(); ++k)
3060 {
3061 //KS: First we need to find parameter number based on name
-
3062 int ParamNo = GetParamIndexFromName(ParNames[k]);
+
3062 int ParamNo = GetParamIndexFromName(ParNames[k]);
3063 bool skip = false;
3064 if(ParamNo == _UNDEF_)
3065 {
@@ -3294,7 +3294,7 @@
3134 for(unsigned int k = 0; k < ParNames.size(); ++k)
3135 {
3136 //KS: First we need to find parameter number based on name
-
3137 int ParamNo = GetParamIndexFromName(ParNames[k]);
+
3137 int ParamNo = GetParamIndexFromName(ParNames[k]);
3138 bool skip = false;
3139 if(ParamNo == _UNDEF_)
3140 {
@@ -3361,7 +3361,7 @@
3199 for(unsigned int k = 0; k < ParNames.size(); ++k)
3200 {
3201 //KS: First we need to find parameter number based on name
-
3202 int ParamNo = GetParamIndexFromName(ParNames[k]);
+
3202 int ParamNo = GetParamIndexFromName(ParNames[k]);
3203 bool skip = false;
3204 if(ParamNo == _UNDEF_)
3205 {
@@ -3513,7 +3513,7 @@
3349 for(unsigned int k = 0; k < Names.size(); ++k)
3350 {
3351 //KS: First we need to find parameter number based on name
-
3352 int ParamNo = GetParamIndexFromName(Names[k]);
+
3352 int ParamNo = GetParamIndexFromName(Names[k]);
3353 if(ParamNo == _UNDEF_)
3354 {
3355 MACH3LOG_WARN("Couldn't find param {}. Can't reweight Prior", Names[k]);
@@ -4801,18 +4801,18 @@
@ kXSecPar
@ kNParameterEnum
@ kFDDetPar
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
#define MACH3LOG_WARN
Definition MaCh3Logger.h:14
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
#define MACH3LOG_WARN
Definition MaCh3Logger.h:17
double * EffectiveSampleSize
Definition RHat.cpp:57
double GetSigmaValue(const int sigma)
KS: Convert sigma from normal distribution into percentage.
double GetSubOptimality(std::vector< double > EigenValues, const int TotalTarameters)
Based on http://probability.ca/jeff/ftpdir/adaptex.pdf.
std::string GetJeffreysScale(const double BayesFactor)
KS: Following H. Jeffreys. The theory of probability. UOP Oxford, 1998. DOI: 10.2307/3619118.
std::string GetDunneKaboth(const double BayesFactor)
KS: Based on Table 1 in https://www.t2k.org/docs/technotes/435.
void RemoveFitter(TH1D *hist, std::string name)
KS: Remove fitted TF1 from hist to make comparison easier.
Definition Structs.cpp:437
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:144
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
YAML::Node TMacroToYAML(const TMacro &macro)
KS: Convert a ROOT TMacro object to a YAML node.
Definition YamlHelper.h:147
void ScanParameterOrder()
Scan order of params from a different groups.
int nBatches
Number of batches for Batched Mean.
TH1D * MakePrefit()
Prepare prefit histogram for parameter overlay plot.
@@ -4859,6 +4859,7 @@
TH2D * hviolin
Holds violin plot for all dials.
std::string StepCut
BurnIn Cuts.
void GetPostfit_Ind(TVectorD *&Central, TVectorD *&Errors, TVectorD *&Peaks, ParameterEnum kParam)
Or the individual post-fits.
+
int GetParamIndexFromName(const std::string &Name)
Get parameter number based on name.
void DrawCorrelations1D()
Draw 1D correlations which might be more helpful than looking at huge 2D Corr matrix.
void GetPostfit(TVectorD *&Central, TVectorD *&Errors, TVectorD *&Central_Gauss, TVectorD *&Errors_Gauss, TVectorD *&Peaks)
Get the post-fit results (arithmetic and Gaussian)
TVectorD * Means_Gauss
Vector with mean values using Gaussian fit.
@@ -4871,7 +4872,6 @@
TChain * Chain
Main chain storing all steps etc.
std::string MCMCFile
Name of MCMC file.
std::vector< std::string > ExcludedNames
-
int GetParamIndexFromName(const std::string Name)
Get parameter number based on name.
TVectorD * Errors_HPD_Negative
Vector with negative error (left hand side) values using Highest Posterior Density.
std::vector< std::vector< std::string > > CovPos
Covariance matrix name position.
double * ParamSums
Total parameter sum for each param.
diff --git a/MCMCProcessor_8h_source.html b/MCMCProcessor_8h_source.html index 2378ac1da..6bcef028b 100644 --- a/MCMCProcessor_8h_source.html +++ b/MCMCProcessor_8h_source.html @@ -219,7 +219,7 @@
193
195 const std::vector<TString>& GetBranchNames() const { return BranchNames;};
197 void GetNthParameter(const int param, double &Prior, double &PriorError, TString &Title);
-
199 int GetParamIndexFromName(const std::string Name);
+
199 int GetParamIndexFromName(const std::string& Name);
201 inline int GetnEntries(){return nEntries;};
203 inline int GetnSteps(){return nSteps;};
204
@@ -408,7 +408,7 @@
@ kNParameterEnum
@ kFDDetPar
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
void ScanParameterOrder()
Scan order of params from a different groups.
int nBatches
Number of batches for Batched Mean.
@@ -465,6 +465,7 @@
TH2D * hviolin
Holds violin plot for all dials.
std::string StepCut
BurnIn Cuts.
void GetPostfit_Ind(TVectorD *&Central, TVectorD *&Errors, TVectorD *&Peaks, ParameterEnum kParam)
Or the individual post-fits.
+
int GetParamIndexFromName(const std::string &Name)
Get parameter number based on name.
void DrawCorrelations1D()
Draw 1D correlations which might be more helpful than looking at huge 2D Corr matrix.
void SetnBatches(const int Batches)
Set value of Nbatches used for batched mean, this need to be done earlier as batches are made when re...
void GetPostfit(TVectorD *&Central, TVectorD *&Errors, TVectorD *&Central_Gauss, TVectorD *&Errors_Gauss, TVectorD *&Peaks)
Get the post-fit results (arithmetic and Gaussian)
@@ -484,7 +485,6 @@
TH1D * GetHpost(const int i)
Get 1D posterior for a given parameter.
std::vector< std::string > ExcludedNames
TH2D * GetHpost2D(const int i, const int j)
Get 2D posterior for a given parameter combination.
-
int GetParamIndexFromName(const std::string Name)
Get parameter number based on name.
TVectorD * Errors_HPD_Negative
Vector with negative error (left hand side) values using Highest Posterior Density.
std::vector< std::vector< std::string > > CovPos
Covariance matrix name position.
double * ParamSums
Total parameter sum for each param.
diff --git a/MaCh3Exception_8h_source.html b/MaCh3Exception_8h_source.html index 5a8dea0ac..c86b89803 100644 --- a/MaCh3Exception_8h_source.html +++ b/MaCh3Exception_8h_source.html @@ -85,44 +85,46 @@
Go to the documentation of this file.
1#pragma once
2
-
3#include <iostream>
-
4#include <string>
-
5#include <stdexcept>
-
6
- -
8
-
-
10class MaCh3Exception : public std::exception {
-
11public:
-
-
16 explicit MaCh3Exception(std::string File, int Line, std::string Message = "")
-
17 {
-
18 size_t lastSlashPos = File.find_last_of('/');
-
19 std::string fileName = (lastSlashPos != std::string::npos) ? File.substr(lastSlashPos + 1) : File;
-
20
-
21 errorMessage = ((Message.empty()) ? "Terminating MaCh3" : Message);
+
3// C++ Includes
+
4#include <iostream>
+
5#include <string>
+
6#include <stdexcept>
+
7
+
8// MaCh3 Includes
+ +
10
+
+
12class MaCh3Exception : public std::exception {
+
13public:
+
+
18 explicit MaCh3Exception(std::string File, int Line, std::string Message = "")
+
19 {
+
20 size_t lastSlashPos = File.find_last_of('/');
+
21 std::string fileName = (lastSlashPos != std::string::npos) ? File.substr(lastSlashPos + 1) : File;
22
-
23 MACH3LOG_ERROR("Find me here: {}::{}", fileName, Line);
-
24 }
+
23 errorMessage = ((Message.empty()) ? "Terminating MaCh3" : Message);
+
24
+
25 MACH3LOG_ERROR("Find me here: {}::{}", fileName, Line);
+
26 }
-
25
-
-
28 const char* what() const noexcept override {
-
29 return errorMessage.c_str();
-
30 }
+
27
+
+
30 const char* what() const noexcept override {
+
31 return errorMessage.c_str();
+
32 }
-
31
-
32private:
-
34 std::string errorMessage;
-
35};
+
33
+
34private:
+
36 std::string errorMessage;
+
37};
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Custom exception class for MaCh3 errors.
-
const char * what() const noexcept override
Returns the error message associated with this exception.
-
MaCh3Exception(std::string File, int Line, std::string Message="")
Constructs a MaCh3Exception object with the specified error message.
-
std::string errorMessage
The error message associated with this exception.
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Custom exception class for MaCh3 errors.
+
const char * what() const noexcept override
Returns the error message associated with this exception.
+
MaCh3Exception(std::string File, int Line, std::string Message="")
Constructs a MaCh3Exception object with the specified error message.
+
std::string errorMessage
The error message associated with this exception.
33}
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Custom exception class for MaCh3 errors.
YAML::Node const & raw()
Return config.
Definition manager.h:48
diff --git a/MaCh3Factory_8cpp_source.html b/MaCh3Factory_8cpp_source.html index 0aa392c59..79c94b7e7 100644 --- a/MaCh3Factory_8cpp_source.html +++ b/MaCh3Factory_8cpp_source.html @@ -120,9 +120,9 @@
std::unique_ptr< FitterBase > MaCh3FitterFactory(manager *fitMan, std::vector< samplePDFBase * > &Samples, std::vector< covarianceBase * > &Covariances)
-
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:15
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
-
Custom exception class for MaCh3 errors.
+
#define MACH3LOG_ERROR
Definition MaCh3Logger.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
+
Custom exception class for MaCh3 errors.
The manager class is responsible for managing configurations and settings.
Definition manager.h:28
YAML::Node const & raw()
Return config.
Definition manager.h:48
diff --git a/MaCh3Factory_8h_source.html b/MaCh3Factory_8h_source.html index bfcd5b94d..ca1b0629c 100644 --- a/MaCh3Factory_8h_source.html +++ b/MaCh3Factory_8h_source.html @@ -100,7 +100,7 @@
std::unique_ptr< FitterBase > MaCh3FitterFactory(manager *fitMan, std::vector< samplePDFBase > &Samples, std::vector< covarianceBase > &Covariances)
MaCh3 Factory initiates one of implemented fitting algorithms.
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
The manager class is responsible for managing configurations and settings.
Definition manager.h:28
diff --git a/MaCh3Logger_8h.html b/MaCh3Logger_8h.html index 128c43d1d..99ef3a12d 100644 --- a/MaCh3Logger_8h.html +++ b/MaCh3Logger_8h.html @@ -129,7 +129,7 @@

-

Definition at line 16 of file MaCh3Logger.h.

+

Definition at line 19 of file MaCh3Logger.h.

@@ -145,7 +145,7 @@

-

Definition at line 12 of file MaCh3Logger.h.

+

Definition at line 15 of file MaCh3Logger.h.

@@ -161,7 +161,7 @@

-

Definition at line 15 of file MaCh3Logger.h.

+

Definition at line 18 of file MaCh3Logger.h.

@@ -177,7 +177,7 @@

-

Definition at line 13 of file MaCh3Logger.h.

+

Definition at line 16 of file MaCh3Logger.h.

@@ -193,7 +193,7 @@

-

Definition at line 17 of file MaCh3Logger.h.

+

Definition at line 20 of file MaCh3Logger.h.

@@ -209,7 +209,7 @@

-

Definition at line 11 of file MaCh3Logger.h.

+

Definition at line 14 of file MaCh3Logger.h.

@@ -225,7 +225,7 @@

-

Definition at line 14 of file MaCh3Logger.h.

+

Definition at line 17 of file MaCh3Logger.h.

@@ -295,41 +295,41 @@

return 0;
}
int main(int argc, char *argv[])
-
#define MACH3LOG_INFO
Definition MaCh3Logger.h:13
-
void LoggerPrint(const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args)
KS: This is bit convoluted but this is to allow redirecting cout and errors from external library int...
Definition MaCh3Logger.h:57
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
#define MACH3LOG_INFO
Definition MaCh3Logger.h:16
+
void LoggerPrint(const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args)
KS: This is bit convoluted but this is to allow redirecting cout and errors from external library int...
Definition MaCh3Logger.h:60
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21
Note
second argument is lambda fucniton whih convers mach3 so template works, it is bit faff... This approach allows seamless integration of func into an existing logging mechanism without modifying func itself
-

Definition at line 57 of file MaCh3Logger.h.

-
58{
-
59 // Create a stringstream to capture the output
-
60 std::stringstream sss;
-
61 // Save the original stream buffers
-
62 std::streambuf* coutBuf = std::cout.rdbuf();
-
63 std::streambuf* cerrBuf = std::cerr.rdbuf();
-
64
-
65 // Redirect std::cout and std::cerr to the stringstream buffer
-
66 std::cout.rdbuf(sss.rdbuf());
-
67 std::cerr.rdbuf(sss.rdbuf());
-
68
-
69 // Call the provided function
-
70 func(std::forward<Args>(args)...);
+

Definition at line 60 of file MaCh3Logger.h.

+
61{
+
62 // Create a stringstream to capture the output
+
63 std::stringstream sss;
+
64 // Save the original stream buffers
+
65 std::streambuf* coutBuf = std::cout.rdbuf();
+
66 std::streambuf* cerrBuf = std::cerr.rdbuf();
+
67
+
68 // Redirect std::cout and std::cerr to the stringstream buffer
+
69 std::cout.rdbuf(sss.rdbuf());
+
70 std::cerr.rdbuf(sss.rdbuf());
71
-
72 // Restore the original stream buffers
-
73 std::cout.rdbuf(coutBuf);
-
74 std::cerr.rdbuf(cerrBuf);
-
75
-
76 std::string line;
-
77 while (std::getline(sss, line))
-
78 {
-
79 auto formatted_message = fmt::format("[{}] {}", LibName, line);
- -
81 }
-
82}
+
72 // Call the provided function
+
73 func(std::forward<Args>(args)...);
+
74
+
75 // Restore the original stream buffers
+
76 std::cout.rdbuf(coutBuf);
+
77 std::cerr.rdbuf(cerrBuf);
+
78
+
79 std::string line;
+
80 while (std::getline(sss, line))
+
81 {
+
82 auto formatted_message = fmt::format("[{}] {}", LibName, line);
+ +
84 }
+
85}
@@ -358,18 +358,18 @@

Definition at line 20 of file MaCh3Logger.h.

-
21{
-
22 //KS: %H for hour, %M for minute, %S for second, [%s:%#] for class and line
-
23 //For documentation see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
-
24 #ifdef DEBUG
-
25 //spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
-
26 spdlog::set_pattern("[%s:%#][%^%l%$] %v");
-
27 #else
-
28 //spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
-
29 spdlog::set_pattern("[%s][%^%l%$] %v");
-
30 #endif
-
31}
+

Definition at line 23 of file MaCh3Logger.h.

+
24{
+
25 //KS: %H for hour, %M for minute, %S for second, [%s:%#] for class and line
+
26 //For documentation see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
+
27 #ifdef DEBUG
+
28 //spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
+
29 spdlog::set_pattern("[%s:%#][%^%l%$] %v");
+
30 #else
+
31 //spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
+
32 spdlog::set_pattern("[%s][%^%l%$] %v");
+
33 #endif
+
34}
diff --git a/MaCh3Logger_8h_source.html b/MaCh3Logger_8h_source.html index 891ea51ac..41ea1feae 100644 --- a/MaCh3Logger_8h_source.html +++ b/MaCh3Logger_8h_source.html @@ -85,69 +85,72 @@
Go to the documentation of this file.
1#pragma once
2
-
3#include "spdlog/spdlog.h"
-
4#include <iostream>
-
5#include <sstream>
-
6#include <functional>
-
7#include <string>
-
8
-
9//KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/include/spdlog/spdlog.h#L284
-
10
-
11#define MACH3LOG_TRACE SPDLOG_TRACE
-
12#define MACH3LOG_DEBUG SPDLOG_DEBUG
-
13#define MACH3LOG_INFO SPDLOG_INFO
-
14#define MACH3LOG_WARN SPDLOG_WARN
-
15#define MACH3LOG_ERROR SPDLOG_ERROR
-
16#define MACH3LOG_CRITICAL SPDLOG_CRITICAL
-
17#define MACH3LOG_OFF SPDLOG_OFF
-
18
-
- -
21{
-
22 //KS: %H for hour, %M for minute, %S for second, [%s:%#] for class and line
-
23 //For documentation see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
-
24 #ifdef DEBUG
-
25 //spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
-
26 spdlog::set_pattern("[%s:%#][%^%l%$] %v");
-
27 #else
-
28 //spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
-
29 spdlog::set_pattern("[%s][%^%l%$] %v");
-
30 #endif
-
31}
+
3// spdlog Includes
+
4#include "spdlog/spdlog.h"
+
5
+
6// C++ Includes
+
7#include <iostream>
+
8#include <sstream>
+
9#include <functional>
+
10#include <string>
+
11
+
12//KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/include/spdlog/spdlog.h#L284
+
13
+
14#define MACH3LOG_TRACE SPDLOG_TRACE
+
15#define MACH3LOG_DEBUG SPDLOG_DEBUG
+
16#define MACH3LOG_INFO SPDLOG_INFO
+
17#define MACH3LOG_WARN SPDLOG_WARN
+
18#define MACH3LOG_ERROR SPDLOG_ERROR
+
19#define MACH3LOG_CRITICAL SPDLOG_CRITICAL
+
20#define MACH3LOG_OFF SPDLOG_OFF
+
21
+
+ +
24{
+
25 //KS: %H for hour, %M for minute, %S for second, [%s:%#] for class and line
+
26 //For documentation see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
+
27 #ifdef DEBUG
+
28 //spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
+
29 spdlog::set_pattern("[%s:%#][%^%l%$] %v");
+
30 #else
+
31 //spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
+
32 spdlog::set_pattern("[%s][%^%l%$] %v");
+
33 #endif
+
34}
-
32
-
56template <typename Func, typename LogFunc, typename... Args>
-
-
57void LoggerPrint(const std::string& LibName, LogFunc logFunction, Func&& func, Args&&... args)
-
58{
-
59 // Create a stringstream to capture the output
-
60 std::stringstream sss;
-
61 // Save the original stream buffers
-
62 std::streambuf* coutBuf = std::cout.rdbuf();
-
63 std::streambuf* cerrBuf = std::cerr.rdbuf();
-
64
-
65 // Redirect std::cout and std::cerr to the stringstream buffer
-
66 std::cout.rdbuf(sss.rdbuf());
-
67 std::cerr.rdbuf(sss.rdbuf());
-
68
-
69 // Call the provided function
-
70 func(std::forward<Args>(args)...);
+
35
+
59template <typename Func, typename LogFunc, typename... Args>
+
+
60void LoggerPrint(const std::string& LibName, LogFunc logFunction, Func&& func, Args&&... args)
+
61{
+
62 // Create a stringstream to capture the output
+
63 std::stringstream sss;
+
64 // Save the original stream buffers
+
65 std::streambuf* coutBuf = std::cout.rdbuf();
+
66 std::streambuf* cerrBuf = std::cerr.rdbuf();
+
67
+
68 // Redirect std::cout and std::cerr to the stringstream buffer
+
69 std::cout.rdbuf(sss.rdbuf());
+
70 std::cerr.rdbuf(sss.rdbuf());
71
-
72 // Restore the original stream buffers
-
73 std::cout.rdbuf(coutBuf);
-
74 std::cerr.rdbuf(cerrBuf);
-
75
-
76 std::string line;
-
77 while (std::getline(sss, line))
-
78 {
-
79 auto formatted_message = fmt::format("[{}] {}", LibName, line);
- -
81 }
-
82}
+
72 // Call the provided function
+
73 func(std::forward<Args>(args)...);
+
74
+
75 // Restore the original stream buffers
+
76 std::cout.rdbuf(coutBuf);
+
77 std::cerr.rdbuf(cerrBuf);
+
78
+
79 std::string line;
+
80 while (std::getline(sss, line))
+
81 {
+
82 auto formatted_message = fmt::format("[{}] {}", LibName, line);
+ +
84 }
+
85}
-
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:20
-
void LoggerPrint(const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args)
KS: This is bit convoluted but this is to allow redirecting cout and errors from external library int...
Definition MaCh3Logger.h:57
-
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:18
+
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition MaCh3Logger.h:23
+
void LoggerPrint(const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args)
KS: This is bit convoluted but this is to allow redirecting cout and errors from external library int...
Definition MaCh3Logger.h:60
+
Type GetFromManager(const YAML::Node &node, Type defval)
Get content of config file if node is not found take default value specified.
Definition YamlHelper.h:21