Skip to content
Merged
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
124 changes: 65 additions & 59 deletions PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.cxx
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,34 +15,33 @@
// \brief This code loops over MFT tracks and collisions and fills histograms
// useful to compute dNdeta

#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <unordered_set>
#include <vector>
#include "PWGMM/Mult/DataModel/bestCollisionTable.h"

#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "CommonConstants/MathConstants.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/Configurable.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Framework/RuntimeError.h"
#include "Framework/runDataProcessing.h"

#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "CommonConstants/MathConstants.h"
#include "MathUtils/Utils.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "TDatabasePDG.h"

#include "PWGMM/Mult/DataModel/bestCollisionTable.h"
#include "TFile.h"

#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <unordered_set>
#include <vector>

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
Expand All@@ -51,7 +50,7 @@
AxisSpec PtAxis = {1001, -0.005, 10.005};
AxisSpec DeltaZAxis = {61, -6.1, 6.1};
AxisSpec ZAxis = {301, -30.1, 30.1};
AxisSpec PhiAxis = {629, 0, 2 * M_PI, "Rad", "phi axis"};
AxisSpec PhiAxis = {629, 0, o2::constants::math::TwoPI, "Rad", "phi axis"};
// AxisSpec EtaAxis = {18, -4.6, -1.};
AxisSpec DCAxyAxis = {100, -1, 10};
AxisSpec CentAxis = {{0, 10, 20, 30, 40, 50, 60, 70, 80, 100}};
Expand DownExpand Up@@ -82,6 +81,7 @@
"eta range for INEL>0 sample definition"};

Configurable<bool> useEvSel{"useEvSel", true, "use event selection"};
Configurable<bool> disableITSROFCut{"disableITSROFCut", false, "Disable ITS ROC cut for event selection"};
ConfigurableAxis multBinning{"multBinning", {701, -0.5, 700.5}, ""};
ConfigurableAxis EtaAxis = {"etaBinning", {18, -4.6, -1.}, ""};

Expand DownExpand Up@@ -145,15 +145,15 @@
auto hstat = registry.get<TH1>(HIST("EventSelection"));
auto* x = hstat->GetXaxis();
x->SetBinLabel(1, "All");
x->SetBinLabel(2, "Selected");
x->SetBinLabel(3, "Selected Vz Cut");
x->SetBinLabel(4, "Sel8+Vz+INEL>0");
x->SetBinLabel(5, "Sel INEL,INEL_fwd>0");
x->SetBinLabel(6, "Rejected");
x->SetBinLabel(7, "Good BCs");
x->SetBinLabel(8, "BCs with collisions");
x->SetBinLabel(9, "BCs with pile-up/splitting");
x->SetBinLabel(10, "midtracks>0");
x->SetBinLabel(2, "Vz");
x->SetBinLabel(3, "Vz+ITSRof");
x->SetBinLabel(4, "Vz+Selected");
x->SetBinLabel(5, "Sel8+Vz+INEL>0");
x->SetBinLabel(6, "Sel INEL,INEL_fwd>0");
x->SetBinLabel(7, "Rejected");
x->SetBinLabel(8, "Good BCs");
x->SetBinLabel(9, "BCs with collisions");
x->SetBinLabel(10, "BCs with pile-up/splitting");
x->SetBinLabel(11, "percollisionSample>0");
x->SetBinLabel(12, "midtracks+percollisionSample>0");
registry.add({"EventsNtrkZvtx",
Expand DownExpand Up@@ -446,13 +446,13 @@
{

std::vector<typename std::decay_t<decltype(collisions)>::iterator> cols;
for (auto& bc : bcs) {
for (const auto& bc : bcs) {
if (!useEvSel ||
(useEvSel && ((bc.selection_bit(aod::evsel::kIsBBT0A) &&
bc.selection_bit(aod::evsel::kIsBBT0C)) != 0))) {
registry.fill(HIST("EventSelection"), 7); // added 5->12
registry.fill(HIST("EventSelection"), 8); // added 5->12
cols.clear();
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
if (collision.has_foundBC()) {
if (collision.foundBCId() == bc.globalIndex()) {
cols.emplace_back(collision);
Expand All@@ -463,9 +463,9 @@
}
LOGP(debug, "BC {} has {} collisions", bc.globalBC(), cols.size());
if (!cols.empty()) {
registry.fill(HIST("EventSelection"), 8); // added 6->13
registry.fill(HIST("EventSelection"), 9); // added 6->13
if (cols.size() > 1) {
registry.fill(HIST("EventSelection"), 9); // added 7->14
registry.fill(HIST("EventSelection"), 10); // added 7->14
}
}
}
Expand All@@ -476,13 +476,13 @@
"Collect event sample stats", true);

Partition<aod::MFTTracks> sample =
(aod::fwdtrack::eta < -2.8f) && (aod::fwdtrack::eta > -3.2f);

Check failure on line 479 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.

Partition<aod::Tracks> sampleCentral = (nabs(aod::track::eta) < 1.f);

expressions::Filter atrackFilter =
(aod::fwdtrack::bestCollisionId >= 0) && (aod::fwdtrack::eta < -2.0f) &&

Check failure on line 484 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
(aod::fwdtrack::eta > -3.9f) && (nabs(aod::fwdtrack::bestDCAXY) <= 2.f);

Check failure on line 485 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.

using CollwEv = soa::Join<aod::Collisions, aod::EvSels>;

Expand DownExpand Up@@ -522,17 +522,17 @@
}

if (tracks.size() > 0) {
for (auto& track : tracks) {
for (const auto& track : tracks) {

float phi = track.phi();
o2::math_utils::bringTo02Pi(phi);

if (usePhiCut) {
if ((phi < cfgPhiCut) ||
((phi > M_PI - cfgPhiCut) && (phi < M_PI + cfgPhiCut)) ||
(phi > 2. * M_PI - cfgPhiCut) ||
((phi > ((M_PI / 2. - 0.1) * M_PI) - cfgPhiCut) &&
(phi < ((M_PI / 2. - 0.1) * M_PI) + cfgPhiCut)))
((phi > o2::constants::math::PI - cfgPhiCut) && (phi < o2::constants::math::PI + cfgPhiCut)) ||
(phi > o2::constants::math::TwoPI - cfgPhiCut) ||
((phi > ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) - cfgPhiCut) &&
(phi < ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) + cfgPhiCut)))
continue;
}

Expand All@@ -543,7 +543,7 @@
}
registry.fill(HIST("TracksPhiEta"), phi, track.eta());
registry.fill(HIST("TracksPtEta"), track.pt(), track.eta());
if ((track.eta() < -2.0f) && (track.eta() > -3.9f)) {

Check failure on line 546 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
registry.fill(HIST("TracksPhiZvtx"), phi, z);
}
}
Expand All@@ -569,25 +569,28 @@
registry.fill(HIST("EventsNtrkZvtx"), Ntrk, z);
if ((z >= cfgVzCut1) && (z <= cfgVzCut2)) {
registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_all"), Ntrk, z);
for (auto& retrack : retracks) {
registry.fill(HIST("EventSelection"), 2.);
for (const auto& retrack : retracks) {
auto track = retrack.mfttrack();
if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster && retrack.ambDegree() > 0) {
registry.fill(HIST("Tracks/2Danalysis/EtaZvtx"), track.eta(), z);
}
}
if (!useEvSel || (useEvSel && collision.sel8())) {
registry.fill(HIST("EventSelection"), 2.);
if (!disableITSROFCut && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
return;
}
registry.fill(HIST("EventSelection"), 3.);
if (!useEvSel || (useEvSel && collision.selection_bit(aod::evsel::kIsTriggerTVX) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) {
registry.fill(HIST("EventSelection"), 4.);
registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8"), Ntrk, z);
registry.fill(HIST("EventSelection"), 3.);
std::unordered_set<int> uniqueEvents;
std::unordered_set<int> uniqueEventsAmb;
std::unordered_set<int> uniqueCollisions;
std::unordered_set<int> uniqueCollisionsAmb;
std::unordered_set<int> eventsInelMFT;
std::unordered_set<int> eventsInel;
if (midtracks.size() > 0) {
registry.fill(HIST("EventSelection"), 4.);
registry.fill(HIST("EventSelection"), 10.);
registry.fill(HIST("EventSelection"), 5.);
registry.fill(HIST("EventsNtrkZvtx_gt0"), Ntrk, z);
registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelgt0"), Ntrk, z);
eventsInel.insert(collision.globalIndex());
Expand All@@ -599,7 +602,7 @@
registry.fill(HIST("EventSelection"), 12.);
}
int64_t i = 0.0, j = 0.0, k = 0.0;
for (auto& retrack : retracks) {
for (const auto& retrack : retracks) {
auto track = retrack.mfttrack();
if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster && retrack.ambDegree() > 0) {
registry.fill(HIST("Tracks/2Danalysis/EtaZvtx_sel8"), track.eta(), z);
Expand All@@ -609,11 +612,11 @@
}
}
if (retracks.size() > 0) {
registry.fill(HIST("EventSelection"), 5.);
registry.fill(HIST("EventSelection"), 6.);
if (midtracks.size() > 0) {
registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelfwdgt0"), Ntrk, z);
}
for (auto& retrack : retracks) {
for (const auto& retrack : retracks) {
auto track = retrack.mfttrack();

if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster) {
Expand All@@ -632,7 +635,7 @@
registry.fill(HIST("Tracks/Control/TrackCount"), 0);
registry.fill(HIST("TracksPhiEta"), phi, track.eta());
registry.fill(HIST("TracksPtEta"), track.pt(), track.eta());
if ((track.eta() < -2.0f) && (track.eta() > -3.9f)) {

Check failure on line 638 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
registry.fill(HIST("TracksPhiZvtx"), phi, z);
}
if (track.collisionId() > -1 && retrack.ambDegree() == 1) {
Expand DownExpand Up@@ -736,7 +739,7 @@
registry.fill(HIST("hNumCollisions_Inel"), 1, eventsInel.size());
}
} else {
registry.fill(HIST("EventSelection"), 6);
registry.fill(HIST("EventSelection"), 7);
}
}
PROCESS_SWITCH(PseudorapidityDensityMFT, processMultReassoc,
Expand All@@ -759,17 +762,17 @@

registry.fill(HIST("Events/Centrality/NtrkZvtx"), Ntrk, z, c);

for (auto& track : tracks) {
for (const auto& track : tracks) {

float phi = track.phi();
o2::math_utils::bringTo02Pi(phi);

if (usePhiCut) {
if ((phi < cfgPhiCut) ||
((phi > M_PI - cfgPhiCut) && (phi < M_PI + cfgPhiCut)) ||
(phi > 2. * M_PI - cfgPhiCut) ||
((phi > ((M_PI / 2. - 0.1) * M_PI) - cfgPhiCut) &&
(phi < ((M_PI / 2. - 0.1) * M_PI) + cfgPhiCut)))
((phi > o2::constants::math::PI - cfgPhiCut) && (phi < o2::constants::math::PI + cfgPhiCut)) ||
(phi > o2::constants::math::TwoPI - cfgPhiCut) ||
((phi > ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) - cfgPhiCut) &&
(phi < ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) + cfgPhiCut)))
continue;
}

Expand All@@ -791,7 +794,7 @@
(aod::mcparticle::flags &
(uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) ==
(uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary;
Partition<Particles> mcSample = nabs(aod::mcparticle::eta) < 1.1f;

Check failure on line 797 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
Partition<Particles> mcSampleCentral =
nabs(aod::mcparticle::eta) < estimatorEta;

Expand All@@ -807,13 +810,13 @@
auto perCollisionMCSample = mcSample->sliceByCached(
aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache);
auto nCharged = 0;
for (auto& particle : perCollisionMCSample) {
for (const auto& particle : perCollisionMCSample) {
auto charge = 0.;
auto p = pdg->GetParticle(particle.pdgCode());
if (p != nullptr) {
charge = p->Charge();
}
if (std::abs(charge) < 3.) {

Check failure on line 819 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
continue;
}
nCharged++;
Expand All@@ -824,13 +827,13 @@
auto perCollisionMCSampleCentral = mcSampleCentral->sliceByCached(
aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache);
auto nChargedCentral = 0;
for (auto& particle : perCollisionMCSampleCentral) {
for (const auto& particle : perCollisionMCSample) {
auto charge = 0.;
auto p = pdg->GetParticle(particle.pdgCode());
if (p != nullptr) {
charge = p->Charge();
}
if (std::abs(charge) < 3.) {

Check failure on line 836 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
continue;
}
nChargedCentral++;
Expand All@@ -849,9 +852,12 @@

LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(),
collisions.size());
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
registry.fill(HIST("EventEfficiency"), 3.);
if (!useEvSel || (useEvSel && collision.sel8())) {
if (!disableITSROFCut && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
return;
}
if (!useEvSel || (useEvSel && collision.selection_bit(aod::evsel::kIsTriggerTVX) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) {
atLeastOne = true;
auto perCollisionSample = sample->sliceByCached(
o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache);
Expand DownExpand Up@@ -888,13 +894,13 @@
registry.fill(HIST("EventsSplitMult"), nCharged);
}
if ((mcCollision.posZ() >= cfgVzCut1) && (mcCollision.posZ() <= cfgVzCut2)) {
for (auto& particle : particles) {
for (const auto& particle : particles) {
auto p = pdg->GetParticle(particle.pdgCode());
auto charge = 0;
if (p != nullptr) {
charge = static_cast<int>(p->Charge());
}
if (std::abs(charge) < 3.) {

Check failure on line 903 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
continue;
}
if (cfgnEta1 < particle.eta() && particle.eta() < cfgnEta2) {
Expand DownExpand Up@@ -943,7 +949,7 @@

float c_gen = -1;
bool atLeastOne = false;
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
float c_rec = -1;
if constexpr (ExColsGenCent::template contains<aod::CentFT0Cs>()) {
c_rec = collision.centFT0C();
Expand DownExpand Up@@ -972,13 +978,13 @@
aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache);
auto nCharged = 0;

for (auto& particle : perCollisionMCSample) {
for (const auto& particle : perCollisionMCSample) {
auto p = pdg->GetParticle(particle.pdgCode());
auto charge = 0;
if (p != nullptr) {
charge = static_cast<int>(p->Charge());
}
if (std::abs(charge) < 3.) {

Check failure on line 987 in PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.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.
continue;
}
nCharged++;
Expand All@@ -989,7 +995,7 @@
mcCollision.posZ(), c_gen);
}

for (auto& particle : particles) {
for (const auto& particle : particles) {
auto p = pdg->GetParticle(particle.pdgCode());
auto charge = 0;
if (p != nullptr) {
Expand DownExpand Up@@ -1025,7 +1031,7 @@
MFTTracksLabeled const& tracks, aod::McParticles const&)
{
if (!useEvSel || (useEvSel && collision.sel8())) {
for (auto& track : tracks) {
for (const auto& track : tracks) {
if (!track.has_mcParticle()) {
continue;
}
Expand Down
Loading