Skip to content

Commit 47a8656

Browse files
Update qgTreeCreator.cxx
1 parent c415b12 commit 47a8656

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

PWGJE/Tasks/qgTreeCreator.cxx

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11-
1211
#include "PWGJE/DataModel/Jet.h"
1312
#include "PWGJE/DataModel/JetMatching.h"
1413

14+
#include "Common/Core/RecoDecay.h"
1515
#include "Common/DataModel/MCTruthContainer.h"
1616
#include "Common/DataModel/TrackSelectionTables.h"
1717

@@ -25,6 +25,19 @@
2525
using namespace o2;
2626
using namespace o2::framework;
2727

28+
namespace
29+
{
30+
constexpr int kGluon = 21;
31+
constexpr int kQuarkMin = 1;
32+
constexpr int kQuarkMax = 6;
33+
34+
float deltaR(float eta1, float phi1, float eta2, float phi2)
35+
{
36+
const float deta = eta1 - eta2;
37+
const float dphi = RecoDecay::constrainAngle(phi1 - phi2);
38+
return std::sqrt(deta * deta + dphi * dphi);
39+
}
40+
} // namespace
2841
namespace o2::aod
2942
{
3043
DECLARE_SOA_COLUMN(JetPt, jetPt, float);
@@ -48,22 +61,6 @@ DECLARE_SOA_TABLE(QGJetTable, "AOD", "QGJET",
4861
PtResponse,
4962
QGLabel);
5063
} // namespace o2::aod
51-
52-
//------------------------------------------------
53-
// helper functions
54-
//------------------------------------------------
55-
float deltaPhi(float phi1, float phi2)
56-
{
57-
return std::remainder(phi1 - phi2, 2.f * static_cast<float>(M_PI));
58-
}
59-
60-
float deltaR(float eta1, float phi1, float eta2, float phi2)
61-
{
62-
float deta = eta1 - eta2;
63-
float dphi = deltaPhi(phi1, phi2);
64-
return std::sqrt(deta * deta + dphi * dphi);
65-
}
66-
6764
//------------------------------------------------
6865
// find initiating parton by ancestry
6966
//------------------------------------------------
@@ -80,10 +77,10 @@ int getInitiatingParton(auto const& particle,
8077
}
8178

8279
auto mom = mothers.iteratorAt(0);
83-
int mpdg = mom.pdgCode();
80+
const int mpdg = mom.pdgCode();
8481

85-
// stop at quark or gluon
86-
if (std::abs(mpdg) == 21 || (std::abs(mpdg) >= 1 && std::abs(mpdg) <= 6)) {
82+
if (std::abs(mpdg) == kGluon ||
83+
(std::abs(mpdg) >= kQuarkMin && std::abs(mpdg) <= kQuarkMax)) {
8784
pdg = mpdg;
8885
}
8986

@@ -92,7 +89,6 @@ int getInitiatingParton(auto const& particle,
9289

9390
return pdg;
9491
}
95-
9692
//------------------------------------------------
9793
// main task
9894
//------------------------------------------------
@@ -133,9 +129,9 @@ struct QGTreeCreator {
133129
float girth = sumPt > 0 ? sumPtDr / sumPt : -1;
134130
float ptd = sumPt > 0 ? std::sqrt(sumPt2) / sumPt : -1;
135131

136-
//----------------------------------
137-
// matching block
138-
//----------------------------------
132+
//------------------------------------------------
133+
// matching
134+
//------------------------------------------------
139135
float matchDr = -1;
140136
float ptResp = -1;
141137
int qg = -1;
@@ -180,11 +176,11 @@ struct QGTreeCreator {
180176
//----------------------------------
181177
// assign q/g label
182178
//----------------------------------
183-
if (std::abs(pdg) == 21) {
184-
qg = 1; // gluon
185-
} else if (std::abs(pdg) >= 1 && std::abs(pdg) <= 6) {
186-
qg = 0; // quark
187-
}
179+
if (std::abs(pdg) == kGluon) {
180+
qg = 1;
181+
} else if (std::abs(pdg) >= kQuarkMin && std::abs(pdg) <= kQuarkMax) {
182+
qg = 0;
183+
}
188184

189185
break;
190186
}
@@ -205,5 +201,5 @@ struct QGTreeCreator {
205201
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
206202
{
207203
return WorkflowSpec{
208-
adaptAnalysisTask<QGTreeCreator>(cfgc, TaskName{"qg-tree-creator"})};
204+
adaptAnalysisTask<QGTreeCreator>(cfgc)};
209205
}

0 commit comments

Comments
 (0)