123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #include "CentralityCalculator.h"
- #include <TLine.h>
- #include <TCanvas.h>
- #include <TLatex.h>
- #include <iostream>
- #include <fstream>
- CentralityCalculator::CentralityCalculator()
- {
- RNG = new TRandom3();
- for (int i = 0; i <= NmultiplicityBins; ++i)
- {
- multiplicity_bins[i] = 1;
- }
- fEfficiency = 1.;
- }
- CentralityCalculator::~CentralityCalculator()
- {
- delete RNG;
- delete fHmult;
- }
- Int_t CentralityCalculator::Integrate(Int_t max_bin, Float_t sum)
- {
- for (Int_t mult_bin = 1; mult_bin <= max_bin; ++mult_bin)
- {
- if (fHmult->Integral(1, mult_bin, "WIDTH") >= sum)
- {
- //return floating-point multiplicity value
- return fHmult->GetBinLowEdge(mult_bin) + 1 - ((fHmult->Integral(1, mult_bin, "WIDTH") - sum) / fHmult->GetBinContent(mult_bin));
- }
- }
- return max_bin;
- }
- Int_t CentralityCalculator::GetCent(Int_t multiplicity)
- {
-
- int CentrBin = -1;
- // --- Centrality bins selection
- for (int i = 0; i < 10; ++i)
- {
- if (multiplicity >= lim.L[i] && multiplicity <= lim.H[i])
- {
- CentrBin = i;
- break;
- }
- else
- CentrBin = 10;
- }
- CentrBin *= 10;
- return CentrBin;
- }
- Int_t CentralityCalculator::GetCentrality(Int_t multiplicity)
- {
- Int_t cent = GetCent(multiplicity);
- return cent;
- }
- void CentralityCalculator::Calc()
- {
- lim = CentralityBorders(fHmult);
- }
- void CentralityCalculator::DrawHistogram(TString outName)
- {
- TH1F *hist = (TH1F *)fHmult->Clone();
- TLine line;
- TCanvas *canv = new TCanvas(Form("%s", "canvas"), Form("%s", "canvas"), 900, 650);
- canv->cd();
- canv->SetLogy();
- hist->Draw();
- line.SetLineColor(1);
- line.SetLineWidth(2);
- for (int i = 0; i < (Int_t)(NmultiplicityBins / 10); i++)
- {
- line.DrawLine(lim.L[i], 0., lim.L[i], hist->GetBinContent(hist->FindBin(lim.L[i])));
- }
- TLatex tex;
- tex.DrawLatexNDC(0.35, 0.85, Form("Au+Au, %s, #sqrt{s_{NN}}=%3.1f GeV", fModel.Data(), fEnergy));
- canv->SaveAs(Form("%s", outName.Data()));
- }
- void CentralityCalculator::GenerateMacro(TString outName)
- {
- const int NcentBins = 7; // We use only 0-80%
- std::cout << "Int_t cent8(Int_t mult)" << std::endl;
- std::cout << "{" << std::endl;
- std::cout << " Int_t fcent = -1;" << std::endl;
- std::cout << " if (mult >= " << lim.L[0] << ") fcent = 0;" << std::endl;
- for (int i = 1; i < NcentBins; i++)
- {
- std::cout << " if (mult >= " << lim.L[i + 1]
- << " && mult < " << lim.L[i] << ") fcent = "
- << i + 1 << ";" << std::endl;
- }
- std::cout << std::endl;
- std::cout << " return fcent;" << std::endl;
- std::cout << "}" << std::endl;
- if (outName != "")
- {
- std::ofstream myfile;
- myfile.open(outName.Data());
- myfile << "Int_t cent8(Int_t mult)" << std::endl;
- myfile << "{" << std::endl;
- myfile << " Int_t fcent = -1;" << std::endl;
- myfile << " if (mult >= " << lim.L[0] << ") fcent = 0;" << std::endl;
- for (int i = 1; i < NcentBins; i++)
- {
- myfile << " if (mult >= " << lim.L[i]
- << " && mult < " << lim.L[i] << ") fcent = "
- << i + 1 << ";" << std::endl;
- }
- myfile << std::endl;
- myfile << " return fcent;" << std::endl;
- myfile << "}" << std::endl;
- myfile.close();
- }
- }
|