Skip to content

Commit d2f1fa0

Browse files
committed
bug fixes to core tasks
1 parent 4949b44 commit d2f1fa0

27 files changed

+156
-224
lines changed

PWGJE/Core/FastJetUtilities.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515

1616
#include <vector>
1717

18-
void fastjetutilities::setFastJetUserInfo(std::vector<fastjet::PseudoJet>& constituents, int index, int status)
18+
void fastjetutilities::setFastJetUserInfo(std::vector<fastjet::PseudoJet>& constituents, int index, JetConstituentStatus status)
1919
{
2020
fastjet_user_info* user_info = new fastjet_user_info(status, index); // FIXME: can setting this as a pointer be avoided?
2121
constituents.back().set_user_info(user_info);
22-
if (index != -99999999) { // FIXME: in principle needed for constituent subtraction, particularly when clusters are added to the subtraction. However since the HF particle is not subtracted then we dont need to check for it in this manner
22+
if (index != invalidIndex) { // FIXME: in principle needed for constituent subtraction, particularly when clusters are added to the subtraction. However since the HF particle is not subtracted then we dont need to check for it in this manner
2323
int i = index;
24-
if (status == static_cast<int>(JetConstituentStatus::track)) {
24+
if (status == JetConstituentStatus::track) {
2525
i = i + 1;
2626
}
27-
if (status == static_cast<int>(JetConstituentStatus::cluster)) {
27+
if (status == JetConstituentStatus::cluster) {
2828
i = -1 * (i + 1);
2929
}
30-
if (status == static_cast<int>(JetConstituentStatus::candidate)) {
30+
if (status == JetConstituentStatus::candidate) {
3131
i = 0;
3232
}
3333
constituents.back().set_user_index(i); // FIXME: needed for constituent subtraction, but need to be quite careful to make sure indices dont overlap between tracks, clusters and HF candidates. Current solution might not be optimal

PWGJE/Core/FastJetUtilities.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include <cmath>
2525
#include <vector>
2626

27+
constexpr int invalidIndex = -99999999;
28+
2729
enum class JetConstituentStatus {
30+
invalidStatus = -1,
2831
track = 0,
2932
cluster = 1,
3033
candidate = 2
@@ -36,24 +39,24 @@ namespace fastjetutilities
3639
// Class defined to store additional info which is passed to the FastJet object
3740
class fastjet_user_info : public fastjet::PseudoJet::UserInfoBase
3841
{
39-
int status; // the status of each particle (Options are: TrueParticle (final state particles in generator event which arent special), HFParticle (heavy-flavour particle of interest in generator event), ThermalParticle (particles belonging to the thermal backgound), DecaySisterParticle (other particles poduced in the decay resulting in a non-prompt heavy-flavour particle of interest))
42+
JetConstituentStatus status; // the status of each particle (Options are: TrueParticle (final state particles in generator event which arent special), HFParticle (heavy-flavour particle of interest in generator event), ThermalParticle (particles belonging to the thermal backgound), DecaySisterParticle (other particles poduced in the decay resulting in a non-prompt heavy-flavour particle of interest))
4043
int index; // a number unique to each particle in the event
4144

4245
public:
4346
fastjet_user_info()
4447
{
45-
status = -9;
48+
status = JetConstituentStatus::invalidStatus;
4649
index = -9;
4750
}
48-
fastjet_user_info(int _status, int _index)
51+
fastjet_user_info(JetConstituentStatus _status, int _index)
4952
{
5053
status = _status;
5154
index = _index;
5255
}
5356
~fastjet_user_info() = default;
54-
void setStatus(int set) { status = set; }
57+
void setStatus(JetConstituentStatus set) { status = set; }
5558
void setIndex(int set) { index = set; }
56-
int getStatus() const { return status; }
59+
JetConstituentStatus getStatus() const { return status; }
5760
int getIndex() const { return index; }
5861
};
5962

@@ -65,7 +68,7 @@ class fastjet_user_info : public fastjet::PseudoJet::UserInfoBase
6568
* @param status status of constituent type
6669
*/
6770

68-
void setFastJetUserInfo(std::vector<fastjet::PseudoJet>& constituents, int index = -99999999, int status = static_cast<int>(JetConstituentStatus::track));
71+
void setFastJetUserInfo(std::vector<fastjet::PseudoJet>& constituents, int index = invalidIndex, JetConstituentStatus status = JetConstituentStatus::track);
6972

7073
/**
7174
* Add track as a pseudojet object to the fastjet vector
@@ -78,9 +81,9 @@ void setFastJetUserInfo(std::vector<fastjet::PseudoJet>& constituents, int index
7881
*/
7982

8083
template <typename T>
81-
void fillTracks(const T& constituent, std::vector<fastjet::PseudoJet>& constituents, int index = -99999999, int status = static_cast<int>(JetConstituentStatus::track), float mass = o2::constants::physics::MassPiPlus)
84+
void fillTracks(const T& constituent, std::vector<fastjet::PseudoJet>& constituents, int index = invalidIndex, JetConstituentStatus status = JetConstituentStatus::track, float mass = o2::constants::physics::MassPiPlus)
8285
{
83-
if (status == static_cast<int>(JetConstituentStatus::track) || status == static_cast<int>(JetConstituentStatus::candidate)) {
86+
if (status == JetConstituentStatus::track || status == JetConstituentStatus::candidate) {
8487
// auto p = std::sqrt((constituent.px() * constituent.px()) + (constituent.py() * constituent.py()) + (constituent.pz() * constituent.pz()));
8588
auto energy = std::sqrt((constituent.p() * constituent.p()) + (mass * mass));
8689
constituents.emplace_back(constituent.px(), constituent.py(), constituent.pz(), energy);
@@ -98,9 +101,9 @@ void fillTracks(const T& constituent, std::vector<fastjet::PseudoJet>& constitue
98101
*/
99102

100103
template <typename T>
101-
void fillClusters(const T& constituent, std::vector<fastjet::PseudoJet>& constituents, int index = -99999999, int hadronicCorrectionType = 0, int status = static_cast<int>(JetConstituentStatus::cluster))
104+
void fillClusters(const T& constituent, std::vector<fastjet::PseudoJet>& constituents, int index = invalidIndex, int hadronicCorrectionType = 0, JetConstituentStatus status = JetConstituentStatus::cluster)
102105
{
103-
if (status == static_cast<int>(JetConstituentStatus::cluster)) {
106+
if (status == JetConstituentStatus::cluster) {
104107
float constituentEnergy = 0.0;
105108
if (hadronicCorrectionType == 0) {
106109
constituentEnergy = constituent.energy();

PWGJE/Core/JetBkgSubUtils.cxx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void JetBkgSubUtils::initialise()
5151
// Note: recommended to use R=0.2
5252
jetDefBkg = fastjet::JetDefinition(algorithmBkg, jetBkgR, recombSchemeBkg, fastjet::Best);
5353
areaDefBkg = fastjet::AreaDefinition(fastjet::active_area_explicit_ghosts, ghostAreaSpec);
54-
selRho = fastjet::SelectorRapRange(bkgEtaMin, bkgEtaMax) && fastjet::SelectorPhiRange(bkgPhiMin, bkgPhiMax) && !fastjet::SelectorNHardest(nHardReject); // here we have to put rap range, to be checked!
54+
selRho = fastjet::SelectorEtaRange(bkgEtaMin, bkgEtaMax) && fastjet::SelectorPhiRange(bkgPhiMin, bkgPhiMax) && !fastjet::SelectorNHardest(nHardReject); // here we have to put rap range, to be checked!
5555
}
5656

5757
std::tuple<double, double> JetBkgSubUtils::estimateRhoAreaMedian(const std::vector<fastjet::PseudoJet>& inputParticles, bool doSparseSub)
@@ -75,6 +75,9 @@ std::tuple<double, double> JetBkgSubUtils::estimateRhoAreaMedian(const std::vect
7575
// Fill a vector for pT/area to be used for the median
7676
for (auto& ijet : alljets) {
7777

78+
if (ijet.area() <= 0.0) {
79+
continue;
80+
}
7881
// Physical area/ Physical jets (no ghost)
7982
if (!clusterSeq.is_pure_ghost(ijet)) {
8083
rhovector.push_back(ijet.perp() / ijet.area());
@@ -122,14 +125,14 @@ std::vector<fastjet::PseudoJet> JetBkgSubUtils::doEventConstSub(std::vector<fast
122125
constituentSub.set_max_distance(constSubRMax);
123126
constituentSub.set_alpha(constSubAlpha);
124127
constituentSub.set_ghost_area(ghostAreaSpec.ghost_area());
125-
constituentSub.set_max_eta(maxEtaEvent);
128+
constituentSub.set_max_eta(std::max(std::abs(bkgEtaMin), std::abs(bkgEtaMax)));
126129

127130
// by default, the masses of all particles are set to zero. With this flag the jet mass will also be subtracted
128131
if (doRhoMassSub) {
129132
constituentSub.set_do_mass_subtraction();
130133
}
131134

132-
return constituentSub.subtract_event(inputParticles, maxEtaEvent);
135+
return constituentSub.subtract_event(inputParticles, std::max(std::abs(bkgEtaMin), std::abs(bkgEtaMax)));
133136
}
134137

135138
std::vector<fastjet::PseudoJet> JetBkgSubUtils::doJetConstSub(std::vector<fastjet::PseudoJet>& jets, double rhoParam, double rhoMParam)
@@ -146,7 +149,7 @@ std::vector<fastjet::PseudoJet> JetBkgSubUtils::doJetConstSub(std::vector<fastje
146149
constituentSub.set_max_distance(constSubRMax);
147150
constituentSub.set_alpha(constSubAlpha);
148151
constituentSub.set_ghost_area(ghostAreaSpec.ghost_area());
149-
constituentSub.set_max_eta(bkgEtaMax);
152+
constituentSub.set_max_eta(std::max(std::abs(bkgEtaMin), std::abs(bkgEtaMax)));
150153

151154
// by default, the masses of all particles are set to zero. With this flag the jet mass will also be subtracted
152155
if (doRhoMassSub) {

PWGJE/Core/JetBkgSubUtils.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JetBkgSubUtils
4646
// Default contructor
4747
JetBkgSubUtils() = default;
4848

49-
JetBkgSubUtils(float jetBkgR_out, float bkgEtaMin_out = -0.8, float bkgEtaMax_out = 0.8,
49+
JetBkgSubUtils(float jetBkgR_out, float bkgEtaMin_out = -0.9, float bkgEtaMax_out = 0.9,
5050
float bkgPhiMin_out = 0., float bkgPhiMax_out = 2 * M_PI, float constSubAlpha_out = 1., float constSubRMax_out = 0.6, int nHardReject_out = 2, fastjet::GhostedAreaSpec ghostAreaSpec_out = fastjet::GhostedAreaSpec());
5151

5252
// Default destructor
@@ -106,20 +106,15 @@ class JetBkgSubUtils
106106
constSubAlpha = alpha_out;
107107
constSubRMax = rmax_out;
108108
}
109-
void setMaxEtaEvent(float etaMaxEvent) { maxEtaEvent = etaMaxEvent; }
110109
void setDoRhoMassSub(bool doMSub_out = true) { doRhoMassSub = doMSub_out; }
111110
void setGhostAreaSpec(fastjet::GhostedAreaSpec ghostAreaSpec_out) { ghostAreaSpec = ghostAreaSpec_out; }
112-
void setJetDefinition(fastjet::JetDefinition jetdefbkg_out) { jetDefBkg = jetdefbkg_out; }
113-
void setAreaDefinition(fastjet::AreaDefinition areaDefBkg_out) { areaDefBkg = areaDefBkg_out; }
114-
void setRhoSelector(fastjet::Selector selRho_out) { selRho = selRho_out; }
115111

116112
// Getters
117113
float getJetBkgR() const { return jetBkgR; }
118114
float getPhiMin() const { return bkgPhiMin; }
119115
float getPhiMax() const { return bkgPhiMax; }
120116
float getEtaMin() const { return bkgEtaMin; }
121117
float getEtaMax() const { return bkgEtaMax; }
122-
float getEtaMaxEvent() const { return maxEtaEvent; }
123118
float getConstSubAlpha() const { return constSubAlpha; }
124119
float getConstSubRMax() const { return constSubRMax; }
125120
float getDoRhoMassSub() const { return doRhoMassSub; }
@@ -139,7 +134,6 @@ class JetBkgSubUtils
139134
float bkgPhiMax = 2.0 * M_PI;
140135
float constSubAlpha = 1.0;
141136
float constSubRMax = 0.24;
142-
float maxEtaEvent = 0.9;
143137
int nHardReject = 2;
144138
bool doRhoMassSub = false; /// flag whether to do jet mass subtraction with the const sub
145139

PWGJE/Core/JetCandidateUtilities.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ template <typename T, typename U, typename V>
188188
auto matchedParticle(const T& candidate, const U& tracks, const V& particles)
189189
{
190190
if constexpr (jethfutilities::isHFCandidate<T>()) {
191-
return jethfutilities::matchedHFParticle(candidate, tracks, particles);
191+
bool isMatched = false;
192+
return jethfutilities::matchedHFParticle(candidate, tracks, particles, isMatched);
192193
} else if constexpr (jetv0utilities::isV0Candidate<T>()) {
193194
return jetv0utilities::matchedV0Particle(candidate, tracks, particles);
194195
} else if constexpr (jetdqutilities::isDielectronCandidate<T>()) {
195196
return jetdqutilities::matchedDielectronParticle(candidate, tracks, particles);
196197
} else {
197-
return jethfutilities::matchedHFParticle(candidate, tracks, particles); // this is a dummy output which should never be triggered
198+
bool isMatched = false;
199+
return jethfutilities::matchedHFParticle(candidate, tracks, particles, isMatched); // this is a dummy output which should never be triggered
198200
}
199201
}
200202

PWGJE/Core/JetDerivedDataUtilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ template <typename T>
296296
bool selectTrigger(T const& collision, int triggerMaskBit)
297297
{
298298
if (triggerMaskBit == -1) {
299-
return false;
299+
return true;
300300
}
301301
return collision.triggerSel() & (1 << triggerMaskBit);
302302
}

PWGJE/Core/JetFinder.cxx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ void JetFinder::setParams()
3636
jetEtaMax += jetR;
3737
}
3838
}
39-
if (isReclustering) {
40-
jetR = 5.0 * jetR;
41-
}
39+
float jetRForClustering = isReclustering ? 5.0 * jetR : jetR;
4240

43-
// selGhosts =fastjet::SelectorRapRange(ghostEtaMin,ghostEtaMax) && fastjet::SelectorPhiRange(phiMin,phiMax);
41+
selGhosts = fastjet::SelectorEtaRange(ghostEtaMin, ghostEtaMax) && fastjet::SelectorPhiRange(phiMin, phiMax);
4442
// ghostAreaSpec=fastjet::GhostedAreaSpec(selGhosts,ghostRepeatN,ghostArea,gridScatter,ktScatter,ghostktMean);
45-
ghostAreaSpec = fastjet::GhostedAreaSpec(ghostEtaMax, ghostRepeatN, ghostArea, gridScatter, ktScatter, ghostktMean); // the first argument is rapidity not pseudorapidity, to be checked
46-
jetDef = fastjet::JetDefinition(fastjet::antikt_algorithm, jetR, recombScheme, strategy);
43+
ghostAreaSpec = fastjet::GhostedAreaSpec(selGhosts, ghostRepeatN, ghostArea, gridScatter, ktScatter, ghostktMean); // the first argument is rapidity not pseudorapidity, to be checked
44+
jetDef = fastjet::JetDefinition(fastjet::antikt_algorithm, jetRForClustering, recombScheme, strategy);
4745
if (fastjetExtraParam > -98.0) {
4846
jetDef.set_extra_param(fastjetExtraParam);
4947
}
@@ -65,8 +63,5 @@ fastjet::ClusterSequenceArea JetFinder::findJets(std::vector<fastjet::PseudoJet>
6563
jets = clusterSeq.inclusive_jets();
6664
jets = selJets(jets);
6765
jets = fastjet::sorted_by_pt(jets);
68-
if (isReclustering) {
69-
jetR = jetR / 5.0;
70-
}
7166
return clusterSeq;
7267
}

PWGJE/Core/JetFindingUtilities.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ bool analyseCandidate(std::vector<fastjet::PseudoJet>& inputParticles, T const&
207207
if (candidate.pt() < candPtMin || candidate.pt() >= candPtMax) {
208208
return false;
209209
}
210-
fastjetutilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), static_cast<int>(JetConstituentStatus::candidate), candMass);
210+
fastjetutilities::fillTracks(candidate, inputParticles, candidate.globalIndex(), JetConstituentStatus::candidate, candMass);
211211
return true;
212212
}
213213

@@ -274,7 +274,7 @@ bool analyseV0s(std::vector<fastjet::PseudoJet>& inputParticles, T const& v0s, f
274274
if (v0.pt() < v0PtMin || v0.pt() >= v0PtMax) {
275275
continue;
276276
}
277-
fastjetutilities::fillTracks(v0, inputParticles, v0.globalIndex(), static_cast<int>(JetConstituentStatus::candidate), v0Mass);
277+
fastjetutilities::fillTracks(v0, inputParticles, v0.globalIndex(), JetConstituentStatus::candidate, v0Mass);
278278
nSelectedV0s++;
279279
}
280280
if (nSelectedV0s > 0) {
@@ -315,8 +315,8 @@ void findJets(JetFinder& jetFinder, std::vector<fastjet::PseudoJet>& inputPartic
315315
if (doCandidateJetFinding) {
316316
bool isCandidateJet = false;
317317
for (const auto& constituent : jet.constituents()) {
318-
auto constituentStatus = constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus();
319-
if (constituentStatus == static_cast<int>(JetConstituentStatus::candidate)) { // note currently we cannot run V0 and HF in the same jet. If we ever need to we can seperate the loops
318+
JetConstituentStatus constituentStatus = constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus();
319+
if (constituentStatus == JetConstituentStatus::candidate) { // note currently we cannot run V0 and HF in the same jet. If we ever need to we can seperate the loops
320320
isCandidateJet = true;
321321
break;
322322
}
@@ -331,13 +331,13 @@ void findJets(JetFinder& jetFinder, std::vector<fastjet::PseudoJet>& inputPartic
331331
jetsTable(collision.globalIndex(), jet.pt(), jet.eta(), jet.phi(),
332332
jet.E(), jet.rapidity(), jet.m(), jet.has_area() ? jet.area() : 0., std::round(R * 100));
333333
for (const auto& constituent : sorted_by_pt(jet.constituents())) {
334-
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == static_cast<int>(JetConstituentStatus::track)) {
334+
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == JetConstituentStatus::track) {
335335
tracks.push_back(constituent.template user_info<fastjetutilities::fastjet_user_info>().getIndex());
336336
}
337-
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == static_cast<int>(JetConstituentStatus::cluster)) {
337+
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == JetConstituentStatus::cluster) {
338338
clusters.push_back(constituent.template user_info<fastjetutilities::fastjet_user_info>().getIndex());
339339
}
340-
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == static_cast<int>(JetConstituentStatus::candidate)) {
340+
if (constituent.template user_info<fastjetutilities::fastjet_user_info>().getStatus() == JetConstituentStatus::candidate) {
341341
cands.push_back(constituent.template user_info<fastjetutilities::fastjet_user_info>().getIndex());
342342
}
343343
}
@@ -406,7 +406,7 @@ void analyseParticles(std::vector<fastjet::PseudoJet>& inputParticles, const std
406406
}
407407
}
408408
}
409-
fastjetutilities::fillTracks(particle, inputParticles, particle.globalIndex(), static_cast<int>(JetConstituentStatus::track), pdgParticle->Mass());
409+
fastjetutilities::fillTracks(particle, inputParticles, particle.globalIndex(), JetConstituentStatus::track, pdgParticle->Mass());
410410
}
411411
}
412412

0 commit comments

Comments
 (0)