Skip to content

Commit

Permalink
Merge 8642aee into sapling-pr-archive-ktf
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf authored Dec 13, 2023
2 parents 26acc39 + 8642aee commit 95225bc
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 234 deletions.
16 changes: 13 additions & 3 deletions CCDB/include/CCDB/BasicCCDBManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,19 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
cached.objPtr.reset(ptr);
}
cached.uuid = mHeaders["ETag"];
try { // this conversion can throw, better to catch immediately
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);
try {
if (mHeaders.find("Valid-From") != mHeaders.end()) {
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
} else {
// if meta-information missing assume infinit validity
// (should happen only for locally created objects)
cached.startvalidity = 0;
}
if (mHeaders.find("Valid-Until") != mHeaders.end()) {
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);
} else {
cached.endvalidity = std::numeric_limits<long>::max();
}
} catch (std::exception const& e) {
reportFatal("Failed to read validity from CCDB response (Valid-From : " + mHeaders["Valid-From"] + std::string(" Valid-Until: ") + mHeaders["Valid-Until"] + std::string(")"));
}
Expand Down
2 changes: 2 additions & 0 deletions Common/Constants/include/CommonConstants/PhysicsConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum Pdg {
kXiCCPlusPlus = 4422,
kXiCPlus = 4232,
kXiCZero = 4132,
kXiC0 = 4132,
kDeuteron = 1000010020,
kTriton = 1000010030,
kHelium3 = 1000020030,
Expand Down Expand Up @@ -93,6 +94,7 @@ constexpr double MassXiB0 = 5.7924;
constexpr double MassXiCCPlusPlus = 3.59798;
constexpr double MassXiCPlus = 2.4679;
constexpr double MassXiCZero = 2.471;
constexpr double MassXiC0 = 2.471;
constexpr double MassDeuteron = 1.87561294257;
constexpr double MassTriton = 2.80892113298;
constexpr double MassHelium3 = 2.80839160743;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Pdg(Enum):
kXiCCPlusPlus = 4422
kXiCPlus = 4232
kXiCZero = 4132
kXiC0 = 4132
kDeuteron = 1000010020
kTriton = 1000010030
kHelium3 = 1000020030
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ class DecayNBodyIndex
void setProngID(int i, GIndex gid) { mProngIDs[i] = gid; }
int getVertexID() const { return mVertexID; }
void setVertexID(int id) { mVertexID = id; }
uint8_t getBits() const { return mBits; }
bool testBit(int i) const { return (mBits & (0x1 << i)) != 0; }
void setBit(int i) { mBits |= (0x1 << i); }
void resetBit(int i) { mBits &= ~(0x1 << i); }

const std::array<GIndex, N>& getProngs() const { return mProngIDs; }
static constexpr int getNProngs() { return N; }

protected:
int mVertexID = -1; // id of parent vertex
std::array<GIndex, N> mProngIDs{}; // global IDs of prongs
ClassDefNV(DecayNBodyIndex, 1);
uint8_t mBits = 0; // user defined bits

ClassDefNV(DecayNBodyIndex, 2);
};

class V0Index : public DecayNBodyIndex<2>
{
public:
using DecayNBodyIndex<2>::DecayNBodyIndex;
V0Index(int v, GIndex p, GIndex n) : DecayNBodyIndex<2>(v, {p, n}) {}
bool isStandaloneV0() const { return testBit(0); }
bool isPhotonOnly() const { return testBit(1); }
void setStandaloneV0() { setBit(0); }
void setPhotonOnly() { setBit(1); }
ClassDefNV(V0Index, 1);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class AODProducerWorkflowDPL : public Task
// * interaction time is for TOF information
template <typename TracksCursorType, typename TracksCovCursorType, typename TracksExtraCursorType, typename TracksQACursorType, typename AmbigTracksCursorType,
typename MFTTracksCursorType, typename AmbigMFTTracksCursorType,
typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType>
typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename FwdTrkClsCursorType>
void fillTrackTablesPerCollision(int collisionID,
std::uint64_t collisionBC,
const o2::dataformats::VtxTrackRef& trackRef,
Expand All @@ -523,8 +523,12 @@ class AODProducerWorkflowDPL : public Task
FwdTracksCursorType& fwdTracksCursor,
FwdTracksCovCursorType& fwdTracksCovCursor,
AmbigFwdTracksCursorType& ambigFwdTracksCursor,
FwdTrkClsCursorType& fwdTrkClsCursor,
const std::map<uint64_t, int>& bcsMap);

template <typename FwdTrkClsCursorType>
void addClustersToFwdTrkClsTable(const o2::globaltracking::RecoContainer& recoData, FwdTrkClsCursorType& fwdTrkClsCursor, GIndex trackID, int fwdTrackId);

void fillIndexTablesPerCollision(const o2::dataformats::VtxTrackRef& trackRef, const gsl::span<const GIndex>& GIndices, const o2::globaltracking::RecoContainer& data);

template <typename V0CursorType, typename CascadeCursorType, typename Decay3bodyCursorType>
Expand Down
44 changes: 40 additions & 4 deletions Detectors/AOD/src/AODProducerWorkflowSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void AODProducerWorkflowDPL::addToMFTTracksTable(mftTracksCursorType& mftTracksC

template <typename TracksCursorType, typename TracksCovCursorType, typename TracksExtraCursorType, typename TracksQACursorType, typename AmbigTracksCursorType,
typename MFTTracksCursorType, typename AmbigMFTTracksCursorType,
typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType>
typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename FwdTrkClsCursorType>
void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
std::uint64_t collisionBC,
const o2::dataformats::VtxTrackRef& trackRef,
Expand All @@ -425,6 +425,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
FwdTracksCursorType& fwdTracksCursor,
FwdTracksCovCursorType& fwdTracksCovCursor,
AmbigFwdTracksCursorType& ambigFwdTracksCursor,
FwdTrkClsCursorType& fwdTrkClsCursor,
const std::map<uint64_t, int>& bcsMap)
{
for (int src = GIndex::NSources; src--;) {
Expand Down Expand Up @@ -460,6 +461,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
}
addToFwdTracksTable(fwdTracksCursor, fwdTracksCovCursor, ambigFwdTracksCursor, trackIndex, data, collisionID, collisionBC, bcsMap);
mGIDToTableFwdID.emplace(trackIndex, mTableTrFwdID);
addClustersToFwdTrkClsTable(data, fwdTrkClsCursor, trackIndex, mTableTrFwdID);
mTableTrFwdID++;
} else {
// barrel track: normal tracks table
Expand Down Expand Up @@ -1199,6 +1201,7 @@ void AODProducerWorkflowDPL::fillSecondaryVertices(const o2::globaltracking::Rec
const auto& v0 = v0s[iv0];
auto trPosID = v0.getProngID(0);
auto trNegID = v0.getProngID(1);
uint8_t v0flags = v0.getBits();
int posTableIdx = -1, negTableIdx = -1, collID = -1;
auto item = mGIDToTableID.find(trPosID);
if (item != mGIDToTableID.end()) {
Expand All @@ -1219,7 +1222,7 @@ void AODProducerWorkflowDPL::fillSecondaryVertices(const o2::globaltracking::Rec
collID = itemV->second;
}
if (posTableIdx != -1 and negTableIdx != -1 and collID != -1) {
v0Cursor(collID, posTableIdx, negTableIdx);
v0Cursor(collID, posTableIdx, negTableIdx, v0flags);
mV0ToTableID[int(iv0)] = mTableV0ID++;
}
}
Expand Down Expand Up @@ -1283,6 +1286,37 @@ void AODProducerWorkflowDPL::fillSecondaryVertices(const o2::globaltracking::Rec
}
}

template <typename FwdTrkClsCursorType>
void AODProducerWorkflowDPL::addClustersToFwdTrkClsTable(const o2::globaltracking::RecoContainer& recoData, FwdTrkClsCursorType& fwdTrkClsCursor, GIndex trackID, int fwdTrackId)
{
const auto& mchTracks = recoData.getMCHTracks();
const auto& mchmidMatches = recoData.getMCHMIDMatches();
const auto& mchClusters = recoData.getMCHTrackClusters();

int mchTrackID = -1;
if (trackID.getSource() == GIndex::MCH) { // This is an MCH track
mchTrackID = trackID.getIndex();
} else if (trackID.getSource() == GIndex::MCHMID) { // This is an MCH-MID track
auto mchmidMatch = mchmidMatches[trackID.getIndex()];
mchTrackID = mchmidMatch.getMCHRef().getIndex();
} // Others are Global Forward Tracks, their clusters will be or were added with the corresponding MCH track

if (mchTrackID > -1 && mchTrackID < mchTracks.size()) {
const auto& mchTrack = mchTracks[mchTrackID];
fwdTrkClsCursor.reserve(mchTrack.getNClusters() + fwdTrkClsCursor.lastIndex());
int first = mchTrack.getFirstClusterIdx();
int last = mchTrack.getLastClusterIdx();
for (int i = first; i <= last; i++) {
const auto& cluster = mchClusters[i];
fwdTrkClsCursor(fwdTrackId,
truncateFloatFraction(cluster.x, mMuonCl),
truncateFloatFraction(cluster.y, mMuonCl),
truncateFloatFraction(cluster.z, mMuonCl),
(((cluster.ey < 5.) & 0x1) << 12) | (((cluster.ex < 5.) & 0x1) << 11) | cluster.getDEId());
}
}
}

template <typename HMPCursorType>
void AODProducerWorkflowDPL::fillHMPID(const o2::globaltracking::RecoContainer& recoData, HMPCursorType& hmpCursor)
{
Expand Down Expand Up @@ -1797,6 +1831,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
auto fv0aCursor = createTableCursor<o2::aod::FV0As>(pc);
auto fwdTracksCursor = createTableCursor<o2::aod::StoredFwdTracks>(pc);
auto fwdTracksCovCursor = createTableCursor<o2::aod::StoredFwdTracksCov>(pc);
auto fwdTrkClsCursor = createTableCursor<o2::aod::FwdTrkCls>(pc);
auto mcColLabelsCursor = createTableCursor<o2::aod::McCollisionLabels>(pc);
auto mcCollisionsCursor = createTableCursor<o2::aod::McCollisions>(pc);
auto mcMFTTrackLabelCursor = createTableCursor<o2::aod::McMFTTrackLabels>(pc);
Expand Down Expand Up @@ -2114,7 +2149,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
// fixme: interaction time is undefined for unassigned tracks (?)
fillTrackTablesPerCollision(-1, std::uint64_t(-1), trackRef, primVerGIs, recoData, tracksCursor, tracksCovCursor, tracksExtraCursor, tracksQACursor,
ambigTracksCursor, mftTracksCursor, ambigMFTTracksCursor,
fwdTracksCursor, fwdTracksCovCursor, ambigFwdTracksCursor, bcsMap);
fwdTracksCursor, fwdTracksCovCursor, ambigFwdTracksCursor, fwdTrkClsCursor, bcsMap);

// filling collisions and tracks into tables
collisionID = 0;
Expand Down Expand Up @@ -2156,7 +2191,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
// passing interaction time in [ps]
fillTrackTablesPerCollision(collisionID, globalBC, trackRef, primVerGIs, recoData, tracksCursor, tracksCovCursor, tracksExtraCursor, tracksQACursor, ambigTracksCursor,
mftTracksCursor, ambigMFTTracksCursor,
fwdTracksCursor, fwdTracksCovCursor, ambigFwdTracksCursor, bcsMap);
fwdTracksCursor, fwdTracksCovCursor, ambigFwdTracksCursor, fwdTrkClsCursor, bcsMap);
collisionID++;
}

Expand Down Expand Up @@ -2939,6 +2974,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
OutputForTable<AmbiguousTracks>::spec(),
OutputForTable<AmbiguousMFTTracks>::spec(),
OutputForTable<AmbiguousFwdTracks>::spec(),
OutputForTable<FwdTrkCls>::spec(),
OutputForTable<V0s>::spec(),
OutputForTable<HMPIDs>::spec(),
OutputForTable<Zdcs>::spec(),
Expand Down
11 changes: 10 additions & 1 deletion Detectors/TPC/calibration/SpacePoints/src/TrackInterpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,19 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
auto propagator = o2::base::Propagator::Instance();
unsigned short rowPrev = 0; // used to calculate dRow of two consecutive cluster residuals
unsigned short nMeasurements = 0;
uint8_t clRowPrev = -1; // used to identify and skip split clusters on the same pad row
uint8_t clRowPrev = constants::MAXGLOBALPADROW; // used to identify and skip split clusters on the same pad row
for (int iCl = trkTPC.getNClusterReferences(); iCl--;) {
uint8_t sector, row;
uint32_t clusterIndexInRow;
const auto& cl = trkTPC.getCluster(mTPCTracksClusIdx, iCl, *mTPCClusterIdxStruct, sector, row);
if (clRowPrev == row) {
// if there are split clusters we only take the first one on the pad row
continue;
} else if (clRowPrev < constants::MAXGLOBALPADROW && clRowPrev > row) {
// we seem to be looping, abort this track
LOGP(debug, "TPC track with pT={} GeV and {} clusters has cluster {} on row {} while the previous cluster was on row {}",
mSeeds[iSeed].getPt(), trkTPC.getNClusterReferences(), iCl, row, clRowPrev);
return;
} else {
// this is the first cluster we see on this pad row
clRowPrev = row;
Expand Down Expand Up @@ -618,6 +623,10 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
}

TrackParams params; // for refitted track parameters and flagging rejected clusters
if (clusterResiduals.size() > constants::MAXGLOBALPADROW) {
LOGP(warn, "Extrapolated ITS-TPC track and found more reesiduals than possible ({})", clusterResiduals.size());
return;
}
if (mParams->skipOutlierFiltering || validateTrack(trackData, params, clusterResiduals)) {
// track is good
int nClValidated = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TPCSectorCompletionPolicy
return std::regex_match(device.name.begin(), device.name.end(), std::regex(expression.c_str()));
};

auto callback = [bRequireAll = mRequireAll, inputMatchers = mInputMatchers, externalInputMatchers = mExternalInputMatchers, pTpcSectorMask = mTpcSectorMask, orderCheck = mOrderCheck](framework::InputSpan const& inputs) -> framework::CompletionPolicy::CompletionOp {
auto callback = [bRequireAll = mRequireAll, inputMatchers = mInputMatchers, externalInputMatchers = mExternalInputMatchers, pTpcSectorMask = mTpcSectorMask, orderCheck = mOrderCheck](framework::InputSpan const& inputs, auto const&, auto&) -> framework::CompletionPolicy::CompletionOp {
unsigned long tpcSectorMask = pTpcSectorMask ? *pTpcSectorMask : 0xFFFFFFFFF;
std::bitset<NSectors> validSectors = 0;
bool haveMatchedInput = false;
Expand Down
11 changes: 9 additions & 2 deletions Detectors/Vertexing/src/SVertexer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP,
// apply mass selections
float p2Pos = pP[0] * pP[0] + pP[1] * pP[1] + pP[2] * pP[2], p2Neg = pN[0] * pN[0] + pN[1] * pN[1] + pN[2] * pN[2];

bool goodHyp = false;
bool goodHyp = false, photonOnly = mSVParams->mTPCTrackPhotonTune && isTPConly;
std::array<bool, NHypV0> hypCheckStatus{};
int nPID = (mSVParams->mTPCTrackPhotonTune && isTPConly) ? (Photon + 1) : NHypV0;
int nPID = photonOnly ? (Photon + 1) : NHypV0;
for (int ipid = 0; (ipid < nPID) && mSVParams->checkV0Hypothesis; ipid++) {
if (mV0Hyps[ipid].check(p2Pos, p2Neg, p2V0, ptV0)) {
goodHyp = hypCheckStatus[ipid] = true;
Expand Down Expand Up @@ -855,6 +855,13 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP,

if (nV0Used || !rejectIfNotCascade) { // need to add this v0
mV0sIdxTmp[ithread].push_back(v0Idxnew);
if (!rejectIfNotCascade) {
mV0sIdxTmp[ithread].back().setStandaloneV0();
}
if (photonOnly) {
mV0sIdxTmp[ithread].back().setPhotonOnly();
}

if (mSVParams->createFullV0s) {
mV0sTmp[ithread].push_back(v0new);
}
Expand Down
28 changes: 27 additions & 1 deletion Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,32 @@ DECLARE_SOA_TABLE(AmbiguousFwdTracks, "AOD", "AMBIGUOUSFWDTR", //! Table for Fwd

using AmbiguousFwdTrack = AmbiguousFwdTracks::iterator;

// Forward Tracks Cluster information
namespace fwdtrkcl
{
DECLARE_SOA_INDEX_COLUMN(FwdTrack, fwdtrack); //! Track index
DECLARE_SOA_COLUMN(X, x, float); //! Cluster x coordinate
DECLARE_SOA_COLUMN(Y, y, float); //! Cluster y coordinate
DECLARE_SOA_COLUMN(Z, z, float); //! Cluster z coordinate
DECLARE_SOA_COLUMN(ClInfo, clInfo, uint16_t); //! Encoded detection element of cluster and cluster type along x and y
DECLARE_SOA_DYNAMIC_COLUMN(DEId, deId, [](uint16_t info) -> uint16_t { return (info & 0x7FF); });
DECLARE_SOA_DYNAMIC_COLUMN(IsGoodX, isGoodX, [](uint16_t info) -> bool { return ((info & 0x800) >> 11); });
DECLARE_SOA_DYNAMIC_COLUMN(IsGoodY, isGoodY, [](uint16_t info) -> bool { return ((info & 0x1000) >> 12); });
} // namespace fwdtrkcl

DECLARE_SOA_TABLE(FwdTrkCls, "AOD", "FWDTRKCL", //! Forward Track Cluster information
o2::soa::Index<>,
fwdtrkcl::FwdTrackId,
fwdtrkcl::X,
fwdtrkcl::Y,
fwdtrkcl::Z,
fwdtrkcl::ClInfo,
fwdtrkcl::DEId<fwdtrkcl::ClInfo>,
fwdtrkcl::IsGoodX<fwdtrkcl::ClInfo>,
fwdtrkcl::IsGoodY<fwdtrkcl::ClInfo>);

using FwdTrkCl = FwdTrkCls::iterator;

// HMPID information
namespace hmpid
{
Expand Down Expand Up @@ -1297,7 +1323,7 @@ DECLARE_SOA_TABLE_VERSIONED(V0s_002, "AOD", "V0", 2, //! Run 3 V0 table (version
v0::IsStandardV0<v0::V0Type>,
v0::IsPhotonV0<v0::V0Type>);

using V0s = V0s_001; //! this defines the current default version
using V0s = V0s_002; //! this defines the current default version
using V0 = V0s::iterator;

namespace cascade
Expand Down
9 changes: 2 additions & 7 deletions Framework/Core/include/Framework/CompletionPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,21 @@ struct CompletionPolicy {

using Matcher = std::function<bool(DeviceSpec const& device)>;
using InputSetElement = DataRef;
using Callback = std::function<CompletionOp(InputSpan const&)>;
using CallbackFull = std::function<CompletionOp(InputSpan const&, std::vector<InputSpec> const&, ServiceRegistryRef&)>;
using CallbackConfigureRelayer = std::function<void(DataRelayer&)>;

/// Constructor
CompletionPolicy()
: name{}, matcher{}, callback{} {}
: name{}, matcher{}, callbackFull{} {}
/// Constructor for emplace_back
CompletionPolicy(std::string _name, Matcher _matcher, Callback _callback, bool _balanceChannels = true)
: name(std::move(_name)), matcher(std::move(_matcher)), callback(std::move(_callback)), callbackFull{nullptr}, balanceChannels{_balanceChannels} {}
CompletionPolicy(std::string _name, Matcher _matcher, CallbackFull _callback, bool _balanceChannels = true)
: name(std::move(_name)), matcher(std::move(_matcher)), callback(nullptr), callbackFull{std::move(_callback)}, balanceChannels{_balanceChannels} {}
: name(std::move(_name)), matcher(std::move(_matcher)), callbackFull{std::move(_callback)}, balanceChannels{_balanceChannels} {}

/// Name of the policy itself.
std::string name = "";
/// Callback to be used to understand if the policy should apply
/// to the given device.
Matcher matcher = nullptr;
/// Actual policy which decides what to do with a partial InputRecord.
Callback callback = nullptr;
/// Actual policy which decides what to do with a partial InputRecord, extended version
CallbackFull callbackFull = nullptr;
/// A callback which allows you to configure the behavior of the data relayer associated
Expand Down
10 changes: 10 additions & 0 deletions Framework/Core/include/Framework/DataProcessorLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ struct DataProcessorLabel {
{
return value == rhs.value;
}

bool operator<(const DataProcessorLabel& rhs) const
{
return value < rhs.value;
}

bool operator>(const DataProcessorLabel& rhs) const
{
return value > rhs.value;
}
};
} // namespace o2::framework
#endif // O2_FRAMEWORK_DATAPROCESSORLABEL_H_
Loading

0 comments on commit 95225bc

Please sign in to comment.