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
75 changes: 42 additions & 33 deletions PWGJE/Core/JetTaggingUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ enum JetTaggingSpecies {
gluon = 5
};

enum TaggingMethodNonML {
IPs = 0,
IPs3D = 1,
SV = 2,
SV3D = 3
enum BJetTaggingMethod {
IPsN2 = 0,
IPsN3 = 1,
IPs3DN2 = 2,
IPs3DN3 = 3,
SV = 4,
SV3D = 5
};

namespace jettaggingutilities
Expand Down Expand Up @@ -443,21 +445,17 @@ bool prongAcceptance(T const& prong, float prongChi2PCAMin, float prongChi2PCAMa
return false;
if (prong.chi2PCA() > prongChi2PCAMax)
return false;
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
return false;
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
return false;

if (!doXYZ) {
if (prong.errorDecayLengthXY() > prongsigmaLxyMax)
return false;
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
return false;
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
return false;
} else {
if (prong.errorDecayLength() > prongsigmaLxyMax)
return false;
// TODO
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
return false;
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
return false;
}
return true;
}
Expand Down Expand Up @@ -514,25 +512,26 @@ void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float trackDcaXYMax

/**
* Checks if a jet is greater than the given tagging working point based on the signed impact parameter significances
* return (true, true) if the jet is tagged by the 2nd and 3rd largest IPs
*/
template <typename T, typename U>
bool isGreaterThanTaggingPoint(T const& jet, U const& jtracks, float trackDcaXYMax, float trackDcaZMax, float taggingPoint = 1.0, int cnt = 1, bool useIPxyz = false)
std::tuple<bool, bool> isGreaterThanTaggingPoint(T const& jet, U const& jtracks, float trackDcaXYMax, float trackDcaZMax, float taggingPoint = 1.0, bool useIPxyz = false)
{
if (cnt == 0) {
return true; // untagged
}
bool taggedIPsN2 = false;
bool taggedIPsN3 = false;
std::vector<float> vecSignImpSig;
orderForIPJetTracks(jet, jtracks, trackDcaXYMax, trackDcaZMax, vecSignImpSig, useIPxyz);
if (vecSignImpSig.size() > static_cast<std::vector<float>::size_type>(cnt) - 1) {
for (int i = 0; i < cnt; i++) {
if (vecSignImpSig[i] < taggingPoint) { // tagger point set
return false;
}
if (vecSignImpSig.size() > 1) {
if (vecSignImpSig[1] > taggingPoint) { // tagger point set
taggedIPsN2 = true;
}
} else {
return false;
}
return true;
if (vecSignImpSig.size() > 2) {
if (vecSignImpSig[2] > taggingPoint) { // tagger point set
taggedIPsN3 = true;
}
}
return std::make_tuple(taggedIPsN2, taggedIPsN3);
}

/**
Expand Down Expand Up @@ -648,6 +647,7 @@ typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, floa
sxy = prong.decayLength() / prong.errorDecayLength();
}
if (maxSxy < sxy) {
maxSxy = sxy;
bjetCand = prong;
}
}
Expand All @@ -674,14 +674,23 @@ bool isTaggedJetSV(T const jet, U const& /*prongs*/, float prongChi2PCAMin, floa
}

template <typename T, typename U, typename V = float>
uint8_t setTaggingIPBit(T const& jet, U const& jtracks, V trackDcaXYMax, V trackDcaZMax, V tagPointForIP, int minIPCount)
uint8_t setTaggingIPBit(T const& jet, U const& jtracks, V trackDcaXYMax, V trackDcaZMax, V tagPointForIP)
{
uint8_t bit = 0;
if (isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) {
SETBIT(bit, TaggingMethodNonML::IPs);
auto [taggedIPsN2, taggedIPsN3] = isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, false);
if (taggedIPsN2) {
SETBIT(bit, BJetTaggingMethod::IPsN2);
}
if (taggedIPsN3) {
SETBIT(bit, BJetTaggingMethod::IPsN3);
}

auto [taggedIPs3DN2, taggedIPs3DN3] = isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, true);
if (taggedIPs3DN2) {
SETBIT(bit, BJetTaggingMethod::IPs3DN2);
}
if (isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) {
SETBIT(bit, TaggingMethodNonML::IPs3D);
if (taggedIPs3DN3) {
SETBIT(bit, BJetTaggingMethod::IPs3DN3);
}
return bit;
}
Expand All @@ -691,10 +700,10 @@ uint8_t setTaggingSVBit(T const& jet, U const& prongs, V prongChi2PCAMin, V pron
{
uint8_t bit = 0;
if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, false, tagPointForSV)) {
SETBIT(bit, TaggingMethodNonML::SV);
SETBIT(bit, BJetTaggingMethod::SV);
}
if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, true, tagPointForSV)) {
SETBIT(bit, TaggingMethodNonML::SV3D);
SETBIT(bit, BJetTaggingMethod::SV3D);
}
return bit;
}
Expand Down
18 changes: 9 additions & 9 deletions PWGJE/DataModel/JetTagging.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ JETSV_TABLES_DEF(Charged, SecondaryVertex2Prong, "2PRONG");
} \
DECLARE_SOA_TABLE(_jet_type_##FlavourDef, "AOD", _description_ "FlavourDef", _name_##flavourdef::Origin);

#define JETTAGGING_TABLE_DEF(_jet_type_, _name_, _description_) \
namespace _name_##tagging \
{ \
DECLARE_SOA_COLUMN(BitTaggedjetNonML, bitTaggedjetNonML, uint8_t); \
DECLARE_SOA_COLUMN(JetProb, jetProb, float); \
DECLARE_SOA_COLUMN(ScoreML, scoreML, float); \
DECLARE_SOA_DYNAMIC_COLUMN(IsTagged, isTagged, [](uint8_t bit, TaggingMethodNonML method) -> bool { return TESTBIT(bit, method); }); \
} \
DECLARE_SOA_TABLE(_jet_type_##Tags, "AOD", _description_ "Tags", _name_##tagging::BitTaggedjetNonML, _name_##tagging::JetProb, _name_##tagging::ScoreML, _name_##tagging::IsTagged<_name_##tagging::BitTaggedjetNonML>);
#define JETTAGGING_TABLE_DEF(_jet_type_, _name_, _description_) \
namespace _name_##tagging \
{ \
DECLARE_SOA_COLUMN(BitTaggedjet, bitTaggedjet, uint8_t); \
DECLARE_SOA_COLUMN(JetProb, jetProb, float); \
DECLARE_SOA_COLUMN(ScoreML, scoreML, float); \
DECLARE_SOA_DYNAMIC_COLUMN(IsTagged, isTagged, [](uint8_t bit, BJetTaggingMethod method) -> bool { return TESTBIT(bit, method); }); \
} \
DECLARE_SOA_TABLE(_jet_type_##Tags, "AOD", _description_ "Tags", _name_##tagging::BitTaggedjet, _name_##tagging::JetProb, _name_##tagging::ScoreML, _name_##tagging::IsTagged<_name_##tagging::BitTaggedjet>);

#define JETTAGGING_TABLES_DEF(_jet_type_, _description_) \
JETTAGGING_TABLE_DEF(_jet_type_##Jet, _jet_type_##jet, _description_) \
Expand Down
3 changes: 1 addition & 2 deletions PWGJE/TableProducer/jetTaggerHF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ struct JetTaggerHFTask {
Configurable<std::vector<float>> paramsResoFuncBeautyJetMC{"paramsResoFuncBeautyJetMC", std::vector<float>{74901.583, -0.082, 0.874, 10.332, 0.941, 7.352, 0.097, 6.220, 0.022}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"};
Configurable<std::vector<float>> paramsResoFuncLfJetMC{"paramsResoFuncLfJetMC", std::vector<float>{1539435.343, -0.061, 0.896, 13.272, 1.034, 5.884, 0.004, 7.843, 0.090}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"};
Configurable<float> minSignImpXYSig{"minSignImpXYSig", -40.0, "minimum of signed impact parameter significance"};
Configurable<int> minIPCount{"minIPCount", 2, "Select at least N signed impact parameter significance in jets"}; // default 2
Configurable<float> tagPointForIP{"tagPointForIP", 2.5, "tagging working point for IP"};
Configurable<float> tagPointForIPxyz{"tagPointForIPxyz", 2.5, "tagging working point for IP xyz"};
// configuration about SV method
Expand Down Expand Up @@ -305,7 +304,7 @@ struct JetTaggerHFTask {
void processIP(JetTable const& jets, JetTracksExt const& jtracks)
{
for (const auto& jet : jets) {
uint8_t bit = jettaggingutilities::setTaggingIPBit(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount);
uint8_t bit = jettaggingutilities::setTaggingIPBit(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP);
decisionNonML[jet.globalIndex()] |= bit;
}
}
Expand Down
Loading
Loading