Skip to content
Merged
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
52 changes: 35 additions & 17 deletions PWGCF/Flow/Tasks/flowEventPlane.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ struct FlowEventPlane {
// Global objects
float cent = 0., mult = 0.;
float posX = 0., posY = 0., posZ = 0.;

std::array<float, 4> znaXWeigthEnergy = {1., 1., 1., 1.};
std::array<float, 4> znaYWeigthEnergy = {1., 1., 1., 1.};
std::array<float, 4> zncXWeigthEnergy = {1., 1., 1., 1.};
std::array<float, 4> zncYWeigthEnergy = {1., 1., 1., 1.};

std::vector<std::vector<std::string>> vCoarseCorrHistNames = {
{"hXZNAVsCentVxVyVz"},
{"hYZNAVsCentVxVyVz"},
Expand All @@ -126,8 +128,18 @@ struct FlowEventPlane {
{"hYZNAVsCent", "hYZNAVsVx", "hYZNAVsVy", "hYZNAVsVz"},
{"hXZNCVsCent", "hXZNCVsVx", "hXZNCVsVy", "hXZNCVsVz"},
{"hYZNCVsCent", "hYZNCVsVx", "hYZNCVsVy", "hYZNCVsVz"}};

// Map for Correction Type and Histogram Names
std::map<CorrectionType, std::vector<std::vector<std::string>>> corrTypeHistNameMap = {{kFineCorr, vFineCorrHistNames}, {kCoarseCorr, vCoarseCorrHistNames}};

// Structure to hold CCDB objects
struct CcdbObjects {
TList* ccdbList;
TObject* obj;
TProfile* hp;
THnSparseF* hn;
} ccdbObjects;
Comment on lines +136 to +141
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a full global structure needed to store entities that are used locally and temporarily?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it wasn't necessary, it was for the bookkeeping. But I will change it.


void init(InitContext const&)
{
// Set CCDB url
Expand Down Expand Up @@ -181,14 +193,14 @@ struct FlowEventPlane {
histos.add("QA/hZNCSignalSector2", "ZNC Signal Sector 2", kTH1F, {axisZDCEnergy});
histos.add("QA/hZNCSignalSector3", "ZNC Signal Sector 3", kTH1F, {axisZDCEnergy});
histos.add("QA/hZNCSignalSector4", "ZNC Signal Sector 4", kTH1F, {axisZDCEnergy});
histos.add("CorrHist/hWtXZNA", "X^{ZNA}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtYZNA", "Y^{ZNA}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtXZNC", "X^{ZNC}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtYZNC", "Y^{ZNC}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtXZNA", "X^{ZNA}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtYZNA", "Y^{ZNA}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtXZNC", "X^{ZNC}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtYZNC", "Y^{ZNC}_{1}", kTHnF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtXZNA", "X^{ZNA}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtYZNA", "Y^{ZNA}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtXZNC", "X^{ZNC}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hWtYZNC", "Y^{ZNC}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtXZNA", "X^{ZNA}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtYZNA", "Y^{ZNA}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtXZNC", "X^{ZNC}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hUWtYZNC", "Y^{ZNC}_{1}", kTHnSparseF, {axisCoarseCent, axisCoarseVx, axisCoarseVy, axisCoarseVz});
histos.add("CorrHist/hXZNAVsCent", "X^{ZNA}_{1} Vs Cent", kTProfile, {axisFineCent});
histos.add("CorrHist/hXZNAVsVx", "X^{ZNA}_{1} Vs V_{x}", kTProfile, {axisFineVx});
histos.add("CorrHist/hXZNAVsVy", "X^{ZNA}_{1} Vs V_{y}", kTProfile, {axisFineVy});
Expand All @@ -214,6 +226,8 @@ struct FlowEventPlane {
histos.add("TrackQA/hPtDcaXY", "DCA_{XY} vs p_{T}", kTH2F, {axisTrackPt, axisTrackDcaXY});
histos.add("TrackQA/hPtDcaZ", "DCA_{Z} vs p_{T}", kTH2F, {axisTrackPt, axisTrackDcaZ});
histos.add("DF/hQaQc", "X^{A}_{1}X^{C}_{1} + Y^{A}_{1}Y^{C}_{1}", kTProfile, {axisCent});
histos.add("DF/hAQu", "u_{x}X^{A}_{1} + u_{y}Y^{A}_{1}", kTH3F, {axisCent, axisV1, axisTrackEta});
histos.add("DF/hCQu", "u_{x}X^{C}_{1} + u_{y}Y^{C}_{1}", kTH3F, {axisCent, axisV1, axisTrackEta});
histos.add("DF/hAQuPos", "u_{x}X^{A}_{1} + u_{y}Y^{A}_{1}", kTH3F, {axisCent, axisV1, axisTrackEta});
histos.add("DF/hCQuPos", "u_{x}X^{C}_{1} + u_{y}Y^{C}_{1}", kTH3F, {axisCent, axisV1, axisTrackEta});
histos.add("DF/hAQuNeg", "u_{x}X^{A}_{1} + u_{y}Y^{A}_{1}", kTH3F, {axisCent, axisV1, axisTrackEta});
Expand Down Expand Up @@ -303,16 +317,18 @@ struct FlowEventPlane {
for (auto const& x : vHistNames) {
int cntry = 0;
for (auto const& y : x) {
TObject* obj = reinterpret_cast<TObject*>(ccdbObject->FindObject(y.c_str()));
ccdbObjects.obj = reinterpret_cast<TObject*>(ccdbObject->FindObject(y.c_str()));
if (corrType == kFineCorr) {
TProfile* hp = reinterpret_cast<TProfile*>(obj->Clone());
vAvgOutput[cntrx] += hp->GetBinContent(hp->GetXaxis()->FindBin(vCollParam[cntry]));
ccdbObjects.hp = reinterpret_cast<TProfile*>(ccdbObjects.obj->Clone());
vAvgOutput[cntrx] += ccdbObjects.hp->GetBinContent(ccdbObjects.hp->GetXaxis()->FindBin(vCollParam[cntry]));
delete ccdbObjects.hp;
Comment on lines +322 to +324
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not recommend allocating and deallocating objects on a per collision level
Is it really needed to clone the CCDB objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any other way other then fetching histograms from CCDB on per collision level, let me know if there is another way of getting them. I am not sure about the cloning at the moment, but I'll try without that, I think its possible.

} else {
THnF* hn = reinterpret_cast<THnF*>(obj->Clone());
ccdbObjects.hn = reinterpret_cast<THnSparseF*>(ccdbObjects.obj->Clone());
for (int i = 0; i < static_cast<int>(vHistNames.size()); ++i) {
binarray[i] = hn->GetAxis(i)->FindBin(vCollParam[i]);
binarray[i] = ccdbObjects.hn->GetAxis(i)->FindBin(vCollParam[i]);
}
vAvgOutput[cntrx] += hn->GetBinContent(hn->GetBin(binarray));
vAvgOutput[cntrx] += ccdbObjects.hn->GetBinContent(ccdbObjects.hn->GetBin(binarray));
delete ccdbObjects.hn;
}
++cntry;
Comment on lines 317 to 333
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is cryptic
Cryptic code is really hard to maintain and to evolve
I would recommend code that is readable with meaningful variable names and no magic numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the moment it may seem like "cryptic", but please give me a few iteration, I will try to modify it.

}
Expand Down Expand Up @@ -345,16 +361,16 @@ struct FlowEventPlane {
ccdbPath = static_cast<std::string>(cCcdbPath) + "/CorrItr_" + std::to_string(i + 1) + "/Run" + std::to_string(runNumber);

// Get object from CCDB
auto ccdbObj = ccdbService->getForTimeStamp<TList>(ccdbPath, -1);
ccdbObjects.ccdbList = ccdbService->getForTimeStamp<TList>(ccdbPath, -1);

// Check CCDB Object
if (!ccdbObj) {
if (!ccdbObjects.ccdbList) {
LOGF(warning, "CCDB OBJECT NOT FOUND");
return;
}

// Get averages
std::vector<float> vAvg = getAvgCorrFactors(ccdbObj, corrType, inputParam);
std::vector<float> vAvg = getAvgCorrFactors(ccdbObjects.ccdbList, corrType, inputParam);

// Apply correction
outputParam[kXa] -= vAvg[kXa];
Expand Down Expand Up @@ -514,6 +530,8 @@ struct FlowEventPlane {
v1c = ux * vSP[kXc] + uy * vSP[kYc];

// Fill histogram
histos.fill(HIST("DF/hAQu"), cent, v1a, track.eta());
histos.fill(HIST("DF/hCQu"), cent, v1c, track.eta());
if (track.sign() > 0) {
histos.fill(HIST("DF/hAQuPos"), cent, v1a, track.eta());
histos.fill(HIST("DF/hCQuPos"), cent, v1c, track.eta());
Expand Down
Loading