Skip to content

Commit 6ea76ab

Browse files
authored
Merge pull request #24 from hahassan7/btagFramework
Adding N2 and N3 taggers instead of just IPs
2 parents da21ffe + ed936ec commit 6ea76ab

File tree

4 files changed

+82
-74
lines changed

4 files changed

+82
-74
lines changed

PWGJE/Core/JetTaggingUtilities.h

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ enum JetTaggingSpecies {
4444
gluon = 5
4545
};
4646

47-
enum TaggingMethodNonML {
48-
IPs = 0,
49-
IPs3D = 1,
50-
SV = 2,
51-
SV3D = 3
47+
enum BJetTaggingMethod {
48+
IPsN2 = 0,
49+
IPsN3 = 1,
50+
IPs3DN2 = 2,
51+
IPs3DN3 = 3,
52+
SV = 4,
53+
SV3D = 5
5254
};
5355

5456
namespace jettaggingutilities
@@ -443,21 +445,17 @@ bool prongAcceptance(T const& prong, float prongChi2PCAMin, float prongChi2PCAMa
443445
return false;
444446
if (prong.chi2PCA() > prongChi2PCAMax)
445447
return false;
448+
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
449+
return false;
450+
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
451+
return false;
452+
446453
if (!doXYZ) {
447454
if (prong.errorDecayLengthXY() > prongsigmaLxyMax)
448455
return false;
449-
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
450-
return false;
451-
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
452-
return false;
453456
} else {
454457
if (prong.errorDecayLength() > prongsigmaLxyMax)
455458
return false;
456-
// TODO
457-
if (std::abs(prong.impactParameterXY()) < prongIPxyMin)
458-
return false;
459-
if (std::abs(prong.impactParameterXY()) > prongIPxyMax)
460-
return false;
461459
}
462460
return true;
463461
}
@@ -514,25 +512,26 @@ void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float trackDcaXYMax
514512

515513
/**
516514
* Checks if a jet is greater than the given tagging working point based on the signed impact parameter significances
515+
* return (true, true) if the jet is tagged by the 2nd and 3rd largest IPs
517516
*/
518517
template <typename T, typename U>
519-
bool isGreaterThanTaggingPoint(T const& jet, U const& jtracks, float trackDcaXYMax, float trackDcaZMax, float taggingPoint = 1.0, int cnt = 1, bool useIPxyz = false)
518+
std::tuple<bool, bool> isGreaterThanTaggingPoint(T const& jet, U const& jtracks, float trackDcaXYMax, float trackDcaZMax, float taggingPoint = 1.0, bool useIPxyz = false)
520519
{
521-
if (cnt == 0) {
522-
return true; // untagged
523-
}
520+
bool taggedIPsN2 = false;
521+
bool taggedIPsN3 = false;
524522
std::vector<float> vecSignImpSig;
525523
orderForIPJetTracks(jet, jtracks, trackDcaXYMax, trackDcaZMax, vecSignImpSig, useIPxyz);
526-
if (vecSignImpSig.size() > static_cast<std::vector<float>::size_type>(cnt) - 1) {
527-
for (int i = 0; i < cnt; i++) {
528-
if (vecSignImpSig[i] < taggingPoint) { // tagger point set
529-
return false;
530-
}
524+
if (vecSignImpSig.size() > 1) {
525+
if (vecSignImpSig[1] > taggingPoint) { // tagger point set
526+
taggedIPsN2 = true;
531527
}
532-
} else {
533-
return false;
534528
}
535-
return true;
529+
if (vecSignImpSig.size() > 2) {
530+
if (vecSignImpSig[2] > taggingPoint) { // tagger point set
531+
taggedIPsN3 = true;
532+
}
533+
}
534+
return std::make_tuple(taggedIPsN2, taggedIPsN3);
536535
}
537536

538537
/**
@@ -648,6 +647,7 @@ typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, floa
648647
sxy = prong.decayLength() / prong.errorDecayLength();
649648
}
650649
if (maxSxy < sxy) {
650+
maxSxy = sxy;
651651
bjetCand = prong;
652652
}
653653
}
@@ -674,14 +674,23 @@ bool isTaggedJetSV(T const jet, U const& /*prongs*/, float prongChi2PCAMin, floa
674674
}
675675

676676
template <typename T, typename U, typename V = float>
677-
uint8_t setTaggingIPBit(T const& jet, U const& jtracks, V trackDcaXYMax, V trackDcaZMax, V tagPointForIP, int minIPCount)
677+
uint8_t setTaggingIPBit(T const& jet, U const& jtracks, V trackDcaXYMax, V trackDcaZMax, V tagPointForIP)
678678
{
679679
uint8_t bit = 0;
680-
if (isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) {
681-
SETBIT(bit, TaggingMethodNonML::IPs);
680+
auto [taggedIPsN2, taggedIPsN3] = isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, false);
681+
if (taggedIPsN2) {
682+
SETBIT(bit, BJetTaggingMethod::IPsN2);
683+
}
684+
if (taggedIPsN3) {
685+
SETBIT(bit, BJetTaggingMethod::IPsN3);
686+
}
687+
688+
auto [taggedIPs3DN2, taggedIPs3DN3] = isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, true);
689+
if (taggedIPs3DN2) {
690+
SETBIT(bit, BJetTaggingMethod::IPs3DN2);
682691
}
683-
if (isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) {
684-
SETBIT(bit, TaggingMethodNonML::IPs3D);
692+
if (taggedIPs3DN3) {
693+
SETBIT(bit, BJetTaggingMethod::IPs3DN3);
685694
}
686695
return bit;
687696
}
@@ -691,10 +700,10 @@ uint8_t setTaggingSVBit(T const& jet, U const& prongs, V prongChi2PCAMin, V pron
691700
{
692701
uint8_t bit = 0;
693702
if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, false, tagPointForSV)) {
694-
SETBIT(bit, TaggingMethodNonML::SV);
703+
SETBIT(bit, BJetTaggingMethod::SV);
695704
}
696705
if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, true, tagPointForSV)) {
697-
SETBIT(bit, TaggingMethodNonML::SV3D);
706+
SETBIT(bit, BJetTaggingMethod::SV3D);
698707
}
699708
return bit;
700709
}

PWGJE/DataModel/JetTagging.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ JETSV_TABLES_DEF(Charged, SecondaryVertex2Prong, "2PRONG");
129129
} \
130130
DECLARE_SOA_TABLE(_jet_type_##FlavourDef, "AOD", _description_ "FlavourDef", _name_##flavourdef::Origin);
131131

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

142142
#define JETTAGGING_TABLES_DEF(_jet_type_, _description_) \
143143
JETTAGGING_TABLE_DEF(_jet_type_##Jet, _jet_type_##jet, _description_) \

PWGJE/TableProducer/jetTaggerHF.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ struct JetTaggerHFTask {
6464
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)))"};
6565
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)))"};
6666
Configurable<float> minSignImpXYSig{"minSignImpXYSig", -40.0, "minimum of signed impact parameter significance"};
67-
Configurable<int> minIPCount{"minIPCount", 2, "Select at least N signed impact parameter significance in jets"}; // default 2
6867
Configurable<float> tagPointForIP{"tagPointForIP", 2.5, "tagging working point for IP"};
6968
Configurable<float> tagPointForIPxyz{"tagPointForIPxyz", 2.5, "tagging working point for IP xyz"};
7069
// configuration about SV method
@@ -305,7 +304,7 @@ struct JetTaggerHFTask {
305304
void processIP(JetTable const& jets, JetTracksExt const& jtracks)
306305
{
307306
for (const auto& jet : jets) {
308-
uint8_t bit = jettaggingutilities::setTaggingIPBit(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount);
307+
uint8_t bit = jettaggingutilities::setTaggingIPBit(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP);
309308
decisionNonML[jet.globalIndex()] |= bit;
310309
}
311310
}

0 commit comments

Comments
 (0)