Skip to content

Commit 4dd5374

Browse files
committed
Feat: add FLiteColShapes table
1 parent 6553b66 commit 4dd5374

4 files changed

Lines changed: 76 additions & 30 deletions

File tree

PWGCF/Femto/Core/femtoUtils.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ inline int signum(T x)
243243
}
244244

245245
template <typename T>
246-
inline T binLinear(float value, float lo, float hi, float step)
246+
T binLinear(float value, float lo, float hi, float step)
247247
{
248248
float v = std::clamp(value, lo, hi);
249249
auto idx = static_cast<int64_t>(std::round((v - lo) / step));
@@ -253,46 +253,46 @@ inline T binLinear(float value, float lo, float hi, float step)
253253
}
254254

255255
template <typename T>
256-
inline float unBinLinear(T binned, float lo, float step)
256+
float unBinLinear(T binned, float lo, float step)
257257
{
258258
auto idx = static_cast<int64_t>(binned) - static_cast<int64_t>(std::numeric_limits<T>::min());
259259
return lo + static_cast<float>(idx) * step;
260260
}
261261

262262
template <typename T>
263-
inline T binLogSigned(float signedValue, float magMin, float magMax)
263+
T binLogSigned(float signedValue, float magMin, float magMax)
264264
{
265265
static_assert(std::is_unsigned_v<T>, "binLogSigned requires an unsigned storage type");
266-
constexpr uint32_t TotalBits = sizeof(T) * 8;
267-
constexpr uint32_t HalfLevels = 1u << (TotalBits - 1);
268-
uint32_t sign = (signedValue < 0.f) ? 1u : 0u;
269-
float mag = std::clamp(std::fabs(signedValue), magMin, magMax);
270-
float logLo = std::log(magMin);
271-
float logHi = std::log(magMax);
272-
float step = (logHi - logLo) / static_cast<float>(HalfLevels - 1);
273-
auto idx = static_cast<uint32_t>(std::round((std::log(mag) - logLo) / step));
274-
idx = std::clamp(idx, 0u, HalfLevels - 1);
275-
return static_cast<T>((sign << (TotalBits - 1)) | idx);
266+
constexpr uint64_t TotalBits = sizeof(T) * 8;
267+
constexpr uint64_t HalfLevels = uint64_t{1} << (TotalBits - 1);
268+
const uint64_t sign = (signedValue < 0.f) ? uint64_t{1} : uint64_t{0};
269+
const float mag = std::clamp(std::fabs(signedValue), magMin, magMax);
270+
const float logLo = std::log(magMin);
271+
const float logHi = std::log(magMax);
272+
const float step = (logHi - logLo) / static_cast<float>(HalfLevels - 1);
273+
auto idx = static_cast<int64_t>(std::round((std::log(mag) - logLo) / step));
274+
idx = std::clamp(idx, int64_t{0}, static_cast<int64_t>(HalfLevels - 1));
275+
return static_cast<T>((sign << (TotalBits - 1)) | static_cast<uint64_t>(idx));
276276
}
277277

278278
template <typename T>
279-
inline float unBinLogSigned(T binned, float magMin, float magMax)
279+
float unBinLogSigned(T binned, float magMin, float magMax)
280280
{
281-
constexpr uint32_t TotalBits = sizeof(T) * 8;
282-
constexpr uint32_t HalfLevels = 1u << (TotalBits - 1);
283-
constexpr T SignMask = static_cast<T>(1u << (TotalBits - 1));
281+
static_assert(std::is_unsigned_v<T>, "unBinLogSigned requires an unsigned storage type");
282+
constexpr uint64_t TotalBits = sizeof(T) * 8;
283+
constexpr uint64_t HalfLevels = uint64_t{1} << (TotalBits - 1);
284+
constexpr T SignMask = static_cast<T>(uint64_t{1} << (TotalBits - 1));
284285
constexpr T MagMask = static_cast<T>(SignMask - 1);
285-
float sign = (binned & SignMask) ? -1.f : 1.f;
286-
uint32_t idx = binned & MagMask;
287-
float logLo = std::log(magMin);
288-
float logHi = std::log(magMax);
289-
float step = (logHi - logLo) / static_cast<float>(HalfLevels - 1);
290-
float mag = std::exp(logLo + static_cast<float>(idx) * step);
291-
return sign * mag;
286+
const float sign = (binned & SignMask) ? -1.f : 1.f;
287+
const auto idx = static_cast<uint64_t>(binned & MagMask);
288+
const float logLo = std::log(magMin);
289+
const float logHi = std::log(magMax);
290+
const float step = (logHi - logLo) / static_cast<float>(HalfLevels - 1);
291+
return sign * std::exp(logLo + static_cast<float>(idx) * step);
292292
}
293293

294294
template <typename T>
295-
inline int unBinSign(T binned)
295+
int unBinSign(T binned)
296296
{
297297
static_assert(std::is_unsigned_v<T>, "unBinSign requires an unsigned storage type");
298298
constexpr uint64_t TotalBits = sizeof(T) * 8;
@@ -301,7 +301,7 @@ inline int unBinSign(T binned)
301301
}
302302

303303
template <typename T>
304-
inline T binLogUnsigned(float value, float magMin, float magMax)
304+
T binLogUnsigned(float value, float magMin, float magMax)
305305
{
306306
static_assert(std::is_unsigned_v<T>, "binLogUnsigned requires an unsigned storage type");
307307
constexpr uint64_t TotalBits = sizeof(T) * 8;
@@ -316,7 +316,7 @@ inline T binLogUnsigned(float value, float magMin, float magMax)
316316
}
317317

318318
template <typename T>
319-
inline float unBinLogUnsigned(T binned, float magMin, float magMax)
319+
float unBinLogUnsigned(T binned, float magMin, float magMax)
320320
{
321321
constexpr uint64_t TotalBits = sizeof(T) * 8;
322322
constexpr uint64_t Levels = uint64_t{1} << TotalBits;

PWGCF/Femto/Core/partitions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
(o2::aod::femtocollisions::posZ >= (selection).vtxZMin && o2::aod::femtocollisions::posZ <= (selection).vtxZMax) && \
2323
(o2::aod::femtocollisions::mult >= (selection).multMin && o2::aod::femtocollisions::mult <= (selection).multMax) && \
2424
(o2::aod::femtocollisions::cent >= (selection).centMin && o2::aod::femtocollisions::cent <= (selection).centMax) && \
25-
(o2::aod::femtocollisions::magField >= o2::framework::expressions::as<int8_t>((selection).magFieldMin) && \
26-
o2::aod::femtocollisions::magField <= o2::framework::expressions::as<int8_t>((selection).magFieldMax)) && \
25+
(o2::aod::femtocollisions::magField >= o2::framework::expressions::as<int8_t>((selection).magFieldMin)) && \
26+
(o2::aod::femtocollisions::magField <= o2::framework::expressions::as<int8_t>((selection).magFieldMax)) && \
2727
ncheckbit(o2::aod::femtocollisions::mask, (selection).collisionMask)
2828

2929
// macro for track momentum, i.e. ||q|*pT/q| * cosh(eta)

PWGCF/Femto/DataModel/FemtoTables.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,20 @@ namespace lite
5252
constexpr float PosZMin = -20.f;
5353
constexpr float PosZMax = 20.f;
5454
constexpr float PosZStep = 0.5f; // bin vtz in 0.5cm steps
55+
5556
constexpr float CentMin = 0.f;
5657
constexpr float CentMax = 100.f;
5758
constexpr float CentStep = 0.5f; // bin centrality in 0.5% steps
59+
5860
constexpr float MultStep = 1.f; // round multiplicity to nearest integer
5961

62+
constexpr float QvecMin = 1e-3f; // close to 0, but not 0 due to log
63+
constexpr float QvecMax = 1e3f; // usual range for qvector
64+
65+
constexpr float EventPlaneAngleMin = 0.f;
66+
constexpr float EventPlaneAngleMax = o2::constants::math::TwoPI; // angle bound in [0,2pi)
67+
constexpr float EventPlaneAngleStep = (EventPlaneAngleMax - EventPlaneAngleMin) / 65536.f;
68+
6069
inline uint8_t binPosZ(float posZ) { return o2::analysis::femto::utils::binLinear<uint8_t>(posZ, PosZMin, PosZMax, PosZStep); }
6170
inline float unBinPosZ(uint8_t binned) { return o2::analysis::femto::utils::unBinLinear<uint8_t>(binned, PosZMin, PosZStep); }
6271

@@ -66,9 +75,17 @@ inline float unBinCent(uint8_t binned) { return o2::analysis::femto::utils::unBi
6675
inline uint16_t binMult(float mult) { return o2::analysis::femto::utils::binLinear<uint16_t>(mult, 0.f, 65535.f, MultStep); } // use full range of uint16_t
6776
inline float unBinMult(uint16_t binned) { return o2::analysis::femto::utils::unBinLinear<uint16_t>(binned, 0.f, MultStep); }
6877

78+
inline uint16_t binQvec(float qvec) { return o2::analysis::femto::utils::binLogUnsigned<uint16_t>(qvec, QvecMin, QvecMax); }
79+
inline float unBinQvec(uint16_t binned) { return o2::analysis::femto::utils::unBinLogUnsigned<uint16_t>(binned, QvecMin, QvecMax); }
80+
81+
inline uint16_t binEventPlaneAngle(float eventPlaneAngle) { return o2::analysis::femto::utils::binLinear<uint16_t>(eventPlaneAngle, EventPlaneAngleMin, EventPlaneAngleMax, EventPlaneAngleStep); }
82+
inline float unBinEventPlaneAngle(uint16_t binned) { return o2::analysis::femto::utils::unBinLinear<uint16_t>(binned, EventPlaneAngleMin, EventPlaneAngleStep); }
83+
6984
DECLARE_SOA_COLUMN(BinnedPosZ, binnedPosZ, uint8_t);
7085
DECLARE_SOA_COLUMN(BinnedMult, binnedMult, uint16_t);
7186
DECLARE_SOA_COLUMN(BinnedCent, binnedCent, uint8_t);
87+
DECLARE_SOA_COLUMN(BinnedQvec, binnedQvec, uint16_t);
88+
DECLARE_SOA_COLUMN(BinnedEventPlaneAngle, binnedEventPlaneAngle, uint16_t);
7289

7390
DECLARE_SOA_DYNAMIC_COLUMN(PosZ, posZ,
7491
[](uint8_t binnedPosZ) -> float {
@@ -82,6 +99,14 @@ DECLARE_SOA_DYNAMIC_COLUMN(Cent, cent,
8299
[](uint8_t binnedCent) -> float {
83100
return unBinCent(binnedCent);
84101
});
102+
DECLARE_SOA_DYNAMIC_COLUMN(Qvec, qvec,
103+
[](uint16_t binnedQvec) -> float {
104+
return unBinQvec(binnedQvec);
105+
});
106+
DECLARE_SOA_DYNAMIC_COLUMN(EventPlaneAngle, eventPlaneAngle,
107+
[](uint16_t binnedEventPlaneAngle) -> float {
108+
return unBinEventPlaneAngle(binnedEventPlaneAngle);
109+
});
85110
} // namespace lite
86111
} // namespace femtocollisions
87112

@@ -120,11 +145,21 @@ DECLARE_SOA_TABLE_STAGED_VERSIONED(FColSphericities_001, "FCOLSPHERICITY", 1, //
120145
femtocollisions::Sphericity);
121146
using FColSphericities = FColSphericities_001;
122147

123-
// table for qn values
148+
// table for event shape analysis
124149
DECLARE_SOA_TABLE_STAGED_VERSIONED(FColShapes_001, "FCOLSHAPE", 1, //! event shape
125150
femtocollisions::Qvec,
126151
femtocollisions::EventPlaneAngle);
127152
using FColShapes = FColShapes_001;
153+
using StoredFColShapes = StoredFColShapes_001;
154+
155+
// lite table for event shape analysis
156+
DECLARE_SOA_TABLE_STAGED_VERSIONED(FLiteColShapes_001, "FLITECOLSHAPE", 1, //! event shape
157+
femtocollisions::lite::BinnedQvec,
158+
femtocollisions::lite::BinnedEventPlaneAngle,
159+
femtocollisions::lite::Qvec<femtocollisions::lite::BinnedQvec>,
160+
femtocollisions::lite::EventPlaneAngle<femtocollisions::lite::BinnedEventPlaneAngle>);
161+
using FLiteColShapes = FLiteColShapes_001;
162+
using StoredFLiteColShapes = StoredFLiteColShapes_001;
128163

129164
// table for primary vertex location
130165
DECLARE_SOA_TABLE_STAGED_VERSIONED(FColPos_001, "FCOLPOS", 1, //! full vertex position

PWGCF/Femto/TableProducer/femtoProducerLiteConverter.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace o2::analysis::femto;
2626

2727
struct FemtoProducerLiteConverter {
2828
o2::framework::Produces<o2::aod::FCols> producedCols;
29+
o2::framework::Produces<o2::aod::FColShapes> producedColShapes;
2930
o2::framework::Produces<o2::aod::FTracks> producedTracks;
3031
o2::framework::Produces<o2::aod::FLambdas> producedLambdas;
3132
o2::framework::Produces<o2::aod::FK0shorts> producedK0shorts;
@@ -36,6 +37,9 @@ struct FemtoProducerLiteConverter {
3637

3738
void init(o2::framework::InitContext&)
3839
{
40+
if (!doprocessLiteCols) {
41+
LOG(fatal) << "At least processLiteCols needs to be enabled, otherwise the collision index points no where!";
42+
}
3943
}
4044

4145
void processLiteCols(o2::aod::FLiteCols::iterator const& liteCol)
@@ -47,6 +51,13 @@ struct FemtoProducerLiteConverter {
4751
}
4852
PROCESS_SWITCH(FemtoProducerLiteConverter, processLiteCols, "Convert FLiteCols to FCols", true);
4953

54+
void processLiteColShapes(o2::aod::FLiteColShapes::iterator const& liteColShape)
55+
{
56+
producedColShapes(liteColShape.qvec(),
57+
liteColShape.eventPlaneAngle());
58+
}
59+
PROCESS_SWITCH(FemtoProducerLiteConverter, processLiteColShapes, "Convert FLiteColShapes to FColShapes", false);
60+
5061
void processLiteTracks(o2::aod::FLiteTracks::iterator const& liteTrack)
5162
{
5263
producedTracks(liteTrack.fLiteColId(),

0 commit comments

Comments
 (0)