Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 56 additions & 50 deletions PWGHF/HFC/Macros/DhCorrelationExtraction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@
#include <THnSparse.h>
#include <TLegend.h>
#include <TMath.h>
#include <TObject.h>
#include <TString.h>

#include <Rtypes.h>
#include <RtypesCore.h>

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <vector>

DhCorrelationExtraction::DhCorrelationExtraction() : // default constructor
fFileMass(nullptr),
Expand Down Expand Up @@ -93,6 +96,7 @@ DhCorrelationExtraction::DhCorrelationExtraction() : // default constructor
fBkgScaleFactor(1.),
fSgnYieldNorm(1.),
fBkgYield(1.),
fSBYield(1.),
fCorrectPoolsSeparately(kTRUE),
fSubtractSoftPiME(kFALSE),
fRebinAngCorr(kFALSE),
Expand All @@ -108,6 +112,7 @@ DhCorrelationExtraction::DhCorrelationExtraction() : // default constructor
}

DhCorrelationExtraction::DhCorrelationExtraction(const DhCorrelationExtraction& source) : // copy constructor
TObject(source),
fFileMass(source.fFileMass),
fFileSE(source.fFileSE),
fFileME(source.fFileME),
Expand Down Expand Up @@ -163,6 +168,7 @@ DhCorrelationExtraction::DhCorrelationExtraction(const DhCorrelationExtraction&
fBkgScaleFactor(source.fBkgScaleFactor),
fSgnYieldNorm(source.fSgnYieldNorm),
fBkgYield(source.fBkgYield),
fSBYield(source.fSBYield),
fCorrectPoolsSeparately(source.fCorrectPoolsSeparately),
fSubtractSoftPiME(source.fSubtractSoftPiME),
fRebinAngCorr(source.fRebinAngCorr),
Expand Down Expand Up @@ -213,44 +219,44 @@ Bool_t DhCorrelationExtraction::extractCorrelations(Double_t ptCandMin, Double_t
}

// Histograms definition
TH2D* hSeSign[fNpools];
TH2D* hMeSign[fNpools];
TH2D* hMeSignSoftPi[fNpools];
TH2D* hSeSideb[fNpools];
TH2D* hMeSideb[fNpools];
TH2D* hMeSidebSoftPi[fNpools];

TH2D* hCorrSign[fNpools];
TH2D* hCorrSideb[fNpools];

TH2D* h2DSign;
TH2D* h2DSideb;
TH2D* h2DSubtr;

TH2D* h2DFdTemplatePrompt;
TH2D* h2DFdTemplateNonPrompt;

TH1D* h1DSign;
TH1D* h1DSideb;
TH1D* h1DSubtr;
TH1D* h1DSignNorm;
TH1D* h1DSidebNorm;
TH1D* h1DSubtrNorm;
TH1D* h1DFdTemplatePrompt;
TH1D* h1DFdTemplateNonPrompt;
TH1D* h1DTemplateTotal;
TH1D* h1DSubtrFdNorm;
TH1D* h1DPrimaryPartCorr;
TH1D* h1DAllPartCorr;
TH1D* h1DSecPartFrac;
TH1D* h1DSubtrNormSecPart;
TH1D* h1DBaselineSubtr;
TH1D* h1DReflCorr;
TH1D* h1DReflCorrBaselineSubtr;
TH1D* hModul;
TH1D* hBeforeModulCorr;

Double_t fdPromptFrac;
std::vector<TH2D*> hSeSign(fNpools, nullptr);
std::vector<TH2D*> hMeSign(fNpools, nullptr);
std::vector<TH2D*> hMeSignSoftPi(fNpools, nullptr);
std::vector<TH2D*> hSeSideb(fNpools, nullptr);
std::vector<TH2D*> hMeSideb(fNpools, nullptr);
std::vector<TH2D*> hMeSidebSoftPi(fNpools, nullptr);

std::vector<TH2D*> hCorrSign(fNpools, nullptr);
std::vector<TH2D*> hCorrSideb(fNpools, nullptr);

TH2D* h2DSign{nullptr};
TH2D* h2DSideb{nullptr};
TH2D* h2DSubtr{nullptr};

TH2D* h2DFdTemplatePrompt{nullptr};
TH2D* h2DFdTemplateNonPrompt{nullptr};

TH1D* h1DSign{nullptr};
TH1D* h1DSideb{nullptr};
TH1D* h1DSubtr{nullptr};
TH1D* h1DSignNorm{nullptr};
TH1D* h1DSidebNorm{nullptr};
TH1D* h1DSubtrNorm{nullptr};
TH1D* h1DFdTemplatePrompt{nullptr};
TH1D* h1DFdTemplateNonPrompt{nullptr};
TH1D* h1DTemplateTotal{nullptr};
TH1D* h1DSubtrFdNorm{nullptr};
TH1D* h1DPrimaryPartCorr{nullptr};
TH1D* h1DAllPartCorr{nullptr};
TH1D* h1DSecPartFrac{nullptr};
TH1D* h1DSubtrNormSecPart{nullptr};
TH1D* h1DBaselineSubtr{nullptr};
TH1D* h1DReflCorr{nullptr};
TH1D* h1DReflCorrBaselineSubtr{nullptr};
TH1D* hModul{nullptr};
TH1D* hBeforeModulCorr{nullptr};

Double_t fdPromptFrac{0.};

// if (fIntegratePtBins && iBinPtHad>0) continue;

Expand Down Expand Up @@ -597,7 +603,7 @@ Bool_t DhCorrelationExtraction::extractCorrelations(Double_t ptCandMin, Double_t
}

Double_t const baselineFd = calculateBaseline(h1DTemplateTotal, kTRUE);
Double_t baselineData;
Double_t baselineData{};
if (fSecPartContamination) {
baselineData = calculateBaseline(h1DSubtrNormSecPart, kTRUE);
} else {
Expand Down Expand Up @@ -714,7 +720,7 @@ Bool_t DhCorrelationExtraction::extractCorrelations(Double_t ptCandMin, Double_t
cFinal->SaveAs(Form("Output_CorrelationExtraction_%s_Root/AzimCorrDistr_%s_Canvas_PtCand%.0fto%.0f_PoolInt_PtAssoc%.0fto%.0f.root", codeName.Data(), fDmesonLabel.Data(), ptCandMin, ptCandMax, ptHadMin, ptHadMax));

// Baseline subtraction
Double_t baselineData, baselineDataErr;
Double_t baselineData{}, baselineDataErr{};
TH1D* hBaseline = dynamic_cast<TH1D*>(h1DSubtrNorm->Clone("hBaseline"));
hBaseline->Sumw2();
if (fFDsubtraction) {
Expand Down Expand Up @@ -1080,8 +1086,8 @@ TH2D* DhCorrelationExtraction::getCorrelHisto(Int_t sEorMe, Int_t sorSb, Int_t p
Int_t const binExtPtCandMax = hSparse->GetAxis(2)->FindBin(ptCandMax - 0.01);
Int_t const binExtPtHadMin = hSparse->GetAxis(3)->FindBin(ptHadMin + 0.01); // axis3: ptHad
Int_t const binExtPtHadMax = hSparse->GetAxis(3)->FindBin(ptHadMax - 0.01);
Int_t binExtPoolMin;
Int_t binExtPoolMax;
Int_t binExtPoolMin{};
Int_t binExtPoolMax{};
if (fCorrectPoolsSeparately) {
binExtPoolMin = hSparse->GetAxis(4)->FindBin(pool + 0.01); // axis4: pool bin
binExtPoolMax = hSparse->GetAxis(4)->FindBin(pool + 0.99);
Expand Down Expand Up @@ -1230,8 +1236,8 @@ TH1D* DhCorrelationExtraction::getCorrelHistoSecondaryPart(Int_t partType, Doubl
Int_t const binExtPtCandMax = hSparse->GetAxis(2)->FindBin(ptCandMax - 0.01);
Int_t const binExtPtHadMin = hSparse->GetAxis(3)->FindBin(ptHadMin + 0.01); // axis3: ptHad
Int_t const binExtPtHadMax = hSparse->GetAxis(3)->FindBin(ptHadMax - 0.01);
Int_t binExtPoolMin;
Int_t binExtPoolMax;
Int_t binExtPoolMin{};
Int_t binExtPoolMax{};
if (partType == kAllPart) {
binExtPoolMin = 1;
binExtPoolMax = hSparse->GetAxis(4)->GetNbins();
Expand Down Expand Up @@ -1278,7 +1284,7 @@ TH1D* DhCorrelationExtraction::reflectCorrHistogram(TH1D*& histo)
// h1D -> GetXaxis() -> SetRange(bin0Phi, binPiPhi);

// reflection
Double_t reflectedContent, reflectedContentError;
Double_t reflectedContent{}, reflectedContentError{};
for (int iBin = 0; iBin < nBinsPhiRefl / 2; iBin++) {
reflectedContent = (histo->GetBinContent(bin0Phi - iBin - 1) + histo->GetBinContent(bin0Phi + iBin)) / 2;
std::cout << "[INFO] Paired bins for reflection: " << bin0Phi - iBin - 1 << " - " << bin0Phi + iBin << std::endl;
Expand All @@ -1302,12 +1308,12 @@ TH1D* DhCorrelationExtraction::reflectCorrHistogram(TH1D*& histo)
TH1D* DhCorrelationExtraction::reflectHistoRun2(TH1D* h, Double_t scale)
{

TH1D* h2 = new TH1D(Form("%sReflected", h->GetName()), Form("%sReflected", h->GetName()), h->GetNbinsX() / 2., 0., TMath::Pi());
TH1D* h2 = new TH1D(Form("%sReflected", h->GetName()), Form("%sReflected", h->GetName()), static_cast<int>(h->GetNbinsX() / 2.), 0., TMath::Pi());
for (Int_t j = 1; j <= h->GetNbinsX(); j++) {
Double_t const x = h->GetBinCenter(j);
Double_t const y0 = h->GetBinContent(j);
Double_t const ey0 = h->GetBinError(j);
Int_t j2;
Int_t j2{};
if (x > 0 && x < TMath::Pi()) {
j2 = h2->FindBin(x);
} else if (x < 0) {
Expand Down Expand Up @@ -1335,7 +1341,7 @@ Double_t DhCorrelationExtraction::getFdPromptFrac(Double_t ptCandMin, Double_t p

Int_t const binPtCandMin = h1D->GetXaxis()->FindBin(ptCandMin + 0.01);
Int_t const binPtCandMax = h1D->GetXaxis()->FindBin(ptCandMax - 0.01);
Double_t promptFraction;
Double_t promptFraction{};
if (binPtCandMin == binPtCandMax) {
promptFraction = h1D->GetBinContent(binPtCandMin);
} else {
Expand Down Expand Up @@ -1381,7 +1387,7 @@ Double_t DhCorrelationExtraction::calculateBaseline(TH1D*& histo, Bool_t totalRa
// total range = 2*Pi
// half range = Pi , for histogram reflected under symmetric assumption

Double_t baseline;
Double_t baseline{};
Int_t const nBinsPhi = histo->GetNbinsX();
Int_t const binPhiHalf = nBinsPhi / 2;
Int_t const binPhiHalfMinus1 = nBinsPhi / 2 - 1;
Expand Down Expand Up @@ -1461,7 +1467,7 @@ Double_t DhCorrelationExtraction::calculateBaselineError(TH1D*& histo, Bool_t to
// total range = 2*Pi
// half range = Pi , for histogram reflected under symmetric assumption

Double_t errBaseline;
Double_t errBaseline{};
Int_t const nBinsPhi = histo->GetNbinsX();
Int_t const binPhiHalf = nBinsPhi / 2;
Int_t const binPhiHalfMinus1 = nBinsPhi / 2 - 1;
Expand Down
2 changes: 1 addition & 1 deletion PWGHF/HFC/Macros/DhCorrelationExtraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class DhCorrelationExtraction : public TObject
/// Analysis methods
TH2D* getCorrelHisto(Int_t sEorMe, Int_t sorSb, Int_t pool, Double_t ptCandMin, Double_t ptCandMax, Double_t ptHadMin, Double_t ptHadMax);
TH2D* getFdTemplateHisto(Int_t promptOrFd, Double_t ptCandMin, Double_t ptCandMax, Double_t ptHadMin, Double_t ptHadMax);
TH1D* getCorrelHistoSecondaryPart(Int_t primaryPart, Double_t ptCandMin, Double_t ptCandMax, Double_t ptHadMin, Double_t ptHadMax);
TH1D* getCorrelHistoSecondaryPart(Int_t partType, Double_t ptCandMin, Double_t ptCandMax, Double_t ptHadMin, Double_t ptHadMax);
TH1D* reflectCorrHistogram(TH1D*& histo);
TH1D* reflectHistoRun2(TH1D* h, Double_t scale);
TH1D* evaluateMcClosModulations(Double_t ptCandMin, Double_t ptCandMax, Double_t ptHadMin, Double_t ptHadMax);
Expand Down
13 changes: 7 additions & 6 deletions PWGHF/HFC/Macros/ExtractOutputCorrel.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <RtypesCore.h>

#include <array>
#include <cstdio>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -74,8 +75,8 @@ void extractOutputCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.jso
// Load config
FILE* configFile = fopen(cfgFileName.Data(), "r");
Document config;
char readBuffer[65536];
FileReadStream is(configFile, readBuffer, sizeof(readBuffer));
std::array<char, 65536> readBuffer{};
FileReadStream is(configFile, readBuffer.data(), readBuffer.size());
config.ParseStream(is);
fclose(configFile);

Expand Down Expand Up @@ -162,10 +163,10 @@ void extractOutputCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.jso
const int nBinsPtCand = binsPtCandIntervals.size() - 1;
const int nBinsPtHad = binsPtHadIntervals.size() - 1;

TH1D* hCorrectedCorrel[nBinsPtCand][nBinsPtHad];
TH1D* hCorrectedCorrelBaselineSubtr[nBinsPtCand][nBinsPtHad];
TH1D* hCorrectedCorrelReflected[nBinsPtCand][nBinsPtHad];
TH1D* hCorrectedCorrelReflectedBaselineSubtr[nBinsPtCand][nBinsPtHad];
std::vector<std::vector<TH1D*>> hCorrectedCorrel(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));
std::vector<std::vector<TH1D*>> hCorrectedCorrelBaselineSubtr(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));
std::vector<std::vector<TH1D*>> hCorrectedCorrelReflected(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));
std::vector<std::vector<TH1D*>> hCorrectedCorrelReflectedBaselineSubtr(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));

// Create and set the correlation plotter class
auto* plotter = new DhCorrelationExtraction();
Expand Down
51 changes: 26 additions & 25 deletions PWGHF/HFC/Macros/FitCorrel.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
#include <TString.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TText.h>

#include <rapidjson/document.h>
#include <rapidjson/filereadstream.h>

#include <Rtypes.h>
#include <RtypesCore.h>

#include <array>
#include <cstddef>
#include <cstdio>
#include <iostream>
#include <string>
Expand All @@ -43,7 +44,7 @@
using namespace std;
using namespace rapidjson;

bool removeNSPeakLowPt = false;
const bool removeNSPeakLowPt = false;

template <typename ValueType>
void readArray(const Value& jsonArray, vector<ValueType>& output)
Expand Down Expand Up @@ -79,8 +80,8 @@ void fitCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.json")
// Load config
FILE* configFile = fopen(cfgFileName.Data(), "r");
Document config;
char readBuffer[65536];
FileReadStream is(configFile, readBuffer, sizeof(readBuffer));
std::array<char, 65536> readBuffer{};
FileReadStream is(configFile, readBuffer.data(), readBuffer.size());
config.ParseStream(is);
fclose(configFile);

Expand Down Expand Up @@ -118,7 +119,7 @@ void fitCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.json")
int const fixBase = config["FixBaseline"].GetInt();
int const fixMean = config["FixMean"].GetInt();

int const nBaselinePoints = config["nBaselinePoints"].GetInt();
std::size_t const nBaselinePoints = config["nBaselinePoints"].GetInt();
std::vector<int> pointsForBaselineVec;
const Value& pointsForBaselineValue = config["binsForBaseline"];
readArray(pointsForBaselineValue, pointsForBaselineVec);
Expand Down Expand Up @@ -147,12 +148,12 @@ void fitCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.json")
auto* inFileFitSystematicErrors = new TFile("OutputSystematicUncertainties/SystematicUncertaintesFitPhysObsMerged.root");

// Canvas
TCanvas* canvasCorrPhi[nBinsPtHad];
std::vector<TCanvas*> canvasCorrPhi(nBinsPtHad, nullptr);

// Histograms
TH1D* hCorrPhi[nBinsPtCand][nBinsPtHad];
TH1F* hSystematicErrors[nBinsPtCand][nBinsPtHad];
TH1D* hSystematicErrorsPlot[nBinsPtCand][nBinsPtHad];
std::vector<std::vector<TH1D*>> hCorrPhi(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));
std::vector<std::vector<TH1F*>> hSystematicErrors(nBinsPtCand, std::vector<TH1F*>(nBinsPtHad, nullptr));
std::vector<std::vector<TH1D*>> hSystematicErrorsPlot(nBinsPtCand, std::vector<TH1D*>(nBinsPtHad, nullptr));

const int nBinsPtD = 5;
if (nBinsPtD != nBinsPtCand) {
Expand All @@ -163,25 +164,25 @@ void fitCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.json")

// DhCorrelationFitter
const double fMin{-0.5 * TMath::Pi()}, fMax{1.5 * TMath::Pi()}; // limits for the fitting function
DhCorrelationFitter* corrFitter[nBinsPtHad][nBinsPtCand];
std::vector<std::vector<DhCorrelationFitter*>> corrFitter(nBinsPtHad, std::vector<DhCorrelationFitter*>(nBinsPtCand, nullptr));

// Input parameters for fitting
const int npars{10}; // PED NSY NSM NSW ASY ASM ASW BETA v2D v2h
const Double_t vals[npars] = {3., 2., 0., 0.5, 2., 3.14, 0.3, 2., 0.1, 0.1};
const Double_t lowBounds[npars] = {0., 0., -1., 0., 0., 2., 0., 0.5, 0., 0.};
const Double_t uppBounds[npars] = {9999., 999., 1., 3.14 / 3., 999., 4., 3.14 / 2., 3.5, 0.5, 0.5};
const Double_t v2AssocPart[nBinsPtD] = {0.15, 0.15, 0.15, 0.15};
const Double_t v2Dmeson[nBinsPtD] = {0.175, 0.09, 0.04, 0.04};
constexpr int npars{10}; // PED NSY NSM NSW ASY ASM ASW BETA v2D v2h
constexpr std::array<Double_t, npars> vals{3., 2., 0., 0.5, 2., 3.14, 0.3, 2., 0.1, 0.1};
constexpr std::array<Double_t, npars> lowBounds{0., 0., -1., 0., 0., 2., 0., 0.5, 0., 0.};
constexpr std::array<Double_t, npars> uppBounds{9999., 999., 1., 3.14 / 3., 999., 4., 3.14 / 2., 3.5, 0.5, 0.5};
constexpr std::array<Double_t, nBinsPtD> v2AssocPart{0.15, 0.15, 0.15, 0.15};
constexpr std::array<Double_t, nBinsPtD> v2Dmeson{0.175, 0.09, 0.04, 0.04};

// Output histograms
TH1D* hBaselin[nBinsPtHad];
TH1D* hNSYield[nBinsPtHad];
TH1D* hNSSigma[nBinsPtHad];
TH1D* hASYield[nBinsPtHad];
TH1D* hASSigma[nBinsPtHad];
TH1D* hBeta[nBinsPtHad];
TH1D* hNSYieldBinCount[nBinsPtHad];
TH1D* hASYieldBinCount[nBinsPtHad];
std::vector<TH1D*> hBaselin(nBinsPtHad, nullptr);
std::vector<TH1D*> hNSYield(nBinsPtHad, nullptr);
std::vector<TH1D*> hNSSigma(nBinsPtHad, nullptr);
std::vector<TH1D*> hASYield(nBinsPtHad, nullptr);
std::vector<TH1D*> hASSigma(nBinsPtHad, nullptr);
std::vector<TH1D*> hBeta(nBinsPtHad, nullptr);
std::vector<TH1D*> hNSYieldBinCount(nBinsPtHad, nullptr);
std::vector<TH1D*> hASYieldBinCount(nBinsPtHad, nullptr);

// extract TH1D and prepare fit
for (int iBinPtCand = 0; iBinPtCand < nBinsPtCand; iBinPtCand++) {
Expand All @@ -202,7 +203,7 @@ void fitCorrelDs(const TString& cfgFileName = "config_CorrAnalysis.json")

corrFitter[iBinPtHad][iBinPtCand]->setFixMean(fixMean);
corrFitter[iBinPtHad][iBinPtCand]->setPtRanges(binsPtCandIntervals[iBinPtCand], binsPtCandIntervals[iBinPtCand + 1], binsPtHadIntervals[iBinPtHad], binsPtHadIntervals[iBinPtHad + 1]);
corrFitter[iBinPtHad][iBinPtCand]->setExternalValsAndBounds(npars, vals, lowBounds, uppBounds); // these are starting points and limits...
corrFitter[iBinPtHad][iBinPtCand]->setExternalValsAndBounds(npars, vals.data(), lowBounds.data(), uppBounds.data()); // these are starting points and limits...
}
}

Expand Down
Loading