Skip to content

Commit e85e638

Browse files
authored
[PWGJE,PWGLF,Trigger] Improvements to the JE framework (#13782)
1 parent c91847f commit e85e638

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+605
-436
lines changed

EventFiltering/PWGJE/jetFilter.cxx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,33 @@
1111

1212
// Author: Filip Krizek
1313

14-
#include <TMath.h>
15-
#include <cmath>
16-
#include <string>
17-
#include <vector>
14+
#include "../filterTables.h"
1815

19-
#include "Framework/ASoA.h"
20-
#include "Framework/ASoAHelpers.h"
21-
#include "Framework/AnalysisDataModel.h"
22-
#include "Framework/AnalysisTask.h"
23-
#include "Framework/runDataProcessing.h"
24-
#include "ReconstructionDataFormats/Track.h"
16+
#include "PWGJE/Core/FastJetUtilities.h"
17+
#include "PWGJE/Core/JetBkgSubUtils.h"
18+
#include "PWGJE/Core/JetDerivedDataUtilities.h"
19+
#include "PWGJE/Core/JetFinder.h"
20+
#include "PWGJE/DataModel/EMCALClusters.h"
21+
#include "PWGJE/DataModel/Jet.h"
2522

2623
#include "Common/Core/TrackSelection.h"
2724
#include "Common/Core/TrackSelectionDefaults.h"
2825
#include "Common/DataModel/EventSelection.h"
2926
#include "Common/DataModel/TrackSelectionTables.h"
3027

31-
#include "PWGJE/Core/JetFinder.h"
32-
#include "PWGJE/Core/FastJetUtilities.h"
33-
#include "PWGJE/Core/JetBkgSubUtils.h"
34-
#include "PWGJE/DataModel/EMCALClusters.h"
35-
#include "PWGJE/DataModel/Jet.h"
28+
#include "Framework/ASoA.h"
29+
#include "Framework/ASoAHelpers.h"
30+
#include "Framework/AnalysisDataModel.h"
31+
#include "Framework/AnalysisTask.h"
32+
#include "Framework/HistogramRegistry.h"
33+
#include "Framework/runDataProcessing.h"
34+
#include "ReconstructionDataFormats/Track.h"
3635

37-
#include "../filterTables.h"
36+
#include <TMath.h>
3837

39-
#include "Framework/HistogramRegistry.h"
38+
#include <cmath>
39+
#include <string>
40+
#include <vector>
4041

4142
using namespace o2;
4243
using namespace o2::framework;
@@ -189,7 +190,7 @@ struct jetFilter {
189190

190191
// collision process loop
191192
bool keepEvent[kTriggerObjects]{false, false, false, false};
192-
if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
193+
if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits(static_cast<std::string>("NoTimeFrameBorder")))) {
193194
tags(keepEvent[kJetChLowPt], keepEvent[kJetChHighPt], keepEvent[kTrackLowPt], keepEvent[kTrackHighPt]);
194195
return;
195196
}
@@ -287,13 +288,13 @@ struct jetFilter {
287288
tags(keepEvent[kJetChLowPt], keepEvent[kJetChHighPt], keepEvent[kTrackLowPt], keepEvent[kTrackHighPt]);
288289
}
289290

290-
void processWithoutRho(soa::Join<aod::JetCollisions, aod::EvSels>::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered<aod::JetTracks> const& tracks)
291+
void processWithoutRho(aod::JetCollision const& collision, o2::aod::ChargedJets const& jets, soa::Filtered<aod::JetTracks> const& tracks)
291292
{
292293
doTriggering<false>(collision, jets, tracks);
293294
}
294295
PROCESS_SWITCH(jetFilter, processWithoutRho, "Do charged jet triggering without background estimation for filling histograms", true);
295296

296-
void processWithRho(soa::Join<aod::JetCollisions, aod::BkgChargedRhos, aod::EvSels>::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered<aod::JetTracks> const& tracks)
297+
void processWithRho(soa::Join<aod::JetCollisions, aod::BkgChargedRhos>::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered<aod::JetTracks> const& tracks)
297298
{
298299
doTriggering<true>(collision, jets, tracks);
299300
}

PWGJE/Core/JetBkgSubUtils.cxx

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ JetBkgSubUtils::JetBkgSubUtils(float jetBkgR_out, float bkgEtaMin_out, float bkg
4848

4949
void JetBkgSubUtils::initialise()
5050
{
51-
// Note: if you are using the PerpCone method you should jetBkgR to be the same as the anit_kt jets R, otherwise use R=0.2
51+
// 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);
5454
selRho = fastjet::SelectorRapRange(bkgEtaMin, bkgEtaMax) && fastjet::SelectorPhiRange(bkgPhiMin, bkgPhiMax) && !fastjet::SelectorNHardest(nHardReject); // here we have to put rap range, to be checked!
@@ -104,62 +104,6 @@ std::tuple<double, double> JetBkgSubUtils::estimateRhoAreaMedian(const std::vect
104104
return std::make_tuple(rho, rhoM);
105105
}
106106

107-
std::tuple<double, double> JetBkgSubUtils::estimateRhoPerpCone(const std::vector<fastjet::PseudoJet>& inputParticles, const std::vector<fastjet::PseudoJet>& jets)
108-
{
109-
110-
JetBkgSubUtils::initialise();
111-
if (inputParticles.size() == 0 || jets.size() == 0) {
112-
return std::make_tuple(0.0, 0.0);
113-
}
114-
115-
double perpPtDensity1 = 0;
116-
double perpPtDensity2 = 0;
117-
double perpMdDensity1 = 0;
118-
double perpMdDensity2 = 0;
119-
120-
fastjet::Selector selectJet = fastjet::SelectorEtaRange(bkgEtaMin, bkgEtaMax) && fastjet::SelectorPhiRange(bkgPhiMin, bkgPhiMax);
121-
122-
std::vector<fastjet::PseudoJet> selectedJets = fastjet::sorted_by_pt(selectJet(jets));
123-
124-
if (selectedJets.size() == 0) {
125-
return std::make_tuple(0.0, 0.0);
126-
}
127-
128-
fastjet::PseudoJet leadingJet = selectedJets[0];
129-
130-
double dPhi1 = 999.;
131-
double dPhi2 = 999.;
132-
double dEta = 999.;
133-
double PerpendicularConeAxisPhi1 = 999., PerpendicularConeAxisPhi2 = 999.;
134-
// build 2 perp cones in phi around the leading jet (right and left of the jet)
135-
PerpendicularConeAxisPhi1 = RecoDecay::constrainAngle<double, double>(leadingJet.phi() + (M_PI / 2.)); // This will contrain the angel between 0-2Pi
136-
PerpendicularConeAxisPhi2 = RecoDecay::constrainAngle<double, double>(leadingJet.phi() - (M_PI / 2.)); // This will contrain the angel between 0-2Pi
137-
138-
for (auto& particle : inputParticles) {
139-
// sum the momentum of all paricles that fill the two cones
140-
dPhi1 = particle.phi() - PerpendicularConeAxisPhi1;
141-
dPhi1 = RecoDecay::constrainAngle<double, double>(dPhi1, -M_PI); // This will contrain the angel between -pi & Pi
142-
dPhi2 = particle.phi() - PerpendicularConeAxisPhi2;
143-
dPhi2 = RecoDecay::constrainAngle<double, double>(dPhi2, -M_PI); // This will contrain the angel between -pi & Pi
144-
dEta = leadingJet.eta() - particle.eta(); // The perp cone eta is the same as the leading jet since the cones are perpendicular only in phi
145-
if (TMath::Sqrt(dPhi1 * dPhi1 + dEta * dEta) <= jetBkgR) {
146-
perpPtDensity1 += particle.perp();
147-
perpMdDensity1 += TMath::Sqrt(particle.m() * particle.m() + particle.pt() * particle.pt()) - particle.pt();
148-
}
149-
150-
if (TMath::Sqrt(dPhi2 * dPhi2 + dEta * dEta) <= jetBkgR) {
151-
perpPtDensity2 += particle.perp();
152-
perpMdDensity2 += TMath::Sqrt(particle.m() * particle.m() + particle.pt() * particle.pt()) - particle.pt();
153-
}
154-
}
155-
156-
// Caculate rho as the ratio of average pT of the two cones / the cone area
157-
double perpPtDensity = (perpPtDensity1 + perpPtDensity2) / (2 * M_PI * jetBkgR * jetBkgR);
158-
double perpMdDensity = (perpMdDensity1 + perpMdDensity2) / (2 * M_PI * jetBkgR * jetBkgR);
159-
160-
return std::make_tuple(perpPtDensity, perpMdDensity);
161-
}
162-
163107
fastjet::PseudoJet JetBkgSubUtils::doRhoAreaSub(const fastjet::PseudoJet& jet, double rhoParam, double rhoMParam)
164108
{
165109

PWGJE/Core/JetBkgSubUtils.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
enum class BkgSubEstimator { none = 0,
3232
medianRho = 1,
33-
medianRhoSparse = 2,
34-
perpCone = 3
33+
medianRhoSparse = 2
34+
// perpendicular cone method is in JetUtilities
3535
};
3636

3737
enum class BkgSubMode { none = 0,
@@ -68,12 +68,6 @@ class JetBkgSubUtils
6868
/// @return Rho, RhoM the underlying event density
6969
std::tuple<double, double> estimateRhoAreaMedian(const std::vector<fastjet::PseudoJet>& inputParticles, bool doSparseSub);
7070

71-
/// @brief Background estimator using the perpendicular cone method
72-
/// @param inputParticles
73-
/// @param jets (all jets in the event)
74-
/// @return Rho, RhoM the underlying event density
75-
std::tuple<double, double> estimateRhoPerpCone(const std::vector<fastjet::PseudoJet>& inputParticles, const std::vector<fastjet::PseudoJet>& jets);
76-
7771
/// @brief method that subtracts the background from jets using the area method
7872
/// @param jet input jet to be background subtracted
7973
/// @param rhoParam the underlying evvent density vs pT (to be set)

PWGJE/Core/JetCandidateUtilities.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,16 @@ constexpr bool isMatchedCandidate(T const& candidate)
118118
*
119119
* @param track track that is being checked
120120
* @param candidate candidate that is being checked
121-
* @param tracks the track table
122121
*/
123-
template <typename T, typename U, typename V>
124-
bool isDaughterTrack(T& track, U& candidate, V const& tracks)
122+
template <typename T, typename U>
123+
bool isDaughterTrack(T& track, U& candidate)
125124
{
126125
if constexpr (jethfutilities::isHFCandidate<U>()) {
127-
return jethfutilities::isHFDaughterTrack(track, candidate, tracks);
126+
return jethfutilities::isHFDaughterTrack(track, candidate);
128127
} else if constexpr (jetv0utilities::isV0Candidate<U>()) {
129-
return jetv0utilities::isV0DaughterTrack(track, candidate, tracks);
128+
return jetv0utilities::isV0DaughterTrack(track, candidate);
130129
} else if constexpr (jetdqutilities::isDielectronCandidate<U>()) {
131-
return jetdqutilities::isDielectronDaughterTrack(track, candidate, tracks);
130+
return jetdqutilities::isDielectronDaughterTrack(track, candidate);
132131
} else {
133132
return false;
134133
}

PWGJE/Core/JetDQUtilities.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,9 @@ constexpr bool isMatchedDielectronCandidate(T const& /*candidate*/)
9494
*
9595
* @param track track that is being checked
9696
* @param candidate Dielectron candidate that is being checked
97-
* @param tracks the track table
9897
*/
99-
template <typename T, typename U, typename V>
100-
bool isDielectronDaughterTrack(T& track, U& candidate, V const& /*tracks*/)
98+
template <typename T, typename U>
99+
bool isDielectronDaughterTrack(T& track, U& candidate)
101100
{
102101
if constexpr (isDielectronCandidate<U>()) {
103102
if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex()) {
@@ -283,7 +282,7 @@ bool selectDielectronParticleDecay(T const& dielectronParticle, int dielectronPa
283282
return (dielectronParticle.decayFlag() & (1 << dielectronParticleDecaySelection));
284283
}
285284

286-
int initialiseDielectronParticleDecaySelection(std::string dielectronParticleDecaySelection)
285+
int initialiseDielectronParticleDecaySelection(const std::string& dielectronParticleDecaySelection)
287286
{
288287
if (dielectronParticleDecaySelection == "JPsiToEE") {
289288
return JDielectronParticleDecays::JPsiToEE;
@@ -353,7 +352,7 @@ void fillDielectronCandidateTable(T const& candidate, int32_t collisionIndex, U&
353352
template <typename T, typename U>
354353
void fillDielectronCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& DielectronMcTable)
355354
{
356-
DielectronMcTable(mcCollisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.y(), candidate.e(), candidate.m(), candidate.pdgCode(), candidate.getGenStatusCode(), candidate.getHepMCStatusCode(), candidate.isPhysicalPrimary(), candidate.decayFlag(), candidate.origin());
355+
DielectronMcTable(mcCollisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.y(), candidate.e(), candidate.m(), candidate.pdgCode(), candidate.statusCode(), candidate.flags(), candidate.decayFlag(), candidate.origin());
357356
}
358357

359358
}; // namespace jetdqutilities

PWGJE/Core/JetDerivedDataUtilities.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define PWGJE_CORE_JETDERIVEDDATAUTILITIES_H_
1919

2020
#include "Common/CCDB/EventSelectionParams.h"
21+
#include "Common/CCDB/RCTSelectionFlags.h"
2122
#include "Common/CCDB/TriggerAliases.h"
2223

2324
#include <Rtypes.h>
@@ -53,11 +54,16 @@ enum JCollisionSubGeneratorId {
5354
};
5455

5556
template <typename T>
56-
bool selectCollision(T const& collision, std::vector<int> eventSelectionMaskBits, bool skipMBGapEvents = true)
57+
bool selectCollision(T const& collision, const std::vector<int>& eventSelectionMaskBits, bool skipMBGapEvents = true, bool rctSelection = true, std::string rctLabel = "CBT_hadronPID", bool rejectLimitedAcceptanceRct = false, bool requireZDCRct = false)
5758
{
5859
if (skipMBGapEvents && collision.subGeneratorId() == JCollisionSubGeneratorId::mbGap) {
5960
return false;
6061
}
62+
o2::aod::rctsel::RCTFlagsChecker rctChecker;
63+
rctChecker.init(rctLabel, requireZDCRct, rejectLimitedAcceptanceRct);
64+
if (rctSelection && !rctChecker.checkTable(collision)) { // CBT_hadronPID given as default so that TOF is included in RCT selection to benefit from better timing for tracks. Impact of this for inclusive jets should be studied
65+
return false;
66+
}
6167
if (eventSelectionMaskBits.size() == 0) {
6268
return true;
6369
}
@@ -69,7 +75,7 @@ bool selectCollision(T const& collision, std::vector<int> eventSelectionMaskBits
6975
return true;
7076
}
7177

72-
bool eventSelectionMasksContainSelection(std::string eventSelectionMasks, std::string selection)
78+
bool eventSelectionMasksContainSelection(const std::string& eventSelectionMasks, std::string selection)
7379
{
7480
size_t position = 0;
7581
while ((position = eventSelectionMasks.find(selection, position)) != std::string::npos) {
@@ -83,7 +89,7 @@ bool eventSelectionMasksContainSelection(std::string eventSelectionMasks, std::s
8389
return false;
8490
}
8591

86-
std::vector<int> initialiseEventSelectionBits(std::string eventSelectionMasks)
92+
std::vector<int> initialiseEventSelectionBits(const std::string& eventSelectionMasks)
8793
{
8894
std::vector<int> eventSelectionMaskBits;
8995
if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel8")) {
@@ -230,7 +236,7 @@ enum JTrigSel {
230236
};
231237

232238
template <typename T>
233-
bool selectTrigger(T const& collision, std::vector<int> triggerMaskBits)
239+
bool selectTrigger(T const& collision, const std::vector<int>& triggerMaskBits)
234240
{
235241
if (triggerMaskBits.size() == 0) {
236242
return true;
@@ -252,7 +258,7 @@ bool selectTrigger(T const& collision, int triggerMaskBit)
252258
return collision.triggerSel() & (1 << triggerMaskBit);
253259
}
254260

255-
bool triggerMasksContainTrigger(std::string triggerMasks, std::string trigger)
261+
bool triggerMasksContainTrigger(const std::string& triggerMasks, std::string trigger)
256262
{
257263
size_t position = 0;
258264
while ((position = triggerMasks.find(trigger, position)) != std::string::npos) {
@@ -266,7 +272,7 @@ bool triggerMasksContainTrigger(std::string triggerMasks, std::string trigger)
266272
return false;
267273
}
268274

269-
std::vector<int> initialiseTriggerMaskBits(std::string triggerMasks)
275+
std::vector<int> initialiseTriggerMaskBits(const std::string& triggerMasks)
270276
{
271277
std::vector<int> triggerMaskBits;
272278
if (triggerMasksContainTrigger(triggerMasks, "fJetChLowPt")) {
@@ -335,7 +341,7 @@ std::vector<int> initialiseTriggerMaskBits(std::string triggerMasks)
335341
return triggerMaskBits;
336342
}
337343

338-
uint64_t setTriggerSelectionBit(std::vector<bool> triggerDecisions)
344+
uint64_t setTriggerSelectionBit(const std::vector<bool>& triggerDecisions)
339345
{
340346
uint64_t bit = 0;
341347
for (std::vector<bool>::size_type i = 0; i < triggerDecisions.size(); i++) {
@@ -363,7 +369,7 @@ bool selectChargedTrigger(T const& collision, int triggerSelection)
363369
return (collision.chargedTriggerSel() & (1 << triggerSelection));
364370
}
365371

366-
int initialiseChargedTriggerSelection(std::string triggerSelection)
372+
int initialiseChargedTriggerSelection(const std::string& triggerSelection)
367373
{
368374
if (triggerSelection == "jetChLowPt") {
369375
return JTrigSelCh::jetChLowPt;
@@ -428,7 +434,7 @@ bool selectFullTrigger(T const& collision, int triggerSelection)
428434
return (collision.fullTriggerSel() & (1 << triggerSelection));
429435
}
430436

431-
int initialiseFullTriggerSelection(std::string triggerSelection)
437+
int initialiseFullTriggerSelection(const std::string& triggerSelection)
432438
{
433439
if (triggerSelection == "emcalReadout") {
434440
return JTrigSelFull::emcalReadout;
@@ -523,7 +529,7 @@ bool selectChargedHFTrigger(T const& collision, int triggerSelection)
523529
return (collision.chargedHFTriggerSel() & (1 << triggerSelection));
524530
}
525531

526-
int initialiseChargedHFTriggerSelection(std::string triggerSelection)
532+
int initialiseChargedHFTriggerSelection(const std::string& triggerSelection)
527533
{
528534
if (triggerSelection == "jetD0ChLowPt") {
529535
return JTrigSelChHF::jetD0ChLowPt;
@@ -586,7 +592,7 @@ bool selectTrack(T const& track, int trackSelection)
586592
return (track.trackSel() & (1 << trackSelection));
587593
}
588594

589-
int initialiseTrackSelection(std::string trackSelection)
595+
int initialiseTrackSelection(const std::string& trackSelection)
590596
{
591597
if (trackSelection == "globalTracks") {
592598
return JTrackSel::globalTrack;

0 commit comments

Comments
 (0)