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
20 changes: 10 additions & 10 deletions PWGJE/Core/JetTaggingUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@

int motherStatusCode = std::abs(mother.getGenStatusCode());

if (motherStatusCode == 23 || motherStatusCode == 33 || motherStatusCode == 43 || motherStatusCode == 63) {

Check failure on line 158 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return mother.globalIndex();
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@

int motherStatusCode = std::abs(mother.getGenStatusCode());

if (motherStatusCode == 23 || motherStatusCode == 33 || motherStatusCode == 43 || motherStatusCode == 63 || (motherStatusCode == 51 && mother.template mothers_first_as<T>().pdgCode() == 21)) {

Check failure on line 186 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 186 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
return mother.globalIndex();
}
}
Expand Down Expand Up @@ -211,12 +211,12 @@
hasMcParticle = true;
auto const& particle = track.template mcParticle_as<V>();
origin = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark);
if (origin == 1 || origin == 2) { // 1=charm , 2=beauty
if (origin == RecoDecay::OriginType::Prompt || origin == RecoDecay::OriginType::NonPrompt) { // 1=charm , 2=beauty
hftrack = track;
if (origin == 1) {
if (origin == RecoDecay::OriginType::Prompt) {
return JetTaggingSpecies::charm;
}
if (origin == 2) {
if (origin == RecoDecay::OriginType::NonPrompt) {
return JetTaggingSpecies::beauty;
}
}
Expand Down Expand Up @@ -244,12 +244,12 @@
for (const auto& particle : jet.template tracks_as<U>()) {
hfparticle = particle; // for init if origin is 1 or 2, the particle is not hfparticle
origin = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark);
if (origin == 1 || origin == 2) { // 1=charm , 2=beauty
if (origin == RecoDecay::OriginType::Prompt || origin == RecoDecay::OriginType::NonPrompt) { // 1=charm , 2=beauty
hfparticle = particle;
if (origin == 1) {
if (origin == RecoDecay::OriginType::Prompt) {
return JetTaggingSpecies::charm;
}
if (origin == 2) {
if (origin == RecoDecay::OriginType::NonPrompt) {
return JetTaggingSpecies::beauty;
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@
typename U::iterator parton1;
typename U::iterator parton2;
for (auto const& particle : particles) {
if (std::abs(particle.getGenStatusCode() == 23)) {

Check failure on line 353 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (!firstPartonFound) {
parton1 = particle;
firstPartonFound = true;
Expand Down Expand Up @@ -387,13 +387,13 @@
bool charmQuark = false;
for (auto const& mcpart : mcparticles) {
int pdgcode = mcpart.pdgCode();
if (std::abs(pdgcode) == 21 || (std::abs(pdgcode) >= 1 && std::abs(pdgcode) <= 5)) {

Check failure on line 390 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 390 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
double dR = jetutilities::deltaR(jet, mcpart);

if (dR < jet.r() / 100.f) {
if (std::abs(pdgcode) == 5) {

Check failure on line 394 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 394 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
return JetTaggingSpecies::beauty; // Beauty jet
} else if (std::abs(pdgcode) == 4) {

Check failure on line 396 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
charmQuark = true;
}
}
Expand Down Expand Up @@ -916,7 +916,7 @@

trkLabels["trkVtxIndex"] = std::vector<int>(nTrks, -1);
if (count.size() != 0) { // If there is any SV cluster not only PV cluster
for (auto& [idx, avgDistance] : avgDistances) // o2-linter: disable=const-ref-in-for-loop

Check failure on line 919 in PWGJE/Core/JetTaggingUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
avgDistance /= count[idx];

nVertices += avgDistances.size();
Expand Down Expand Up @@ -993,11 +993,11 @@

// Looping over the track info and putting them in the input vector
template <typename AnalysisJet, typename AnyTracks, typename SecondaryVertices>
void analyzeJetTrackInfo4ML(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector<BJetTrackParams>& tracksParams, float trackPtMin = 0.5)
void analyzeJetTrackInfo4ML(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector<BJetTrackParams>& tracksParams, float trackPtMin = 0.5, float trackDcaXYMax = 10.0, float trackDcaZMax = 10.0)
{
for (const auto& constituent : analysisJet.template tracks_as<AnyTracks>()) {

if (constituent.pt() < trackPtMin) {
if (constituent.pt() < trackPtMin || !trackAcceptanceWithDca(constituent, trackDcaXYMax, trackDcaZMax)) {
continue;
}

Expand Down Expand Up @@ -1026,11 +1026,11 @@

// Looping over the track info and putting them in the input vector without using any SV info
template <typename AnalysisJet, typename AnyTracks>
void analyzeJetTrackInfo4MLnoSV(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, std::vector<BJetTrackParams>& tracksParams, float trackPtMin = 0.5)
void analyzeJetTrackInfo4MLnoSV(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, std::vector<BJetTrackParams>& tracksParams, float trackPtMin = 0.5, float trackDcaXYMax = 10.0, float trackDcaZMax = 10.0)
{
for (const auto& constituent : analysisJet.template tracks_as<AnyTracks>()) {

if (constituent.pt() < trackPtMin) {
if (constituent.pt() < trackPtMin || !trackAcceptanceWithDca(constituent, trackDcaXYMax, trackDcaZMax)) {
continue;
}

Expand Down
5 changes: 5 additions & 0 deletions PWGJE/Core/MlResponseHfTagging.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class MlResponseHfTagging : public MlResponse<TypeOutputScore>
/// @return A vector of input shapes
std::vector<std::vector<int64_t>> getInputShape() const { return this->mModels[0].getInputShapes(); }

/// @brief Method to get the output shape of a model
/// \param imod is the index of the model
/// @return number of output nodes
int getOutputNodes(int imod = 0) const { return this->mModels[imod].getNumOutputNodes(); }

/// Method to fill the inputs of jet, tracks and secondary vertices
/// \param jet is the b-jet candidate
/// \param tracks is the vector of tracks associated to the jet
Expand Down
33 changes: 21 additions & 12 deletions PWGJE/TableProducer/jetTaggerHF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct JetTaggerHFTask {
Configurable<LabeledArray<double>> cutsMl{"cutsMl", {DefaultCutsMl[0], 1, 2, {"pT bin 0"}, {"score for default b-jet tagging", "uncer 1"}}, "ML selections per pT bin"};
Configurable<int> nClassesMl{"nClassesMl", 2, "Number of classes in ML model"};
Configurable<std::vector<std::string>> namesInputFeatures{"namesInputFeatures", std::vector<std::string>{"feature1", "feature2"}, "Names of ML model input features"};
Configurable<bool> useDb{"useDb", false, "Flag to use DB for ML model instead of the score"};

Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<std::vector<std::string>> modelPathsCCDB{"modelPathsCCDB", std::vector<std::string>{"Users/h/hahassan"}, "Paths of models on CCDB"};
Expand Down Expand Up @@ -297,16 +298,16 @@ struct JetTaggerHFTask {
std::map<std::string, std::string> metadata;
resoFuncMatch = resoFuncMatching;

const int IPmethodResolutionFunctionSize = 7;
const int mIPmethodResolutionFunctionSize = 7;

auto loadCCDBforIP = [&](const std::vector<std::string>& paths, std::vector<TF1*>& targetVec, const std::string& name) {
if (paths.size() != IPmethodResolutionFunctionSize) {
if (paths.size() != mIPmethodResolutionFunctionSize) {
usepTcategorize.value = false;
LOG(info) << name << " does not have 7 entries. Disabling pT categorization (usepTcategorize = false).";
resoFuncMatch = 0;
return;
}
for (int i = 0; i < IPmethodResolutionFunctionSize; i++) {
for (int i = 0; i < mIPmethodResolutionFunctionSize; i++) {
targetVec.push_back(ccdbApi.retrieveFromTFileAny<TF1>(paths[i], metadata, -1));
}
};
Expand Down Expand Up @@ -335,7 +336,7 @@ struct JetTaggerHFTask {
}

maxOrder = numCount + 1; // 0: untagged, >1 : N ordering
const int IPmethodNumOfParameters = 9;
const int mIPmethodNumOfParameters = 9;

// Set up the resolution function
switch (resoFuncMatch) {
Expand Down Expand Up @@ -383,7 +384,7 @@ struct JetTaggerHFTask {
for (size_t j = 0; j < resoFuncIncCCDB.size(); j++) {
std::vector<float> params;
if (resoFuncIncCCDB[j]) {
for (int i = 0; i < IPmethodNumOfParameters; i++) {
for (int i = 0; i < mIPmethodNumOfParameters; i++) {
params.emplace_back(resoFuncIncCCDB[j]->GetParameter(i));
}
}
Expand All @@ -397,7 +398,7 @@ struct JetTaggerHFTask {
for (size_t j = 0; j < resoFuncBeautyCCDB.size(); j++) {
std::vector<float> params;
if (resoFuncBeautyCCDB[j]) {
for (int i = 0; i < IPmethodNumOfParameters; i++) {
for (int i = 0; i < mIPmethodNumOfParameters; i++) {
params.emplace_back(resoFuncBeautyCCDB[j]->GetParameter(i));
}
}
Expand All @@ -406,7 +407,7 @@ struct JetTaggerHFTask {
for (size_t j = 0; j < resoFuncCharmCCDB.size(); j++) {
std::vector<float> params;
if (resoFuncCharmCCDB[j]) {
for (int i = 0; i < IPmethodNumOfParameters; i++) {
for (int i = 0; i < mIPmethodNumOfParameters; i++) {
params.emplace_back(resoFuncCharmCCDB[j]->GetParameter(i));
}
}
Expand All @@ -415,7 +416,7 @@ struct JetTaggerHFTask {
for (size_t j = 0; j < resoFuncLfCCDB.size(); j++) {
std::vector<float> params;
if (resoFuncLfCCDB[j]) {
for (int i = 0; i < IPmethodNumOfParameters; i++) {
for (int i = 0; i < mIPmethodNumOfParameters; i++) {
params.emplace_back(resoFuncLfCCDB[j]->GetParameter(i));
}
}
Expand All @@ -427,7 +428,7 @@ struct JetTaggerHFTask {
for (size_t j = 0; j < resoFuncDataCCDB.size(); j++) {
std::vector<float> params;
if (resoFuncDataCCDB[j]) {
for (int i = 0; i < IPmethodNumOfParameters; i++) {
for (int i = 0; i < mIPmethodNumOfParameters; i++) {
params.emplace_back(resoFuncDataCCDB[j]->GetParameter(i));
}
}
Expand Down Expand Up @@ -507,7 +508,7 @@ struct JetTaggerHFTask {
std::vector<jettaggingutilities::BJetSVParams> svsParams;

jettaggingutilities::analyzeJetSVInfo4ML(analysisJet, allTracks, allSVs, svsParams, svPtMin, svReductionFactor);
jettaggingutilities::analyzeJetTrackInfo4ML(analysisJet, allTracks, allSVs, tracksParams, trackPtMin);
jettaggingutilities::analyzeJetTrackInfo4ML(analysisJet, allTracks, allSVs, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax);

int nSVs = analysisJet.template secondaryVertices_as<SecondaryVertices>().size();

Expand All @@ -525,7 +526,15 @@ struct JetTaggerHFTask {
bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output);
}

scoreML[analysisJet.globalIndex()] = output[0];
if (bMlResponse.getOutputNodes() > 1) {
auto mDb = [](std::vector<float> scores, float fC) {
return std::log(scores[2] / (fC * scores[1] + (1 - fC) * scores[0]));
};

scoreML[analysisJet.globalIndex()] = useDb ? mDb(output, fC) : output[2]; // 2 is the b-jet index
} else {
scoreML[analysisJet.globalIndex()] = output[0];
}
}
}

Expand All @@ -537,7 +546,7 @@ struct JetTaggerHFTask {
std::vector<jettaggingutilities::BJetTrackParams> tracksParams;
std::vector<jettaggingutilities::BJetSVParams> svsParams;

jettaggingutilities::analyzeJetTrackInfo4MLnoSV(analysisJet, allTracks, tracksParams, trackPtMin);
jettaggingutilities::analyzeJetTrackInfo4MLnoSV(analysisJet, allTracks, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax);

jettaggingutilities::BJetParams jetparam = {analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), static_cast<int>(tracksParams.size()), 0, analysisJet.mass()};
tracksParams.resize(nJetConst); // resize to the number of inputs of the ML
Expand Down
4 changes: 3 additions & 1 deletion PWGJE/TableProducer/secondaryVertexReconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct SecondaryVertexReconstruction {
Configurable<float> ptMinTrack{"ptMinTrack", -1., "min. track pT"};
Configurable<float> etaMinTrack{"etaMinTrack", -99999., "min. pseudorapidity"};
Configurable<float> etaMaxTrack{"etaMaxTrack", 4., "max. pseudorapidity"};
Configurable<float> maxIPxy{"maxIPxy", 10, "maximum track DCA in xy plane"};
Configurable<float> maxIPz{"maxIPz", 10, "maximum track DCA in z direction"};
Configurable<bool> fillHistograms{"fillHistograms", true, "do validation plots"};

Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Expand Down Expand Up @@ -288,7 +290,7 @@ struct SecondaryVertexReconstruction {
for (size_t iprong = prongIndex; iprong < particles.size(); ++iprong) {

const auto& testTrack = particles[iprong].template track_as<OriginalTracks>();
if (testTrack.pt() < ptMinTrack || testTrack.eta() < etaMinTrack || testTrack.eta() > etaMaxTrack) {
if (testTrack.pt() < ptMinTrack || testTrack.eta() < etaMinTrack || testTrack.eta() > etaMaxTrack || std::abs(testTrack.dcaXY()) > maxIPxy || std::abs(testTrack.dcaZ()) > maxIPz) {
continue;
}

Expand Down
Loading
Loading