Skip to content
Open
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
78 changes: 71 additions & 7 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 Down Expand Up @@ -42,6 +42,8 @@
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Framework/Configurable.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/InitContext.h>
#include <Framework/runDataProcessing.h>
#include <ReconstructionDataFormats/PID.h>
Expand Down Expand Up @@ -103,12 +105,18 @@
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 output tables reservation size
Configurable<float> reserveV0Ratio{"reserveV0Ratio", 0.05, "Ratio of how many tracks from V0s are expected in the output table to the input V0 table size"};
Configurable<float> reserveCascRatio{"reserveCascRatio", 0.0025, "Ratio of how many tracks from cascades are expected in the output table to the input Cascade table size"};
Configurable<bool> saveReserveQaHisto{"saveReserveQaHisto", true, "Flag to save the DF-wise ratio of output table size to that of input table"};
// 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"};

HistogramRegistry registry{"registry", {}};

// 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};
const float nSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f};
Expand Down Expand Up @@ -182,6 +190,11 @@
ccdb->setFatalWhenNull(false);

rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);

if (saveReserveQaHisto) {
registry.add("hV0OutputRatio", "V0 out/in ratio;V0 out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveV0Ratio}}});
registry.add("hCascOutputRatio", "Casc out/in ratio;Casc out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveCascRatio}}});
}
}

template <bool IsCorrectedDeDx, typename V0Casc, typename T>
Expand Down Expand Up @@ -422,6 +435,16 @@
aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi,
aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks);

int nV0Entries{0};
int nCascEntries{0};

const int64_t expectedOutputTableSize = static_cast<int64_t>(reserveV0Ratio * myV0s.size() + reserveCascRatio * myCascs.size());
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
rowTPCTree.reserve(expectedOutputTableSize);
} else {
rowTPCTreeWithTrkQA.reserve(expectedOutputTableSize);
}

for (const auto& collision : collisions) {
if (!isEventSelected(collision, applyEvSel)) {
continue;
Expand All @@ -441,11 +464,9 @@
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
bcTimeFrameId = UndefValueInt;
bcBcInTimeFrame = UndefValueInt;
rowTPCTree.reserve(2 * v0s.size() + cascs.size());
} else if constexpr (ModeId == ModeWithTrkQA) {
bcTimeFrameId = bc.tfId();
bcBcInTimeFrame = bc.bcInTF();
rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size());
}

auto getTrackQA = [&](const TrksType::iterator& track) {
Expand Down Expand Up @@ -481,7 +502,9 @@
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, isGoodRctEvent);
return true;
}
return false;
};

/// Loop over v0 candidates
Expand All @@ -493,8 +516,12 @@
const auto posTrack = v0.posTrack_as<TrksType>();
const auto negTrack = v0.negTrack_as<TrksType>();

fillDaughterTrack(v0, posTrack, v0, true);
fillDaughterTrack(v0, negTrack, v0, false);
if (fillDaughterTrack(v0, posTrack, v0, true)) {
++nV0Entries;
}
if (fillDaughterTrack(v0, negTrack, v0, false)) {
++nV0Entries;
}
}

/// Loop over cascade candidates
Expand All @@ -506,9 +533,23 @@
const auto bachTrack = casc.bachelor_as<TrksType>();
// Omega and antiomega
const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false;
fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive);
if (fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive)) {
++nCascEntries;
}
}
}
LOG(info) << "runV0() summary:";
LOG(info) << "V0 table size = " << myV0s.size();
LOG(info) << "Cascade table size = " << myCascs.size();
LOG(info) << "nV0Entries = " << nV0Entries;
LOG(info) << "nCascEntries = " << nCascEntries;
LOG(info) << "nV0Entries / V0 table size = " << static_cast<double>(nV0Entries) / myV0s.size();
LOG(info) << "nCascEntries / Cascade table size = " << static_cast<double>(nCascEntries) / myCascs.size();

if (saveReserveQaHisto) {
registry.fill(HIST("hV0OutputRatio"), static_cast<double>(nV0Entries) / myV0s.size());
registry.fill(HIST("hCascOutputRatio"), static_cast<double>(nCascEntries) / myCascs.size());
}
} /// runV0

void processStandard(Colls const& collisions,
Expand Down Expand Up @@ -632,12 +673,17 @@
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"};
// Configurable for output table reservation size
Configurable<float> reserveTrackRatio{"reserveTrackRatio", 0.003, "Ratio of how many tracks are expected in the output table to the input Tracks table size"};
Configurable<bool> saveReserveQaHisto{"saveReserveQaHisto", true, "Flag to save the DF-wise ratio of output table size to that of input table"};
// 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"};

HistogramRegistry registry{"registry", {}};

struct TofTrack {
bool isApplyHardCutOnly;
double maxMomHardCutOnly;
Expand Down Expand Up @@ -692,6 +738,10 @@
ccdb->setFatalWhenNull(false);

rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad);

if (saveReserveQaHisto) {
registry.add("hTrackOutputRatio", "Track out/in ratio;Track out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveTrackRatio}}});
}
}

template <bool DoCorrectDeDx, int ModeId, typename T, typename C>
Expand Down Expand Up @@ -803,6 +853,14 @@
labelTrack2TrackQA.at(trackId) = trackQA.globalIndex();
}
}

const int64_t expectedOutputTableSize = static_cast<int64_t>(reserveTrackRatio * myTracks.size());
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
rowTPCTOFTree.reserve(expectedOutputTableSize);
} else {
rowTPCTOFTreeWithTrkQA.reserve(expectedOutputTableSize);
}

for (const auto& collision : collisions) {
const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
if (!isEventSelected(collision, applyEvSel)) {
Expand All @@ -829,11 +887,9 @@
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
bcTimeFrameId = UndefValueInt;
bcBcInTimeFrame = UndefValueInt;
rowTPCTOFTree.reserve(tracks.size());
} else {
bcTimeFrameId = bc.tfId();
bcBcInTimeFrame = bc.bcInTF();
rowTPCTOFTreeWithTrkQA.reserve(tracks.size());
}
for (auto const& trk : tracksWithITSPid) {
if (!isTrackSelected(trk, trackSelection)) {
Expand Down Expand Up @@ -875,6 +931,14 @@
}
} /// Loop tracks
}
LOG(info) << "runTof() summary:";
LOG(info) << "Track table size = " << myTracks.size();
LOG(info) << "nTrackEntries = " << rowTPCTOFTree.lastIndex() + 1;
LOG(info) << "nTrackEntries / Track table size = " << static_cast<double>((rowTPCTOFTree.lastIndex() + 1)) / myTracks.size();

if (saveReserveQaHisto) {
registry.fill(HIST("hTrackOutputRatio"), static_cast<double>((rowTPCTOFTree.lastIndex() + 1)) / myTracks.size());
}
} /// runTof

void processStandard(Colls const& collisions,
Expand Down
Loading