Skip to content

Commit dc4bf3a

Browse files
authored
Introducing McParticle version 001 (#8041)
* Add DECLARE_EQUIVALENT_FOR_INDEX * add _ for slice and array index * MCParticle version 001 with slice and array * Equivalent for McParticles
1 parent b728b2d commit dc4bf3a

3 files changed

Lines changed: 67 additions & 14 deletions

File tree

Framework/Core/include/Framework/ASoA.h

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,11 +1382,28 @@ using JoinBase = decltype(join(std::declval<Ts>()...));
13821382
template <typename T1, typename T2>
13831383
using ConcatBase = decltype(concat(std::declval<T1>(), std::declval<T2>()));
13841384

1385-
template <typename T1, typename T2>
1386-
constexpr auto is_binding_compatible_v()
1385+
template <typename B, typename E>
1386+
struct EquivalentIndex {
1387+
constexpr static bool value = false;
1388+
};
1389+
1390+
template <typename B, typename E>
1391+
constexpr bool is_index_equivalent_v = EquivalentIndex<B, E>::value;
1392+
1393+
template <typename T, typename... Os>
1394+
constexpr bool are_bindings_compatible_v(framework::pack<Os...>&&)
13871395
{
1388-
return framework::pack_size(
1389-
framework::intersected_pack_t<originals_pack_t<T1>, originals_pack_t<T2>>{}) > 0;
1396+
if constexpr (is_type_with_originals_v<T>) {
1397+
return (are_bindings_compatible_v<Os>(originals_pack_t<T>{}) || ...);
1398+
} else {
1399+
return ((std::is_same_v<T, Os> || is_index_equivalent_v<T, Os>) || ...);
1400+
}
1401+
}
1402+
1403+
template <typename T, typename B>
1404+
constexpr bool is_binding_compatible_v()
1405+
{
1406+
return are_bindings_compatible_v<T>(originals_pack_t<B>{});
13901407
}
13911408

13921409
} // namespace o2::soa
@@ -1397,6 +1414,12 @@ constexpr auto is_binding_compatible_v()
13971414
using metadata = std::void_t<T>; \
13981415
}
13991416

1417+
#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
1418+
template <> \
1419+
struct EquivalentIndex<_Base_, _Equiv_> { \
1420+
constexpr static bool value = true; \
1421+
}
1422+
14001423
#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
14011424
struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
14021425
static constexpr const char* mLabel = _Label_; \
@@ -1549,7 +1572,7 @@ constexpr auto is_binding_compatible_v()
15491572

15501573
#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
15511574

1552-
///ARRAY
1575+
/// ARRAY
15531576
#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) \
15541577
struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
15551578
static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
@@ -1628,7 +1651,7 @@ constexpr auto is_binding_compatible_v()
16281651

16291652
#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
16301653

1631-
///NORMAL
1654+
/// NORMAL
16321655
#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) \
16331656
struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
16341657
static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
@@ -1701,7 +1724,7 @@ constexpr auto is_binding_compatible_v()
17011724

17021725
#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
17031726

1704-
///SELF
1727+
/// SELF
17051728
#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
17061729
struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
17071730
static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
@@ -1808,7 +1831,7 @@ constexpr auto is_binding_compatible_v()
18081831
void const* mBinding = nullptr; \
18091832
};
18101833

1811-
#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
1834+
#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
18121835
/// SELF ARRAY
18131836
#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
18141837
struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
@@ -1867,7 +1890,8 @@ constexpr auto is_binding_compatible_v()
18671890
void const* mBinding = nullptr; \
18681891
};
18691892

1870-
#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
1893+
#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
1894+
18711895
/// A dynamic column is a column whose values are derived
18721896
/// from those of other real columns. These can be used for
18731897
/// example to provide different coordinate systems (e.g. polar,

Framework/Core/include/Framework/AnalysisDataModel.h

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Mother0, mother0, int, "McParticles_Mother0")
795795
DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Mother1, mother1, int, "McParticles_Mother1"); //! Track index of the last mother
796796
DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Daughter0, daughter0, int, "McParticles_Daughter0"); //! Track index of the first daugther
797797
DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Daughter1, daughter1, int, "McParticles_Daughter1"); //! Track index of the last daugther
798-
DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(Daughters, daughters); //! Daughter tracks (possibly empty) slice
799-
DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(Mothers, mothers); //! Mother tracks (possible empty) array
798+
DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(Mothers, mothers); //! Mother tracks (possible empty) array. Iterate over mcParticle.mothers_as<aod::McParticles>())
799+
DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(Daughters, daughters); //! Daughter tracks (possibly empty) slice. Check for non-zero with mcParticle.has_daughters(). Iterate over mcParticle.daughters_as<aod::McParticles>())
800800
DECLARE_SOA_COLUMN(Weight, weight, float); //! MC weight
801801
DECLARE_SOA_COLUMN(Px, px, float); //! Momentum in x in GeV/c
802802
DECLARE_SOA_COLUMN(Py, py, float); //! Momentum in y in GeV/c
@@ -847,7 +847,7 @@ DECLARE_SOA_EXPRESSION_COLUMN(Y, y, float, //! Particle rapidity, conditionally
847847
(aod::mcparticle::e - aod::mcparticle::pz))));
848848
} // namespace mcparticle
849849

850-
DECLARE_SOA_TABLE_FULL(StoredMcParticles, "McParticles", "AOD", "MCPARTICLE", //! On disk version of the MC particle table
850+
DECLARE_SOA_TABLE_FULL(StoredMcParticles_000, "McParticles", "AOD", "MCPARTICLE", //! MC particle table, version 000
851851
o2::soa::Index<>, mcparticle::McCollisionId,
852852
mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags,
853853
mcparticle::Mother0Id, mcparticle::Mother1Id,
@@ -860,15 +860,42 @@ DECLARE_SOA_TABLE_FULL(StoredMcParticles, "McParticles", "AOD", "MCPARTICLE", //
860860
mcparticle::GetProcess<mcparticle::Flags, mcparticle::StatusCode>,
861861
mcparticle::IsPhysicalPrimary<mcparticle::Flags>);
862862

863-
DECLARE_SOA_EXTENDED_TABLE(McParticles, StoredMcParticles, "MCPARTICLE", //! Basic MC particle properties
863+
DECLARE_SOA_TABLE_FULL(StoredMcParticles_001, "McParticles_001", "AOD", "MCPARTICLE_001", //! MC particle table, version 001
864+
o2::soa::Index<>, mcparticle::McCollisionId,
865+
mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags,
866+
mcparticle::MothersIds, mcparticle::DaughtersIdSlice, mcparticle::Weight,
867+
mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E,
868+
mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt,
869+
mcparticle::ProducedByGenerator<mcparticle::Flags>,
870+
mcparticle::FromBackgroundEvent<mcparticle::Flags>,
871+
mcparticle::GetGenStatusCode<mcparticle::Flags, mcparticle::StatusCode>,
872+
mcparticle::GetProcess<mcparticle::Flags, mcparticle::StatusCode>,
873+
mcparticle::IsPhysicalPrimary<mcparticle::Flags>);
874+
875+
DECLARE_SOA_EXTENDED_TABLE(McParticles_000, StoredMcParticles_000, "MCPARTICLE", //! Basic MC particle properties
876+
mcparticle::Phi,
877+
mcparticle::Eta,
878+
mcparticle::Pt,
879+
mcparticle::P,
880+
mcparticle::Y);
881+
882+
DECLARE_SOA_EXTENDED_TABLE(McParticles_001, StoredMcParticles_001, "MCPARTICLE_001", //! Basic MC particle properties
864883
mcparticle::Phi,
865884
mcparticle::Eta,
866885
mcparticle::Pt,
867886
mcparticle::P,
868887
mcparticle::Y);
869888

889+
using McParticles = McParticles_000;
870890
using McParticle = McParticles::iterator;
891+
} // namespace aod
892+
namespace soa
893+
{
894+
DECLARE_EQUIVALENT_FOR_INDEX(aod::StoredMcParticles_000, aod::StoredMcParticles_001);
895+
}
871896

897+
namespace aod
898+
{
872899
namespace mctracklabel
873900
{
874901
DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle

Framework/Core/src/AODReaderHelpers.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ AlgorithmSpec AODReaderHelpers::aodSpawnerCallback(std::vector<InputSpec>& reque
168168
} else if (description == header::DataDescription{"FWDTRACKCOV"}) {
169169
outputs.adopt(Output{origin, description}, maker(o2::aod::FwdTracksCovExtensionMetadata{}));
170170
} else if (description == header::DataDescription{"MCPARTICLE"}) {
171-
outputs.adopt(Output{origin, description}, maker(o2::aod::McParticlesExtensionMetadata{}));
171+
outputs.adopt(Output{origin, description}, maker(o2::aod::McParticles_000ExtensionMetadata{}));
172+
} else if (description == header::DataDescription{"MCPARTICLE_001"}) {
173+
outputs.adopt(Output{origin, description}, maker(o2::aod::McParticles_001ExtensionMetadata{}));
172174
} else {
173175
throw runtime_error("Not an extended table");
174176
}

0 commit comments

Comments
 (0)