#include "CentralityCalculator.h" #include #include #include #include #include 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(); } }