Skip to content
Open
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
96 changes: 65 additions & 31 deletions DPG/Tasks/TPC/tpcSkimsTableCreator.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -25,6 +25,7 @@
#include "PWGLF/DataModel/LFStrangenessPIDTables.h"
#include "PWGLF/DataModel/LFStrangenessTables.h"

#include "Common/CCDB/RCTSelectionFlags.h"
#include "Common/CCDB/ctpRateFetcher.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
Expand Down Expand Up @@ -101,6 +102,11 @@
Configurable<float> maxPt4dwnsmplTsalisProtons{"maxPt4dwnsmplTsalisProtons", 100., "Maximum Pt for applying downsampling factor of protons"};
Configurable<float> maxPt4dwnsmplTsalisElectrons{"maxPt4dwnsmplTsalisElectrons", 100., "Maximum Pt for applying downsampling factor of electrons"};
Configurable<float> maxPt4dwnsmplTsalisKaons{"maxPt4dwnsmplTsalisKaons", 100., "Maximum Pt for applying downsampling factor of kaons"};
// Configurables for run condtion table
Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"};
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};

// an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits
constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue};
Expand Down Expand Up @@ -145,9 +151,11 @@
int negDaughterId{UndefValueInt};
};

Service<o2::ccdb::BasicCCDBManager> ccdb;
Service<o2::ccdb::BasicCCDBManager> ccdb{};

ctpRateFetcher mRateFetcher;
ctpRateFetcher mRateFetcher{};

o2::aod::rctsel::RCTFlagsChecker rctChecker{};

TRandom3* fRndm = new TRandom3(0);

Expand All @@ -171,6 +179,8 @@
ccdb->setURL("http://alice-ccdb.cern.ch");
ccdb->setCaching(true);
ccdb->setFatalWhenNull(false);

rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);
}

template <bool IsCorrectedDeDx, typename V0Casc, typename T>
Expand Down Expand Up @@ -249,7 +259,7 @@
}

template <bool DoUseCorrectedDeDx, int ModeId, typename T, typename C, typename V0Casc>
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues)
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const float hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues, const bool isGoodRctEvent)
{
const double ncl = track.tpcNClsFound();
const double nclPID = track.tpcNClsFindableMinusPID();
Expand All @@ -276,7 +286,8 @@
tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat;
}
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
rowTPCTree(usedDedx,
rowTPCTree(isGoodRctEvent,
usedDedx,
1. / dEdxExp,
track.tpcInnerParam(),
track.tgl(),
Expand Down Expand Up @@ -306,7 +317,8 @@
v0radius,
gammapsipair);
} else {
rowTPCTreeWithTrkQA(usedDedx,
rowTPCTreeWithTrkQA(isGoodRctEvent,
usedDedx,
1. / dEdxExp,
track.tpcInnerParam(),
track.tgl(),
Expand Down Expand Up @@ -405,17 +417,22 @@
}
}

const auto& tracksWithITSPid = soa::Attach<TrksType,
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);
const auto tracksWithITSPid = soa::Attach<TrksType,
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);

for (const auto& collision : collisions) {
if (!isEventSelected(collision, applyEvSel)) {
continue;
}
const auto& v0s = myV0s.sliceBy(perCollisionV0s, static_cast<int>(collision.globalIndex()));
const auto& cascs = myCascs.sliceBy(perCollisionCascs, static_cast<int>(collision.globalIndex()));
const auto& bc = collision.bc_as<BCType>();
const bool isGoodRctEvent = rctChecker.checkTable(collision);
if (requireGoodRct && !isGoodRctEvent) {
continue;
}

const auto v0s = myV0s.sliceBy(perCollisionV0s, static_cast<int>(collision.globalIndex()));
const auto cascs = myCascs.sliceBy(perCollisionCascs, static_cast<int>(collision.globalIndex()));
const auto bc = collision.bc_as<BCType>();
const int runnumber = bc.runNumber();
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
const int bcGlobalIndex = bc.globalIndex();
Expand Down Expand Up @@ -447,11 +464,11 @@
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const auto& v0, const bool isPositive) {
const auto [trackQAInstance, existTrkQA] = getTrackQA(dauTrack);
const auto trackId = dauTrack.globalIndex();
const auto& dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId);
const auto dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId);
const auto v0Id = getAddId(v0);
const V0Mother v0Mother = createV0Mother(v0Id);
const auto daighterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId;
const V0Daughter daughter = createV0Daughter<IsCorrectedDeDx>(v0, dauTrackWithITSPid, v0Id, daighterId, isPositive);
const auto daughterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId;
const V0Daughter daughter = createV0Daughter<IsCorrectedDeDx>(v0, dauTrackWithITSPid, v0Id, daughterId, isPositive);

const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection);
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
Expand All @@ -462,7 +479,7 @@
if constexpr (ModeId == ModeWithTrkQA) {
evaluateOccupancyVariables(dauTrack, occValues);
}
fillSkimmedV0Table<IsCorrectedDeDx, ModeId>(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues);
fillSkimmedV0Table<IsCorrectedDeDx, ModeId>(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues, isGoodRctEvent);
}
};

Expand All @@ -472,8 +489,8 @@
if (v0Id == MotherUndef) {
continue;
}
const auto& posTrack = v0.posTrack_as<TrksType>();
const auto& negTrack = v0.negTrack_as<TrksType>();
const auto posTrack = v0.posTrack_as<TrksType>();
const auto negTrack = v0.negTrack_as<TrksType>();

fillDaughterTrack(v0, posTrack, v0, true);
fillDaughterTrack(v0, negTrack, v0, false);
Expand All @@ -485,7 +502,7 @@
if (cascId == MotherUndef) {
continue;
}
const auto& bachTrack = casc.bachelor_as<TrksType>();
const auto bachTrack = casc.bachelor_as<TrksType>();
// Omega and antiomega
const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false;
fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive);
Expand Down Expand Up @@ -614,6 +631,11 @@
Configurable<float> downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"};
Configurable<float> downsamplingTsalisKaons{"downsamplingTsalisKaons", -1., "Downsampling factor to reduce the number of kaons"};
Configurable<float> downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"};
// Configurables for run condtion table
Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"};
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};

struct TofTrack {
bool isApplyHardCutOnly;
Expand All @@ -632,9 +654,11 @@
double nSigmaTpcTpctof;
};

Service<o2::ccdb::BasicCCDBManager> ccdb;
Service<o2::ccdb::BasicCCDBManager> ccdb{};

ctpRateFetcher mRateFetcher;
ctpRateFetcher mRateFetcher{};

o2::aod::rctsel::RCTFlagsChecker rctChecker{};

TRandom3* fRndm = new TRandom3(0);

Expand Down Expand Up @@ -665,10 +689,12 @@
ccdb->setURL("http://alice-ccdb.cern.ch");
ccdb->setCaching(true);
ccdb->setFatalWhenNull(false);

rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);
}

template <bool DoCorrectDeDx, int ModeId, typename T, typename C>
void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues)
void fillSkimmedTpcTofTable(T const& track, aod::TracksQA const& trackQA, const bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, const int runnumber, const double dwnSmplFactor, const double hadronicRate, const int bcGlobalIndex, const int bcTimeFrameId, const int bcBcInTimeFrame, const OccupancyValues& occValues, const bool isGoodRctEvent)
{
const double ncl = track.tpcNClsFound();
const double nclPID = track.tpcNClsFindableMinusPID();
Expand All @@ -688,7 +714,8 @@
tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat;
}
if (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
rowTPCTOFTree(usedEdx,
rowTPCTOFTree(isGoodRctEvent,
usedEdx,
1. / dEdxExp,
track.tpcInnerParam(),
track.tgl(),
Expand All @@ -712,7 +739,8 @@
hadronicRate,
tpcdEdxNorm);
} else {
rowTPCTOFTreeWithTrkQA(usedEdx,
rowTPCTOFTreeWithTrkQA(isGoodRctEvent,
usedEdx,
1. / dEdxExp,
track.tpcInnerParam(),
track.tgl(),
Expand Down Expand Up @@ -775,10 +803,15 @@
}
}
for (const auto& collision : collisions) {
const auto& tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
if (!isEventSelected(collision, applyEvSel)) {
continue;
}
const bool isGoodRctEvent = rctChecker.checkTable(collision);
if (requireGoodRct && !isGoodRctEvent) {
continue;
}

auto tracksWithITSPid = soa::Attach<TrksType,
aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr,
aod::pidits::ITSNSigmaDe, aod::pidits::ITSNSigmaTr>(tracks);
Expand All @@ -787,7 +820,7 @@
tracksWithITSPid.bindExternalIndices(&trackMeanOccs);
}

const auto& bc = collision.bc_as<BCType>();
const auto bc = collision.bc_as<BCType>();
const int runnumber = bc.runNumber();
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
const int bcGlobalIndex = bc.globalIndex();
Expand Down Expand Up @@ -825,17 +858,18 @@

TofTrack tofPion(false, UndefValueDouble, maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi);

OccupancyValues occValues;
OccupancyValues occValues{};
if constexpr (ModeId == ModeWithTrkQA) {
evaluateOccupancyVariables(trk, occValues);
}

for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) {
if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) &&
((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) ||
(trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) &&
downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) {
fillSkimmedTpcTofTable<IsCorrectedDeDx, ModeId>(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues);
const bool passMomHardCut = !tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly;
const bool passMomTpcOnly = trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly;
const bool passMomTpcTof = trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof;
const bool passDownsamplig = downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN);
if (passMomHardCut && (passMomTpcOnly || passMomTpcTof) && passDownsamplig) {
fillSkimmedTpcTofTable<IsCorrectedDeDx, ModeId>(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues, isGoodRctEvent);
}
}
} /// Loop tracks
Expand Down
4 changes: 3 additions & 1 deletion DPG/Tasks/TPC/tpcSkimsTableCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace o2::aod
{
namespace tpcskims
{
DECLARE_SOA_COLUMN(IsGoodRct, isGoodRct, bool);
DECLARE_SOA_COLUMN(InvDeDxExpTPC, invDeDxExpTPC, float);
DECLARE_SOA_COLUMN(Mass, mass, float);
DECLARE_SOA_COLUMN(BetaGamma, betaGamma, float);
Expand Down Expand Up @@ -59,7 +60,8 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int);
} // namespace tpcskims

#define TPCSKIMS_COLUMNS_BASE \
o2::aod::track::TPCSignal, \
tpcskims::IsGoodRct, \
o2::aod::track::TPCSignal, \
tpcskims::InvDeDxExpTPC, \
o2::aod::track::TPCInnerParam, \
o2::aod::track::Tgl, \
Expand Down
10 changes: 5 additions & 5 deletions DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum {

/// Event selection
template <typename CollisionType>
inline bool isEventSelected(const CollisionType& collision, const int applyEvSel)
bool isEventSelected(const CollisionType& collision, const int applyEvSel)
{
if ((applyEvSel == EventSelectionRun2 && !collision.sel7()) || (applyEvSel == EventSelectionRun3 && !collision.sel8())) {
return false;
Expand Down Expand Up @@ -86,7 +86,7 @@ inline bool downsampleTsalisCharged(TRandom3* fRndm, const double pt, const doub

// Track selection
template <typename TrackType>
inline bool isTrackSelected(const TrackType& track, const int trackSelection)
bool isTrackSelected(const TrackType& track, const int trackSelection)
{
bool isSelected{false};
isSelected |= trackSelection == TrackSelectionNoCut;
Expand All @@ -101,7 +101,7 @@ inline bool isTrackSelected(const TrackType& track, const int trackSelection)

/// Evaluate tpcSignal with or without dEdx correction
template <bool IsCorrectedDeDx, typename TrkType>
inline double tpcSignalGeneric(const TrkType& track)
double tpcSignalGeneric(const TrkType& track)
{
if constexpr (IsCorrectedDeDx) {
return track.tpcSignalCorrected();
Expand All @@ -127,12 +127,12 @@ using TrackMeanOccs = soa::Join<aod::TmoTrackIds, aod::TmoToTrackQA, aod::TmoPri

/// Evaluate occupancy-related variables
template <typename TrkType>
inline void evaluateOccupancyVariables(const TrkType& track, OccupancyValues& occValues)
void evaluateOccupancyVariables(const TrkType& track, OccupancyValues& occValues)
{
if (track.tmoId() == -1) {
return;
}
const auto& tmoFromTrack = track.template tmo_as<TrackMeanOccs>();
const auto tmoFromTrack = track.template tmo_as<TrackMeanOccs>();
occValues.tmoPrimUnfm80 = tmoFromTrack.tmoPrimUnfm80();
occValues.tmoFV0AUnfm80 = tmoFromTrack.tmoFV0AUnfm80();
occValues.tmoFT0AUnfm80 = tmoFromTrack.tmoFT0AUnfm80();
Expand Down
Loading