Skip to content

Commit aa53e5d

Browse files
authored
[DPG] tpcSkimsTableCreator: add RCT check, minor refactory (#16196)
1 parent 337e7fe commit aa53e5d

3 files changed

Lines changed: 73 additions & 37 deletions

File tree

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "PWGLF/DataModel/LFStrangenessPIDTables.h"
2626
#include "PWGLF/DataModel/LFStrangenessTables.h"
2727

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

106112
// an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits
107113
constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue};
@@ -146,9 +152,11 @@ struct TreeWriterTpcV0 {
146152
int negDaughterId{UndefValueInt};
147153
};
148154

149-
Service<o2::ccdb::BasicCCDBManager> ccdb;
155+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
150156

151-
ctpRateFetcher mRateFetcher;
157+
ctpRateFetcher mRateFetcher{};
158+
159+
o2::aod::rctsel::RCTFlagsChecker rctChecker{};
152160

153161
TRandom3* fRndm = new TRandom3(0);
154162

@@ -172,6 +180,8 @@ struct TreeWriterTpcV0 {
172180
ccdb->setURL("http://alice-ccdb.cern.ch");
173181
ccdb->setCaching(true);
174182
ccdb->setFatalWhenNull(false);
183+
184+
rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);
175185
}
176186

177187
template <bool IsCorrectedDeDx, typename V0Casc, typename T>
@@ -250,7 +260,7 @@ struct TreeWriterTpcV0 {
250260
}
251261

252262
template <bool DoUseCorrectedDeDx, int ModeId, typename T, typename C, typename V0Casc>
253-
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)
263+
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)
254264
{
255265
const double ncl = track.tpcNClsFound();
256266
const double nclPID = track.tpcNClsFindableMinusPID();
@@ -277,7 +287,8 @@ struct TreeWriterTpcV0 {
277287
tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat;
278288
}
279289
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
280-
rowTPCTree(usedDedx,
290+
rowTPCTree(isGoodRctEvent,
291+
usedDedx,
281292
1. / dEdxExp,
282293
track.tpcInnerParam(),
283294
track.tgl(),
@@ -307,7 +318,8 @@ struct TreeWriterTpcV0 {
307318
v0radius,
308319
gammapsipair);
309320
} else {
310-
rowTPCTreeWithTrkQA(usedDedx,
321+
rowTPCTreeWithTrkQA(isGoodRctEvent,
322+
usedDedx,
311323
1. / dEdxExp,
312324
track.tpcInnerParam(),
313325
track.tgl(),
@@ -406,17 +418,22 @@ struct TreeWriterTpcV0 {
406418
}
407419
}
408420

409-
const auto& tracksWithITSPid = soa::Attach<TrksType,
410-
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
411-
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);
421+
const auto tracksWithITSPid = soa::Attach<TrksType,
422+
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
423+
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);
412424

413425
for (const auto& collision : collisions) {
414426
if (!isEventSelected(collision, applyEvSel)) {
415427
continue;
416428
}
417-
const auto& v0s = myV0s.sliceBy(perCollisionV0s, static_cast<int>(collision.globalIndex()));
418-
const auto& cascs = myCascs.sliceBy(perCollisionCascs, static_cast<int>(collision.globalIndex()));
419-
const auto& bc = collision.bc_as<BCType>();
429+
const bool isGoodRctEvent = rctChecker.checkTable(collision);
430+
if (requireGoodRct && !isGoodRctEvent) {
431+
continue;
432+
}
433+
434+
const auto v0s = myV0s.sliceBy(perCollisionV0s, static_cast<int>(collision.globalIndex()));
435+
const auto cascs = myCascs.sliceBy(perCollisionCascs, static_cast<int>(collision.globalIndex()));
436+
const auto bc = collision.bc_as<BCType>();
420437
const int runnumber = bc.runNumber();
421438
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
422439
const int bcGlobalIndex = bc.globalIndex();
@@ -448,11 +465,11 @@ struct TreeWriterTpcV0 {
448465
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const auto& v0, const bool isPositive) {
449466
const auto [trackQAInstance, existTrkQA] = getTrackQA(dauTrack);
450467
const auto trackId = dauTrack.globalIndex();
451-
const auto& dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId);
468+
const auto dauTrackWithITSPid = tracksWithITSPid.rawIteratorAt(trackId);
452469
const auto v0Id = getAddId(v0);
453470
const V0Mother v0Mother = createV0Mother(v0Id);
454-
const auto daighterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId;
455-
const V0Daughter daughter = createV0Daughter<IsCorrectedDeDx>(v0, dauTrackWithITSPid, v0Id, daighterId, isPositive);
471+
const auto daughterId = isPositive ? v0Mother.posDaughterId : v0Mother.negDaughterId;
472+
const V0Daughter daughter = createV0Daughter<IsCorrectedDeDx>(v0, dauTrackWithITSPid, v0Id, daughterId, isPositive);
456473

457474
const bool passTrackSelection = isTrackSelected(dauTrack, trackSelection);
458475
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
@@ -463,7 +480,7 @@ struct TreeWriterTpcV0 {
463480
if constexpr (ModeId == ModeWithTrkQA) {
464481
evaluateOccupancyVariables(dauTrack, occValues);
465482
}
466-
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);
483+
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);
467484
}
468485
};
469486

@@ -473,8 +490,8 @@ struct TreeWriterTpcV0 {
473490
if (v0Id == MotherUndef) {
474491
continue;
475492
}
476-
const auto& posTrack = v0.posTrack_as<TrksType>();
477-
const auto& negTrack = v0.negTrack_as<TrksType>();
493+
const auto posTrack = v0.posTrack_as<TrksType>();
494+
const auto negTrack = v0.negTrack_as<TrksType>();
478495

479496
fillDaughterTrack(v0, posTrack, v0, true);
480497
fillDaughterTrack(v0, negTrack, v0, false);
@@ -486,7 +503,7 @@ struct TreeWriterTpcV0 {
486503
if (cascId == MotherUndef) {
487504
continue;
488505
}
489-
const auto& bachTrack = casc.bachelor_as<TrksType>();
506+
const auto bachTrack = casc.bachelor_as<TrksType>();
490507
// Omega and antiomega
491508
const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false;
492509
fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive);
@@ -615,6 +632,11 @@ struct TreeWriterTpcTof {
615632
Configurable<float> downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"};
616633
Configurable<float> downsamplingTsalisKaons{"downsamplingTsalisKaons", -1., "Downsampling factor to reduce the number of kaons"};
617634
Configurable<float> downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"};
635+
// Configurables for run condtion table
636+
Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"};
637+
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
638+
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
639+
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};
618640

619641
struct TofTrack {
620642
bool isApplyHardCutOnly;
@@ -633,9 +655,11 @@ struct TreeWriterTpcTof {
633655
double nSigmaTpcTpctof;
634656
};
635657

636-
Service<o2::ccdb::BasicCCDBManager> ccdb;
658+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
637659

638-
ctpRateFetcher mRateFetcher;
660+
ctpRateFetcher mRateFetcher{};
661+
662+
o2::aod::rctsel::RCTFlagsChecker rctChecker{};
639663

640664
TRandom3* fRndm = new TRandom3(0);
641665

@@ -666,10 +690,12 @@ struct TreeWriterTpcTof {
666690
ccdb->setURL("http://alice-ccdb.cern.ch");
667691
ccdb->setCaching(true);
668692
ccdb->setFatalWhenNull(false);
693+
694+
rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);
669695
}
670696

671697
template <bool DoCorrectDeDx, int ModeId, typename T, typename C>
672-
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)
698+
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)
673699
{
674700
const double ncl = track.tpcNClsFound();
675701
const double nclPID = track.tpcNClsFindableMinusPID();
@@ -689,7 +715,8 @@ struct TreeWriterTpcTof {
689715
tpcdEdxNorm = existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat;
690716
}
691717
if (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
692-
rowTPCTOFTree(usedEdx,
718+
rowTPCTOFTree(isGoodRctEvent,
719+
usedEdx,
693720
1. / dEdxExp,
694721
track.tpcInnerParam(),
695722
track.tgl(),
@@ -713,7 +740,8 @@ struct TreeWriterTpcTof {
713740
hadronicRate,
714741
tpcdEdxNorm);
715742
} else {
716-
rowTPCTOFTreeWithTrkQA(usedEdx,
743+
rowTPCTOFTreeWithTrkQA(isGoodRctEvent,
744+
usedEdx,
717745
1. / dEdxExp,
718746
track.tpcInnerParam(),
719747
track.tgl(),
@@ -776,10 +804,15 @@ struct TreeWriterTpcTof {
776804
}
777805
}
778806
for (const auto& collision : collisions) {
779-
const auto& tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
807+
const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
780808
if (!isEventSelected(collision, applyEvSel)) {
781809
continue;
782810
}
811+
const bool isGoodRctEvent = rctChecker.checkTable(collision);
812+
if (requireGoodRct && !isGoodRctEvent) {
813+
continue;
814+
}
815+
783816
auto tracksWithITSPid = soa::Attach<TrksType,
784817
aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr,
785818
aod::pidits::ITSNSigmaDe, aod::pidits::ITSNSigmaTr>(tracks);
@@ -788,7 +821,7 @@ struct TreeWriterTpcTof {
788821
tracksWithITSPid.bindExternalIndices(&trackMeanOccs);
789822
}
790823

791-
const auto& bc = collision.bc_as<BCType>();
824+
const auto bc = collision.bc_as<BCType>();
792825
const int runnumber = bc.runNumber();
793826
const auto hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
794827
const int bcGlobalIndex = bc.globalIndex();
@@ -826,17 +859,18 @@ struct TreeWriterTpcTof {
826859

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

829-
OccupancyValues occValues;
862+
OccupancyValues occValues{};
830863
if constexpr (ModeId == ModeWithTrkQA) {
831864
evaluateOccupancyVariables(trk, occValues);
832865
}
833866

834867
for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) {
835-
if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) &&
836-
((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) ||
837-
(trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) &&
838-
downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) {
839-
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);
868+
const bool passMomHardCut = !tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly;
869+
const bool passMomTpcOnly = trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly;
870+
const bool passMomTpcTof = trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof;
871+
const bool passDownsamplig = downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN);
872+
if (passMomHardCut && (passMomTpcOnly || passMomTpcTof) && passDownsamplig) {
873+
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);
840874
}
841875
}
842876
} /// Loop tracks

DPG/Tasks/TPC/tpcSkimsTableCreator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace o2::aod
3131
{
3232
namespace tpcskims
3333
{
34+
DECLARE_SOA_COLUMN(IsGoodRct, isGoodRct, bool);
3435
DECLARE_SOA_COLUMN(InvDeDxExpTPC, invDeDxExpTPC, float);
3536
DECLARE_SOA_COLUMN(Mass, mass, float);
3637
DECLARE_SOA_COLUMN(BetaGamma, betaGamma, float);
@@ -58,7 +59,8 @@ DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int);
5859
} // namespace tpcskims
5960

6061
#define TPCSKIMS_COLUMNS_BASE \
61-
o2::aod::track::TPCSignal, \
62+
tpcskims::IsGoodRct, \
63+
o2::aod::track::TPCSignal, \
6264
tpcskims::InvDeDxExpTPC, \
6365
o2::aod::track::TPCInnerParam, \
6466
o2::aod::track::Tgl, \

DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ enum {
4949

5050
/// Event selection
5151
template <typename CollisionType>
52-
inline bool isEventSelected(const CollisionType& collision, const int applyEvSel)
52+
bool isEventSelected(const CollisionType& collision, const int applyEvSel)
5353
{
5454
if ((applyEvSel == EventSelectionRun2 && !collision.sel7()) || (applyEvSel == EventSelectionRun3 && !collision.sel8())) {
5555
return false;
@@ -88,7 +88,7 @@ inline bool downsampleTsalisCharged(TRandom3* fRndm, const double pt, const doub
8888

8989
// Track selection
9090
template <typename TrackType>
91-
inline bool isTrackSelected(const TrackType& track, const int trackSelection)
91+
bool isTrackSelected(const TrackType& track, const int trackSelection)
9292
{
9393
bool isSelected{false};
9494
isSelected |= trackSelection == TrackSelectionNoCut;
@@ -103,7 +103,7 @@ inline bool isTrackSelected(const TrackType& track, const int trackSelection)
103103

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

130130
/// Evaluate occupancy-related variables
131131
template <typename TrkType>
132-
inline void evaluateOccupancyVariables(const TrkType& track, OccupancyValues& occValues)
132+
void evaluateOccupancyVariables(const TrkType& track, OccupancyValues& occValues)
133133
{
134134
if (track.tmoId() == -1) {
135135
return;
136136
}
137-
const auto& tmoFromTrack = track.template tmo_as<TrackMeanOccs>();
137+
const auto tmoFromTrack = track.template tmo_as<TrackMeanOccs>();
138138
occValues.tmoPrimUnfm80 = tmoFromTrack.tmoPrimUnfm80();
139139
occValues.tmoFV0AUnfm80 = tmoFromTrack.tmoFV0AUnfm80();
140140
occValues.tmoFT0AUnfm80 = tmoFromTrack.tmoFT0AUnfm80();

0 commit comments

Comments
 (0)