Skip to content

Commit 3d037f2

Browse files
committed
Reduce unnecessary operations
1 parent 02871af commit 3d037f2

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

PWGHF/TableProducer/trackIndexSkimCreator.cxx

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,16 +1497,15 @@ struct HfTrackIndexSkimCreator {
14971497
{
14981498
whichHypo[kN2ProngDecays] = 0; // D0 for D*
14991499

1500-
auto arrMom = std::array{pVecTrack0, pVecTrack1};
15011500
pt2Prong = RecoDecay::pt(pVecTrack0, pVecTrack1);
1502-
auto pT = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex
1501+
auto pt = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex
15031502

15041503
for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) {
15051504

15061505
// pT
1507-
auto pTBin = findBin(&pTBins2Prong[iDecay2P], pT);
1506+
auto binPt = findBin(&pTBins2Prong[iDecay2P], pt);
15081507
// return immediately if it is outside the defined pT bins
1509-
if (pTBin == -1) {
1508+
if (binPt == -1) {
15101509
CLRBIT(isSelected, iDecay2P);
15111510
if (config.debug) {
15121511
cutStatus[iDecay2P][0] = false;
@@ -1515,34 +1514,37 @@ struct HfTrackIndexSkimCreator {
15151514
}
15161515

15171516
// invariant mass
1518-
double massHypos[2] = {0.f, 0.f};
1519-
whichHypo[iDecay2P] = 3;
1520-
double minMass = cut2Prong[iDecay2P].get(pTBin, 0u);
1521-
double maxMass = cut2Prong[iDecay2P].get(pTBin, 1u);
1522-
double min2 = minMass * minMass;
1523-
double max2 = maxMass * maxMass;
1524-
1525-
if ((config.debug || TESTBIT(isSelected, iDecay2P)) && minMass >= 0. && maxMass > 0.) {
1526-
massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]);
1527-
massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0];
1528-
if (massHypos[0] < min2 || massHypos[0] >= max2) {
1529-
CLRBIT(whichHypo[iDecay2P], 0);
1530-
}
1531-
if (massHypos[1] < min2 || massHypos[1] >= max2) {
1532-
CLRBIT(whichHypo[iDecay2P], 1);
1533-
}
1534-
if (whichHypo[iDecay2P] == 0) {
1535-
CLRBIT(isSelected, iDecay2P);
1536-
if (config.debug) {
1537-
cutStatus[iDecay2P][1] = false;
1517+
double massHypos[2] = {0., 0.};
1518+
whichHypo[iDecay2P] = 3; // 2 bits on
1519+
1520+
if (config.debug || TESTBIT(isSelected, iDecay2P)) {
1521+
double minMass = cut2Prong[iDecay2P].get(binPt, 0u);
1522+
double maxMass = cut2Prong[iDecay2P].get(binPt, 1u);
1523+
if (minMass >= 0. && maxMass > 0.) {
1524+
auto arrMom = std::array{pVecTrack0, pVecTrack1};
1525+
massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]);
1526+
massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0];
1527+
double min2 = minMass * minMass;
1528+
double max2 = maxMass * maxMass;
1529+
if (massHypos[0] < min2 || massHypos[0] >= max2) {
1530+
CLRBIT(whichHypo[iDecay2P], 0);
1531+
}
1532+
if (massHypos[1] < min2 || massHypos[1] >= max2) {
1533+
CLRBIT(whichHypo[iDecay2P], 1);
1534+
}
1535+
if (whichHypo[iDecay2P] == 0) {
1536+
CLRBIT(isSelected, iDecay2P);
1537+
if (config.debug) {
1538+
cutStatus[iDecay2P][1] = false;
1539+
}
15381540
}
15391541
}
15401542
}
15411543

15421544
// imp. par. product cut
15431545
if (config.debug || TESTBIT(isSelected, iDecay2P)) {
15441546
auto impParProduct = dcaTrack0 * dcaTrack1;
1545-
if (impParProduct > cut2Prong[iDecay2P].get(pTBin, 3u)) {
1547+
if (impParProduct > cut2Prong[iDecay2P].get(binPt, 3u)) {
15461548
CLRBIT(isSelected, iDecay2P);
15471549
if (config.debug) {
15481550
cutStatus[iDecay2P][2] = false;
@@ -1552,7 +1554,7 @@ struct HfTrackIndexSkimCreator {
15521554

15531555
// additional check for D0 to be used in D* finding
15541556
if (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK && config.doDstar && TESTBIT(isSelected, iDecay2P)) {
1555-
auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pT * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe
1557+
auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe
15561558
if (pTBinDstar >= 0) {
15571559
whichHypo[kN2ProngDecays] = whichHypo[hf_cand_2prong::DecayType::D0ToPiK];
15581560
double deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u);
@@ -1592,7 +1594,6 @@ struct HfTrackIndexSkimCreator {
15921594
CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1);
15931595
}
15941596
}
1595-
15961597
if (whichHypo[hf_cand_3prong::DecayType::DsToKKPi] == 0) {
15971598
CLRBIT(isSelected, hf_cand_3prong::DecayType::DsToKKPi);
15981599
if (config.debug) {
@@ -1613,14 +1614,12 @@ struct HfTrackIndexSkimCreator {
16131614
template <typename T1, typename T2, typename T3>
16141615
void applyPreselection3Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, int8_t& isIdentifiedPidTrack0, int8_t& isIdentifiedPidTrack2, T2& cutStatus, T3& whichHypo, int& isSelected)
16151616
{
1616-
1617-
auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2};
1618-
auto pT = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex
1617+
auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex
16191618

16201619
for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) {
16211620

16221621
// check proton PID for Lc and Xic
1623-
whichHypo[iDecay3P] = 3;
1622+
whichHypo[iDecay3P] = 3; // 2 bits on
16241623
if ((iDecay3P == hf_cand_3prong::DecayType::LcToPKPi && config.applyProtonPidForLcToPKPi) || (iDecay3P == hf_cand_3prong::DecayType::XicToPKPi && config.applyProtonPidForXicToPKPi)) {
16251624
if ((iDecay3P == hf_cand_3prong::DecayType::LcToPKPi && !TESTBIT(isIdentifiedPidTrack0, ChannelsProtonPid::LcToPKPi)) || (iDecay3P == hf_cand_3prong::DecayType::XicToPKPi && !TESTBIT(isIdentifiedPidTrack0, ChannelsProtonPid::XicToPKPi))) {
16261625
CLRBIT(whichHypo[iDecay3P], 0);
@@ -1638,9 +1637,9 @@ struct HfTrackIndexSkimCreator {
16381637
}
16391638

16401639
// pT
1641-
auto pTBin = findBin(&pTBins3Prong[iDecay3P], pT);
1640+
auto binPt = findBin(&pTBins3Prong[iDecay3P], pt);
16421641
// return immediately if it is outside the defined pT bins
1643-
if (pTBin == -1) {
1642+
if (binPt == -1) {
16441643
CLRBIT(isSelected, iDecay3P);
16451644
whichHypo[iDecay3P] = 0;
16461645
if (config.debug) {
@@ -1650,31 +1649,33 @@ struct HfTrackIndexSkimCreator {
16501649
}
16511650

16521651
// invariant mass
1653-
double massHypos[2];
1654-
double minMass = cut3Prong[iDecay3P].get(pTBin, 0u);
1655-
double maxMass = cut3Prong[iDecay3P].get(pTBin, 1u);
1656-
double min2 = minMass * minMass;
1657-
double max2 = maxMass * maxMass;
1658-
1659-
if ((config.debug || TESTBIT(isSelected, iDecay3P)) && minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes
1660-
massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]);
1661-
massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0];
1662-
if (massHypos[0] < min2 || massHypos[0] >= max2) {
1663-
CLRBIT(whichHypo[iDecay3P], 0);
1664-
}
1665-
if (massHypos[1] < min2 || massHypos[1] >= max2) {
1666-
CLRBIT(whichHypo[iDecay3P], 1);
1667-
}
1668-
if (whichHypo[iDecay3P] == 0) {
1669-
CLRBIT(isSelected, iDecay3P);
1670-
if (config.debug) {
1671-
cutStatus[iDecay3P][1] = false;
1652+
if ((config.debug || TESTBIT(isSelected, iDecay3P))) {
1653+
double minMass = cut3Prong[iDecay3P].get(binPt, 0u);
1654+
double maxMass = cut3Prong[iDecay3P].get(binPt, 1u);
1655+
if (minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes
1656+
double massHypos[2] = {0., 0.};
1657+
auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2};
1658+
double min2 = minMass * minMass;
1659+
double max2 = maxMass * maxMass;
1660+
massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]);
1661+
massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0];
1662+
if (massHypos[0] < min2 || massHypos[0] >= max2) {
1663+
CLRBIT(whichHypo[iDecay3P], 0);
1664+
}
1665+
if (massHypos[1] < min2 || massHypos[1] >= max2) {
1666+
CLRBIT(whichHypo[iDecay3P], 1);
1667+
}
1668+
if (whichHypo[iDecay3P] == 0) {
1669+
CLRBIT(isSelected, iDecay3P);
1670+
if (config.debug) {
1671+
cutStatus[iDecay3P][1] = false;
1672+
}
16721673
}
16731674
}
16741675
}
16751676

16761677
if ((config.debug || TESTBIT(isSelected, iDecay3P)) && iDecay3P == hf_cand_3prong::DecayType::DsToKKPi) {
1677-
applyPreselectionPhiDecay(pTBin, pVecTrack0, pVecTrack1, pVecTrack2, cutStatus, whichHypo, isSelected);
1678+
applyPreselectionPhiDecay(binPt, pVecTrack0, pVecTrack1, pVecTrack2, cutStatus, whichHypo, isSelected);
16781679
}
16791680
}
16801681
}

0 commit comments

Comments
 (0)