Skip to content
Closed
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
45 changes: 23 additions & 22 deletions PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
#include "Framework/runDataProcessing.h"
#include "ReconstructionDataFormats/Track.h"

#include "Math/Vector4D.h"
#include "TRandom3.h"
#include <Math/Vector4D.h>
#include <TMCProcess.h>
#include <TPDGCode.h> // for PDG codes
#include <TRandom3.h>

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -331,7 +332,7 @@
// CCDB options
Configurable<int> cfgMaterialCorrection{"cfgMaterialCorrection", static_cast<int>(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"};
Configurable<std::string> cfgCCDBurl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<std::string> cfgZorroCCDBpath{"cfgZorroCCDBpath", "/Users/m/mpuccio/EventFiltering/OTS/", "path to the zorro ccdb objects"};
Configurable<std::string> cfgZorroCCDBpath{"cfgZorroCCDBpath", "EventFiltering/Zorro/", "path to the zorro ccdb objects"};
int mRunNumber = 0;
float mBz = 0.f;

Expand All @@ -356,7 +357,7 @@
float dauVtx[3]{0.f, 0.f, 0.f};
auto daughters = particle.daughters_as<aod::McParticles>();
for (const auto& dau : daughters) {
if (abs(dau.pdgCode()) != 22 && abs(dau.pdgCode()) != 11) {
if (std::abs(dau.pdgCode()) != PDG_t::kGamma && std::abs(dau.pdgCode()) != PDG_t::kElectron) {
dauVtx[0] = dau.vx();
dauVtx[1] = dau.vy();
dauVtx[2] = dau.vz();
Expand Down Expand Up @@ -510,14 +511,14 @@
spectra.add("hTpcSignalDataSelected", "Specific energy loss for selected particles", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}});
spectra.add("hTofSignalData", "TOF beta", HistType::kTH2F, {{500, 0., 5., "#it{p} (GeV/#it{c})"}, {750, 0, 1.5, "TOF #beta"}});

for (int iC{0}; iC < 2; ++iC) {
for (unsigned int iC{0}; iC < nuclei::matter.size(); ++iC) {
nuclei::hGloTOFtracks[iC] = spectra.add<TH2>(fmt::format("hTPCTOFtracks{}", nuclei::matter[iC]).data(), fmt::format("Global vs TOF matched {} tracks in a collision", nuclei::chargeLabelNames[iC]).data(), HistType::kTH2D, {{300, -0.5, 300.5, "Number of global tracks"}, {300, -0.5, 300.5, "Number of TOF matched tracks"}});

for (int iS{0}; iS < nuclei::species; ++iS) {
nuclei::hNsigma[0][iS][iC] = spectra.add<TH3>(fmt::format("h{}nsigma{}_{}", nuclei::pidName[0], nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("n#sigma_{{}} {} {}", nuclei::pidName[0], nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTH3D, {centAxis, ptAxes[iS], nSigmaAxes[0]});
nuclei::hNsigmaEta[0][iS][iC] = spectra.add<TH3>(fmt::format("h{}nsigmaEta{}_{}", nuclei::pidName[0], nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("n#sigma_{{}} {} {} vs #eta", nuclei::pidName[0], nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTH3D, {etaAxis, ptAxes[iS], nSigmaAxes[0]});

for (int iPID{0}; iPID < 2; ++iPID) {
for (unsigned int iPID{0}; iPID < nuclei::matter.size(); ++iPID) {
nuclei::hDCAxy[iPID][iS][iC] = spectra.add<TH3>(fmt::format("hDCAxy{}_{}_{}", nuclei::pidName[iPID], nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("DCAxy {} {} {}", nuclei::pidName[iPID], nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTH3D, {centAxis, ptAxes[iS], dcaxyAxes[iS]});
nuclei::hDCAz[iPID][iS][iC] = spectra.add<TH3>(fmt::format("hDCAz{}_{}_{}", nuclei::pidName[iPID], nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("DCAz {} {} {}", nuclei::pidName[iPID], nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTH3D, {centAxis, ptAxes[iS], dcazAxes[iS]});
}
Expand All @@ -540,15 +541,15 @@
}

for (int iS{0}; iS < nuclei::species; ++iS) {
for (int iMax{0}; iMax < 2; ++iMax) {
for (unsigned int iMax{0}; iMax < nuclei::pidName.size(); ++iMax) {
nuclei::pidCuts[0][iS][iMax] = cfgNsigmaTPC->get(iS, iMax);
}
}

if (doprocessMatching) {
std::vector<double> occBins{-0.5, 499.5, 999.5, 1999.5, 2999.5, 3999.5, 4999.5, 10000., 50000.};
AxisSpec occAxis{occBins, "Occupancy"};
for (int iC{0}; iC < 2; ++iC) {
for (unsigned int iC{0}; iC < nuclei::matter.size(); ++iC) {
nuclei::hMatchingStudy[iC] = spectra.add<THnSparse>(fmt::format("hMatchingStudy{}", nuclei::matter[iC]).data(), ";#it{p}_{T};#phi;#eta;n#sigma_{ITS};n#sigma{TPC};n#sigma_{TOF};Centrality", HistType::kTHnSparseF, {{20, 1., 9.}, {10, 0., o2::constants::math::TwoPI}, {10, -1., 1.}, {50, -5., 5.}, {50, -5., 5.}, {50, 0., 1.}, {8, 0., 80.}});
nuclei::hMatchingStudyHadrons[iC] = spectra.add<THn>(fmt::format("hMatchingStudyHadrons{}", nuclei::matter[iC]).data(), ";#it{p}_{T};#phi;#eta;Centrality;Track type; Occupancy", HistType::kTHnF, {{23, 0.4, 5.}, {20, 0., o2::constants::math::TwoPI}, {10, -1., 1.}, {8, 0., 80.}, {2, -0.5, 1.5}, occAxis});
}
Expand Down Expand Up @@ -605,15 +606,15 @@
{nuclei::charges[4] * cfgMomentumScalingBetheBloch->get(3u, 0u) / nuclei::masses[4], nuclei::charges[4] * cfgMomentumScalingBetheBloch->get(3u, 1u) / nuclei::masses[4]}};

int nGloTracks[2]{0, 0}, nTOFTracks[2]{0, 0};
for (auto& track : tracks) { // start loop over tracks
for (const auto& track : tracks) { // start loop over tracks
if (std::abs(track.eta()) > cfgCutEta ||
track.tpcInnerParam() < cfgCutTpcMom ||
track.itsNCls() < cfgCutNclusITS ||
track.tpcNClsFound() < cfgCutNclusTPC ||
track.tpcNClsCrossedRows() < 70 ||

Check failure on line 614 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() ||

Check failure on line 615 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
track.tpcChi2NCl() > 4.f ||

Check failure on line 616 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
track.itsChi2NCl() > 36.f) {

Check failure on line 617 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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;
}
// temporary fix: tpcInnerParam() returns the momentum in all the software tags before
Expand Down Expand Up @@ -641,7 +642,7 @@
nSigmaTPC[iS] = nSigma[0][iS];
selectedTPC[iS] = (nSigma[0][iS] > nuclei::pidCuts[0][iS][0] && nSigma[0][iS] < nuclei::pidCuts[0][iS][1]);
goodToAnalyse = goodToAnalyse || selectedTPC[iS];
if (selectedTPC[iS] && track.p() > 0.2) {

Check failure on line 645 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
nuclei::hDeltaP[iC][iS]->Fill(track.p(), 1 - correctedTpcInnerParam / track.p());
}
}
Expand Down Expand Up @@ -683,13 +684,13 @@
}
ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float>> fvector{mTrackParCov.getPt() * nuclei::charges[iS], mTrackParCov.getEta(), mTrackParCov.getPhi(), nuclei::masses[iS]};
float y{fvector.Rapidity() + cfgCMrapidity};
for (int iPID{0}; iPID < 2; ++iPID) { /// 0 TPC, 1 TOF
for (unsigned int iPID{0}; iPID < nuclei::pidName.size(); ++iPID) { /// 0 TPC, 1 TOF
if (selectedTPC[iS]) {
if (iPID && !track.hasTOF()) {
continue;
} else if (iPID) {
selectedTOF = true; /// temporarly skipped
float charge{1.f + static_cast<float>(iS == 3 || iS == 4)};

Check failure on line 693 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
tofMasses[iS] = correctedTpcInnerParam * charge * std::sqrt(1.f / (beta * beta) - 1.f) - nuclei::masses[iS];
}
if (!cfgCutOnReconstructedRapidity || (y > cfgCutRapidityMin && y < cfgCutRapidityMax)) {
Expand Down Expand Up @@ -845,7 +846,7 @@
return;
}
fillDataInfo(collision, tracks);
for (auto& c : nuclei::candidates) {

Check failure on line 849 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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 (c.fillTree) {
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS);
}
Expand All @@ -857,7 +858,7 @@
}
}
}
for (auto& c : nuclei::candidates_flow) {
for (const auto& c : nuclei::candidates_flow) {
nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr);
}
}
Expand All @@ -874,7 +875,7 @@
return;
}
fillDataInfo(collision, tracks);
for (auto& c : nuclei::candidates) {
for (const auto& c : nuclei::candidates) {
if (c.fillTree) {
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS);
}
Expand All @@ -886,7 +887,7 @@
}
}
}
for (auto& c : nuclei::candidates_flow) {
for (const auto& c : nuclei::candidates_flow) {
nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr);
}
}
Expand All @@ -896,11 +897,11 @@
void processMC(soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels> const& collisions, aod::McCollisions const& mcCollisions, soa::Join<TrackCandidates, aod::McTrackLabels> const& tracks, aod::McParticles const& particlesMC, aod::BCsWithTimestamps const&)
{
nuclei::candidates.clear();
for (auto& c : mcCollisions) {
for (const auto& c : mcCollisions) {
spectra.fill(HIST("hGenVtxZ"), c.posZ());
}
std::vector<bool> goodCollisions(mcCollisions.size(), false);
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
if (!eventSelection(collision)) {
continue;
}
Expand All @@ -909,7 +910,7 @@
fillDataInfo(collision, slicedTracks);
}
std::vector<bool> isReconstructed(particlesMC.size(), false);
for (auto& c : nuclei::candidates) {

Check failure on line 913 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
auto label = tracks.iteratorAt(c.globalIndex);
if (label.mcParticleId() < -1 || label.mcParticleId() >= particlesMC.size()) {
continue;
Expand Down Expand Up @@ -948,7 +949,7 @@
if (particle.isPhysicalPrimary()) {
c.flags |= kIsPhysicalPrimary;
if (particle.has_mothers()) {
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) {
c.flags |= kIsSecondaryFromWeakDecay;
motherPdgCode = motherparticle.pdgCode();
Expand All @@ -959,7 +960,7 @@
}
} else if (particle.has_mothers()) {
c.flags |= kIsSecondaryFromWeakDecay;
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
motherPdgCode = motherparticle.pdgCode();
motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy());
}
Expand All @@ -973,7 +974,7 @@
}

int index{0};
for (auto& particle : particlesMC) {
for (const auto& particle : particlesMC) {
int pdg{std::abs(particle.pdgCode())};
for (int iS{0}; iS < nuclei::species; ++iS) {
if (pdg != nuclei::codes[iS]) {
Expand All @@ -991,7 +992,7 @@
nuclei::hGenNuclei[iS][particle.pdgCode() < 0]->Fill(1., particle.pt());
// antinuclei from B hadrons are classified as physical primaries
if (particle.has_mothers()) {
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {

Check failure on line 995 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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 (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) {
flags |= kIsSecondaryFromWeakDecay;
motherPdgCode = motherparticle.pdgCode();
Expand All @@ -1005,7 +1006,7 @@
continue; // skip secondaries from weak decay without mothers
}
flags |= kIsSecondaryFromWeakDecay;
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
motherPdgCode = motherparticle.pdgCode();
motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy());
}
Expand Down Expand Up @@ -1039,7 +1040,7 @@
o2::aod::ITSResponse itsResponse;
for (const auto& track : tracks) {
if (std::abs(track.eta()) > cfgCutEta ||
track.itsNCls() < 7 ||

Check failure on line 1043 in PWGLF/TableProducer/Nuspex/nucleiSpectra.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.
track.itsChi2NCl() > 36.f) {
continue;
}
Expand All @@ -1062,7 +1063,7 @@
{
nuclei::candidates.clear();
std::vector<bool> goodCollisions(mcCollisions.size(), false);
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
if (!eventSelection(collision)) {
continue;
}
Expand All @@ -1085,7 +1086,7 @@
if (particle.isPhysicalPrimary()) {
c.flags |= kIsPhysicalPrimary;
if (particle.has_mothers()) {
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) {
c.flags |= kIsSecondaryFromWeakDecay;
motherPdgCode = motherparticle.pdgCode();
Expand All @@ -1096,7 +1097,7 @@
}
} else if (particle.has_mothers()) {
c.flags |= kIsSecondaryFromWeakDecay;
for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
motherPdgCode = motherparticle.pdgCode();
motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy());
}
Expand Down
Loading