From 179444361969721ca62ef81ec1dde94a1d98e15c Mon Sep 17 00:00:00 2001 From: Viktor Klochkov <v.klochkov@gsi.de> Date: Fri, 19 Jul 2019 10:53:17 +0200 Subject: [PATCH] some plotting --- main.cpp | 6 ++--- src/BordersFinderHelper.cpp | 47 ++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index 537cba7..97939b5 100644 --- a/main.cpp +++ b/main.cpp @@ -33,9 +33,9 @@ int main(int argc, char **argv) { std::unique_ptr <TH1F> histo {(TH1F*) (fIn->Get(argv[2]))}; Centrality::BordersFinder bf; bf.SetHisto(*histo); - bf.SetRanges( 10,0,100 ); // number of bins, min, max value + bf.SetRanges( 20,0,100 ); // number of bins, min, max value // bf.SetRanges( {0,10,30,60,100} ); // centrality bins borders with array - bf.IsSpectator(false); // true if impact parameter b correlated with estimator (spectators eneggy), + bf.IsSpectator(true); // true if impact parameter b correlated with estimator (spectators eneggy), // false - anticorrelated (multiplicity of produced particles) bf.FindBorders(); @@ -49,7 +49,7 @@ int main(int argc, char **argv) { std::unique_ptr<TH1F> h1d = bf.Convert(); bf.SetHisto(*h1d); - bf.SetRanges( 10,0,100 ); // number of bins, min, max value + bf.SetRanges( 20,0,100 ); // number of bins, min, max value // bf.SetRanges( {0,10,30,60,100} ); // centrality bins borders with array bf.IsSpectator(false); // true if impact parameter b correlated with estimator (spectators eneggy), // false - anticorrelated (multiplicity of produced particles) diff --git a/src/BordersFinderHelper.cpp b/src/BordersFinderHelper.cpp index 80b1877..b34dc3c 100644 --- a/src/BordersFinderHelper.cpp +++ b/src/BordersFinderHelper.cpp @@ -6,6 +6,10 @@ #include "TCanvas.h" #include "TLine.h" +#include "TStyle.h" + + + namespace Centrality { void BordersFinderHelper::QA(const Getter& getter, const TH1F& histo) const @@ -62,25 +66,50 @@ void BordersFinderHelper::PlotHisto(const Getter& getter, TH1F& histo) const void BordersFinderHelper::PlotHisto2D(const Getter& getter, TH2F& histo, TF1& func) const { - std::unique_ptr <TCanvas> c {new TCanvas("c", "", 1200, 800)}; + gStyle->SetOptStat(0000); + + std::unique_ptr <TCanvas> c {new TCanvas("c", "", 1000, 1000)}; + histo.GetXaxis()->SetRangeUser(0,1.1); + histo.GetYaxis()->SetRangeUser(0,1.1); histo.Draw("colz"); + func.SetLineColor(kBlack); func.Draw("same"); const auto& borders = getter.GetBorders2D(); TLine *line{nullptr}; - for (uint i=0; i<borders.size(); ++i) + for (uint i=0; i<borders.size()-1; ++i) { - const float x1 = 0.; - const float x2 = 1.; - - const float y1 = borders.at(i)[0] + borders.at(i)[1] * x1; - const float y2 = borders.at(i)[0] + borders.at(i)[1] * x2; + + float x1{0.}; + float x2{1.}; + float x{0.5}; + + for(int iter=0; iter<10; ++iter) + { + x=(x1+x2)/2; - line = new TLine(x1, y1, x2 ,y2); - line->Draw("same"); + if ( (func.Eval(x1) - borders.at(i)[0] - borders.at(i)[1] * x1) * (func.Eval(x) - borders.at(i)[0] - borders.at(i)[1] * x) < 0 ) + x2=x; + else + x1=x; + } + x1 = x - 0.06*borders.at(i)[1]; + x2 = x + 0.06*borders.at(i)[1]; + if (x1 < 0) x1=0; + + float y1 = borders.at(i)[0] + borders.at(i)[1] * x1; + float y2 = borders.at(i)[0] + borders.at(i)[1] * x2; + +// if (y1 < 0) y1=0; + + line = new TLine(x1, y1, x2 ,y2); + line->SetLineWidth(2); + line->SetLineColor(kRed); + line->Draw("same"); } + c->SetLogz(true); c->Write(name_ + "_histo_2d"); if (ispdf_) -- GitLab