Skip to content

Commit c0227ab

Browse files
authored
[PWGUD] use get track size and add flowMC (#15679)
1 parent ed0e19a commit c0227ab

File tree

4 files changed

+240
-29
lines changed

4 files changed

+240
-29
lines changed

PWGUD/Tasks/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ o2physics_add_dpl_workflow(flow-correlations-upc
254254
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGCFCore
255255
COMPONENT_NAME Analysis)
256256

257+
o2physics_add_dpl_workflow(flow-mc-upc
258+
SOURCES flowMcUpc.cxx
259+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore
260+
COMPONENT_NAME Analysis)
261+
257262
o2physics_add_dpl_workflow(analysis-mc-dpm-jet-sg-v3
258263
SOURCES analysisMCDPMJetSGv3.cxx
259264
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
@@ -272,4 +277,4 @@ o2physics_add_dpl_workflow(sg-exclusive-jpsi-midrapidity
272277
o2physics_add_dpl_workflow(fitbit-mapping
273278
SOURCES upcTestFITBitMapping.cxx
274279
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
275-
COMPONENT_NAME Analysis)
280+
COMPONENT_NAME Analysis)

PWGUD/Tasks/flowCorrelationsUpc.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,21 @@ struct FlowCorrelationsUpc {
377377
// event mixing
378378

379379
SliceCache cache;
380-
using MixedBinning = ColumnBinningPolicy<aod::collision::PosZ, aod::flowcorrupc::Multiplicity>;
380+
// using MixedBinning = ColumnBinningPolicy<aod::collision::PosZ, aod::flowcorrupc::Multiplicity>;
381381

382382
// the process for filling the mixed events
383383
void processMixed(UDCollisionsFull const& collisions, UdTracksFull const& tracks)
384384
{
385-
MixedBinning binningOnVtxAndMult{{vtxMix, multMix}, true}; // true is for 'ignore overflows' (true by default)
385+
auto getTracksSize = [&tracks, this](UDCollisionsFull::iterator const& collision) {
386+
auto associatedTracks = tracks.sliceByCached(o2::aod::udtrack::udCollisionId, collision.udCollisionId(), this->cache);
387+
388+
auto mult = associatedTracks.size();
389+
return mult;
390+
};
391+
392+
using MixedBinning = FlexibleBinningPolicy<std::tuple<decltype(getTracksSize)>, aod::collision::PosZ, decltype(getTracksSize)>;
393+
MixedBinning binningOnVtxAndMult{{getTracksSize}, {vtxMix, multMix}, true};
394+
// MixedBinning binningOnVtxAndMult{{vtxMix, multMix}, true}; // true is for 'ignore overflows' (true by default)
386395
auto tracksTuple = std::make_tuple(tracks);
387396
SameKindPair<UDCollisionsFull, UdTracksFull, MixedBinning> pairs{binningOnVtxAndMult, cfgMinMixEventNum, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip
388397

PWGUD/Tasks/flowCumulantsUpc.cxx

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -404,33 +404,34 @@ struct FlowCumulantsUpc {
404404
delete oba;
405405

406406
// eta region
407-
fGFW->AddRegion("full", -0.8, 0.8, 1, 1);
408-
fGFW->AddRegion("refN00", -0.8, 0., 1, 1); // gap0 negative region
409-
fGFW->AddRegion("refP00", 0., 0.8, 1, 1); // gap0 positve region
410-
fGFW->AddRegion("refN02", -0.8, -0.1, 1, 1); // gap2 negative region
411-
fGFW->AddRegion("refP02", 0.1, 0.8, 1, 1); // gap2 positve region
412-
fGFW->AddRegion("refN04", -0.8, -0.2, 1, 1); // gap4 negative region
413-
fGFW->AddRegion("refP04", 0.2, 0.8, 1, 1); // gap4 positve region
414-
fGFW->AddRegion("refN06", -0.8, -0.3, 1, 1); // gap6 negative region
415-
fGFW->AddRegion("refP06", 0.3, 0.8, 1, 1); // gap6 positve region
416-
fGFW->AddRegion("refN08", -0.8, -0.4, 1, 1);
417-
fGFW->AddRegion("refP08", 0.4, 0.8, 1, 1);
418-
fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1);
419-
fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1);
420-
fGFW->AddRegion("refN12", -0.8, -0.6, 1, 1);
421-
fGFW->AddRegion("refP12", 0.6, 0.8, 1, 1);
422-
fGFW->AddRegion("refN14", -0.8, -0.7, 1, 1);
423-
fGFW->AddRegion("refP14", 0.7, 0.8, 1, 1);
424-
fGFW->AddRegion("refN", -0.8, -0.4, 1, 1);
425-
fGFW->AddRegion("refP", 0.4, 0.8, 1, 1);
407+
fGFW->AddRegion("full", -0.9, 0.9, 1, 1);
408+
fGFW->AddRegion("refN00", -0.9, 0., 1, 1); // gap0 negative region
409+
fGFW->AddRegion("refP00", 0., 0.9, 1, 1); // gap0 positve region
410+
fGFW->AddRegion("refN02", -0.9, -0.1, 1, 1); // gap2 negative region
411+
fGFW->AddRegion("refP02", 0.1, 0.9, 1, 1); // gap2 positve region
412+
fGFW->AddRegion("refN04", -0.9, -0.2, 1, 1); // gap4 negative region
413+
fGFW->AddRegion("refP04", 0.2, 0.9, 1, 1); // gap4 positve region
414+
fGFW->AddRegion("refN06", -0.9, -0.3, 1, 1); // gap6 negative region
415+
fGFW->AddRegion("refP06", 0.3, 0.9, 1, 1); // gap6 positve region
416+
fGFW->AddRegion("refN08", -0.9, -0.4, 1, 1);
417+
fGFW->AddRegion("refP08", 0.4, 0.9, 1, 1);
418+
fGFW->AddRegion("refN10", -0.9, -0.5, 1, 1);
419+
fGFW->AddRegion("refP10", 0.5, 0.9, 1, 1);
420+
fGFW->AddRegion("refN12", -0.9, -0.6, 1, 1);
421+
fGFW->AddRegion("refP12", 0.6, 0.9, 1, 1);
422+
fGFW->AddRegion("refN14", -0.9, -0.7, 1, 1);
423+
fGFW->AddRegion("refP14", 0.7, 0.9, 1, 1);
424+
fGFW->AddRegion("refN", -0.9, -0.4, 1, 1);
425+
fGFW->AddRegion("refP", 0.4, 0.9, 1, 1);
426426
fGFW->AddRegion("refM", -0.4, 0.4, 1, 1);
427-
fGFW->AddRegion("poiN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 2);
428-
fGFW->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2);
429-
fGFW->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2);
430-
fGFW->AddRegion("olN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 4);
431-
fGFW->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4);
432-
fGFW->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4);
433-
427+
fGFW->AddRegion("poiN", -0.9, -0.4, 1 + fPtAxis->GetNbins(), 2);
428+
fGFW->AddRegion("poiN10", -0.9, -0.5, 1 + fPtAxis->GetNbins(), 2);
429+
fGFW->AddRegion("poifull", -0.9, 0.9, 1 + fPtAxis->GetNbins(), 2);
430+
fGFW->AddRegion("olN", -0.9, -0.4, 1 + fPtAxis->GetNbins(), 4);
431+
fGFW->AddRegion("olN10", -0.9, -0.5, 1 + fPtAxis->GetNbins(), 4);
432+
fGFW->AddRegion("olfull", -0.9, 0.9, 1 + fPtAxis->GetNbins(), 4);
433+
434+
// eta region for MC, can be different from data to study the effect of acceptance
434435
fGFWMC->AddRegion("full", -0.8, 0.8, 1, 1);
435436
fGFWMC->AddRegion("refN00", -0.8, 0., 1, 1); // gap0 negative region
436437
fGFWMC->AddRegion("refP00", 0., 0.8, 1, 1); // gap0 positve region

PWGUD/Tasks/flowMcUpc.cxx

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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 flowMcUpc.cxx
13+
/// \author Zhiyong Lu (zhiyong.lu@cern.ch), Yongxi Du (yongxi.du@cern.ch)
14+
/// \since Apr/2/2026
15+
/// \brief flow efficiency analysis on UPC MC
16+
17+
#include "PWGUD/Core/SGSelector.h"
18+
#include "PWGUD/DataModel/UDTables.h"
19+
20+
#include "Common/Core/RecoDecay.h"
21+
#include "Common/Core/TrackSelection.h"
22+
#include "Common/Core/TrackSelectionDefaults.h"
23+
#include "Common/Core/trackUtilities.h"
24+
#include "Common/DataModel/TrackSelectionTables.h"
25+
26+
#include <CCDB/BasicCCDBManager.h>
27+
#include <CommonConstants/MathConstants.h>
28+
#include <CommonConstants/PhysicsConstants.h>
29+
#include <Framework/ASoAHelpers.h>
30+
#include <Framework/AnalysisDataModel.h>
31+
#include <Framework/AnalysisTask.h>
32+
#include <Framework/HistogramRegistry.h>
33+
#include <Framework/RunningWorkflowInfo.h>
34+
#include <Framework/runDataProcessing.h>
35+
#include <ReconstructionDataFormats/Track.h>
36+
37+
#include <TPDGCode.h>
38+
39+
#include <string>
40+
#include <vector>
41+
42+
using namespace o2;
43+
using namespace o2::framework;
44+
using namespace o2::framework::expressions;
45+
46+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
47+
48+
struct FlowMcUpc {
49+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
50+
51+
Configurable<float> minB{"minB", 0.0f, "min impact parameter"};
52+
Configurable<float> maxB{"maxB", 20.0f, "max impact parameter"};
53+
O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range")
54+
O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks")
55+
O2_DEFINE_CONFIGURABLE(cfgPtCutMin, float, 0.1f, "Minimal pT for tracks")
56+
O2_DEFINE_CONFIGURABLE(cfgPtCutMax, float, 1000.0f, "Maximal pT for tracks")
57+
O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "DCAxy cut for tracks")
58+
O2_DEFINE_CONFIGURABLE(cfgDcaxy, bool, true, "choose dcaxy")
59+
60+
ConfigurableAxis axisB{"axisB", {100, 0.0f, 20.0f}, ""};
61+
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f}, "pt axis"};
62+
// Connect to ccdb
63+
Service<ccdb::BasicCCDBManager> ccdb;
64+
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
65+
66+
double epsilon = 1e-6;
67+
68+
using McParts = soa::Join<aod::UDMcParticles, aod::UDMcTrackLabels>;
69+
70+
void init(InitContext&)
71+
{
72+
ccdb->setURL(ccdbUrl.value);
73+
ccdb->setCaching(true);
74+
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
75+
ccdb->setCreatedNotAfter(now);
76+
77+
const AxisSpec axisVertex{20, -10, 10, "Vtxz (cm)"};
78+
const AxisSpec axisEta{20, -1., 1., "#eta"};
79+
const AxisSpec axisCounter{1, 0, +1, ""};
80+
// QA histograms
81+
histos.add<TH1>("mcEventCounter", "Monte Carlo Truth EventCounter", HistType::kTH1F, {{5, 0, 5}});
82+
histos.add<TH1>("RecoProcessEventCounter", "Reconstruction EventCounter", HistType::kTH1F, {{5, 0, 5}});
83+
histos.add<TH1>("hImpactParameter", "hImpactParameter", HistType::kTH1D, {axisB});
84+
85+
histos.add<TH1>("hPtMCGen", "Monte Carlo Truth; pT (GeV/c);", {HistType::kTH1D, {axisPt}});
86+
histos.add<TH3>("hEtaPtVtxzMCGen", "Monte Carlo Truth; #eta; p_{T} (GeV/c); V_{z} (cm);", {HistType::kTH3D, {axisEta, axisPt, axisVertex}});
87+
histos.add<TH1>("hPtReco", "Monte Carlo Reco Global; pT (GeV/c);", {HistType::kTH1D, {axisPt}});
88+
histos.add<TH3>("hEtaPtVtxzMCReco", "Monte Carlo Global; #eta; p_{T} (GeV/c); V_{z} (cm);", {HistType::kTH3D, {axisEta, axisPt, axisVertex}});
89+
}
90+
91+
// template <typename TCollision>
92+
// bool eventSelected(TCollision collision)
93+
// {
94+
// return true;
95+
// }
96+
97+
template <typename TTrack>
98+
bool trackSelected(TTrack const& track)
99+
{
100+
// auto momentum = std::array<double, 3>{track.px(), track.py(), track.pz()};
101+
auto pt = track.pt();
102+
if (pt < cfgPtCutMin || pt > cfgPtCutMax) {
103+
return false;
104+
}
105+
double dcaLimit = 0.0105 + 0.035 / std::pow(pt, 1.1);
106+
if (cfgDcaxy && !(std::fabs(track.dcaXY()) < dcaLimit)) {
107+
return false;
108+
}
109+
return true;
110+
}
111+
112+
void processMCTrue(aod::UDMcCollisions::iterator const& mcCollision, McParts const& mcParts, aod::BCs const& bcs)
113+
{
114+
if (bcs.size() == 0) {
115+
return;
116+
}
117+
histos.fill(HIST("mcEventCounter"), 0.5);
118+
float imp = mcCollision.impactParameter();
119+
float vtxz = mcCollision.posZ();
120+
121+
if (imp >= minB && imp <= maxB) {
122+
// event within range
123+
histos.fill(HIST("hImpactParameter"), imp);
124+
125+
for (auto const& mcParticle : mcParts) {
126+
auto momentum = std::array<double, 3>{mcParticle.px(), mcParticle.py(), mcParticle.pz()};
127+
int pdgCode = std::abs(mcParticle.pdgCode());
128+
129+
double pt = RecoDecay::pt(momentum);
130+
double eta = RecoDecay::eta(momentum);
131+
132+
if (pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != PDG_t::kKPlus && pdgCode != PDG_t::kProton)
133+
continue;
134+
135+
if (!mcParticle.isPhysicalPrimary())
136+
continue;
137+
if (std::fabs(eta) > cfgCutEta) // main acceptance
138+
continue;
139+
140+
histos.fill(HIST("hPtMCGen"), pt);
141+
histos.fill(HIST("hEtaPtVtxzMCGen"), eta, pt, vtxz);
142+
}
143+
}
144+
}
145+
PROCESS_SWITCH(FlowMcUpc, processMCTrue, "process pure simulation information", true);
146+
147+
using MCRecoTracks = soa::Join<aod::UDTracks, aod::UDTracksPID, aod::UDTracksExtra, aod::UDTracksFlags, aod::UDTracksDCA, aod::UDMcTrackLabels>;
148+
using MCRecoCollisions = soa::Join<aod::UDCollisions, aod::SGCollisions, aod::UDCollisionSelExtras, aod::UDCollisionsSels, aod::UDZdcsReduced, aod::UDMcCollsLabels>;
149+
150+
void processReco(MCRecoCollisions::iterator const& collision, MCRecoTracks const& tracks)
151+
{
152+
histos.fill(HIST("RecoProcessEventCounter"), 0.5);
153+
// if (!eventSelected(collision))
154+
// return;
155+
histos.fill(HIST("RecoProcessEventCounter"), 1.5);
156+
if (!collision.has_udMcCollision())
157+
return;
158+
histos.fill(HIST("RecoProcessEventCounter"), 2.5);
159+
if (tracks.size() < 1)
160+
return;
161+
histos.fill(HIST("RecoProcessEventCounter"), 3.5);
162+
163+
float vtxz = collision.posZ();
164+
165+
for (const auto& track : tracks) {
166+
// focus on bulk: e, mu, pi, k, p
167+
auto momentum = std::array<double, 3>{track.px(), track.py(), track.pz()};
168+
double pt = RecoDecay::pt(momentum);
169+
double eta = RecoDecay::eta(momentum);
170+
// double phi = RecoDecay::phi(momentum);
171+
if (!trackSelected(track) || (!track.has_udMcParticle()))
172+
continue;
173+
auto mcParticle = track.udMcParticle();
174+
int pdgCode = std::abs(mcParticle.pdgCode());
175+
176+
// double pt = recoMC.Pt();
177+
// double eta = recoMC.Eta();
178+
if (pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != PDG_t::kKPlus && pdgCode != PDG_t::kProton)
179+
continue;
180+
if (std::fabs(eta) > cfgCutEta) // main acceptance
181+
continue;
182+
if (!mcParticle.isPhysicalPrimary())
183+
continue;
184+
185+
histos.fill(HIST("hPtReco"), pt);
186+
histos.fill(HIST("hEtaPtVtxzMCReco"), eta, pt, vtxz);
187+
}
188+
}
189+
PROCESS_SWITCH(FlowMcUpc, processReco, "process reconstructed information", true);
190+
};
191+
192+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
193+
{
194+
return WorkflowSpec{
195+
adaptAnalysisTask<FlowMcUpc>(cfgc)};
196+
}

0 commit comments

Comments
 (0)