From 205ae278c6c7bb537dfe5a8a6443174d70246181 Mon Sep 17 00:00:00 2001
From: Viktor Klochkov <v.klochkov@gsi.de>
Date: Wed, 11 Sep 2019 17:30:24 +0200
Subject: [PATCH] clion fixes

---
 glauber/Fitter.cpp          |  2 +-
 glauber/Fitter.h            | 16 ++++++++--------
 glauber/main.cpp            |  2 --
 src/BordersFinder.h         |  4 ++--
 src/BordersFinder2D.cpp     | 18 +++++++++---------
 src/BordersFinder2D.h       |  8 ++++----
 src/BordersFinderHelper.cpp |  2 +-
 src/BordersFinderHelper.h   |  4 ++--
 src/Container.h             |  2 +-
 src/Getter.h                |  2 +-
 10 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/glauber/Fitter.cpp b/glauber/Fitter.cpp
index 91e86e2..dfaf4c4 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 b0a96ed..cfd75b7 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 64f7c64..b49df89 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 f03b836..c2c9647 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 b715062..2eb8ce7 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 abbc304..4a665df 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 b34dc3c..fa3d067 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 36f477a..94cf34c 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 1a2216d..116f6a0 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 12a36b9..39a0a2d 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"
 
-- 
GitLab