Skip to content

Commit 0e086fb

Browse files
author
Changhwan Choi
committed
Resolved MegaLinter issues, changed HnSparse inputs
1 parent 648a912 commit 0e086fb

File tree

1 file changed

+21
-41
lines changed

1 file changed

+21
-41
lines changed

PWGJE/Tasks/bjetTaggingGNN.cxx

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <algorithm>
1818
#include <cmath>
19+
#include <vector>
20+
#include <string>
1921

2022
#include "Framework/AnalysisDataModel.h"
2123
#include "Framework/AnalysisTask.h"
@@ -82,19 +84,15 @@ struct BjetTaggingGNN {
8284

8385
Configurable<bool> doDataDriven{"doDataDriven", false, "Flag whether to use fill THnSpase for data driven methods"};
8486

85-
std::vector<int> eventSelectionBits;
87+
int eventSelection = -1;
8688

8789
std::vector<double> jetRadiiValues;
8890

8991
void init(InitContext const&)
9092
{
91-
// Seed the random number generator using current time
92-
// std::srand(static_cast<unsigned int>(std::time(nullptr)));
93-
// std::srand(42);
94-
9593
jetRadiiValues = (std::vector<double>)jetRadii;
9694

97-
eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast<std::string>(eventSelections));
95+
eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast<std::string>(eventSelections));
9896

9997
registry.add("h_vertexZ", "Vertex Z;#it{Z} (cm)", {HistType::kTH1F, {{40, -20.0, 20.0}}});
10098

@@ -173,13 +171,13 @@ struct BjetTaggingGNN {
173171
}
174172

175173
if (doDataDriven) {
176-
registry.add("hSparse_Incljets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
174+
registry.add("hSparse_Incljets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
177175
if (doprocessMCJets) {
178-
registry.add("hSparse_bjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
179-
registry.add("hSparse_cjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
180-
registry.add("hSparse_lfjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
181-
registry.add("hSparse_lfjets_none", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
182-
registry.add("hSparse_lfjets_matched", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisSVEnergy, axisSLxy, axisJetMass, axisJetProb, axisNTracks}});
176+
registry.add("hSparse_bjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
177+
registry.add("hSparse_cjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
178+
registry.add("hSparse_lfjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
179+
registry.add("hSparse_lfjets_none", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
180+
registry.add("hSparse_lfjets_matched", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}});
183181
}
184182
}
185183
}
@@ -205,6 +203,8 @@ struct BjetTaggingGNN {
205203
continue;
206204
}
207205

206+
// ...
207+
208208
++nTracks;
209209
}
210210
return nTracks;
@@ -215,15 +215,12 @@ struct BjetTaggingGNN {
215215
{
216216
using SVType = typename SecondaryVertices::iterator;
217217

218-
// Min-heap to store the top 30 SVs by decayLengthXY/errorDecayLengthXY
219218
auto compare = [](SVType& sv1, SVType& sv2) {
220219
return (sv1.decayLengthXY() / sv1.errorDecayLengthXY()) > (sv2.decayLengthXY() / sv2.errorDecayLengthXY());
221220
};
222221

223222
auto svs = analysisJet.template secondaryVertices_as<SecondaryVertices>();
224223

225-
// Sort the SVs based on their decay length significance in descending order
226-
// This is needed in order to select longest SVs since some jets could have thousands of SVs
227224
std::sort(svs.begin(), svs.end(), compare);
228225

229226
checkSV = false;
@@ -235,27 +232,10 @@ struct BjetTaggingGNN {
235232

236233
checkSV = true;
237234
return candSV;
238-
239-
// double deltaRJetSV = jetutilities::deltaR(myJet, candSV);
240-
// double massSV = candSV.m();
241-
// double energySV = candSV.e();
242235
}
243236

244237
// No SV found
245238
return *allSVs.begin();
246-
247-
// auto isValidSV = [this](const SVType& sv) {
248-
// return sv.pt() > this->svPtMin;
249-
// };
250-
// auto compare = [&isValidSV](const SVType& sv1, const SVType& sv2) {
251-
// return (sv1.decayLengthXY() / sv1.errorDecayLengthXY() < sv2.decayLengthXY() / sv2.errorDecayLengthXY() && isValidSV(sv2)) || (!isValidSV(sv1) && isValidSV(sv2));
252-
// };
253-
254-
// auto svs = analysisJet.template secondaryVertices_as<SecondaryVertices>();
255-
// auto maxSV = std::max_element(svs.begin(), svs.end(), compare);
256-
// checkSV = (maxSV != svs.end()) && isValidSV(*maxSV);
257-
258-
// return *maxSV;
259239
}
260240

261241
void processDummy(FilteredCollision::iterator const& /*collision*/)
@@ -265,7 +245,7 @@ struct BjetTaggingGNN {
265245

266246
void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, SVTable const& allSVs)
267247
{
268-
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
248+
if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) {
269249
return;
270250
}
271251

@@ -312,7 +292,7 @@ struct BjetTaggingGNN {
312292
registry.fill(HIST("h2_jetpT_nTracks"), analysisJet.pt(), nTracks);
313293

314294
if (doDataDriven) {
315-
registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks);
295+
registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks);
316296
}
317297
}
318298
}
@@ -324,7 +304,7 @@ struct BjetTaggingGNN {
324304

325305
void processMCJets(FilteredCollisionMCD::iterator const& collision, MCDJetTable const& MCDjets, MCPJetTable const& /*MCPjets*/, JetTracksMCDwID const& allTracks, MCDSVTable const& allSVs, aod::JetParticles const& /*MCParticles*/)
326306
{
327-
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
307+
if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) {
328308
return;
329309
}
330310

@@ -441,17 +421,17 @@ struct BjetTaggingGNN {
441421
}
442422

443423
if (doDataDriven) {
444-
registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
424+
registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
445425
if (jetFlavor == JetTaggingSpecies::beauty) {
446-
registry.fill(HIST("hSparse_bjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
426+
registry.fill(HIST("hSparse_bjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
447427
} else if (jetFlavor == JetTaggingSpecies::charm) {
448-
registry.fill(HIST("hSparse_cjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
428+
registry.fill(HIST("hSparse_cjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
449429
} else {
450-
registry.fill(HIST("hSparse_lfjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
430+
registry.fill(HIST("hSparse_lfjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
451431
if (jetFlavor == JetTaggingSpecies::none) {
452-
registry.fill(HIST("hSparse_lfjets_none"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
432+
registry.fill(HIST("hSparse_lfjets_none"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
453433
} else {
454-
registry.fill(HIST("hSparse_lfjets_matched"), analysisJet.pt(), analysisJet.scoreML(), mSV, eSV, slXY, analysisJet.mass(), analysisJet.jetProb(), nTracks, weight);
434+
registry.fill(HIST("hSparse_lfjets_matched"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight);
455435
}
456436
}
457437
}

0 commit comments

Comments
 (0)