Skip to content

Commit 560cd5f

Browse files
[PWGJE] New task for jetShape.cxx (#9644)
1 parent d357b14 commit 560cd5f

File tree

2 files changed

+281
-0
lines changed

2 files changed

+281
-0
lines changed

PWGJE/Tasks/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,8 @@ if(FastJet_FOUND)
265265
SOURCES bjetTaggingGNN.cxx
266266
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore
267267
COMPONENT_NAME Analysis)
268+
o2physics_add_dpl_workflow(jet-shape
269+
SOURCES jetShape.cxx
270+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore
271+
COMPONENT_NAME Analysis)
268272
endif()

PWGJE/Tasks/jetShape.cxx

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file jetShape.cxx
13+
/// \author Yuto Nishida <yuto.nishida@cern.ch>
14+
/// \brief Task for measuring the dependence of the jet shape function rho(r) on the distance r from the jet axis.
15+
16+
#include <string>
17+
#include <vector>
18+
#include <cmath>
19+
20+
#include "Framework/ASoA.h"
21+
#include "Framework/AnalysisDataModel.h"
22+
#include "Framework/AnalysisTask.h"
23+
#include "Framework/HistogramRegistry.h"
24+
25+
#include "Common/Core/RecoDecay.h"
26+
#include "Common/Core/TrackSelection.h"
27+
#include "Common/Core/TrackSelectionDefaults.h"
28+
#include "Common/DataModel/EventSelection.h"
29+
#include "Common/DataModel/TrackSelectionTables.h"
30+
31+
#include "PWGJE/Core/FastJetUtilities.h"
32+
#include "PWGJE/Core/JetUtilities.h"
33+
#include "PWGJE/Core/JetDerivedDataUtilities.h"
34+
#include "PWGJE/DataModel/Jet.h"
35+
36+
#include "Framework/runDataProcessing.h"
37+
38+
using namespace o2;
39+
using namespace o2::framework;
40+
using namespace o2::framework::expressions;
41+
42+
struct JetShapeTask {
43+
HistogramRegistry registry{"registry",
44+
{{"tpcPi", "tpcPi", {HistType::kTH2F, {{1000, 0, 5}, {401, -10.025f, 10.025f}}}},
45+
{"tofPi", "tofPi", {HistType::kTH2F, {{1000, 0, 5}, {401, -10.025f, 10.025f}}}},
46+
{"tpcPr", "tpcPr", {HistType::kTH2F, {{1000, 0, 5}, {401, -10.025f, 10.025f}}}},
47+
{"tofPr", "tofPr", {HistType::kTH2F, {{1000, 0, 5}, {401, -10.025f, 10.025f}}}},
48+
{"tpcDedx", "tpcDedx", {HistType::kTH2F, {{1000, 0, 5}, {1000, 0, 1000}}}},
49+
{"tofBeta", "tofBeta", {HistType::kTH2F, {{1000, 0, 5}, {900, 0.2, 1.1}}}},
50+
{"tofMass", "tofMass", {HistType::kTH1F, {{3000, 0, 3}}}},
51+
{"jetPt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}},
52+
{"jetEta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}},
53+
{"jetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}},
54+
{"area", "area", {HistType::kTH1F, {{200, 0, 4}}}},
55+
{"rho", "rho", {HistType::kTH1F, {{200, -1, 119}}}},
56+
{"ptCorr", "Corrected jet pT; p_{T}^{corr} (GeV/c); Counts", {HistType::kTH1F, {{200, 0, 200}}}},
57+
{"ptCorrVsDistance", "ptcorr_vs_distance", {HistType::kTH2F, {{70, 0, 0.7}, {100, 0, 100}}}},
58+
{"distanceVsTrackpt", "trackpt_vs_distance", {HistType::kTH2F, {{70, 0, 0.7}, {100, 0, 100}}}},
59+
{"ptSum", "ptSum", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}},
60+
{"ptSumBg1", "ptSumBg1", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}},
61+
{"ptSumBg2", "ptSumBg2", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}},
62+
{"ptVsCentrality", "ptvscentrality", {HistType::kTH2F, {{100, 0, 100}, {300, 0, 300}}}}}};
63+
64+
Configurable<float> vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"};
65+
66+
Configurable<float> jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"};
67+
Configurable<float> jetR{"jetR", 0.4, "jet resolution parameter"};
68+
69+
Configurable<std::string> eventSelections{"eventSelections", "sel8", "choose event selection"};
70+
Configurable<std::string> trackSelections{"trackSelections", "globalTracks", "set track selections"};
71+
72+
Configurable<float> jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"};
73+
Configurable<float> leadingConstituentPtMin{"leadingConstituentPtMin", 5.0, "minimum pT selection on jet constituent"};
74+
Configurable<float> leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT selection on jet constituent"};
75+
76+
// for jet shape
77+
Configurable<std::vector<float>> distanceCategory{"distanceCategory", {0.00f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.40f, 0.45f, 0.50f, 0.55f, 0.60f, 0.65f, 0.70f}, "distance of category"};
78+
79+
// for ppi production
80+
Configurable<float> maxTpcNClsCrossedRows{"maxTpcNClsCrossedRows", 70, ""};
81+
Configurable<float> maxDcaXY{"maxDcaXY", 0.2, ""};
82+
Configurable<float> maxItsNCls{"maxItsNCls", 2, ""};
83+
84+
Configurable<std::string> triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"};
85+
86+
std::vector<int> eventSelectionBits;
87+
int trackSelection = -1;
88+
std::vector<int> triggerMaskBits;
89+
90+
void init(o2::framework::InitContext&)
91+
{
92+
eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast<std::string>(eventSelections));
93+
trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast<std::string>(trackSelections));
94+
triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks);
95+
}
96+
97+
template <typename T, typename U>
98+
bool isAcceptedJet(U const& jet)
99+
{
100+
if (jetAreaFractionMin > -98.0) {
101+
if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) {
102+
return false;
103+
}
104+
if (jet.area() < o2::constants::math::PIHalf * (jet.r() / 100.0) * (jet.r() / 100.0)) {
105+
return false;
106+
}
107+
}
108+
bool checkConstituentPt = true;
109+
bool checkConstituentMinPt = (leadingConstituentPtMin > 5);
110+
bool checkConstituentMaxPt = (leadingConstituentPtMax < 9998.0);
111+
if (!checkConstituentMinPt && !checkConstituentMaxPt) {
112+
checkConstituentPt = false;
113+
}
114+
115+
if (checkConstituentPt) {
116+
bool isMinLeadingConstituent = !checkConstituentMinPt;
117+
bool isMaxLeadingConstituent = true;
118+
119+
for (const auto& constituent : jet.template tracks_as<T>()) {
120+
double pt = constituent.pt();
121+
122+
if (checkConstituentMinPt && pt >= leadingConstituentPtMin) {
123+
isMinLeadingConstituent = true;
124+
}
125+
if (checkConstituentMaxPt && pt > leadingConstituentPtMax) {
126+
isMaxLeadingConstituent = false;
127+
}
128+
}
129+
return isMinLeadingConstituent && isMaxLeadingConstituent;
130+
}
131+
132+
return true;
133+
}
134+
135+
Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f);
136+
Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut;
137+
Filter mcCollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut;
138+
139+
Preslice<soa::Filtered<aod::ChargedMCParticleLevelJets>> perMcCollisionJets = aod::jet::mcCollisionId;
140+
141+
void processJetShape(soa::Filtered<soa::Join<aod::JetCollisions, aod::BkgChargedRhos>>::iterator const& collision, aod::JetTracks const& tracks, soa::Join<aod::ChargedJets, aod::ChargedJetConstituents> const& jets)
142+
{
143+
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
144+
return;
145+
}
146+
std::vector<float> ptDensity;
147+
std::vector<float> ptDensityBg1;
148+
std::vector<float> ptDensityBg2;
149+
150+
ptDensity.reserve(distanceCategory->size() - 1);
151+
ptDensityBg1.reserve(distanceCategory->size() - 1);
152+
ptDensityBg2.reserve(distanceCategory->size() - 1);
153+
154+
// std::cout << collision.centrality() << std::endl;
155+
156+
for (auto const& jet : jets) {
157+
if (!isAcceptedJet<aod::JetTracks>(jet)) {
158+
continue;
159+
}
160+
161+
// Get underlying event subtracted jet.pt() as ptCorr
162+
float ptCorr = jet.pt() - collision.rho() * jet.area();
163+
164+
for (const auto& track : tracks) {
165+
float preDeltaPhi1 = track.phi() - jet.phi();
166+
float deltaPhi1 = RecoDecay::constrainAngle(preDeltaPhi1);
167+
float deltaEta = track.eta() - jet.eta();
168+
169+
// calculate distance from jet axis
170+
float distance = std::sqrt(deltaEta * deltaEta + deltaPhi1 * deltaPhi1);
171+
172+
registry.fill(HIST("ptCorrVsDistance"), distance, ptCorr);
173+
registry.fill(HIST("ptVsCentrality"), collision.centrality(), track.pt());
174+
175+
// calculate compornents of jetshapefunction rho(r)
176+
std::vector<float> trackPtSum;
177+
std::vector<float> trackPtSumBg1;
178+
std::vector<float> trackPtSumBg2;
179+
trackPtSum.reserve(distanceCategory->size() - 1);
180+
trackPtSumBg1.reserve(distanceCategory->size() - 1);
181+
trackPtSumBg2.reserve(distanceCategory->size() - 1);
182+
float phiBg1 = jet.phi() + (o2::constants::math::PIHalf);
183+
float phiBg2 = jet.phi() - (o2::constants::math::PIHalf);
184+
185+
float preDeltaPhiBg1 = track.phi() - phiBg1;
186+
float preDeltaPhiBg2 = track.phi() - phiBg2;
187+
188+
float deltaPhiBg1 = RecoDecay::constrainAngle(preDeltaPhiBg1);
189+
float deltaPhiBg2 = RecoDecay::constrainAngle(preDeltaPhiBg2);
190+
191+
float distanceBg1 = std::sqrt(deltaEta * deltaEta + deltaPhiBg1 * deltaPhiBg1);
192+
float distanceBg2 = std::sqrt(deltaEta * deltaEta + deltaPhiBg2 * deltaPhiBg2);
193+
194+
for (size_t i = 0; i < distanceCategory->size() - 1; i++) {
195+
if (distance < distanceCategory->at(i + 1))
196+
trackPtSum[i] += track.pt();
197+
if (distanceBg1 < distanceCategory->at(i + 1))
198+
trackPtSumBg1[i] += track.pt();
199+
if (distanceBg2 < distanceCategory->at(i + 1))
200+
trackPtSumBg2[i] += track.pt();
201+
}
202+
203+
for (size_t i = 0; i < distanceCategory->size() - 1; i++) {
204+
ptDensity[i] += trackPtSum[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr);
205+
ptDensityBg1[i] += trackPtSumBg1[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr);
206+
ptDensityBg2[i] += trackPtSumBg2[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr);
207+
}
208+
}
209+
210+
registry.fill(HIST("jetPt"), jet.pt());
211+
registry.fill(HIST("jetEta"), jet.eta());
212+
registry.fill(HIST("jetPhi"), jet.phi());
213+
registry.fill(HIST("area"), jet.area());
214+
registry.fill(HIST("rho"), collision.rho());
215+
registry.fill(HIST("ptCorr"), ptCorr);
216+
217+
for (size_t i = 0; i < distanceCategory->size() - 1; i++) {
218+
double jetX = (distanceCategory->at(i + 1) - distanceCategory->at(i)) * i + (distanceCategory->at(i + 1) - distanceCategory->at(i)) / 2;
219+
double jetShapeFunction = ptDensity[i + 1];
220+
double jetShapeFunctionBg1 = ptDensityBg1[i + 1];
221+
double jetShapeFunctionBg2 = ptDensityBg2[i + 1];
222+
registry.fill(HIST("ptSum"), jetX, jetShapeFunction);
223+
registry.fill(HIST("ptSumBg1"), jetX, jetShapeFunctionBg1);
224+
registry.fill(HIST("ptSumBg2"), jetX, jetShapeFunctionBg2);
225+
}
226+
}
227+
}
228+
PROCESS_SWITCH(JetShapeTask, processJetShape, "JetShape", true);
229+
230+
void processProductionRatio(soa::Filtered<soa::Join<aod::JetCollisions, aod::BkgChargedRhos>>::iterator const& collision, soa::Join<aod::JetTracks, aod::pidTPCFullPi, aod::pidTOFFullPi, aod::pidTPCFullPr, aod::pidTOFFullPr, aod::TracksExtra, aod::TracksDCA, aod::pidTOFbeta, aod::pidTOFmass> const& tracks, soa::Join<aod::ChargedJets, aod::ChargedJetConstituents> const& jets)
231+
{
232+
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
233+
return;
234+
}
235+
236+
for (auto const& jet : jets) {
237+
if (!isAcceptedJet<aod::JetTracks>(jet)) {
238+
continue;
239+
}
240+
241+
// tracks conditions
242+
for (const auto& track : tracks) {
243+
if (track.tpcNClsCrossedRows() < maxTpcNClsCrossedRows)
244+
continue;
245+
if (std::fabs(track.dcaXY()) > maxDcaXY)
246+
continue;
247+
if (track.itsNCls() < maxItsNCls) {
248+
continue;
249+
}
250+
251+
// PID check
252+
registry.fill(HIST("tpcDedx"), track.pt(), track.tpcSignal());
253+
registry.fill(HIST("tofBeta"), track.pt(), track.beta());
254+
registry.fill(HIST("tofMass"), track.mass());
255+
256+
// for calculate purity
257+
registry.fill(HIST("tpcPi"), track.pt(), track.tpcNSigmaPi());
258+
registry.fill(HIST("tofPi"), track.pt(), track.tofNSigmaPi());
259+
registry.fill(HIST("tpcPr"), track.pt(), track.tpcNSigmaPr());
260+
registry.fill(HIST("tofPr"), track.pt(), track.tofNSigmaPr());
261+
262+
// for calculate distance
263+
float preDeltaPhi1 = track.phi() - jet.phi();
264+
float deltaPhi1 = RecoDecay::constrainAngle(preDeltaPhi1);
265+
float deltaEta = track.eta() - jet.eta();
266+
267+
// calculate distance from jet axis
268+
float distance = std::sqrt(deltaEta * deltaEta + deltaPhi1 * deltaPhi1);
269+
270+
registry.fill(HIST("distanceVsTrackpt"), distance, track.pt());
271+
}
272+
}
273+
}
274+
PROCESS_SWITCH(JetShapeTask, processProductionRatio, "production ratio", true);
275+
};
276+
277+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<JetShapeTask>(cfgc)}; }

0 commit comments

Comments
 (0)