Skip to content
Open
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
131 changes: 78 additions & 53 deletions PWGCF/Flow/Tasks/flowEventPlane.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,70 @@ struct SpectatorPlaneTableProducer {
return true;
}

void gainCalib(bool const& loadGainCalib, float const& vz, std::array<float, 4>& eA, std::array<float, 4>& eC)
// Load Gain Calibrations and ZDC Q-Vector Recentering Corrections
void loadCorrections()
{
// Store gain calibration histograms per run number
if (loadGainCalib) {
// Load ZDC gain calibration
if (cDoGainCalib) {
std::string ccdbPath = static_cast<std::string>(cCcdbPath) + "/GainCalib" + "/Run" + std::to_string(cRunNum);
auto ccdbObj = ccdbService->getForTimeStamp<TList>(ccdbPath, -1);
CorrectionHistContainer.hGainCalib[0] = reinterpret_cast<TH2F*>(ccdbObj->FindObject("hZNASignal"));
CorrectionHistContainer.hGainCalib[1] = reinterpret_cast<TH2F*>(ccdbObj->FindObject("hZNCSignal"));
}

// Apply gain calibration
// Load shift corrections for ZDC Q-Vectors
if (cApplyRecentCorr) {
std::vector<int> vCorrFlags = static_cast<std::vector<int>>(cCorrFlagVector);
int nitr = vCorrFlags.size();
CorrectionType corrType = kFineCorr;

for (int i = 0; i < nitr; ++i) {
// Skip correction if corrFlag != 1
if (vCorrFlags[i] != 1) {
continue;
}

// Set correction type
if (i % kNCorr == 0) {
corrType = kCoarseCorr;
} else {
corrType = kFineCorr;
}

// Set ccdb path
std::string ccdbPath = static_cast<std::string>(cCcdbPath) + "/CorrItr_" + std::to_string(i + 1) + "/Run" + std::to_string(cRunNum);

// Get object from CCDB
auto ccdbObject = ccdbService->getForTimeStamp<TList>(ccdbPath, -1);

// Check CCDB Object
if (!ccdbObject) {
LOGF(warning, "CCDB OBJECT NOT FOUND");
return;
}

// Store histograms in Hist Container
std::vector<std::vector<std::string>> vHistNames = corrTypeHistNameMap.at(corrType);
int cntrx = 0;
for (auto const& x : vHistNames) {
int cntry = 0;
for (auto const& y : x) {
if (corrType == kFineCorr) {
CorrectionHistContainer.vFineCorrHist[i][cntrx][cntry] = reinterpret_cast<TProfile*>(ccdbObject->FindObject(y.c_str()));
} else {
CorrectionHistContainer.vCoarseCorrHist[i][cntrx][cntry] = reinterpret_cast<THnSparseF*>(ccdbObject->FindObject(y.c_str()));
}
++cntry;
}
++cntrx;
}
}
}
}

// Apply gain calibrations
void gainCalib(float const& vz, std::array<float, 4>& eA, std::array<float, 4>& eC)
{
float vA = 0., vC = 0.;
for (int i = 0; i < static_cast<int>(eA.size()); ++i) {
vA = CorrectionHistContainer.hGainCalib[0]->GetBinContent(CorrectionHistContainer.hGainCalib[0]->FindBin(i + 0.5, vz + 0.00001));
Expand Down Expand Up @@ -406,12 +459,11 @@ struct SpectatorPlaneTableProducer {
return vAvgOutput;
}

void applyCorrection(bool const& loadShiftCorr, std::array<float, 4> const& inputParam, std::array<float, 4>& outputParam)
void applyCorrection(std::array<float, 4> const& inputParam, std::array<float, 4>& outputParam)
{
std::vector<int> vCorrFlags = static_cast<std::vector<int>>(cCorrFlagVector);
int nitr = vCorrFlags.size();
CorrectionType corrType = kFineCorr;
std::string ccdbPath;

// Correction iterations
for (int i = 0; i < nitr; ++i) {
Expand All @@ -427,37 +479,6 @@ struct SpectatorPlaneTableProducer {
corrType = kFineCorr;
}

// Check current and last run number, fetch ccdb object and store corrections in container
if (loadShiftCorr) {
// Set ccdb path
ccdbPath = static_cast<std::string>(cCcdbPath) + "/CorrItr_" + std::to_string(i + 1) + "/Run" + std::to_string(cRunNum);

// Get object from CCDB
auto ccdbObject = ccdbService->getForTimeStamp<TList>(ccdbPath, -1);

// Check CCDB Object
if (!ccdbObject) {
LOGF(warning, "CCDB OBJECT NOT FOUND");
return;
}

// Store histograms in Hist Container
std::vector<std::vector<std::string>> vHistNames = corrTypeHistNameMap.at(corrType);
int cntrx = 0;
for (auto const& x : vHistNames) {
int cntry = 0;
for (auto const& y : x) {
if (corrType == kFineCorr) {
CorrectionHistContainer.vFineCorrHist[i][cntrx][cntry] = reinterpret_cast<TProfile*>(ccdbObject->FindObject(y.c_str()));
} else {
CorrectionHistContainer.vCoarseCorrHist[i][cntrx][cntry] = reinterpret_cast<THnSparseF*>(ccdbObject->FindObject(y.c_str()));
}
++cntry;
}
++cntrx;
}
}

// Get averages
std::vector<float> vAvg = getAvgCorrFactors(i, corrType, inputParam);

Expand Down Expand Up @@ -497,8 +518,8 @@ struct SpectatorPlaneTableProducer {
histos.fill(HIST("CorrHist/hYZNCVsVz"), vCollParam[kVz], vSP[kYc]);
}

template <typename C>
bool analyzeCollision(C const& collision, std::array<float, 4>& vSP)
template <typename C, typename B>
bool analyzeCollision(B const& bc, C const& collision, std::array<float, 4>& vSP)
{
// Event selection
if (!selCollision(collision)) {
Expand All @@ -515,17 +536,6 @@ struct SpectatorPlaneTableProducer {
histos.fill(HIST("Event/hVy"), posY);
histos.fill(HIST("Event/hVz"), posZ);

// Get bunch crossing
auto bc = collision.template foundBC_as<BCsRun3>();
cRunNum = collision.template foundBC_as<BCsRun3>().runNumber();

// Load calibration flags
bool loadGainCalib = false, loadShiftCorr = false;
if (cRunNum != lRunNum) {
loadGainCalib = true;
loadShiftCorr = true;
}

// check zdc
if (!bc.has_zdc()) {
return false;
Expand All @@ -552,7 +562,7 @@ struct SpectatorPlaneTableProducer {

// Do gain calibration
if (cDoGainCalib) {
gainCalib(loadGainCalib, vCollParam[kVz], znaEnergy, zncEnergy);
gainCalib(vCollParam[kVz], znaEnergy, zncEnergy);
}

// Fill zdc signal
Expand Down Expand Up @@ -599,7 +609,7 @@ struct SpectatorPlaneTableProducer {

// Do corrections
if (cApplyRecentCorr) {
applyCorrection(loadShiftCorr, vCollParam, vSP);
applyCorrection(vCollParam, vSP);
}

// Fill X and Y histograms for corrections after each iteration
Expand Down Expand Up @@ -675,9 +685,17 @@ struct SpectatorPlaneTableProducer {

void processSpectatorPlane(CollisionsRun3::iterator const& collision, BCsRun3 const&, aod::Zdcs const&)
{
// Get bunch crossing
auto bc = collision.template foundBC_as<BCsRun3>();
cRunNum = collision.template foundBC_as<BCsRun3>().runNumber();

if (lRunNum != cRunNum) {
loadCorrections();
}

// Analyze collision and get Spectator Plane Vector
std::array<float, 4> vSP = {0., 0., 0., 0.};
bool colSPExtFlag = analyzeCollision(collision, vSP);
bool colSPExtFlag = analyzeCollision(bc, collision, vSP);

// Update run number
lRunNum = cRunNum;
Expand Down Expand Up @@ -870,6 +888,7 @@ struct FlowEventPlane {
histos.add("V0/Lambda/Flow/hQuA", "hQuA", kTProfile3D, {axisCent, axisTrackRap, axisLambdaInvMass});
histos.add("V0/Lambda/Flow/hQuC", "hQuC", kTProfile3D, {axisCent, axisTrackRap, axisLambdaInvMass});
histos.addClone("V0/Lambda/", "V0/AntiLambda/");
histos.addClone("V0/Lambda/", "V0/LambdaAntiLambda/");
histos.add("V0/K0Short/hMassVsRap", "hMassVsRap", kTH3F, {axisCent, axisK0ShortInvMass, axisTrackEta});
histos.add("V0/K0Short/Flow/hQuA", "hQuA", kTProfile3D, {axisCent, axisTrackRap, axisK0ShortInvMass});
histos.add("V0/K0Short/Flow/hQuC", "hQuC", kTProfile3D, {axisCent, axisTrackRap, axisK0ShortInvMass});
Expand Down Expand Up @@ -1208,6 +1227,9 @@ struct FlowEventPlane {
histos.fill(HIST("V0/Lambda/hMassVsRap"), cent, v0.mLambda(), v0.eta());
histos.fill(HIST("V0/Lambda/Flow/hQuA"), cent, v0.eta(), v0.mLambda(), v1a);
histos.fill(HIST("V0/Lambda/Flow/hQuC"), cent, v0.eta(), v0.mLambda(), v1c);
histos.fill(HIST("V0/LambdaAntiLambda/hMassVsRap"), cent, v0.mLambda(), v0.eta());
histos.fill(HIST("V0/LambdaAntiLambda/Flow/hQuA"), cent, v0.eta(), v0.mLambda(), v1a);
histos.fill(HIST("V0/LambdaAntiLambda/Flow/hQuC"), cent, v0.eta(), v0.mLambda(), v1c);
}

// AntiLambda
Expand All @@ -1216,6 +1238,9 @@ struct FlowEventPlane {
histos.fill(HIST("V0/AntiLambda/hMassVsRap"), cent, v0.mAntiLambda(), v0.eta());
histos.fill(HIST("V0/AntiLambda/Flow/hQuA"), cent, v0.eta(), v0.mAntiLambda(), v1a);
histos.fill(HIST("V0/AntiLambda/Flow/hQuC"), cent, v0.eta(), v0.mAntiLambda(), v1c);
histos.fill(HIST("V0/LambdaAntiLambda/hMassVsRap"), cent, v0.mAntiLambda(), v0.eta());
histos.fill(HIST("V0/LambdaAntiLambda/Flow/hQuA"), cent, v0.eta(), v0.mAntiLambda(), v1a);
histos.fill(HIST("V0/LambdaAntiLambda/Flow/hQuC"), cent, v0.eta(), v0.mAntiLambda(), v1c);
}
}
}
Expand Down
Loading