diff --git a/glauber/Fitter.cpp b/glauber/Fitter.cpp index 91e86e2074678190d3c21cf9ea6637510409c935..dfaf4c4d307059ae0e8ebaee40ab46475999fae9 100644 --- a/glauber/Fitter.cpp +++ b/glauber/Fitter.cpp @@ -348,7 +348,7 @@ float Glauber::Fitter::NBD(float n, float mu, float k) const * @param Nevents * @return pointer to the histogram */ -std::unique_ptr<TH1F> Glauber::Fitter::GetModelHisto (const float range[2], TString name, const float par[3], int nEvents) +std::unique_ptr<TH1F> Glauber::Fitter::GetModelHisto (const float range[2], const TString& name, const float par[3], int nEvents) { const float f = par[0]; const float mu = par[1]; diff --git a/glauber/Fitter.h b/glauber/Fitter.h index b0a96ed0990d51d7403e866da3f4b9ecbcd9fbbb..cfd75b7b33fae6f4ca4e0765bf4659992e7fbaa8 100644 --- a/glauber/Fitter.h +++ b/glauber/Fitter.h @@ -24,27 +24,27 @@ namespace Glauber public: /** Default constructor **/ - Fitter() {}; - Fitter(std::unique_ptr<TTree> tree) ; + Fitter() = default;; + explicit Fitter(std::unique_ptr<TTree> tree) ; /** Destructor **/ - virtual ~Fitter(){}; + virtual ~Fitter()= default;; void Init(int nEntries); void SetGlauberFitHisto (Float_t f, Float_t mu, Float_t k, Int_t n = 10000, Bool_t Norm2Data = true); void NormalizeGlauberFit (); - void DrawHistos (Bool_t isSim = true, Bool_t isData = true, Bool_t isGlauber = false, Bool_t isNBD = false); + void DrawHistos (Bool_t isSim = true, Bool_t isData = true, Bool_t isGlauber = false, Bool_t isNBD = false) {}; float FitGlauber (float *par, Float_t f0, Int_t k0, Int_t k1, Int_t nEvents); void FindMuGoldenSection (Float_t *mu, Float_t *chi2, Float_t mu_min, Float_t mu_max, Float_t f, Float_t k, Int_t nEvents = 10000, Int_t nIter = 5); - Float_t GetChi2 (void) const; + Float_t GetChi2 () const; Float_t NBD(Float_t n, Float_t mu, Float_t k) const; void SetNBDhist(Float_t mu, Float_t k); float Nancestors(float f) const; float NancestorsMax(float f) const; - std::unique_ptr<TH1F> GetModelHisto (const Float_t range[2], TString name, const Float_t par[3], Int_t nEvents); + std::unique_ptr<TH1F> GetModelHisto (const Float_t range[2], const TString& name, const Float_t par[3], Int_t nEvents); // // Setters @@ -54,8 +54,8 @@ namespace Glauber void SetFitMaxBin (Int_t min) { fFitMaxBin = min; } void SetNormMinBin (Int_t min) { fNormMinBin = min; } void SetBinSize (Int_t size) { fBinSize = size; } - void SetOutDirName (TString name) { fOutDirName = name; } - void SetMode (const TString mode) { fMode = mode; } + void SetOutDirName (const TString& name) { fOutDirName = name; } + void SetMode (const TString& mode) { fMode = mode; } // // Getters diff --git a/glauber/main.cpp b/glauber/main.cpp index 64f7c6476f9e7cf45d3a21c4c7806fe5ffd1ae0d..b49df89fdc2c4fcc9afafaa2b2b14dc5d61b90bc 100644 --- a/glauber/main.cpp +++ b/glauber/main.cpp @@ -5,11 +5,9 @@ #include "FitterHelper.h" #include "TH1.h" -#include "TH2.h" #include "TFile.h" #include "TLegend.h" #include "TH2.h" - using namespace Glauber; int main(int argc, char *argv[]) diff --git a/src/BordersFinder.h b/src/BordersFinder.h index f03b836fdfc472351bba39651ea01907c6dbc8c6..c2c9647f67e0b41c3559d251b5c733c75174261c 100644 --- a/src/BordersFinder.h +++ b/src/BordersFinder.h @@ -16,7 +16,7 @@ class BordersFinder { public: - BordersFinder() {} + BordersFinder() = default; void FindBorders(); void SaveBorders(const std::string &filename, const std::string &getter_name); @@ -25,7 +25,7 @@ class BordersFinder { TH1F &GetHisto() { return histo_; } // not const to use Draw etc void SetNormalization(long int norm) { norm_ = norm; } - long int GetNormalization() const { return norm_; } + Double_t GetNormalization() const { return norm_; } void SetRanges(const std::vector<float> &ranges) { ranges_ = ranges; } void SetRanges(int n, float min, float max) { diff --git a/src/BordersFinder2D.cpp b/src/BordersFinder2D.cpp index b71506214b45c2f5584107ab7efbe14ccc46c1b1..2eb8ce701104c15ea193524744c77745bdd2b434 100644 --- a/src/BordersFinder2D.cpp +++ b/src/BordersFinder2D.cpp @@ -57,18 +57,18 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert() { // if ( histo2d_.Integral(iBin, iBin, 0, histo2d_.GetNbinsY()) <= 1. ) continue; - const float x1 = iBin==1 ? -0.2 : histo2d_.GetXaxis()->GetBinCenter(iBin-1); - const float x2 = histo2d_.GetXaxis()->GetBinCenter(iBin); + const auto x1 = iBin==1 ? -0.2 : histo2d_.GetXaxis()->GetBinCenter(iBin-1); + const auto x2 = histo2d_.GetXaxis()->GetBinCenter(iBin); const auto norm1 = FindNorm( par, x1); const auto norm2 = FindNorm( par, x2); - - const float integral = FindIntegral(norm1, norm2); + + const auto integral = FindIntegral(norm1, norm2); // std::cout << integral << std::endl; histo1d->SetBinContent(iBin, integral); } - return std::move(histo1d); + return histo1d; } /** @@ -138,7 +138,7 @@ void BordersFinder2D::SaveBorders2D(const std::string &filename, const std::stri } -void BordersFinder2D::Fit2D(const TString func) +void BordersFinder2D::Fit2D(const TString& func) { std::unique_ptr<TProfile> prof{ histo2d_.ProfileX() }; fit_ = new TF1("fit", func, histo2d_.GetXaxis()->GetXmin(), histo2d_.GetXaxis()->GetXmax() ); @@ -152,10 +152,10 @@ void BordersFinder2D::Fit2D(const TString func) * @param x argument * @return a0 and a1 parameters y = a0 + a1 * x */ -std::array <float,2> BordersFinder2D::FindNorm (const std::vector <double> par, float x) +std::array <float,2> BordersFinder2D::FindNorm (const std::vector <double>& par, float x) { - std::array <float,2> ret; - const float dx = (histo2d_.GetXaxis()->GetXmax() - histo2d_.GetXaxis()->GetXmin()) / 10000. ; + std::array <float,2> ret{}; + const auto dx = (histo2d_.GetXaxis()->GetXmax() - histo2d_.GetXaxis()->GetXmin()) / 10000. ; /* left */ const float y1 = polN(par, x - dx); diff --git a/src/BordersFinder2D.h b/src/BordersFinder2D.h index abbc304f22c693ffb20112efb57f11ea01c1447d..4a665df5c940836fefd48d76d0439dd4cc61b40a 100644 --- a/src/BordersFinder2D.h +++ b/src/BordersFinder2D.h @@ -23,15 +23,15 @@ class BordersFinder2D : public BordersFinder { public: - BordersFinder2D(){} + BordersFinder2D()= default; void SetHisto2D(TH2F&& histo2d) { histo2d_ = histo2d; } TH2F&& GetHisto2D() { return std::move(histo2d_); } void Init(); std::unique_ptr<TH1F> Convert(); - void Fit2D(const TString func); - std::array <float,2> FindNorm (const std::vector <double> par, float x); + void Fit2D(const TString& func); + std::array <float,2> FindNorm (const std::vector <double>& par, float x); float FindIntegral( const std::array <float,2> &norm1, const std::array <float,2> &norm2); void SaveBorders2D(const std::string &filename, const std::string &getter_name); @@ -42,7 +42,7 @@ public: * @param N order * @return */ - float polN (std::vector <double> par, float x) + static float polN (const std::vector <double>& par, float x) { float res{0.}; float xn{1.}; diff --git a/src/BordersFinderHelper.cpp b/src/BordersFinderHelper.cpp index b34dc3c83a675133832f1092736def9293d5b40f..fa3d06762c0f08c3bfd3576d9c24d16551c9c398 100644 --- a/src/BordersFinderHelper.cpp +++ b/src/BordersFinderHelper.cpp @@ -44,7 +44,7 @@ void BordersFinderHelper::PlotHisto(const Getter& getter, TH1F& histo) const std::unique_ptr <TCanvas> c {new TCanvas("c", "", 1200, 800)}; histo.Draw(); - auto borders = getter.GetBorders(); + const auto& borders = getter.GetBorders(); TLine *line; for (int i=0; i<borders.GetNbins(); ++i) diff --git a/src/BordersFinderHelper.h b/src/BordersFinderHelper.h index 36f477ad959f62a57138ac931eb2cbaa5e94b10b..94cf34ce901a42500d6fe54803f91e4c9d967da6 100644 --- a/src/BordersFinderHelper.h +++ b/src/BordersFinderHelper.h @@ -20,12 +20,12 @@ class BordersFinderHelper { public: - BordersFinderHelper(){} + BordersFinderHelper()= default; void QA(const Getter& getter, const TH1F &histo) const; void PlotHisto(const Getter& getter, TH1F& histo) const; void PlotHisto2D(const Getter& getter, TH2F& histo, TF1& func) const; - void SetName(const TString name) { name_ = name; } + void SetName(const TString& name) { name_ = name; } void SetIsPdf(bool is = true) { ispdf_ = is; } private: diff --git a/src/Container.h b/src/Container.h index 1a2216dbf8b74901d7b411746bfcb0b3b919f3b2..116f6a04041f6e77206e070a7cd4545111f2dc22 100644 --- a/src/Container.h +++ b/src/Container.h @@ -16,7 +16,7 @@ class Container{ public: - Container(){} + Container()= default; void AddCentralityEstimator(uint num, float centrality) { diff --git a/src/Getter.h b/src/Getter.h index 12a36b9e3d4288748a6d93cd0302b846ffbfbfb8..39a0a2d04d7df2259bca669e2ea5e02415a0eb5d 100644 --- a/src/Getter.h +++ b/src/Getter.h @@ -8,7 +8,7 @@ #ifndef CENTRALITY_GETTER_H #define CENTRALITY_GETTER_H -#include <assert.h> +#include <cassert> #include "vector" #include "array"