Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace lambdaloosecollision
{
DECLARE_SOA_COLUMN(Cent, cent, float);
DECLARE_SOA_COLUMN(Mult, mult, float);
DECLARE_SOA_COLUMN(Nch, nch, float);
DECLARE_SOA_COLUMN(NchEff, nchEff, float);
DECLARE_SOA_COLUMN(PosX, posX, float);
DECLARE_SOA_COLUMN(PosY, posY, float);
DECLARE_SOA_COLUMN(PosZ, posZ, float);
Expand All @@ -38,6 +40,8 @@ DECLARE_SOA_TABLE(LambdaLooseCols, "AOD", "LAMBDALOOSECOL",
o2::soa::Index<>,
lambdaloosecollision::Cent,
lambdaloosecollision::Mult,
lambdaloosecollision::Nch,
lambdaloosecollision::NchEff,
lambdaloosecollision::PosX,
lambdaloosecollision::PosY,
lambdaloosecollision::PosZ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Common/DataModel/PIDResponseTPC.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include <CCDB/BasicCCDBManager.h>
#include <CommonConstants/PhysicsConstants.h>
#include <Framework/ASoA.h>
#include <Framework/AnalysisDataModel.h>
Expand All @@ -36,12 +37,16 @@
#include <Framework/OutputObjHeader.h>
#include <Framework/runDataProcessing.h>

#include <TAxis.h>
#include <TH1.h>
#include <TH3.h>

#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <set>
#include <string>
#include <utility>
#include <vector>

Expand All @@ -60,6 +65,7 @@ enum LooseEventCutFlow { kLeAll = 1,
kLeGoodItsLayers,
kLeCentrality,
kLeVz,
kLeNch,
kLeOneV0,
kLeTwoV0,
kLeWritten,
Expand Down Expand Up @@ -105,6 +111,18 @@ struct LambdaSpinPolarizationLooseProducer {
Configurable<bool> cZVtxTimeDiff{"cZVtxTimeDiff", false, "z-vtx time diff selection"};
Configurable<bool> cIsGoodITSLayers{"cIsGoodITSLayers", false, "Good ITS Layers All"};

Configurable<float> cNchMinPt{"cNchMinPt", 0.15f, "Minimum track pT used for Nch"};
Configurable<float> cNchMaxPt{"cNchMaxPt", 3.0f, "Maximum track pT used for Nch"};
Configurable<float> cNchEtaCut{"cNchEtaCut", 0.8f, "Track eta cut used for Nch"};
Configurable<float> cMinNch{"cMinNch", 0.0f, "Minimum Nch"};
Configurable<float> cMaxNch{"cMaxNch", 100000.0f, "Maximum Nch"};
ConfigurableAxis axisNch{"axisNch", {500, -0.5, 499.5}, "N_{ch} QA axis"};
Configurable<float> cNchMaxDcaZ{"cNchMaxDcaZ", 2.0f, "Max |DCA_z| (cm) of N_ch tracks (2 = same as isGlobalTrack)"};
Configurable<int> cNchMinTpcNClsFound{"cNchMinTpcNClsFound", 0, "Min TPC found clusters of N_ch tracks (0 = same as isGlobalTrack)"};
Configurable<std::string> cCcdbUrl{"cCcdbUrl", "http://alice-ccdb.cern.ch", "CCDB url"};
Configurable<std::string> cNchEffPath{"cNchEffPath", "", "CCDB path of the efficiency map: TH3D, axes (Vz, eta, pT), content = efficiency. Empty = NchEff not computed (-1)"};
ConfigurableAxis axisNchEff{"axisNchEff", {1400, 0., 700.}, "N_{ch}^{eff} QA axis"};

Configurable<float> cTrackMinPt{"cTrackMinPt", 0.15, "p_{T} minimum"};
Configurable<float> cTrackMaxPt{"cTrackMaxPt", 999.0, "p_{T} maximum"};
Configurable<float> cTrackEtaCut{"cTrackEtaCut", 0.8, "Pseudorapidity cut"};
Expand Down Expand Up @@ -153,6 +171,10 @@ struct LambdaSpinPolarizationLooseProducer {
std::vector<LooseCandidate> candidates;

float cent = 0., mult = 0.;
float nch = 0.f;
float nchEff = -1.f;
Service<o2::ccdb::BasicCCDBManager> ccdb;
TH3D* hNchEffMap = nullptr;

void init(InitContext const&)
{
Expand All @@ -175,6 +197,7 @@ struct LambdaSpinPolarizationLooseProducer {
hCutFlow->GetXaxis()->SetBinLabel(kLeGoodItsLayers, "good ITS layers");
hCutFlow->GetXaxis()->SetBinLabel(kLeCentrality, "centrality range");
hCutFlow->GetXaxis()->SetBinLabel(kLeVz, "V_{z} range");
hCutFlow->GetXaxis()->SetBinLabel(kLeNch, "Nch range");
hCutFlow->GetXaxis()->SetBinLabel(kLeOneV0, "#geq 1 V0 with a loose candidate");
hCutFlow->GetXaxis()->SetBinLabel(kLeTwoV0, "#geq 2 V0s with a loose candidate");
hCutFlow->GetXaxis()->SetBinLabel(kLeWritten, "written");
Expand All @@ -194,6 +217,45 @@ struct LambdaSpinPolarizationLooseProducer {
histos.add("Tracks/hLambdaMassVsPt", "#Lambda candidates", kTH2F, {axisV0Mass, axisV0Pt});
histos.add("Tracks/hAntiLambdaMassVsPt", "#bar{#Lambda} candidates", kTH2F, {axisV0Mass, axisV0Pt});
histos.add("Events/hNV0Written", "written collisions", kTH1F, {axisNV0});

const AxisSpec axisNchQA(axisNch, "N_{ch} (without candidate daughters)");
const AxisSpec axisMultPVQA(axisNch, "multNTracksPV");
const AxisSpec axisCentQA(100, 0., 100., "centrality (%)");
const AxisSpec axisVzQA(200, -20., 20., "V_{z} (cm)");
histos.add("Events/hNchSelected", "selected collisions, before the V0 requirement;;collisions", kTH1D, {axisNchQA});
histos.add("Events/hNchVsMultPVSelected", "selected collisions, before the V0 requirement", kTH2F, {axisMultPVQA, axisNchQA});
histos.add("Events/hMultPVSelectedVsCentSelected", "selected collisions, before the V0 requirement", kTH2F, {axisCentQA, axisMultPVQA});
histos.add("Events/hNchVsCentSelected", "selected collisions, before the V0 requirement", kTH2F, {axisCentQA, axisNchQA});
histos.add("Events/hNchVsVzSelected", "selected collisions, before the V0 requirement", kTH2F, {axisVzQA, axisNchQA});
histos.add("Events/hNchWritten", "written collisions;;collisions", kTH1D, {axisNchQA});

ccdb->setURL(cCcdbUrl.value);
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();

const AxisSpec axisNchEffQA(axisNchEff, "N_{ch}^{eff} = #sum 1/#varepsilon");
const AxisSpec axisNDauQA(20, -0.5, 19.5, "N_{ch} tracks removed (candidate daughters)");

histos.add("Events/hNchEffSelected", "selected collisions with a valid NchEff, before the V0 requirement;;collisions", kTH1D, {axisNchEffQA});
histos.add("Events/hNchEffVsNchSelected", "selected collisions with a valid NchEff, before the V0 requirement", kTH2F, {axisNchQA, axisNchEffQA});
histos.add("Events/hNchEffBadLookup", "selected collisions;N_{ch} tracks without a valid efficiency;collisions", kTH1D, {{20, -0.5, 19.5}});
histos.add("Events/hNchEffWritten", "written collisions with a valid NchEff;;collisions", kTH1D, {axisNchEffQA});

histos.add("Events/hDndetaVsCentSelected", "selected collisions, before the V0 requirement;centrality (%);#LT dN_{ch}/d#eta #GT", kTProfile, {axisCentQA});
histos.add("Events/hDndetaEffVsCentSelected", "selected collisions with a valid NchEff, before the V0 requirement;centrality (%);#LT dN_{ch}^{eff}/d#eta #GT", kTProfile, {axisCentQA});

const double detaNch = 2. * cNchEtaCut.value;
const AxisSpec axisDndetaQA(500, -0.5 / detaNch, 499.5 / detaNch, "dN_{ch}/d#eta");
const AxisSpec axisDndetaEffQA(1400, 0., 700. / detaNch, "dN_{ch}^{eff}/d#eta");
histos.add("Events/hDndetaSelected", "selected collisions, before the V0 requirement;;collisions", kTH1D, {axisDndetaQA});
histos.add("Events/hDndetaEffSelected", "selected collisions with a valid NchEff, before the V0 requirement;;collisions", kTH1D, {axisDndetaEffQA});

histos.add("Tracks/hNchDcaXYVsPt", "N_{ch} tracks before the DCA_{z} / TPC-cluster cuts;p_{T} (GeV/#it{c});DCA_{xy} (cm)", kTH2F, {{100, 0., 10.}, {600, -0.3, 0.3}});
histos.add("Tracks/hNchDcaZVsPt", "N_{ch} tracks before the DCA_{z} / TPC-cluster cuts;p_{T} (GeV/#it{c});DCA_{z} (cm)", kTH2F, {{100, 0., 10.}, {400, -2., 2.}});
histos.add("Tracks/hNchTpcFoundVsCrossedRows", "N_{ch} tracks before the DCA_{z} / TPC-cluster cuts;TPC crossed rows;TPC found clusters", kTH2F, {{160, -0.5, 159.5}, {160, -0.5, 159.5}});

histos.add("Events/hNchDauVsNchWritten", "written collisions", kTH2F, {axisNchQA, axisNDauQA});
histos.add("Events/hNchDauVsNDauWritten", "written collisions;distinct daughter tracks of the loose candidates", kTH2F, {{40, -0.5, 39.5}, axisNDauQA});
}

template <typename C>
Expand Down Expand Up @@ -252,6 +314,96 @@ struct LambdaSpinPolarizationLooseProducer {
return true;
}

void loadNchEffMap(aod::BCsWithTimestamps::iterator const& bc)
{
if (cNchEffPath.value.empty()) {
return;
}
auto* map = ccdb->getForTimeStamp<TH3D>(cNchEffPath.value, bc.timestamp());
if (map == nullptr) {
LOG(fatal) << "NchEff map " << cNchEffPath.value << " not found for timestamp " << bc.timestamp();
}
if (map != hNchEffMap) {
hNchEffMap = map;
checkNchEffMapRange();
LOG(info) << "NchEff map loaded from " << cNchEffPath.value << " for timestamp " << bc.timestamp();
}
}

void checkNchEffMapRange()
{
constexpr double Tol = 1e-5;
auto outside = [](const TAxis* ax, double lo, double hi) { return lo < ax->GetXmin() - Tol || hi > ax->GetXmax() + Tol; };
if (outside(hNchEffMap->GetXaxis(), cMinZVtx.value, cMaxZVtx.value) ||
outside(hNchEffMap->GetYaxis(), -cNchEtaCut.value, cNchEtaCut.value) ||
outside(hNchEffMap->GetZaxis(), cNchMinPt.value, cNchMaxPt.value)) {
LOG(fatal) << "NchEff map " << cNchEffPath.value << " does not cover the N_ch acceptance (Vz, eta, pT)";
}
}

double nchEffWeight(float posZ, float eta, float pt)
{
const int bx = hNchEffMap->GetXaxis()->FindBin(posZ);
const int by = hNchEffMap->GetYaxis()->FindBin(eta);
const int bz = hNchEffMap->GetZaxis()->FindBin(pt);
if (bx < 1 || bx > hNchEffMap->GetNbinsX() || by < 1 || by > hNchEffMap->GetNbinsY() || bz < 1 || bz > hNchEffMap->GetNbinsZ()) {
return -1.;
}
const double eff = hNchEffMap->GetBinContent(bx, by, bz);
if (!std::isfinite(eff) || eff <= 0. || eff > 1.) {
return -1.;
}
return 1. / eff;
}

struct NchCount {
int nch = 0;
double eff = 0.;
int badLookup = 0;
int nDau = 0;
};

template <typename T>
NchCount countNch(T const& tracks, float posZ, std::set<int64_t> const& dauIds)
{
NchCount n;
for (auto const& track : tracks) {
if (!track.isGlobalTrack()) {
continue;
}
if (track.pt() < cNchMinPt || track.pt() >= cNchMaxPt) {
continue;
}
if (std::abs(track.eta()) >= cNchEtaCut) {
continue;
}
histos.fill(HIST("Tracks/hNchDcaXYVsPt"), track.pt(), track.dcaXY());
histos.fill(HIST("Tracks/hNchDcaZVsPt"), track.pt(), track.dcaZ());
histos.fill(HIST("Tracks/hNchTpcFoundVsCrossedRows"), track.tpcNClsCrossedRows(), track.tpcNClsFound());
if (std::abs(track.dcaZ()) > cNchMaxDcaZ) {
continue;
}
if (track.tpcNClsFound() < cNchMinTpcNClsFound) {
continue;
}

if (dauIds.contains(track.globalIndex())) {
++n.nDau;
continue;
}
++n.nch;
if (hNchEffMap != nullptr) {
const double w = nchEffWeight(posZ, track.eta(), track.pt());
if (w > 0.) {
n.eff += w;
} else {
++n.badLookup;
}
}
}
return n;
}

bool kinCutSelection(float const& pt, float const& rap, float const& ptMin, float const& ptMax, float const& rapMax)
{
return pt > ptMin && pt < ptMax && rap < rapMax;
Expand Down Expand Up @@ -365,6 +517,8 @@ struct LambdaSpinPolarizationLooseProducer {
if (!selCollision(collision)) {
return;
}
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
loadNchEffMap(bc);

candidates.clear();
std::size_t nV0 = 0;
Expand Down Expand Up @@ -453,6 +607,35 @@ struct LambdaSpinPolarizationLooseProducer {
++nV0;
}

std::set<int64_t> dauIds;
for (auto const& c : candidates) {
dauIds.insert(c.posTrackId);
dauIds.insert(c.negTrackId);
}
const NchCount nchCount = countNch(tracks, collision.posZ(), dauIds);
nch = static_cast<float>(nchCount.nch);
nchEff = (hNchEffMap != nullptr && nchCount.badLookup == 0) ? static_cast<float>(nchCount.eff) : -1.f; // never a partial sum
if (nch < cMinNch || nch >= cMaxNch) {
return;
}
histos.fill(HIST("Events/hEventCutFlow"), kLeNch);
histos.fill(HIST("Events/hNchSelected"), nch);
histos.fill(HIST("Events/hNchVsMultPVSelected"), mult, nch);
histos.fill(HIST("Events/hNchVsCentSelected"), cent, nch);
histos.fill(HIST("Events/hDndetaVsCentSelected"), cent, nch / (2.f * cNchEtaCut.value));
histos.fill(HIST("Events/hDndetaSelected"), nch / (2.f * cNchEtaCut.value));
histos.fill(HIST("Events/hMultPVSelectedVsCentSelected"), cent, mult);
histos.fill(HIST("Events/hNchVsVzSelected"), collision.posZ(), nch);
if (hNchEffMap != nullptr) {
histos.fill(HIST("Events/hNchEffBadLookup"), nchCount.badLookup);
}
if (nchEff >= 0.f) {
histos.fill(HIST("Events/hNchEffSelected"), nchEff);
histos.fill(HIST("Events/hNchEffVsNchSelected"), nch, nchEff);
histos.fill(HIST("Events/hDndetaEffVsCentSelected"), cent, nchEff / (2.f * cNchEtaCut.value));
histos.fill(HIST("Events/hDndetaEffSelected"), nchEff / (2.f * cNchEtaCut.value));
}

if (nV0 >= 1) {
histos.fill(HIST("Events/hEventCutFlow"), kLeOneV0);
}
Expand All @@ -464,9 +647,14 @@ struct LambdaSpinPolarizationLooseProducer {
}
histos.fill(HIST("Events/hEventCutFlow"), kLeWritten);
histos.fill(HIST("Events/hNV0Written"), nV0);
histos.fill(HIST("Events/hNchWritten"), nch);
if (nchEff >= 0.f) {
histos.fill(HIST("Events/hNchEffWritten"), nchEff);
}
histos.fill(HIST("Events/hNchDauVsNchWritten"), nch, nchCount.nDau);
histos.fill(HIST("Events/hNchDauVsNDauWritten"), dauIds.size(), nchCount.nDau);

auto bc = collision.bc_as<aod::BCsWithTimestamps>();
lambdaLooseCollisionTable(cent, mult, collision.posX(), collision.posY(), collision.posZ(), bc.timestamp());
lambdaLooseCollisionTable(cent, mult, nch, nchEff, collision.posX(), collision.posY(), collision.posZ(), bc.timestamp());
for (auto const& c : candidates) {
lambdaLooseTrackTable(lambdaLooseCollisionTable.lastIndex(), c.px, c.py, c.pz, c.pt, c.eta, c.phi, c.rap, c.mass, c.massOther, c.prPx, c.prPy, c.prPz,
c.posTrackId, c.negTrackId, c.v0Type, c.cosPA, c.dcaDau, c.dcaV0ToPV, c.cTau, c.mK0Short,
Expand Down
Loading