Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions PWGMM/UE/Tasks/uecharged.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
/// \file uecharged.cxx
/// \brief Underlying event analysis task
/// \since November 2021
/// \last update: April 2026
/// \last update: June 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no \last Doxygen command.


#include "PWGLF/Utils/inelGt.h"

#include "Common/CCDB/EventSelectionParams.h"
#include "Common/Core/TrackSelection.h"
#include "Common/Core/TrackSelectionDefaults.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/McCollisionExtra.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/TrackSelectionTables.h"

Expand Down Expand Up @@ -62,6 +63,7 @@
Configurable<bool> removeITSROFBorder{"event_removeITSROFBorder", false, "Remove ITS Read-Out Frame border and only apply kIsTriggerTVX & kNoTimeFrameBorder (recommended for MC)"};
Configurable<int> cfgINELCut{"event_cfgINELCut", 0, "INEL event selection: 0 no sel, 1 INEL>0, 2 INEL>1"};
Configurable<float> CollPosZ{"event_CollPosZ", 10.f, "Cut on the z component of the vertex position"};
Configurable<bool> GoodITS{"event_GoodITS", true, "Numbers of inactive chips on all ITS layers are below maximum allowed values"};
Configurable<bool> analyzeEvandTracksel{"analyzeEvandTracksel", true, "Analyze the event and track selection"};

// Track selection configurables
Expand All @@ -72,16 +74,16 @@
Configurable<float> minPt{"trkcfg_minPt", 0.1f, "Set minimum pT of tracks"};
Configurable<float> maxPt{"trkcfg_maxPt", 1e10f, "Set maximum pT of tracks"};
Configurable<float> requireEta{"trkcfg_requireEta", 0.8f, "Set eta range of tracks"};
Configurable<bool> requireITSRefit{"trkcfg_requireITSRefit", true, "Additional cut on the ITS requirement"};
Configurable<bool> requireTPCRefit{"trkcfg_requireTPCRefit", true, "Additional cut on the TPC requirement"};
Configurable<bool> requireGoldenChi2{"trkcfg_requireGoldenChi2", true, "Additional cut on the GoldenChi2"};
Configurable<float> maxChi2PerClusterTPC{"trkcfg_maxChi2PerClusterTPC", 4.f, "Additional cut on the maximum value of the chi2 per cluster in the TPC"};
Configurable<float> maxChi2PerClusterITS{"trkcfg_maxChi2PerClusterITS", 36.f, "Additional cut on the maximum value of the chi2 per cluster in the ITS"};
// Configurable<int> minITSnClusters{"trkcfg_minITSnClusters", 5, "minimum number of found ITS clusters"};
Configurable<float> minNCrossedRowsTPC{"trkcfg_minNCrossedRowsTPC", 70.f, "Additional cut on the minimum number of crossed rows in the TPC"};
Configurable<float> minNCrossedRowsOverFindableClustersTPC{"trkcfg_minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"};
Configurable<float> maxDcaXYFactor{"trkcfg_maxDcaXYFactor", 1.f, "Multiplicative factor on the maximum value of the DCA xy"};
Configurable<float> maxDcaZ{"trkcfg_maxDcaZ", 0.1f, "Additional cut on the maximum value of the DCA z"};
// Configurable<bool> requireITSRefit{"trkcfg_requireITSRefit", true, "Additional cut on the ITS requirement"};
// Configurable<bool> requireTPCRefit{"trkcfg_requireTPCRefit", true, "Additional cut on the TPC requirement"};
// Configurable<float> minNCrossedRowsOverFindableClustersTPC{"trkcfg_minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"};
// Configurable<int> minITSnClusters{"trkcfg_minITSnClusters", 5, "minimum number of found ITS clusters"};

Service<o2::framework::O2DatabasePDG> pdg;

Expand All @@ -94,6 +96,7 @@
using TrackMCTrueTable = aod::McParticles;

// reconstructed collisions associated to MC collisions (small groups keyed by mcCollisionId)
using ColMCTrueTableWithExtra = soa::Join<aod::McCollisions, aod::McCollsExtra>;
using ColMCRecTable = soa::SmallGroups<soa::Join<aod::McCollisionLabels, aod::Collisions, aod::EvSels, aod::Mults, aod::PVMults>>;
using TrackMCRecTable = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::McTrackLabels>;
using FilTrackMCRecTable = soa::Filtered<TrackMCRecTable>;
Expand Down Expand Up @@ -138,17 +141,17 @@
myTrkSel = getGlobalTrackSelectionRun3ITSMatch(setITSreq.value);
myTrkSel.SetPtRange(minPt.value, maxPt.value);
myTrkSel.SetEtaRange(-requireEta.value, requireEta.value);
myTrkSel.SetRequireITSRefit(requireITSRefit.value);
myTrkSel.SetRequireTPCRefit(requireTPCRefit.value);
myTrkSel.SetRequireGoldenChi2(requireGoldenChi2.value);
myTrkSel.SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC.value);
myTrkSel.SetMaxChi2PerClusterITS(maxChi2PerClusterITS.value);
// myTrkSel.SetMinNClustersITS(minITSnClusters.value);
myTrkSel.SetMinNCrossedRowsTPC(minNCrossedRowsTPC.value);
myTrkSel.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC.value);
// myTrkSel.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / pow(pt, 1.1f); });
myTrkSel.SetMaxDcaXYPtDep([](float /*pt*/) { return 10000.f; });
myTrkSel.SetMaxDcaZ(maxDcaZ.value);
// myTrkSel.SetRequireITSRefit(requireITSRefit.value);
// myTrkSel.SetRequireTPCRefit(requireTPCRefit.value);
// myTrkSel.SetMinNClustersITS(minITSnClusters.value);
// myTrkSel.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC.value);
// myTrkSel.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / pow(pt, 1.1f); });
myTrkSel.print();
}

Expand Down Expand Up @@ -193,7 +196,7 @@
ue.add("hmultTrueGen", "mult true all Gen", HistType::kTH1F, {{200, -0.5, 199.5, " "}});
ue.add("hvtxZmc", "vtxZ mctrue", HistType::kTH1F, {{40, -20.0, 20.0, " "}});
ue.add("hPtLeadingTrue", "true pTleading after physics selection", HistType::kTH1D, {ptAxist});
for (int i = 0; i < 3; ++i) {

Check failure on line 199 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ue.add(hPtVsPtLeadingTrue[i].data(), " ", HistType::kTH2D, {{ptAxist}, {ptAxis}});
ue.add(hPtVsPtLeadingTruePS[i].data(), " ", HistType::kTH2D, {{ptAxist}, {ptAxis}});
ue.add(pNumDenTrueAll[i].data(), "", HistType::kTProfile, {ptAxist});
Expand All @@ -203,7 +206,7 @@
ue.add(pNumDenTruePS[i].data(), "", HistType::kTProfile, {ptAxist});
ue.add(pSumPtTruePS[i].data(), "", HistType::kTProfile, {ptAxist});
}
for (int i = 0; i < 3; ++i) {

Check failure on line 209 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ue.add(hPhiTrue[i].data(), "all charged true; #Delta#phi; Counts", HistType::kTH1D, {{64, -o2::constants::math::PI / 2.0, 3.0 * o2::constants::math::PI / 2.0, ""}});
}
}
Expand All @@ -214,7 +217,7 @@
ue.add("vtxZEta", ";#eta;vtxZ", HistType::kTH2F, {{50, -2.5, 2.5, " "}, {60, -30, 30, " "}});
ue.add("phiEta", ";#eta;#varphi", HistType::kTH2F, {{50, -2.5, 2.5}, {200, 0., 2 * o2::constants::math::PI, " "}});
ue.add("hvtxZ", "vtxZ", HistType::kTH1F, {{40, -20.0, 20.0, " "}});
ue.add("hCounter", "Counter; sel; Nev", HistType::kTH1D, {{7, 0, 7, " "}});
ue.add("hCounter", "Counter; sel; Nev", HistType::kTH1D, {{8, 0, 8, " "}});
ue.add("hPtLeadingRecPS", "rec pTleading after physics selection", HistType::kTH1D, {ptAxist});
ue.add("hPtLeadingMeasured", "measured pTleading after physics selection", HistType::kTH1D, {ptAxist});
ue.add("hPtLeadingVsTracks", "", HistType::kTProfile, {{ptAxist}});
Expand All @@ -226,8 +229,9 @@
h->GetXaxis()->SetBinLabel(4, "NoSameBunchPileup");
h->GetXaxis()->SetBinLabel(5, "IsGoodZvtxFT0vsPV");
h->GetXaxis()->SetBinLabel(6, "posZ passed");
h->GetXaxis()->SetBinLabel(7, "GoodITSLayersAll");

for (int i = 0; i < 3; ++i) {

Check failure on line 234 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
ue.add(pNumDenMeasuredPS[i].data(), "Number Density; ; #LT #it{N}_{trk} #GT", HistType::kTProfile, {ptAxist});
ue.add(pSumPtMeasuredPS[i].data(), "Total #it{p}_{T}; ; #LT#sum#it{p}_{T}#GT", HistType::kTProfile, {ptAxist});
ue.add(hPhi[i].data(), "all charged; #Delta#phi; Counts", HistType::kTH1D, {{64, -o2::constants::math::PI / 2.0, 3.0 * o2::constants::math::PI / 2.0, ""}});
Expand Down Expand Up @@ -302,20 +306,20 @@
{
float dphi = -999;
if (phia < 0) {
phia += 2 * o2::constants::math::PI;

Check failure on line 309 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
} else if (phia > 2 * o2::constants::math::PI) {
phia -= 2 * o2::constants::math::PI;

Check failure on line 311 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
}
if (phib < 0) {
phib += 2 * o2::constants::math::PI;

Check failure on line 314 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
} else if (phib > 2 * o2::constants::math::PI) {
phib -= 2 * o2::constants::math::PI;

Check failure on line 316 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
}
dphi = phib - phia;
if (dphi < rangeMin) {
dphi += 2 * o2::constants::math::PI;

Check failure on line 320 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
} else if (dphi > rangeMax) {
dphi -= 2 * o2::constants::math::PI;

Check failure on line 322 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
}
return dphi;
}
Expand Down Expand Up @@ -422,8 +426,14 @@
if ((std::abs(collision.posZ()) > CollPosZ)) {
return false;
}

ue.fill(HIST("hCounter"), 5);

if (GoodITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) {
return false;
}

ue.fill(HIST("hCounter"), 6);

return true;
}

Expand Down Expand Up @@ -470,6 +480,12 @@
}

ue.fill(HIST("hCounter"), 5);

if (GoodITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) {
return false;
}

ue.fill(HIST("hCounter"), 6);
return true;
}

Expand Down Expand Up @@ -652,7 +668,7 @@
}
PROCESS_SWITCH(ueCharged, processData, "Process data", false);

void processMC(ColMCTrueTable::iterator const& mcCollision,
void processMC(ColMCTrueTableWithExtra::iterator const& mcCollision,
ColMCRecTable const& RecCols,
TrackMCTrueTable const& GenParticles,
TrackMCRecTable const& RecTracks,
Expand All @@ -672,20 +688,22 @@
ue.fill(HIST("hStat"), mcCollision.size());
const auto vtxZ = mcCollision.posZ();

// pick best reconstructed collision associated to this mcCollision (max ntracks = recRow.size())
// pick best reconstructed collision associated to this mcCollision using bestCollisionIndex
bool foundRec = false;
auto chosenRec = *RecCols.begin();
int64_t chosenRecGlobalIndex = -1;
int maxTracks = -1;

if (RecCols.size() != 0) {
for (const auto& recRow : RecCols) {
int ntracks = recRow.size();
if (ntracks > maxTracks) {
chosenRec = recRow;
chosenRecGlobalIndex = recRow.globalIndex();
maxTracks = ntracks;
foundRec = true;

if (mcCollision.has_mcCollsExtra()) {
int bestCollIdx = mcCollision.bestCollisionIndex();
if (bestCollIdx >= 0) {
// Find the reconstructed collision with this index
for (const auto& recRow : RecCols) {
if (recRow.globalIndex() == bestCollIdx) {
chosenRec = recRow;
chosenRecGlobalIndex = bestCollIdx;
foundRec = true;
break;
}
}
}
}
Expand Down Expand Up @@ -1157,7 +1175,7 @@
int tracks_before = 0;
int tracks_after = 0;

for (auto& track : tracks) {

Check failure on line 1178 in PWGMM/UE/Tasks/uecharged.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.

if (track.hasITS() && track.hasTPC()) {
ue.fill(HIST("preselection_track/ITS/itsNCls"), track.itsNCls());
Expand Down
Loading