diff --git a/include/Lattice.hh b/include/Lattice.hh new file mode 100644 index 0000000..a364d59 --- /dev/null +++ b/include/Lattice.hh @@ -0,0 +1,49 @@ +#ifndef Lattice_h +#define LAttice_h 1 + +#include +#include +#include +#include + +#include "TMath.h" + + +////////////////////////////////////////////////////////// +// // +// Create a lattice around the estimated mu, sigma // +// // +////////////////////////////////////////////////////////// + + +typedef struct { + + Double_t mu = 0.0; + Double_t sigma = 0.0; + }MuSigma; + +class Lattice{ + +public: + Lattice(); + ~Lattice(); + + void SetNop(Int_t num); + void SetPercent(Int_t num); + + void SetLattice(Double_t mu_est, Double_t sigma_est); + + MuSigma GetMuSigma(Int_t index); + + +private: + Int_t _nop; //number of points in [mu-_percent; mu+_percent] + Double_t _percent; + + std::vector ms_vect; + + +}; + + +#endif diff --git a/src/Lattice.cc b/src/Lattice.cc new file mode 100644 index 0000000..5a4f6b1 --- /dev/null +++ b/src/Lattice.cc @@ -0,0 +1,74 @@ +#include "Lattice.hh" + + +Lattice::Lattice() : _nop(100), _percent(0.2){;} + +Lattice::~Lattice(){;} + + +void Lattice::SetNop(Int_t num){ + + _nop = num; +} + + +void Lattice::SetPercent(Int_t num){ + + if((num > 1) && (num <= 100)) + _percent = num/100.0; + + else + std::cout << "Invalid value for percent, set to default" << std::endl; +} + + +MuSigma Lattice::GetMuSigma(Int_t index){ + + return ms_vect[index]; + +} + + +void Lattice::SetLattice(Double_t mu_est, Double_t sigma_est){ + + Double_t loc_sigma, loc_mu; + + Double_t sigmin, sigmax, mumin, mumax; + + Double_t ds, dm; + + mumax = mu_est + mu_est*_percent; + mumin = mu_est - mu_est*_percent; + sigmax = sigma_est + sigma_est*_percent; + sigmin = sigma_est - sigma_est*_percent; + + dm = (mumax-mumin) / _nop; + ds = (sigmax-sigmin) / _nop; + + loc_mu = mumin; + loc_sigma = sigmin; + + int i = 0; + + while(loc_mu <= mumax){ + + ms_vect.push_back(MuSigma()); + + ms_vect[i].mu = loc_mu; + ms_vect[i].sigma = loc_sigma; + + i++; + loc_mu += dm; + loc_sigma += ds; + + + } + +} + + + + + + +