Skip to content

Commit

Permalink
Remove warninig related to system call on newer gcc, and furhter imrp…
Browse files Browse the repository at this point in the history
…ove doxy docuemtniaton
  • Loading branch information
KSkwarczynski committed Jul 3, 2024
1 parent 7081b9d commit 2be8c0a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
30 changes: 27 additions & 3 deletions covariance/covarianceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ class covarianceBase {
/// @brief Set matrix name
void setName(const char *name) { matrixName = name; }
/// @brief change parameter name
/// @param i Parameter index
void setParName(int i, char *name) { _fNames.at(i) = std::string(name); }
void setSingleParameter(const int parNo, const double parVal);
/// @brief Set all the covariance matrix parameters to a user-defined value
/// @param i Parameter index
void setPar(const int i, const double val);
/// @brief Set current parameter value
/// @param i Parameter index
void setParCurrProp(const int i, const double val);
/// @brief Set proposed parameter value
void setParProp(const int i, const double val) {
Expand All @@ -78,15 +81,20 @@ class covarianceBase {
}
void setParameters(std::vector<double> pars = std::vector<double>());
/// @brief Set if parameter should have flat prior or not
/// @param i Parameter index
void setFlatPrior(const int i, const bool eL);

/// @brief set branches for output file
void SetBranches(TTree &tree, bool SaveProposal = false);
/// @brief Set global step scale for covariance object
/// @param scale Value of global step scale
void setStepScale(const double scale);
/// @brief DB Function to set fIndivStepScale from a vector (Can be used from execs and inside covariance constructors)
/// @param ParameterIndex Parameter Index
/// @param StepScale Value of individual step scale
void setIndivStepScale(const int ParameterIndex, const double StepScale){ _fIndivStepScale.at(ParameterIndex) = StepScale; }
/// @brief DB Function to set fIndivStepScale from a vector (Can be used from execs and inside covariance constructors)
/// @param stepscale Vector of individual step scale, should have same
void setIndivStepScale(std::vector<double> stepscale);
/// @brief KS: In case someone really want to change this
inline void setPrintLength(const unsigned int PriLen) { PrintLength = PriLen; }
Expand All @@ -113,8 +121,9 @@ class covarianceBase {
/// @brief Return CalcLikelihood if some params were thrown out of boundary return _LARGE_LOGL_
virtual double GetLikelihood();

// Getters
/// @brief Return covariance matrix
TMatrixDSym *getCovMatrix() { return covMatrix; }
/// @brief Return inverted covariance matrix
TMatrixDSym *getInvCovMatrix() { return invCovMatrix; }
/// @brief Get if param has flat prior or not
/// @param i Parameter index
Expand All @@ -138,6 +147,7 @@ class covarianceBase {
std::string getInputFile() const { return inputFile; }

/// @brief Get diagonal error for ith parameter
/// @param i Parameter index
inline double getDiagonalError(const int i) { return std::sqrt((*covMatrix)(i,i)); }

// Adaptive Step Tuning Stuff
Expand Down Expand Up @@ -195,14 +205,24 @@ class covarianceBase {

virtual double getNominal(const int i) { return getParInit(i); }
inline double GetGenerated(const int i) { return _fGenerated[i];}
/// @brief Get upper parameter bound in which it is physically valid
/// @param i Parameter index
inline double GetUpperBound(const int i){ return _fUpBound[i];}
/// @brief Get lower parameter bound in which it is physically valid
/// @param i Parameter index
inline double GetLowerBound(const int i){ return _fLowBound[i]; }
inline double GetIndivStepScale(int ParameterIndex){return _fIndivStepScale.at(ParameterIndex); }
/// @brief Get individual step scale for selected parameter
/// @param ParameterIndex Parameter index
inline double GetIndivStepScale(const int ParameterIndex){return _fIndivStepScale.at(ParameterIndex); }
/// @brief Get current parameter value using PCA
/// @param i Parameter index
inline double getParProp_PCA(const int i) {
if (!pca) { MACH3LOG_ERROR("Am not running in PCA mode"); throw; }
return fParProp_PCA(i);
}

/// @brief Get current parameter value using PCA
/// @param i Parameter index
inline double getParCurr_PCA(const int i) {
if (!pca) { MACH3LOG_ERROR("Am not running in PCA mode"); throw; }
return fParCurr_PCA(i);
Expand Down Expand Up @@ -268,8 +288,9 @@ class covarianceBase {
else return _fNumPar;
}

// Printers
/// @brief Print nominal value for every parameter
void printNominal();
/// @brief Print nominal, current and proposed value for each parameter
void printNominalCurrProp();
void printPars();
/// @brief Print step scale for each parameter
Expand All @@ -283,11 +304,14 @@ class covarianceBase {
/// @brief fix parameters at prior values
void toggleFixAllParameters();
/// @brief fix parameter at prior values
/// @param i Parameter index
void toggleFixParameter(const int i);
/// @brief Fix parameter at prior values
/// @param name Name of parameter you want to fix
void toggleFixParameter(const std::string& name);

/// @brief Is parameter fixed or not
/// @param i Parameter index
bool isParameterFixed(const int i) {
if (_fError[i] < 0) { return true; }
else { return false; }
Expand Down
3 changes: 2 additions & 1 deletion covariance/covarianceOsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class covarianceOsc : public covarianceBase
inline int CheckBounds() override;
/// @brief Retrieves the proposed parameters.
double *getPropPars();
/// @brief Propose MCMC step, including mass fliping
/// @brief Propose MCMC step, including mass flipping
void proposeStep() override;
/// @brief Sets whether to flip delta M23.
void setFlipDeltaM23(bool flip){flipdelM = flip;}
Expand All @@ -28,6 +28,7 @@ class covarianceOsc : public covarianceBase
/// @warning May become deprecated
void useReactorPrior(bool reactor){reactorPrior = reactor;};
/// @brief Sets extra branches for processing.
/// @param tree ROOT tree to which we set additional variables
void setExtraBranches(TTree &tree);

/// @brief Get baseline
Expand Down
6 changes: 4 additions & 2 deletions manager/MaCh3Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ inline void SetMaCh3LoggerFormat()
//KS: %H for hour, %M for minute, %S for second, [%s:%#] for class and line
//For documentation see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
#ifdef DEBUG
spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
//spdlog::set_pattern("[%H:%M:%S][%s:%#][%^%l%$] %v");
spdlog::set_pattern("[%s:%#][%^%l%$] %v");
#else
spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
//spdlog::set_pattern("[%H:%M:%S][%s][%^%l%$] %v");
spdlog::set_pattern("[%s][%^%l%$] %v");
#endif
}

Expand Down
4 changes: 3 additions & 1 deletion mcmc/MCMCProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3399,7 +3399,9 @@ void MCMCProcessor::ReweightPrior(std::vector<std::string> Names, std::vector<do
std::string OutputFilename = MCMCFile + "_reweighted.root";

//KS: Simply create copy of file and add there new branch
system(("cp "+InputFile+" "+OutputFilename).c_str());
int ret = system(("cp " + InputFile + " " + OutputFilename).c_str());
if (ret != 0)
MACH3LOG_WARN("Error: system call to copy file failed with code {}", ret);

TFile *OutputChain = new TFile(OutputFilename.c_str(), "UPDATE");
OutputChain->cd();
Expand Down
11 changes: 11 additions & 0 deletions splines/SplineMonolith.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ class SMonolith : public SplineBase {
inline void Initialise();
/// @brief CW: Function to scan through the MasterSpline of TSpline3
/// @param MasterSpline Vector of TSpline3_red pointers which we strip back
/// @param NEvents Number of MC events
/// @param MaxPoints Maximal number of knots per splines
/// @param numParams Total number of parameters
/// @param numKnots Total number of knots, which is sum of individual knots per each spline
inline void ScanMasterSpline(std::vector<std::vector<TSpline3_red*> > &MasterSpline, unsigned int &NEvents, int &MaxPoints, short int &numParams, int &nSplines, unsigned int &numKnots);
/// @brief CW: Function to scan through the MasterSpline of TF1
/// @param MasterSpline Vector of TF1_red pointers which we strip back
/// @param NEvents Number of MC events
/// @param MaxPoints Maximal number of knots per splines
/// @param numParams Total number of parameters
inline void ScanMasterSpline(std::vector<std::vector<TF1_red*> > &MasterSpline, unsigned int &NEvents, int &MaxPoints, short int &numParams);
/// @brief CW: Prepare the TSpline3_red objects for the GPU
/// @param MasterSpline Vector of TSpline3_red pointers which we strip back
Expand Down Expand Up @@ -101,6 +108,9 @@ class SMonolith : public SplineBase {
/// @param spl pointer to TSpline3_red that will be checked
inline bool isFlat(TSpline3_red* &spl);
/// @brief CW: Gets the polynomial coefficients for TF1
/// @param spl pointer to TF1_red that will be checked
/// @param nPoints number of knots
/// @param coeffs Array holding coefficients for each knot
inline void getTF1Coeff(TF1_red* &spl, int &nPoints, float *&coeffs);

/// @brief CW:Code used in step by step reweighting, Find Spline Segment for each param
Expand All @@ -117,6 +127,7 @@ class SMonolith : public SplineBase {
/// @brief KS: Prepare spline file that can be used for fast loading
inline void PrepareSplineFile();
/// @brief KS: Load preprocessed spline file
/// @param FileName Path to ROOT file with predefined reduced Spline Monolith
inline void LoadSplineFile(std::string FileName);

/// Array of FastSplineInfo structs: keeps information on each xsec spline for fast evaluation
Expand Down

0 comments on commit 2be8c0a

Please sign in to comment.