Skip to content

Commit

Permalink
📚 documentation added
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielWielanek committed Jan 24, 2025
1 parent f925084 commit 99d0fab
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 0 deletions.
135 changes: 135 additions & 0 deletions features/minimizer/FitParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
#include <TString.h>

namespace Hal {
/**
* class that represents the fitted parameters
* additionally support discretization of parameters, in such case user should
* configure map range and number of points.
* In discrete parameter only discrete values of parameters are used. The distance between
* all those values is always the same and equal to GetStepSize(), minimal/maximal values set during
* fitting should be always inside of map range
*/
class FitParam : public TObject {
Bool_t fIsFixed {kFALSE};
Bool_t fIsDiscrete {kFALSE};
Expand All @@ -33,37 +41,164 @@ namespace Hal {
public:
FitParam();
FitParam(const FitParam& other) = default;
/**
*
* @return true if parameter is discrete
*/
Bool_t IsDiscrete() const { return fIsDiscrete; };
/**
*
* @return true if parameter is fixed
*/
Bool_t IsFixed() const { return fIsFixed; };
/**
*
* @return true if map is set
*/
Bool_t IsMapSet() const { return fIsMapSet; }
/**
* recalculate limits according to map ranges etc.
*/
void Init();
/**
* set range of map, used mostly in discrete parameters
* @param min
* @param max
* @param points
*/
void SetMapRange(Double_t min, Double_t max, Int_t points);
/**
* like SetMapRange but use step instead of number of points
* @param min
* @param max
* @param step
*/
void SetMapRangeByStep(Double_t min, Double_t max, Double_t step);
/**
* set range of parameter (should be the same or smaller than map range
* @param min
* @param max
*/
void SetRange(Double_t min, Double_t max);
/**
* set start value
* @param val
*/
void SetStartVal(Double_t val) { fStart = val; };
/**
* set discrete flag
* @param isDiscrete
*/
void SetIsDiscrete(Bool_t isDiscrete) { fIsDiscrete = isDiscrete; }
/**
* set fixed parameter flag
* @param isFixed
*/
void SetIsFixed(Bool_t isFixed) { fIsFixed = isFixed; }
/**
* set map min
* @param mapMax
*/
void SetMapMax(Double_t mapMax) { fMapMax = mapMax; }
/**
* set map max
* @param mapMin
*/
void SetMapMin(Double_t mapMin) { fMapMin = mapMin; }
/**
* set maximal value of parameter
* @param max
*/
void SetMax(Double_t max) { fMax = max; }
/**
* set minimal value of parameter
* @param min
*/
void SetMin(Double_t min) { fMin = min; }
/**
* set parameter name
* @param name
*/
void SetParName(const TString& name) { fName = name; }
/**
* set value of fitted parameter
* @param val
*/
void SetFittedValue(Double_t val) { fFitted = val; };
/**
* set uncertainty of fitted parameter
* @param error
*/
void SetError(Double_t error) { fError = error; };
/**
* set min and max to be the same as map range
*/
void ExtendToMapLimts();
/**
* shrink min/max range to be inside of the map but not on the edges
*/
void ShirkBorders();
/**
*
* @return number of points
*/
Int_t GetNPoints() const { return fNPoint; };
/**
*
* @return step size
*/
Double_t GetStepSize() const { return fDParam; };
/**
*
* @return upper edge of map
*/
Double_t GetMapMax() const { return fMapMax; }
/**
*
* @return lower edge of map
*/
Double_t GetMapMin() const { return fMapMin; }
/**
*
* @return upper edge of parameter during fitting
*/
Double_t GetMax() const { return fMax; }
/**
*
* @return lower edge of paramter during fitting
*/
Double_t GetMin() const { return fMin; }
/**
*
* @return initial value
*/
Double_t GetStartVal() const { return fStart; };
/**
*
* @return fitted value
*/
Double_t GetFittedValue() const { return fFitted; };
/**
*
* @return uncertainty of parameter
*/
Double_t GetError() const { return fError; };
/**
* return 1.0/GetStepSize()
* @return
*/
Double_t GetOverStepSize() const { return fOverDParam; }
FitParam& operator=(const FitParam& other) = default;
/**
*
* @return parameter name
*/
TString GetParName() const { return fName; }
/**
*
* @return allowed values of discrete parameters, if parameter is continous
* returns min
*/
const std::vector<Double_t> GetValuesArray() const;
virtual void Print(Option_t* option = "") const;
virtual ~FitParam();
Expand Down
47 changes: 47 additions & 0 deletions features/minimizer/MultiDimDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,62 @@ namespace Hal {

public:
MultiDimDataManager() {};
/**
* add parameter
* @param name
* @param low
* @param high
* @param step
*/
void AddParameter(TString name, Double_t low, Double_t high, Double_t step);
/**
* add parameter
* @param param
*/
void AddParameter(FitParam& param);
/**
* initialize mamanger by initialization of parameters
*/
void Init();
/**
*
* @return number of parameters/dimensions
*/
inline Int_t GetParametersNo() const { return fParams.size(); }
/**
*
* @param paramsId
* @return index in TTree for given point in grid [par1 index ][par2 index] ..
*/
Int_t GetIndexInt(std::vector<int> paramsId) const;
/**
*
* @param paramsVal
* @return index in Tree for given coordinates (or the closest place)
*/
Int_t GetIndexAny(std::vector<double> paramsVal) const;
/**
* return parameter configuration copy
* @param pos
* @return
*/
const FitParam& GetParam(Int_t pos) const { return fParams[pos]; }
/**
* return array of allowed values for given entry in tree
* @param entry
* @return
*/
std::vector<Double_t> GetValues(Int_t entry) const;
/**
*
* @param entry
* @return positions in parameters space for given entry in tree
*/
std::vector<Int_t> GetIndexes(Int_t entry) const;
/**
* return copy of parameters
* @return
*/
std::vector<FitParam> GetParams() const { return fParams; }
virtual void Print(Option_t* option = "") const;
virtual ~MultiDimDataManager() {};
Expand Down
20 changes: 20 additions & 0 deletions features/minimizer/MultiDimExtrapolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,34 @@ class TFile;
namespace Hal {
class MultiDimFile;
class CorrelationHisto;
/**
* class for interpolation of multimensional data
*/
class MultiDimExtrapolator : public Object {
MultiDimFile* fInFile = {nullptr};

public:
MultiDimExtrapolator() {};
/**
* opens file with data, file should be created via MultiDimFile class
* @param file
*/
void OpenFile(TString file);
/**
* extrapolate value for given position
* @param pos
* @return
*/
Double_t Extrapolate(const std::vector<Double_t>& pos) const;
/**
*
* @return correlation histogram for all entries
*/
Hal::CorrelationHisto* GetCorrHisto() const;
/**
*
* @return information about file congiguration (e.g. number of dimensions etc.)
*/
MultiDimDataManager* GetConfig() const;
virtual ~MultiDimExtrapolator();
ClassDef(MultiDimExtrapolator, 1)
Expand Down
34 changes: 34 additions & 0 deletions features/minimizer/MultiDimFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class TTree;

namespace Hal {
class MultiDimDataManager;
/**
* class for storing/reading files with multidimensional data
*/
class MultiDimFile : public Object {
TFile* fFile;
TTree* fTree;
Expand All @@ -30,12 +33,43 @@ namespace Hal {
Bool_t Write() const { return (fMode == 1) ? kTRUE : kFALSE; };

public:
/**
*
* @param file name of the file
* @param option if "create" or "recreate" make new file, otherwise works in read mode
* @param writeParams if true positions in dimiensions are writted accoring to sheme
* Vector[value][par1][par2]....
*/
MultiDimFile(TString file = "", TString option = "", Bool_t writeParams = kTRUE);
/**
* set manager of information about parameters, used only in write mode
* @param mng
*/
void SetManager(const Hal::MultiDimDataManager& mng);
/**
* load entry from data
* @param i
*/
void GetEntry(Int_t i);
/**
*
* @return number of points
*/
Int_t GetEntries() const;
/**
* return values from tree
* if data writed with "writeParams" options vector looks like
* vec[data][par1][par2].. otherwise looks like vec[data]
*/
std::vector<Float_t>* GetValues() const { return fValues; }
/**
* fill tree
*/
void Fill();
/**
*
* @return configuration of file
*/
MultiDimDataManager* GetConfig() const { return fDataManager; }
virtual ~MultiDimFile();
ClassDef(MultiDimFile, 1)
Expand Down

0 comments on commit 99d0fab

Please sign in to comment.