Skip to content

Commit 1344d86

Browse files
author
Nima Zardoshti
committed
PWGJE: merging the common aspects of the inclusive and HF jet finders
1 parent 750b769 commit 1344d86

3 files changed

Lines changed: 442 additions & 533 deletions

File tree

PWGJE/TableProducer/jetfinder.cxx

Lines changed: 45 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,7 @@
1313
//
1414
// Author: Jochen Klein, Nima Zardoshti, Raymond Ehlers
1515

16-
#include "Framework/AnalysisTask.h"
17-
#include "Framework/AnalysisDataModel.h"
18-
#include "Framework/ASoA.h"
19-
#include "Framework/O2DatabasePDGPlugin.h"
20-
21-
#include "Common/Core/TrackSelection.h"
22-
#include "Common/Core/TrackSelectionDefaults.h"
23-
#include "Common/DataModel/EventSelection.h"
24-
#include "Common/DataModel/TrackSelectionTables.h"
25-
#include "Common/Core/RecoDecay.h"
26-
#include "PWGJE/DataModel/EMCALClusters.h"
27-
28-
#include "PWGJE/DataModel/Jet.h"
29-
#include "PWGJE/Core/JetFinder.h"
30-
#include "PWGJE/Core/FastJetUtilities.h"
16+
#include "PWGJE/TableProducer/jetfinder.h"
3117

3218
using namespace o2;
3319
using namespace o2::framework;
@@ -50,11 +36,7 @@ struct JetFinderTask {
5036
OutputObj<TH1F> hJetNTracks{"h_jet_ntracks"};
5137

5238
Service<O2DatabasePDG> pdg;
53-
TrackSelection globalTracks;
54-
55-
std::vector<fastjet::PseudoJet> jets;
56-
std::vector<fastjet::PseudoJet> inputParticles;
57-
JetFinder jetFinder;
39+
std::string trackSelection;
5840

5941
// event level configurables
6042
Configurable<float> vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"};
@@ -94,10 +76,14 @@ struct JetFinderTask {
9476

9577
void init(InitContext const&)
9678
{
97-
if (static_cast<std::string>(trackSelections) == "globalTracks") {
98-
globalTracks = getGlobalTrackSelection();
99-
globalTracks.SetEtaRange(trackEtaMin, trackEtaMax);
100-
}
79+
// variables passed to the common header
80+
trackEtaMin_ = static_cast<float>(trackEtaMin);
81+
trackEtaMax_ = static_cast<float>(trackEtaMax);
82+
jetRadius_ = static_cast<std::vector<double>>(jetRadius);
83+
DoConstSub_ = static_cast<bool>(DoConstSub);
84+
85+
trackSelection = static_cast<std::string>(trackSelections);
86+
jetTypeParticleLevelCheck = jetTypeParticleLevel;
10187

10288
h2JetPt.setObject(new TH2F("h2_jet_pt", "jet p_{T};p_{T} (GeV/#it{c})",
10389
100, 0., 100., 10, 0.05, 1.05));
@@ -142,119 +128,43 @@ struct JetFinderTask {
142128
Filter trackCuts = (aod::track::pt >= trackPtMin && aod::track::pt < trackPtMax && aod::track::eta > trackEtaMin && aod::track::eta < trackEtaMax && aod::track::phi >= trackPhiMin && aod::track::phi <= trackPhiMax); // do we need eta cut both here and in globalselection?
143129
Filter partCuts = (aod::mcparticle::pt >= trackPtMin && aod::mcparticle::pt < trackPtMax);
144130
Filter clusterFilter = (o2::aod::emcalcluster::definition == static_cast<int>(clusterDefinition) && aod::emcalcluster::eta > clusterEtaMin && aod::emcalcluster::eta < clusterEtaMax && aod::emcalcluster::phi >= clusterPhiMin && aod::emcalcluster::phi <= clusterPhiMax && aod::emcalcluster::energy >= clusterEnergyMin && aod::emcalcluster::time > clusterTimeMin && aod::emcalcluster::time < clusterTimeMax && (clusterRejectExotics && aod::emcalcluster::isExotic != true));
145-
using JetTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection>>;
146-
using JetClusters = o2::soa::Filtered<o2::aod::EMCALClusters>;
147-
148-
// function that performs track selections on each track
149-
template <typename T>
150-
bool processTrackSelection(T const& track)
151-
{
152-
if (static_cast<std::string>(trackSelections) == "globalTracks" && !globalTracks.IsSelected(track)) {
153-
return false;
154-
} else if (static_cast<std::string>(trackSelections) == "QualityTracks" && !track.isQualityTrack()) {
155-
return false;
156-
} else {
157-
return true;
158-
}
159-
}
160-
161-
// function that adds tracks to the fastjet list
162-
template <typename T>
163-
void processTracks(T const& tracks)
164-
{
165-
for (auto& track : tracks) {
166-
if (!processTrackSelection(track)) {
167-
continue;
168-
}
169-
FastJetUtilities::fillTracks(track, inputParticles, track.globalIndex());
170-
}
171-
}
172-
173-
// function that adds clusters to the fastjet list
174-
template <typename T>
175-
void processClusters(T const& clusters)
176-
{
177-
for (auto& cluster : *clusters) {
178-
// add cluster selections
179-
FastJetUtilities::fillClusters(cluster, inputParticles, cluster.globalIndex());
180-
}
181-
}
182-
183-
// function that calls the jet finding and fills the relevant tables
184-
template <typename T>
185-
void jetFinding(T const& collision)
186-
{
187-
auto jetRValues = static_cast<std::vector<double>>(jetRadius);
188-
for (auto R : jetRValues) {
189-
jetFinder.jetR = R;
190-
jets.clear();
191-
fastjet::ClusterSequenceArea clusterSeq(jetFinder.findJets(inputParticles, jets));
192-
for (const auto& jet : jets) {
193-
std::vector<int> trackconst;
194-
std::vector<int> clusterconst;
195-
jetsTable(collision, jet.pt(), jet.eta(), jet.phi(),
196-
jet.E(), jet.m(), jet.area(), std::round(R * 100));
197-
for (const auto& constituent : sorted_by_pt(jet.constituents())) {
198-
// need to add seperate thing for constituent subtraction
199-
if (DoConstSub) { // FIXME: needs to be addressed in Haadi's PR
200-
constituentsSubTable(jetsTable.lastIndex(), constituent.pt(), constituent.eta(), constituent.phi(),
201-
constituent.E(), constituent.m(), constituent.user_index());
202-
}
203-
204-
if (constituent.template user_info<FastJetUtilities::fastjet_user_info>().getStatus() == static_cast<int>(JetConstituentStatus::track)) {
205-
trackconst.push_back(constituent.template user_info<FastJetUtilities::fastjet_user_info>().getIndex());
206-
}
207-
if (constituent.template user_info<FastJetUtilities::fastjet_user_info>().getStatus() == static_cast<int>(JetConstituentStatus::cluster)) {
208-
clusterconst.push_back(constituent.template user_info<FastJetUtilities::fastjet_user_info>().getIndex());
209-
}
210-
}
211-
constituentsTable(jetsTable.lastIndex(), trackconst, clusterconst, std::vector<int>());
212-
h2JetPt->Fill(jet.pt(), R);
213-
h2JetPhi->Fill(jet.phi(), R);
214-
h2JetEta->Fill(jet.rap(), R);
215-
h2JetNTracks->Fill(jet.constituents().size(), R);
216-
hJetPt->Fill(jet.pt());
217-
hJetPhi->Fill(jet.phi());
218-
hJetEta->Fill(jet.rap());
219-
hJetNTracks->Fill(jet.constituents().size());
220-
}
221-
}
222-
}
223131

224132
void processDummy(aod::Collisions const& collision)
225133
{
226134
}
227135

228136
PROCESS_SWITCH(JetFinderTask, processDummy, "Dummy process function turned on by default", true);
229137

230-
void processDataCharged(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
138+
void processChargedJets(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
231139
JetTracks const& tracks)
232140
{
233-
if (!collision.sel8()) {
141+
if (!selectCollision(collision)) {
234142
return;
235143
}
144+
236145
LOG(debug) << "Process data charged!";
237146
inputParticles.clear();
238-
processTracks(tracks);
239-
jetFinding(collision);
147+
using ArgType = std::decay_t<decltype(tracks)>;
148+
analyseTracks<ArgType, typename ArgType::iterator>(tracks, trackSelection);
149+
findJets(collision, jetsTable, constituentsTable, constituentsSubTable);
240150
}
241151

242-
PROCESS_SWITCH(JetFinderTask, processDataCharged, "Data jet finding for charged jets", false);
152+
PROCESS_SWITCH(JetFinderTask, processChargedJets, "Data jet finding for charged jets", false);
243153

244-
void processDataNeutral(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
154+
void processNeutralJets(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
245155
JetClusters const& clusters)
246156
{
247157
if (!collision.alias()[kTVXinEMC]) {
248158
return;
249159
}
250160
LOG(debug) << "Process data neutral!";
251161
inputParticles.clear();
252-
processClusters(&clusters);
253-
jetFinding(collision);
162+
analyseClusters(&clusters);
163+
findJets(collision, jetsTable, constituentsTable, constituentsSubTable);
254164
}
255-
PROCESS_SWITCH(JetFinderTask, processDataNeutral, "Data jet finding for neutral jets", false);
165+
PROCESS_SWITCH(JetFinderTask, processNeutralJets, "Data jet finding for neutral jets", false);
256166

257-
void processDataFull(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
167+
void processFullJets(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
258168
JetTracks const& tracks,
259169
JetClusters const& clusters)
260170
{
@@ -263,56 +173,44 @@ struct JetFinderTask {
263173
}
264174
LOG(debug) << "Process data full!";
265175
inputParticles.clear();
266-
processTracks(tracks);
267-
processClusters(&clusters);
268-
jetFinding(collision);
176+
using ArgType = std::decay_t<decltype(tracks)>;
177+
analyseTracks<ArgType, typename ArgType::iterator>(tracks, trackSelection);
178+
analyseClusters(&clusters);
179+
findJets(collision, jetsTable, constituentsTable, constituentsSubTable);
269180
}
270181

271-
PROCESS_SWITCH(JetFinderTask, processDataFull, "Data jet finding for full and neutral jets", false);
182+
PROCESS_SWITCH(JetFinderTask, processFullJets, "Data jet finding for full and neutral jets", false);
272183

273-
void processParticleLevel(aod::McCollision const& collision, aod::McParticles const& particles)
184+
void processParticleLevelJets(aod::McCollision const& collision, aod::McParticles const& particles)
274185
{
275186
// TODO: MC event selection?
276-
inputParticles.clear();
277-
for (auto& particle : particles) {
278-
if (particle.getGenStatusCode() != 1) {
279-
continue;
280-
}
281-
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
282-
auto pdgCharge = pdgParticle ? std::abs(pdgParticle->Charge()) : -1.0;
283-
if (jetTypeParticleLevel == static_cast<int>(JetType::charged) && pdgCharge < 3.0) { // pdg charge is in increments of 1/3
284-
continue;
285-
}
286-
if (jetTypeParticleLevel == static_cast<int>(JetType::neutral) && pdgCharge != 0.0) {
287-
continue;
288-
}
289-
FastJetUtilities::fillTracks(particle, inputParticles, particle.globalIndex(), static_cast<int>(JetConstituentStatus::track), RecoDecay::getMassPDG(particle.pdgCode()));
290-
}
291-
jetFinding(collision);
187+
using ArgType = std::decay_t<decltype(particles)>;
188+
analyseParticles<ArgType, typename ArgType::iterator>(particles, pdg->Instance());
189+
findJets(collision, jetsTable, constituentsTable, constituentsSubTable);
292190
}
293191

294-
PROCESS_SWITCH(JetFinderTask, processParticleLevel, "Particle level jet finding", false);
192+
PROCESS_SWITCH(JetFinderTask, processParticleLevelJets, "Particle level jet finding", false);
295193
};
296194

297-
using JetFinderData = JetFinderTask<o2::aod::Jets, o2::aod::JetConstituents, o2::aod::JetConstituentsSub>;
195+
using JetFinderDataCharged = JetFinderTask<o2::aod::Jets, o2::aod::JetConstituents, o2::aod::JetConstituentsSub>;
298196
using JetFinderDataFull = JetFinderTask<o2::aod::FullJets, o2::aod::FullJetConstituents, o2::aod::FullJetConstituentsSub>;
299197
using JetFinderDataNeutral = JetFinderTask<o2::aod::NeutralJets, o2::aod::NeutralJetConstituents, o2::aod::NeutralJetConstituentsSub>;
300-
using JetFinderMCDetectorLevel = JetFinderTask<o2::aod::MCDetectorLevelJets, o2::aod::MCDetectorLevelJetConstituents, o2::aod::MCDetectorLevelJetConstituentsSub>;
198+
using JetFinderMCDetectorLevelCharged = JetFinderTask<o2::aod::MCDetectorLevelJets, o2::aod::MCDetectorLevelJetConstituents, o2::aod::MCDetectorLevelJetConstituentsSub>;
301199
using JetFinderMCDetectorLevelFull = JetFinderTask<o2::aod::MCDetectorLevelFullJets, o2::aod::MCDetectorLevelFullJetConstituents, o2::aod::MCDetectorLevelFullJetConstituentsSub>;
302200
using JetFinderMCDetectorLevelNeutral = JetFinderTask<o2::aod::MCDetectorLevelNeutralJets, o2::aod::MCDetectorLevelNeutralJetConstituents, o2::aod::MCDetectorLevelNeutralJetConstituentsSub>;
303-
using JetFinderMCParticleLevel = JetFinderTask<o2::aod::MCParticleLevelJets, o2::aod::MCParticleLevelJetConstituents, o2::aod::MCParticleLevelJetConstituentsSub>;
201+
using JetFinderMCParticleLevelCharged = JetFinderTask<o2::aod::MCParticleLevelJets, o2::aod::MCParticleLevelJetConstituents, o2::aod::MCParticleLevelJetConstituentsSub>;
304202
using JetFinderMCParticleLevelFull = JetFinderTask<o2::aod::MCParticleLevelFullJets, o2::aod::MCParticleLevelFullJetConstituents, o2::aod::MCParticleLevelFullJetConstituentsSub>;
305203
using JetFinderMCParticleLevelNeutral = JetFinderTask<o2::aod::MCParticleLevelNeutralJets, o2::aod::MCParticleLevelNeutralJetConstituents, o2::aod::MCParticleLevelNeutralJetConstituentsSub>;
306-
using JetFinderHybridIntermediate = JetFinderTask<o2::aod::HybridIntermediateJets, o2::aod::HybridIntermediateJetConstituents, o2::aod::HybridIntermediateJetConstituentsSub>;
204+
// using JetFinderHybridIntermediate = JetFinderTask<o2::aod::HybridIntermediateJets, o2::aod::HybridIntermediateJetConstituents, o2::aod::HybridIntermediateJetConstituentsSub>;
307205

308206
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
309207
{
310208

311209
std::vector<o2::framework::DataProcessorSpec> tasks;
312210

313211
tasks.emplace_back(
314-
adaptAnalysisTask<JetFinderData>(cfgc,
315-
SetDefaultProcesses{}, TaskName{"jet-finder-data"}));
212+
adaptAnalysisTask<JetFinderDataCharged>(cfgc,
213+
SetDefaultProcesses{}, TaskName{"jet-finder-data-charged"}));
316214

317215
tasks.emplace_back(
318216
adaptAnalysisTask<JetFinderDataFull>(cfgc,
@@ -323,8 +221,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
323221
SetDefaultProcesses{}, TaskName{"jet-finder-data-neutral"}));
324222

325223
tasks.emplace_back(
326-
adaptAnalysisTask<JetFinderMCDetectorLevel>(cfgc,
327-
SetDefaultProcesses{}, TaskName{"jet-finder-mcd"}));
224+
adaptAnalysisTask<JetFinderMCDetectorLevelCharged>(cfgc,
225+
SetDefaultProcesses{}, TaskName{"jet-finder-mcd-charged"}));
328226

329227
tasks.emplace_back(
330228
adaptAnalysisTask<JetFinderMCDetectorLevelFull>(cfgc,
@@ -334,13 +232,13 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
334232
adaptAnalysisTask<JetFinderMCDetectorLevelNeutral>(cfgc,
335233
SetDefaultProcesses{}, TaskName{"jet-finder-mcd-neutral"}));
336234

337-
tasks.emplace_back(
338-
adaptAnalysisTask<JetFinderHybridIntermediate>(cfgc,
339-
SetDefaultProcesses{}, TaskName{"jet-finder-hybrid-intermedaite-full"}));
235+
// tasks.emplace_back(
236+
// adaptAnalysisTask<JetFinderHybridIntermediate>(cfgc,
237+
// SetDefaultProcesses{}, TaskName{"jet-finder-hybrid-intermedaite-full"}));
340238

341239
tasks.emplace_back(
342-
adaptAnalysisTask<JetFinderMCParticleLevel>(cfgc,
343-
SetDefaultProcesses{}, TaskName{"jet-finder-mcp"}));
240+
adaptAnalysisTask<JetFinderMCParticleLevelCharged>(cfgc,
241+
SetDefaultProcesses{}, TaskName{"jet-finder-mcp-charged"}));
344242

345243
tasks.emplace_back(
346244
adaptAnalysisTask<JetFinderMCParticleLevelFull>(cfgc,

0 commit comments

Comments
 (0)