Skip to content

Commit

Permalink
Qatable (#13633)
Browse files Browse the repository at this point in the history
* TreeStream: Allow also for int8_t to be dumped as signed char

Signed-off-by: Felix Schlepper <[email protected]>

* AOD: Extend TrackQA table

* AOD: TrackQA leave _000 as default

* COMMON: Add helper macros for bitwise enum struct

* AOD: Add optional streamer to producer

---------

Signed-off-by: Felix Schlepper <[email protected]>
  • Loading branch information
f3sch authored Dec 2, 2024
1 parent 73a96c3 commit feea3ad
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 56 deletions.
66 changes: 66 additions & 0 deletions Common/Utils/include/CommonUtils/EnumBitOperators.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef O2_FRAMEWORK_ENUM_BIT_OPERATORS_H_
#define O2_FRAMEWORK_ENUM_BIT_OPERATORS_H_

#include <type_traits>

#define O2_DEFINE_ENUM_BIT_OPERATORS(enum_t) \
constexpr auto operator|(enum_t lhs, enum_t rhs) \
{ \
return static_cast<enum_t>( \
static_cast<std::underlying_type_t<enum_t>>(lhs) | \
static_cast<std::underlying_type_t<enum_t>>(rhs)); \
} \
\
constexpr auto operator&(enum_t lhs, enum_t rhs) \
{ \
return static_cast<enum_t>( \
static_cast<std::underlying_type_t<enum_t>>(lhs) & \
static_cast<std::underlying_type_t<enum_t>>(rhs)); \
} \
\
constexpr auto operator^(enum_t lhs, enum_t rhs) \
{ \
return static_cast<enum_t>( \
static_cast<std::underlying_type_t<enum_t>>(lhs) ^ \
static_cast<std::underlying_type_t<enum_t>>(rhs)); \
} \
\
constexpr auto operator~(enum_t op) \
{ \
return static_cast<enum_t>( \
~static_cast<std::underlying_type_t<enum_t>>(op)); \
} \
\
constexpr auto& operator|=(enum_t& lhs, enum_t rhs) \
{ \
lhs = lhs | rhs; \
return lhs; \
} \
\
constexpr auto& operator&=(enum_t& lhs, enum_t rhs) \
{ \
lhs = lhs & rhs; \
return lhs; \
} \
\
constexpr enum_t& operator^=(enum_t& lhs, enum_t rhs) \
{ \
lhs = lhs ^ rhs; \
return lhs; \
}

#define O2_ENUM_TEST_BIT(mask, value) ((mask & value) == value)
#define O2_ENUM_SET_BIT(bit) ((1 << bit))
#define O2_ENUM_ANY_BIT(enum) ((static_cast<std::underlying_type_t<decltype(enum)>>(enum) != 0))

#endif
7 changes: 7 additions & 0 deletions Common/Utils/include/CommonUtils/TreeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TreeStream
const char* getName() const { return mTree.GetName(); }
void setID(int id) { mID = id; }
int getID() const { return mID; }

TreeStream& operator<<(const Bool_t& b)
{
CheckIn('B', &b);
Expand All @@ -75,6 +76,12 @@ class TreeStream
return *this;
}

TreeStream& operator<<(const int8_t& i)
{
CheckIn('B', &i);
return *this;
}

TreeStream& operator<<(const UChar_t& c)
{
CheckIn('b', &c);
Expand Down
52 changes: 39 additions & 13 deletions Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
#include "TStopwatch.h"
#include "ZDCBase/Constants.h"
#include "GlobalTracking/MatchGlobalFwd.h"
#include "CommonUtils/TreeStreamRedirector.h"
#include "CommonUtils/EnumBitOperators.h"

#include <cstdint>
#include <limits>
#include <set>
#include <string>
#include <vector>
Expand Down Expand Up @@ -203,7 +207,15 @@ class BunchCrossings

std::vector<TimeWindow> mTimeWindows; // the time window structure covering the complete duration of mBCTimeVector
double mWindowSize; // the size of a single time window
}; // end internal class
}; // end internal class

// Steering bits for additional output during AOD production
enum struct AODProducerStreamerMask : uint8_t {
None = 0,
TrackQA = O2_ENUM_SET_BIT(0),
All = std::numeric_limits<std::underlying_type_t<AODProducerStreamerMask>>::max(),
};
O2_DEFINE_ENUM_BIT_OPERATORS(AODProducerStreamerMask)

class AODProducerWorkflowDPL : public Task
{
Expand Down Expand Up @@ -241,6 +253,9 @@ class AODProducerWorkflowDPL : public Task
std::unordered_set<GIndex> mGIDUsedBySVtx;
std::unordered_set<GIndex> mGIDUsedByStr;

AODProducerStreamerMask mStreamerMask;
std::shared_ptr<o2::utils::TreeStreamRedirector> mStreamer;

int mNThreads = 1;
bool mUseMC = true;
bool mEnableSV = true; // enable secondary vertices
Expand Down Expand Up @@ -339,6 +354,7 @@ class AODProducerWorkflowDPL : public Task
uint32_t mTrackCovOffDiag = 0xFFFF0000; // 7 bits
uint32_t mTrackSignal = 0xFFFFFF00; // 15 bits
uint32_t mTrackTime = 0xFFFFFFFF; // use full float precision for time
uint32_t mTPCTime0 = 0xFFFFFFE0; // 18 bits, providing 14256./(1<<19) = 0.027 TB precision e.g., ~0.13 mm in z
uint32_t mTrackTimeError = 0xFFFFFF00; // 15 bits
uint32_t mTrackPosEMCAL = 0xFFFFFF00; // 15 bits
uint32_t mTracklets = 0xFFFFFF00; // 15 bits
Expand Down Expand Up @@ -397,18 +413,28 @@ class AODProducerWorkflowDPL : public Task

struct TrackQA {
GID trackID;
float tpcTime0;
int16_t tpcdcaR;
int16_t tpcdcaZ;
uint8_t tpcClusterByteMask;
uint8_t tpcdEdxMax0R;
uint8_t tpcdEdxMax1R;
uint8_t tpcdEdxMax2R;
uint8_t tpcdEdxMax3R;
uint8_t tpcdEdxTot0R;
uint8_t tpcdEdxTot1R;
uint8_t tpcdEdxTot2R;
uint8_t tpcdEdxTot3R;
float tpcTime0{};
int16_t tpcdcaR{};
int16_t tpcdcaZ{};
uint8_t tpcClusterByteMask{};
uint8_t tpcdEdxMax0R{};
uint8_t tpcdEdxMax1R{};
uint8_t tpcdEdxMax2R{};
uint8_t tpcdEdxMax3R{};
uint8_t tpcdEdxTot0R{};
uint8_t tpcdEdxTot1R{};
uint8_t tpcdEdxTot2R{};
uint8_t tpcdEdxTot3R{};
int8_t dRefContY{std::numeric_limits<int8_t>::min()};
int8_t dRefContZ{std::numeric_limits<int8_t>::min()};
int8_t dRefContSnp{std::numeric_limits<int8_t>::min()};
int8_t dRefContTgl{std::numeric_limits<int8_t>::min()};
int8_t dRefContQ2Pt{std::numeric_limits<int8_t>::min()};
int8_t dRefGloY{std::numeric_limits<int8_t>::min()};
int8_t dRefGloZ{std::numeric_limits<int8_t>::min()};
int8_t dRefGloSnp{std::numeric_limits<int8_t>::min()};
int8_t dRefGloTgl{std::numeric_limits<int8_t>::min()};
int8_t dRefGloQ2Pt{std::numeric_limits<int8_t>::min()};
};

// helper struct for addToFwdTracksTable()
Expand Down
Loading

0 comments on commit feea3ad

Please sign in to comment.