Skip to content
Merged
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
39 changes: 31 additions & 8 deletions EventFiltering/PWGHF/HFFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ enum HfTriggers {
kHighPt = 0,
kBeauty,
kFemto,
kDoubleCharm,
kNtriggersHF
};

static const std::vector<std::string> HfTriggerNames{"highPt", "beauty", "femto"};
static const std::vector<std::string> HfTriggerNames{"highPt", "beauty", "femto", "doubleCharm"};

enum BeautyCandType {
kBeauty3Prong = 0, // combination of charm 2-prong and pion
Expand Down Expand Up @@ -98,12 +99,14 @@ DECLARE_SOA_TABLE(Colls3Prong, "AOD", "COLLSID3P", o2::aod::extra3Prong::Collisi

namespace hftraining2p
{
DECLARE_SOA_COLUMN(PT1, pT1, float); //!
DECLARE_SOA_COLUMN(DCAPrimXY1, dcaPrimXY1, float); //!
DECLARE_SOA_COLUMN(DCAPrimZ1, dcaPrimZ1, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTPC1, nsigmaPiTPC1, float); //!
DECLARE_SOA_COLUMN(NsigmaKaTPC1, nsigmaKaTPC1, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTOF1, nsigmaPiTOF1, float); //!
DECLARE_SOA_COLUMN(NsigmaKaTOF1, nsigmaKaTOF1, float); //!
DECLARE_SOA_COLUMN(PT2, pT2, float); //!
DECLARE_SOA_COLUMN(DCAPrimXY2, dcaPrimXY2, float); //!
DECLARE_SOA_COLUMN(DCAPrimZ2, dcaPrimZ2, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTPC2, nsigmaPiTPC2, float); //!
Expand All @@ -113,12 +116,14 @@ DECLARE_SOA_COLUMN(NsigmaKaTOF2, nsigmaKaTOF2, float); //!
DECLARE_SOA_COLUMN(FlagOrigin, flagOrigin, int8_t); //!
} // namespace hftraining2p
DECLARE_SOA_TABLE(HFTrigTrain2P, "AOD", "HFTRIGTRAIN2P", //!
hftraining2p::PT1,
hftraining2p::DCAPrimXY1,
hftraining2p::DCAPrimZ1,
hftraining2p::NsigmaPiTPC1,
hftraining2p::NsigmaKaTPC1,
hftraining2p::NsigmaPiTOF1,
hftraining2p::NsigmaKaTOF1,
hftraining2p::PT2,
hftraining2p::DCAPrimXY2,
hftraining2p::DCAPrimZ2,
hftraining2p::NsigmaPiTPC2,
Expand All @@ -129,6 +134,7 @@ DECLARE_SOA_TABLE(HFTrigTrain2P, "AOD", "HFTRIGTRAIN2P", //!

namespace hftraining3p
{
DECLARE_SOA_COLUMN(PT1, pT1, float); //!
DECLARE_SOA_COLUMN(DCAPrimXY1, dcaPrimXY1, float); //!
DECLARE_SOA_COLUMN(DCAPrimZ1, dcaPrimZ1, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTPC1, nsigmaPiTPC1, float); //!
Expand All @@ -137,6 +143,7 @@ DECLARE_SOA_COLUMN(NsigmaPrTPC1, nsigmaPrTPC1, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTOF1, nsigmaPiTOF1, float); //!
DECLARE_SOA_COLUMN(NsigmaKaTOF1, nsigmaKaTOF1, float); //!
DECLARE_SOA_COLUMN(NsigmaPrTOF1, nsigmaPrTOF1, float); //!
DECLARE_SOA_COLUMN(PT2, pT2, float); //!
DECLARE_SOA_COLUMN(DCAPrimXY2, dcaPrimXY2, float); //!
DECLARE_SOA_COLUMN(DCAPrimZ2, dcaPrimZ2, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTPC2, nsigmaPiTPC2, float); //!
Expand All @@ -145,6 +152,7 @@ DECLARE_SOA_COLUMN(NsigmaPrTPC2, nsigmaPrTPC2, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTOF2, nsigmaPiTOF2, float); //!
DECLARE_SOA_COLUMN(NsigmaKaTOF2, nsigmaKaTOF2, float); //!
DECLARE_SOA_COLUMN(NsigmaPrTOF2, nsigmaPrTOF2, float); //!
DECLARE_SOA_COLUMN(PT3, pT3, float); //!
DECLARE_SOA_COLUMN(DCAPrimXY3, dcaPrimXY3, float); //!
DECLARE_SOA_COLUMN(DCAPrimZ3, dcaPrimZ3, float); //!
DECLARE_SOA_COLUMN(NsigmaPiTPC3, nsigmaPiTPC3, float); //!
Expand All @@ -158,6 +166,7 @@ DECLARE_SOA_COLUMN(Channel, channel, int8_t); //!
DECLARE_SOA_COLUMN(HFSelBit, hfselbit, int8_t); //!
} // namespace hftraining3p
DECLARE_SOA_TABLE(HFTrigTrain3P, "AOD", "HFTRIGTRAIN3P", //!
hftraining3p::PT1,
hftraining3p::DCAPrimXY1,
hftraining3p::DCAPrimZ1,
hftraining3p::NsigmaPiTPC1,
Expand All @@ -166,6 +175,7 @@ DECLARE_SOA_TABLE(HFTrigTrain3P, "AOD", "HFTRIGTRAIN3P", //!
hftraining3p::NsigmaPiTOF1,
hftraining3p::NsigmaKaTOF1,
hftraining3p::NsigmaPrTOF1,
hftraining3p::PT2,
hftraining3p::DCAPrimXY2,
hftraining3p::DCAPrimZ2,
hftraining3p::NsigmaPiTPC2,
Expand All @@ -174,6 +184,7 @@ DECLARE_SOA_TABLE(HFTrigTrain3P, "AOD", "HFTRIGTRAIN3P", //!
hftraining3p::NsigmaPiTOF2,
hftraining3p::NsigmaKaTOF2,
hftraining3p::NsigmaPrTOF2,
hftraining3p::PT3,
hftraining3p::DCAPrimXY3,
hftraining3p::DCAPrimZ3,
hftraining3p::NsigmaPiTPC3,
Expand Down Expand Up @@ -341,6 +352,8 @@ struct HfFilter { // Main struct for HF triggers
bool keepEvent[kNtriggersHF]{false};
//

int n2Prongs{0}, n3Prongs{0};

for (const auto& cand2Prong : cand2Prongs) { // start loop over 2 prongs

if (!TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_prong2::DecayType::D0ToPiK)) { // check if it's a D0
Expand All @@ -352,6 +365,9 @@ struct HfFilter { // Main struct for HF triggers
std::array<float, 3> pVecPos = {trackPos.px(), trackPos.py(), trackPos.pz()};
std::array<float, 3> pVecNeg = {trackNeg.px(), trackNeg.py(), trackNeg.pz()};

// TODO: add ML selections here
n2Prongs++;

auto pVec2Prong = RecoDecay::PVec(pVecPos, pVecNeg);
auto pt2Prong = RecoDecay::Pt(pVec2Prong);
if (pt2Prong >= pTThreshold2Prong) {
Expand Down Expand Up @@ -407,6 +423,9 @@ struct HfFilter { // Main struct for HF triggers

float sign3Prong = trackFirst.signed1Pt() * trackSecond.signed1Pt() * trackThird.signed1Pt();

// TODO: add ML selections here
n3Prongs++;

auto pVec3Prong = RecoDecay::PVec(pVecFirst, pVecSecond, pVecThird);
auto pt3Prong = RecoDecay::Pt(pVec3Prong);
if (pt3Prong >= pTThreshold3Prong) {
Expand Down Expand Up @@ -450,9 +469,13 @@ struct HfFilter { // Main struct for HF triggers
} // end loop over tracks
} // end loop over 3-prong candidates

tags(keepEvent[kHighPt], keepEvent[kBeauty], keepEvent[kFemto]);
if (n2Prongs > 1 || n3Prongs > 1 || (n2Prongs > 0 && n3Prongs > 0)) {
keepEvent[kDoubleCharm] = true;
}

tags(keepEvent[kHighPt], keepEvent[kBeauty], keepEvent[kFemto], keepEvent[kDoubleCharm]);

if (!keepEvent[kHighPt] && !keepEvent[kBeauty] && !keepEvent[kFemto]) {
if (!keepEvent[kHighPt] && !keepEvent[kBeauty] && !keepEvent[kFemto] && keepEvent[kDoubleCharm]) {
hProcessedEvents->Fill(1);
} else {
for (int iTrigger{0}; iTrigger < kNtriggersHF; iTrigger++) {
Expand Down Expand Up @@ -493,8 +516,8 @@ struct HfFilter { // Main struct for HF triggers

double pseudoRndm = trackPos.pt() * 1000. - (long)(trackPos.pt() * 1000);
if ((fillSignal && indexRec > -1) || (fillBackground && indexRec < 0 && pseudoRndm < donwSampleBkgFactor)) {
train2P(trackPos.dcaPrim0(), trackPos.dcaPrim1(), trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), trackPos.tofNSigmaPi(), trackPos.tofNSigmaKa(),
trackNeg.dcaPrim0(), trackNeg.dcaPrim1(), trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaPi(), trackNeg.tofNSigmaKa(),
train2P(trackPos.pt(), trackPos.dcaPrim0(), trackPos.dcaPrim1(), trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), trackPos.tofNSigmaPi(), trackPos.tofNSigmaKa(),
trackNeg.pt(), trackNeg.dcaPrim0(), trackNeg.dcaPrim1(), trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaPi(), trackNeg.tofNSigmaKa(),
flag);
}
} // end loop over 2-prong candidates
Expand Down Expand Up @@ -552,9 +575,9 @@ struct HfFilter { // Main struct for HF triggers

double pseudoRndm = trackFirst.pt() * 1000. - (long)(trackFirst.pt() * 1000);
if ((fillSignal && indexRec > -1) || (fillBackground && indexRec < 0 && pseudoRndm < donwSampleBkgFactor)) {
train3P(trackFirst.dcaPrim0(), trackFirst.dcaPrim1(), trackFirst.tpcNSigmaPi(), trackFirst.tpcNSigmaKa(), trackFirst.tpcNSigmaPr(), trackFirst.tofNSigmaPi(), trackFirst.tofNSigmaKa(), trackFirst.tofNSigmaPr(),
trackSecond.dcaPrim0(), trackSecond.dcaPrim1(), trackSecond.tpcNSigmaPi(), trackSecond.tpcNSigmaKa(), trackSecond.tpcNSigmaPr(), trackSecond.tofNSigmaPi(), trackSecond.tofNSigmaKa(), trackSecond.tofNSigmaPr(),
trackThird.dcaPrim0(), trackThird.dcaPrim1(), trackThird.tpcNSigmaPi(), trackThird.tpcNSigmaKa(), trackThird.tpcNSigmaPr(), trackThird.tofNSigmaPi(), trackThird.tofNSigmaKa(), trackThird.tofNSigmaPr(),
train3P(trackFirst.pt(), trackFirst.dcaPrim0(), trackFirst.dcaPrim1(), trackFirst.tpcNSigmaPi(), trackFirst.tpcNSigmaKa(), trackFirst.tpcNSigmaPr(), trackFirst.tofNSigmaPi(), trackFirst.tofNSigmaKa(), trackFirst.tofNSigmaPr(),
trackSecond.pt(), trackSecond.dcaPrim0(), trackSecond.dcaPrim1(), trackSecond.tpcNSigmaPi(), trackSecond.tpcNSigmaKa(), trackSecond.tpcNSigmaPr(), trackSecond.tofNSigmaPi(), trackSecond.tofNSigmaKa(), trackSecond.tofNSigmaPr(),
trackThird.pt(), trackThird.dcaPrim0(), trackThird.dcaPrim1(), trackThird.tpcNSigmaPi(), trackThird.tpcNSigmaKa(), trackThird.tpcNSigmaPr(), trackThird.tofNSigmaPi(), trackThird.tofNSigmaKa(), trackThird.tofNSigmaPr(),
flag, channel, cand3Prong.hfflag());
}
} // end loop over 3-prong candidates
Expand Down
9 changes: 5 additions & 4 deletions EventFiltering/filterTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ DECLARE_SOA_COLUMN(DiElectron, hasDiElectron, bool); //! dielectron trigger
DECLARE_SOA_COLUMN(DiMuon, hasDiMuon, bool); //! dimuon trigger with low pT on muons

// heavy flavours
DECLARE_SOA_COLUMN(HfHighPt, hasHfHighPt, bool); //! high-pT charm hadron
DECLARE_SOA_COLUMN(HfBeauty, hasHfBeauty, bool); //! beauty hadron
DECLARE_SOA_COLUMN(HfFemto, hasHfFemto, bool); //! charm-hadron - N pair
DECLARE_SOA_COLUMN(HfHighPt, hasHfHighPt, bool); //! high-pT charm hadron
DECLARE_SOA_COLUMN(HfBeauty, hasHfBeauty, bool); //! beauty hadron
DECLARE_SOA_COLUMN(HfFemto, hasHfFemto, bool); //! charm-hadron - N pair
DECLARE_SOA_COLUMN(HfDoubleCharm, hasHfDoubleCharm, bool); //! at least two charm-hadron candidates

// CF three body triggers
DECLARE_SOA_COLUMN(PPP, hasPPP, bool); //! has p-p-p triplet
Expand Down Expand Up @@ -78,7 +79,7 @@ using DqFilter = DqFilters::iterator;

// heavy flavours
DECLARE_SOA_TABLE(HfFilters, "AOD", "HF Filters", //!
filtering::HfHighPt, filtering::HfBeauty, filtering::HfFemto);
filtering::HfHighPt, filtering::HfBeauty, filtering::HfFemto, filtering::HfDoubleCharm);

using HfFilter = HfFilters::iterator;

Expand Down