Skip to content

Commit ffbdc9f

Browse files
authored
[PWGLF] Added extra option for calibration (#13893)
1 parent 9cbe9f3 commit ffbdc9f

File tree

1 file changed

+67
-40
lines changed

1 file changed

+67
-40
lines changed

PWGLF/Tasks/GlobalEventProperties/flattenictyPikp.cxx

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <TGraph.h>
5656
#include <TH1.h>
5757

58+
#include <algorithm>
5859
#include <cmath>
5960
#include <cstdlib>
6061
#include <map>
@@ -227,6 +228,7 @@ struct FlattenictyPikp {
227228
Configurable<bool> cfgFillNsigmaQAHist{"cfgFillNsigmaQAHist", false, "fill nsigma QA histograms"};
228229
Configurable<bool> cfgFillV0Hist{"cfgFillV0Hist", false, "fill V0 histograms"};
229230
Configurable<bool> cfgFillChrgType{"cfgFillChrgType", false, "fill histograms per charge types"};
231+
Configurable<bool> cfgFillChrgTypeV0s{"cfgFillChrgTypeV0s", false, "fill V0s histograms per charge types"};
230232
Configurable<std::vector<float>> paramsFuncMIPpos{"paramsFuncMIPpos", std::vector<float>{-1.f}, "parameters of pol2"};
231233
Configurable<std::vector<float>> paramsFuncMIPneg{"paramsFuncMIPneg", std::vector<float>{-1.f}, "parameters of pol2"};
232234
Configurable<std::vector<float>> paramsFuncMIPall{"paramsFuncMIPall", std::vector<float>{-1.f}, "parameters of pol2"};
@@ -426,13 +428,13 @@ struct FlattenictyPikp {
426428
}
427429
};
428430
addVec(vecParamsMIP, "vecParamsMIP", true);
429-
for (const auto& params : vecParamsMIP) {
430-
fDeDxVsEta.emplace_back(setFuncPars(params));
431-
}
431+
std::transform(std::begin(vecParamsMIP), std::end(vecParamsMIP), std::back_inserter(fDeDxVsEta), [&](auto const& params) {
432+
return setFuncPars(params);
433+
});
432434
addVec(vecParamsPLA, "vecParamsPLA", false);
433-
for (const auto& params : vecParamsPLA) {
434-
fEDeDxVsEta.emplace_back(setFuncPars(params));
435-
}
435+
std::transform(std::begin(vecParamsPLA), std::end(vecParamsPLA), std::back_inserter(fEDeDxVsEta), [&](auto const& params) {
436+
return setFuncPars(params);
437+
});
436438

437439
ccdb->setURL(ccdbConf.ccdbUrl.value);
438440
ccdb->setCaching(true);
@@ -791,7 +793,7 @@ struct FlattenictyPikp {
791793
if (applyCalibGain) {
792794
fullPathCalibGain = cfgGainEqCcdbPath;
793795
fullPathCalibGain += "/FV0";
794-
auto objfv0Gain = getForTsOrRun<std::vector<float>>(fullPathCalibGain, timestamp, runnumber);
796+
const auto* objfv0Gain = getForTsOrRun<std::vector<float>>(fullPathCalibGain, timestamp, runnumber);
795797
if (!objfv0Gain) {
796798
for (auto i{0u}; i < CnCellsFV0; i++) {
797799
fv0AmplCorr.push_back(1.);
@@ -812,7 +814,7 @@ struct FlattenictyPikp {
812814
fullPathCalibDeDxMip += "/MIP";
813815
fullPathCalibDeDxPlateau = cfgDeDxCalibCcdbPath;
814816
fullPathCalibDeDxPlateau += "/Plateau";
815-
if (fullPathCalibDeDxMip.empty() == false) {
817+
if (!fullPathCalibDeDxMip.empty()) {
816818
dedxcalib.lCalibObjects = getForTsOrRun<TList>(fullPathCalibDeDxMip, timestamp, runnumber);
817819
if (dedxcalib.lCalibObjects) {
818820
LOG(info) << "CCDB objects loaded successfully";
@@ -829,7 +831,7 @@ struct FlattenictyPikp {
829831
dedxcalib.lCalibLoaded = false;
830832
}
831833
}
832-
if (fullPathCalibDeDxPlateau.empty() == false) {
834+
if (!fullPathCalibDeDxPlateau.empty()) {
833835
dedxcalib.lCalibObjects = getForTsOrRun<TList>(fullPathCalibDeDxPlateau, timestamp, runnumber);
834836
if (dedxcalib.lCalibObjects) {
835837
LOG(info) << "CCDB objects loaded successfully";
@@ -1046,28 +1048,54 @@ struct FlattenictyPikp {
10461048
float dEdxNeg = negTrack.tpcSignal();
10471049

10481050
if (applyCalibDeDx) {
1049-
if (applyCalibDeDxFromCCDB) {
1050-
dEdxPos *= (50.0 / dedxcalib.hMIPcalibAll->GetBinContent(dedxcalib.hMIPcalibAll->FindBin(posTrack.eta())));
1051-
dEdxNeg *= (50.0 / dedxcalib.hMIPcalibAll->GetBinContent(dedxcalib.hMIPcalibAll->FindBin(negTrack.eta())));
1051+
if (cfgFillChrgTypeV0s) {
1052+
if (applyCalibDeDxFromCCDB) {
1053+
dEdxPos *= (50.0 / dedxcalib.hMIPcalibPos->GetBinContent(dedxcalib.hMIPcalibPos->FindBin(posTrack.eta())));
1054+
dEdxNeg *= (50.0 / dedxcalib.hMIPcalibNeg->GetBinContent(dedxcalib.hMIPcalibNeg->FindBin(negTrack.eta())));
1055+
} else {
1056+
dEdxPos *= (50.0 / getCalibration(fDeDxVsEta, posTrack));
1057+
dEdxNeg *= (50.0 / getCalibration(fDeDxVsEta, negTrack));
1058+
}
10521059
} else {
1053-
dEdxPos *= (50.0 / getCalibration<false>(fDeDxVsEta, posTrack));
1054-
dEdxNeg *= (50.0 / getCalibration<false>(fDeDxVsEta, negTrack));
1060+
if (applyCalibDeDxFromCCDB) {
1061+
dEdxPos *= (50.0 / dedxcalib.hMIPcalibAll->GetBinContent(dedxcalib.hMIPcalibAll->FindBin(posTrack.eta())));
1062+
dEdxNeg *= (50.0 / dedxcalib.hMIPcalibAll->GetBinContent(dedxcalib.hMIPcalibAll->FindBin(negTrack.eta())));
1063+
} else {
1064+
dEdxPos *= (50.0 / getCalibration<false>(fDeDxVsEta, posTrack));
1065+
dEdxNeg *= (50.0 / getCalibration<false>(fDeDxVsEta, negTrack));
1066+
}
10551067
}
10561068
}
10571069

10581070
if (selectTypeV0s(collision, v0, posTrack, negTrack) == kGa) { // Gamma selection
10591071
if (applyCalibDeDx) {
1060-
if (applyCalibDeDxFromCCDB) {
1061-
const float dEdxPosGa = dedxcalib.hPlateauCalibAll->GetBinContent(dedxcalib.hPlateauCalibAll->FindBin(posTrack.eta()));
1062-
const float dEdxNegGa = dedxcalib.hPlateauCalibAll->GetBinContent(dedxcalib.hPlateauCalibAll->FindBin(negTrack.eta()));
1063-
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1064-
continue;
1072+
if (cfgFillChrgTypeV0s) {
1073+
if (applyCalibDeDxFromCCDB) {
1074+
const float dEdxPosGa = dedxcalib.hMIPcalibPos->GetBinContent(dedxcalib.hMIPcalibPos->FindBin(posTrack.eta()));
1075+
const float dEdxNegGa = dedxcalib.hMIPcalibNeg->GetBinContent(dedxcalib.hMIPcalibNeg->FindBin(negTrack.eta()));
1076+
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1077+
continue;
1078+
}
1079+
} else {
1080+
const float dEdxPosGa = getCalibration(fEDeDxVsEta, posTrack);
1081+
const float dEdxNegGa = getCalibration(fEDeDxVsEta, negTrack);
1082+
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1083+
continue;
1084+
}
10651085
}
10661086
} else {
1067-
const float dEdxPosGa = getCalibration<false>(fEDeDxVsEta, posTrack);
1068-
const float dEdxNegGa = getCalibration<false>(fEDeDxVsEta, negTrack);
1069-
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1070-
continue;
1087+
if (applyCalibDeDxFromCCDB) {
1088+
const float dEdxPosGa = dedxcalib.hPlateauCalibAll->GetBinContent(dedxcalib.hPlateauCalibAll->FindBin(posTrack.eta()));
1089+
const float dEdxNegGa = dedxcalib.hPlateauCalibAll->GetBinContent(dedxcalib.hPlateauCalibAll->FindBin(negTrack.eta()));
1090+
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1091+
continue;
1092+
}
1093+
} else {
1094+
const float dEdxPosGa = getCalibration<false>(fEDeDxVsEta, posTrack);
1095+
const float dEdxNegGa = getCalibration<false>(fEDeDxVsEta, negTrack);
1096+
if (std::abs(dEdxPos - dEdxPosGa) >= v0SelOpt.cfgdEdxPlateauSel || std::abs(dEdxNeg - dEdxNegGa) >= v0SelOpt.cfgdEdxPlateauSel) {
1097+
continue;
1098+
}
10711099
}
10721100
}
10731101
}
@@ -1643,33 +1671,33 @@ struct FlattenictyPikp {
16431671
iRing = Cfv0IndexPhi[4];
16441672
} else if (i_ch == Cfv0IndexPhi[4] + 8) {
16451673
iRing = i_ch - 7; // 33;
1646-
} else if (i_ch == Cfv0IndexPhi[4] - 3) {
1674+
} else if (i_ch == Cfv0IndexPhi[4] + 1) {
16471675
iRing = i_ch + 1; // 34;
1648-
} else if (i_ch == Cfv0IndexPhi[4] + 5) {
1676+
} else if (i_ch == Cfv0IndexPhi[4] + 9) {
16491677
iRing = i_ch - 6; // 35;
1650-
} else if (i_ch == Cfv0IndexPhi[4] - 2) {
1678+
} else if (i_ch == Cfv0IndexPhi[4] + 2) {
16511679
iRing = i_ch + 2; // 36;
1652-
} else if (i_ch == Cfv0IndexPhi[4] + 6) {
1680+
} else if (i_ch == Cfv0IndexPhi[4] + 10) {
16531681
iRing = i_ch - 5; // 37;
1654-
} else if (i_ch == Cfv0IndexPhi[4] - 1) {
1682+
} else if (i_ch == Cfv0IndexPhi[4] + 3) {
16551683
iRing = i_ch + 3; // 38;
1656-
} else if (i_ch == Cfv0IndexPhi[4] + 7) {
1657-
iRing = i_ch - 4; // 39;
16581684
} else if (i_ch == Cfv0IndexPhi[4] + 11) {
1659-
iRing = i_ch + 7; // 40;
1660-
} else if (i_ch == Cfv0IndexPhi[4] + 3) {
1685+
iRing = i_ch - 4; // 39;
1686+
} else if (i_ch == Cfv0IndexPhi[4] + 15) {
1687+
iRing = i_ch - 7; // 40;
1688+
} else if (i_ch == Cfv0IndexPhi[4] + 7) {
16611689
iRing = i_ch + 2; // 41;
1662-
} else if (i_ch == Cfv0IndexPhi[4] + 10) {
1690+
} else if (i_ch == Cfv0IndexPhi[4] + 14) {
16631691
iRing = i_ch - 4; // 42;
1664-
} else if (i_ch == Cfv0IndexPhi[4] + 1) {
1692+
} else if (i_ch == Cfv0IndexPhi[4] + 6) {
16651693
iRing = i_ch + 5; // 43;
1666-
} else if (i_ch == Cfv0IndexPhi[4] + 9) {
1694+
} else if (i_ch == Cfv0IndexPhi[4] + 13) {
16671695
iRing = i_ch - 1; // 44;
1668-
} else if (i_ch == Cfv0IndexPhi[4] + 1) {
1696+
} else if (i_ch == Cfv0IndexPhi[4] + 5) {
16691697
iRing = i_ch + 8; // 45;
1670-
} else if (i_ch == Cfv0IndexPhi[4] + 8) {
1698+
} else if (i_ch == Cfv0IndexPhi[4] + 12) {
16711699
iRing = i_ch + 2; // 46;
1672-
} else if (i_ch == Cfv0IndexPhi[4]) {
1700+
} else if (i_ch == Cfv0IndexPhi[4] + 4) {
16731701
iRing = i_ch + 11; // 47;
16741702
}
16751703
return iRing;
@@ -1746,11 +1774,10 @@ struct FlattenictyPikp {
17461774
{
17471775
rhoLatticeFV0.fill(0);
17481776
fv0AmplitudeWoCalib.fill(0);
1749-
bool isOkFV0OrA = false;
17501777
if (collision.has_foundFV0()) {
17511778
auto fv0 = collision.foundFV0();
17521779
std::bitset<8> fV0Triggers = fv0.triggerMask();
1753-
isOkFV0OrA = fV0Triggers[o2::fit::Triggers::bitA];
1780+
bool isOkFV0OrA = fV0Triggers[o2::fit::Triggers::bitA];
17541781
if (isOkFV0OrA) {
17551782
for (std::size_t ich = 0; ich < fv0.channel().size(); ich++) {
17561783
float amplCh = fv0.amplitude()[ich];

0 commit comments

Comments
 (0)