Skip to content

Commit e8e5f9e

Browse files
authored
Merge branch 'AliceO2Group:dev' into TPC_CMV
2 parents 44b00c4 + a0f94b4 commit e8e5f9e

65 files changed

Lines changed: 2377 additions & 247 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/Utils/include/CommonUtils/EnumFlags.h

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string>
2525
#include <sstream>
2626
#include <limits>
27+
#include <bit>
2728
#include <bitset>
2829
#include <initializer_list>
2930
#include <cstdint>
@@ -34,7 +35,9 @@
3435
#include <iostream>
3536
#include <iomanip>
3637

38+
#ifndef GPUCA_GPUCODE
3739
#include "CommonUtils/StringUtils.h"
40+
#endif
3841

3942
namespace o2::utils
4043
{
@@ -55,6 +58,7 @@ concept EnumFlagHelper = requires {
5558
// This is very much inspired by much more extensive libraries like magic_enum.
5659
// Inspiration by its c++20 version (https://github.com/fix8mt/conjure_enum).
5760
// NOTE: Cannot detect if bit values past the underlying type are defined.
61+
#ifndef GPUCA_GPUCODE
5862
template <EnumFlagHelper E>
5963
struct FlagsHelper final {
6064
using U = std::underlying_type_t<E>;
@@ -317,10 +321,12 @@ struct FlagsHelper final {
317321
return false;
318322
}
319323
};
324+
#endif
320325

321326
} // namespace details::enum_flags
322327

323328
// Require an enum to fullfil what one would except from a bitset.
329+
#ifndef GPUCA_GPUCODE
324330
template <typename E>
325331
concept EnumFlag = requires {
326332
// range checks
@@ -332,6 +338,10 @@ concept EnumFlag = requires {
332338
requires !details::enum_flags::FlagsHelper<E>::hasNone(); // added automatically
333339
requires !details::enum_flags::FlagsHelper<E>::hasAll(); // added automatically
334340
};
341+
#else
342+
template <typename E>
343+
concept EnumFlag = details::enum_flags::EnumFlagHelper<E>;
344+
#endif
335345

336346
/**
337347
* \brief Class to aggregate and manage enum-based on-off flags.
@@ -358,7 +368,9 @@ template <EnumFlag E>
358368
class EnumFlags
359369
{
360370
static constexpr int DefaultBase{2};
371+
#ifndef GPUCA_GPUCODE
361372
using H = details::enum_flags::FlagsHelper<E>;
373+
#endif
362374
using U = std::underlying_type_t<E>;
363375
U mBits{0};
364376

@@ -388,18 +400,21 @@ class EnumFlags
388400
// Initialize with a list of flags.
389401
constexpr EnumFlags(std::initializer_list<E> flags) noexcept
390402
{
391-
std::for_each(flags.begin(), flags.end(), [this](const E f) noexcept { mBits |= to_bit(f); });
403+
for (const E f : flags) {
404+
mBits |= to_bit(f);
405+
}
392406
}
407+
#ifndef GPUCA_GPUCODE
393408
// Init from a string.
394409
//
395410
explicit EnumFlags(const std::string& str, int base = DefaultBase)
396411
{
397412
set(str, base);
398413
}
399-
// Destructor.
400-
constexpr ~EnumFlags() = default;
414+
#endif
401415

402-
static constexpr U None{0}; // Represents no flags set.
416+
static constexpr U None{0}; // Represents no flags set.
417+
#ifndef GPUCA_GPUCODE
403418
static constexpr U All{H::MaxRep}; // Represents all flags set.
404419

405420
// Return list of all enum values
@@ -432,6 +447,7 @@ class EnumFlags
432447
throw;
433448
}
434449
}
450+
#endif
435451
// Returns the raw bitset value.
436452
[[nodiscard]] constexpr auto value() const noexcept
437453
{
@@ -493,6 +509,7 @@ class EnumFlags
493509
}
494510

495511
// Checks if all flags are set.
512+
#ifndef GPUCA_GPUCODE
496513
[[nodiscard]] constexpr bool all() const noexcept
497514
{
498515
return mBits == All;
@@ -537,6 +554,7 @@ class EnumFlags
537554
}
538555
return oss.str();
539556
}
557+
#endif
540558

541559
// Checks if any flag is set (Boolean context).
542560
[[nodiscard]] constexpr explicit operator bool() const noexcept
@@ -645,6 +663,7 @@ class EnumFlags
645663
}
646664

647665
// Serializes the flag set to a string.
666+
#ifndef GPUCA_GPUCODE
648667
[[nodiscard]] std::string serialize() const
649668
{
650669
return std::to_string(mBits);
@@ -659,6 +678,7 @@ class EnumFlags
659678
}
660679
mBits = static_cast<U>(v);
661680
}
681+
#endif
662682

663683
// Counts the number of set bits (active flags).
664684
[[nodiscard]] constexpr size_t count() const noexcept
@@ -686,6 +706,7 @@ class EnumFlags
686706

687707
private:
688708
// Set implementation, bits was zeroed before.
709+
#ifndef GPUCA_GPUCODE
689710
void setImpl(const std::string& s, int base = 2)
690711
{
691712
// Helper to check if character is valid for given base
@@ -782,14 +803,17 @@ class EnumFlags
782803
throw std::invalid_argument("Cannot parse string!");
783804
}
784805
}
806+
#endif
785807
};
786808

809+
#ifndef GPUCA_GPUCODE
787810
template <EnumFlag E>
788811
std::ostream& operator<<(std::ostream& os, const EnumFlags<E>& f)
789812
{
790813
os << f.pstring(true);
791814
return os;
792815
}
816+
#endif
793817

794818
} // namespace o2::utils
795819

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/ChannelData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ struct ChannelData {
7676
void print() const;
7777
void printLog() const;
7878
[[nodiscard]] uint8_t getChannelID() const { return ChId; }
79-
[[nodiscard]] uint16_t getTime() const { return CFDTime; }
80-
[[nodiscard]] uint16_t getAmp() const { return QTCAmpl; }
79+
[[nodiscard]] int16_t getTime() const { return CFDTime; }
80+
[[nodiscard]] int16_t getAmp() const { return QTCAmpl; }
8181

8282
bool operator==(ChannelData const& other) const
8383
{

DataFormats/Detectors/FIT/FV0/include/DataFormatsFV0/ChannelData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ struct ChannelData {
7676
void print() const;
7777
void printLog() const;
7878
[[nodiscard]] uint8_t getChannelID() const { return ChId; }
79-
[[nodiscard]] uint16_t getTime() const { return CFDTime; }
80-
[[nodiscard]] uint16_t getAmp() const { return QTCAmpl; }
79+
[[nodiscard]] int16_t getTime() const { return CFDTime; }
80+
[[nodiscard]] int16_t getAmp() const { return QTCAmpl; }
8181

8282
bool operator==(ChannelData const& other) const
8383
{

DataFormats/Detectors/ITSMFT/ITS/include/DataFormatsITS/TrackITS.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,33 @@ class TrackITSExt : public TrackITS
210210
return mIndex;
211211
}
212212

213+
#ifndef GPUCA_GPUCODE
214+
// build order-independent hash via the external cluster idx (unique within a TF) for the selected layers
215+
// cluster indices are either sorted inward or outward
216+
size_t hash(uint16_t layerMask = 0xFFFF, bool inward = true) const noexcept
217+
{
218+
size_t h1 = 0, h2 = 0;
219+
int from = (int)getLastClusterLayer(), to = -1, step = -1;
220+
if (inward) {
221+
from = (int)getFirstClusterLayer();
222+
to = MaxClusters;
223+
step = 1;
224+
}
225+
// clusters are stored continously but they do not necesarrily correspond to the layers
226+
for (int layer = from, slot{0}; layer != to; layer += step) {
227+
if (hasHitOnLayer(layer)) {
228+
int idx = mIndex[slot++];
229+
if (layerMask & (uint16_t(1) << layer)) {
230+
size_t v = std::hash<int>{}(idx);
231+
h1 ^= v;
232+
h2 += v * 0x9e3779b97f4a7c15ULL; // boost's hash_combine
233+
}
234+
}
235+
}
236+
return h1 ^ (h2 << 1);
237+
}
238+
#endif
239+
213240
private:
214241
std::array<int, MaxClusters> mIndex = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; ///< Indices of associated clusters
215242
ClassDefNV(TrackITSExt, 3);

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class AODProducerWorkflowDPL : public Task
249249
bool mThinTracks{false};
250250
bool mPropTracks{false};
251251
bool mPropMuons{false};
252+
bool mStoreAllMFTCov{false};
252253
float mTrackQCKeepGlobalTracks{false};
253254
float mTrackQCRetainOnlydEdx{false};
254255
float mTrackQCFraction{0.00};
@@ -547,8 +548,8 @@ class AODProducerWorkflowDPL : public Task
547548
template <typename TRDsExtraCursorType>
548549
void addToTRDsExtra(const o2::globaltracking::RecoContainer& recoData, TRDsExtraCursorType& trdExtraCursor, const GIndex& trkIdx, int trkTableIdx);
549550

550-
template <typename mftTracksCursorType, typename AmbigMFTTracksCursorType>
551-
void addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
551+
template <typename mftTracksCursorType, typename mftTracksCovCursorType, typename AmbigMFTTracksCursorType>
552+
void addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, mftTracksCovCursorType& mftTracksCovCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
552553
GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID,
553554
std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap);
554555

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ void AODProducerWorkflowDPL::addToTRDsExtra(const o2::globaltracking::RecoContai
507507
trdExtraCursor(trkTableIdx, q0s, q1s, q2s, q0sCor, q1sCor, q2sCor, ttgls, tphis);
508508
}
509509

510-
template <typename mftTracksCursorType, typename AmbigMFTTracksCursorType>
511-
void AODProducerWorkflowDPL::addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
510+
template <typename mftTracksCursorType, typename mftTracksCovCursorType, typename AmbigMFTTracksCursorType>
511+
void AODProducerWorkflowDPL::addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, mftTracksCovCursorType& mftTracksCovCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
512512
GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID,
513513
std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap)
514514
{
@@ -543,6 +543,30 @@ void AODProducerWorkflowDPL::addToMFTTracksTable(mftTracksCursorType& mftTracksC
543543
truncateFloatFraction(track.getTrackChi2(), mTrackChi2),
544544
truncateFloatFraction(trackTime, mTrackTime),
545545
truncateFloatFraction(trackTimeRes, mTrackTimeError));
546+
if (mStoreAllMFTCov) {
547+
float sX = TMath::Sqrt(track.getSigma2X());
548+
float sY = TMath::Sqrt(track.getSigma2Y());
549+
float sPhi = TMath::Sqrt(track.getSigma2Phi());
550+
float sTgl = TMath::Sqrt(track.getSigma2Tanl());
551+
float sQ2Pt = TMath::Sqrt(track.getSigma2InvQPt());
552+
553+
mftTracksCovCursor(mTableTrMFTID,
554+
truncateFloatFraction(sX, mTrackCovDiag),
555+
truncateFloatFraction(sY, mTrackCovDiag),
556+
truncateFloatFraction(sPhi, mTrackCovDiag),
557+
truncateFloatFraction(sTgl, mTrackCovDiag),
558+
truncateFloatFraction(sQ2Pt, mTrackCovDiag),
559+
(Char_t)(128. * track.getCovariances()(0, 1) / (sX * sY)),
560+
(Char_t)(128. * track.getCovariances()(0, 2) / (sPhi * sX)),
561+
(Char_t)(128. * track.getCovariances()(1, 2) / (sPhi * sY)),
562+
(Char_t)(128. * track.getCovariances()(0, 3) / (sTgl * sX)),
563+
(Char_t)(128. * track.getCovariances()(1, 3) / (sTgl * sY)),
564+
(Char_t)(128. * track.getCovariances()(2, 3) / (sTgl * sPhi)),
565+
(Char_t)(128. * track.getCovariances()(0, 4) / (sQ2Pt * sX)),
566+
(Char_t)(128. * track.getCovariances()(1, 4) / (sQ2Pt * sY)),
567+
(Char_t)(128. * track.getCovariances()(2, 4) / (sQ2Pt * sPhi)),
568+
(Char_t)(128. * track.getCovariances()(3, 4) / (sQ2Pt * sTgl)));
569+
}
546570
if (needBCSlice) {
547571
ambigMFTTracksCursor(mTableTrMFTID, bcSlice);
548572
}
@@ -579,10 +603,13 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
579603
int nToReserve = end - start; // + last index for a given table
580604
if (src == GIndex::Source::MFT) {
581605
mftTracksCursor.reserve(nToReserve + mftTracksCursor.lastIndex());
606+
if (mStoreAllMFTCov) {
607+
mftTracksCovCursor.reserve(nToReserve + mftTracksCovCursor.lastIndex());
608+
}
582609
} else if (src == GIndex::Source::MCH || src == GIndex::Source::MFTMCH || src == GIndex::Source::MCHMID) {
583610
fwdTracksCursor.reserve(nToReserve + fwdTracksCursor.lastIndex());
584611
fwdTracksCovCursor.reserve(nToReserve + fwdTracksCovCursor.lastIndex());
585-
if (src == GIndex::Source::MFTMCH) {
612+
if (!mStoreAllMFTCov && src == GIndex::Source::MFTMCH) {
586613
mftTracksCovCursor.reserve(nToReserve + mftTracksCovCursor.lastIndex());
587614
}
588615
} else {
@@ -597,7 +624,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
597624
if (trackIndex.isAmbiguous() && mGIDToTableMFTID.find(trackIndex) != mGIDToTableMFTID.end()) { // was it already stored ?
598625
continue;
599626
}
600-
addToMFTTracksTable(mftTracksCursor, ambigMFTTracksCursor, trackIndex, data, collisionID, collisionBC, bcsMap);
627+
addToMFTTracksTable(mftTracksCursor, mftTracksCovCursor, ambigMFTTracksCursor, trackIndex, data, collisionID, collisionBC, bcsMap);
601628
mGIDToTableMFTID.emplace(trackIndex, mTableTrMFTID);
602629
mTableTrMFTID++;
603630
} else if (src == GIndex::Source::MCH || src == GIndex::Source::MFTMCH || src == GIndex::Source::MCHMID) { // FwdTracks tracks are treated separately since they are stored in a different table
@@ -929,22 +956,24 @@ void AODProducerWorkflowDPL::addToFwdTracksTable(FwdTracksCursorType& fwdTracksC
929956
float sX = TMath::Sqrt(mfttrack.getSigma2X()), sY = TMath::Sqrt(mfttrack.getSigma2Y()), sPhi = TMath::Sqrt(mfttrack.getSigma2Phi()),
930957
sTgl = TMath::Sqrt(mfttrack.getSigma2Tanl()), sQ2Pt = TMath::Sqrt(mfttrack.getSigma2InvQPt());
931958

932-
mftTracksCovCursor(fwdInfo.matchmfttrackid,
933-
truncateFloatFraction(sX, mTrackCovDiag),
934-
truncateFloatFraction(sY, mTrackCovDiag),
935-
truncateFloatFraction(sPhi, mTrackCovDiag),
936-
truncateFloatFraction(sTgl, mTrackCovDiag),
937-
truncateFloatFraction(sQ2Pt, mTrackCovDiag),
938-
(Char_t)(128. * mfttrack.getCovariances()(0, 1) / (sX * sY)),
939-
(Char_t)(128. * mfttrack.getCovariances()(0, 2) / (sPhi * sX)),
940-
(Char_t)(128. * mfttrack.getCovariances()(1, 2) / (sPhi * sY)),
941-
(Char_t)(128. * mfttrack.getCovariances()(0, 3) / (sTgl * sX)),
942-
(Char_t)(128. * mfttrack.getCovariances()(1, 3) / (sTgl * sY)),
943-
(Char_t)(128. * mfttrack.getCovariances()(2, 3) / (sTgl * sPhi)),
944-
(Char_t)(128. * mfttrack.getCovariances()(0, 4) / (sQ2Pt * sX)),
945-
(Char_t)(128. * mfttrack.getCovariances()(1, 4) / (sQ2Pt * sY)),
946-
(Char_t)(128. * mfttrack.getCovariances()(2, 4) / (sQ2Pt * sPhi)),
947-
(Char_t)(128. * mfttrack.getCovariances()(3, 4) / (sQ2Pt * sTgl)));
959+
if (!mStoreAllMFTCov) {
960+
mftTracksCovCursor(fwdInfo.matchmfttrackid,
961+
truncateFloatFraction(sX, mTrackCovDiag),
962+
truncateFloatFraction(sY, mTrackCovDiag),
963+
truncateFloatFraction(sPhi, mTrackCovDiag),
964+
truncateFloatFraction(sTgl, mTrackCovDiag),
965+
truncateFloatFraction(sQ2Pt, mTrackCovDiag),
966+
(Char_t)(128. * mfttrack.getCovariances()(0, 1) / (sX * sY)),
967+
(Char_t)(128. * mfttrack.getCovariances()(0, 2) / (sPhi * sX)),
968+
(Char_t)(128. * mfttrack.getCovariances()(1, 2) / (sPhi * sY)),
969+
(Char_t)(128. * mfttrack.getCovariances()(0, 3) / (sTgl * sX)),
970+
(Char_t)(128. * mfttrack.getCovariances()(1, 3) / (sTgl * sY)),
971+
(Char_t)(128. * mfttrack.getCovariances()(2, 3) / (sTgl * sPhi)),
972+
(Char_t)(128. * mfttrack.getCovariances()(0, 4) / (sQ2Pt * sX)),
973+
(Char_t)(128. * mfttrack.getCovariances()(1, 4) / (sQ2Pt * sY)),
974+
(Char_t)(128. * mfttrack.getCovariances()(2, 4) / (sQ2Pt * sPhi)),
975+
(Char_t)(128. * mfttrack.getCovariances()(3, 4) / (sQ2Pt * sTgl)));
976+
}
948977
}
949978

950979
std::uint64_t bcOfTimeRef;
@@ -1830,6 +1859,7 @@ void AODProducerWorkflowDPL::init(InitContext& ic)
18301859
mPropTracks = ic.options().get<bool>("propagate-tracks");
18311860
mMaxPropXiu = ic.options().get<float>("propagate-tracks-max-xiu");
18321861
mPropMuons = ic.options().get<bool>("propagate-muons");
1862+
mStoreAllMFTCov = ic.options().get<bool>("store-all-mft-cov");
18331863
if (auto s = ic.options().get<std::string>("with-streamers"); !s.empty()) {
18341864
mStreamerFlags.set(s);
18351865
if (mStreamerFlags) {
@@ -3524,6 +3554,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
35243554
ConfigParamSpec{"propagate-tracks-max-xiu", VariantType::Float, 5.0f, {"Propagate tracks to IP if X_IU smaller than this value (and if propagate tracks enabled)"}},
35253555
ConfigParamSpec{"hepmc-update", VariantType::String, "always", {"When to update HepMC Aux tables: always - force update, never - never update, all - if all keys are present, any - when any key is present (not valid yet)"}},
35263556
ConfigParamSpec{"propagate-muons", VariantType::Bool, false, {"Propagate muons to IP"}},
3557+
ConfigParamSpec{"store-all-mft-cov", VariantType::Bool, false, {"Store covariance matrices for all MFT tracks"}},
35273558
ConfigParamSpec{"thin-tracks", VariantType::Bool, false, {"Produce thinned track tables"}},
35283559
ConfigParamSpec{"trackqc-keepglobaltracks", VariantType::Bool, false, {"Always keep TrackQA for global tracks"}},
35293560
ConfigParamSpec{"trackqc-retainonlydedx", VariantType::Bool, false, {"Keep only dEdx information, zero out everything else"}},

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/TRUDataHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <array>
1515
#include <bitset>
16+
#include <climits>
1617
#include <cstdint>
1718
#include <exception>
1819
#include <iosfwd>

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace o2::checkresid
2020
{
2121
/// create a processor spec
22-
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly);
22+
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly, bool postProcOnly);
2323

2424
} // namespace o2::checkresid
2525

0 commit comments

Comments
 (0)