Skip to content

Commit defbab4

Browse files
authored
[Tutorial] Add an example of a configurable expression column (#10779)
1 parent 259fce3 commit defbab4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Tutorials/src/extendedTables.cxx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace o2::aod
2121
namespace extension
2222
{
2323
DECLARE_SOA_EXPRESSION_COLUMN(P2exp, p2exp, float, track::p* track::p);
24+
DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(Cfg, cfg, float, "cfg");
2425

2526
DECLARE_SOA_COLUMN(mX, mx, float);
2627
DECLARE_SOA_COLUMN(mY, my, float);
@@ -36,6 +37,8 @@ DECLARE_SOA_TABLE(DynTable, "AOD", "DYNTABLE",
3637

3738
DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE",
3839
extension::P2exp);
40+
DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(CExTable, Tracks, "CTRK",
41+
extension::Cfg);
3942
} // namespace o2::aod
4043

4144
using namespace o2;
@@ -107,6 +110,14 @@ struct ExtendAndAttach {
107110
struct SpawnDynamicColumns {
108111
Produces<aod::DynTable> dyntable;
109112
Spawns<aod::ExTable> extable;
113+
Defines<aod::CExTable> cextable;
114+
115+
Configurable<float> factor{"factor", 1.0f, "scale factor"};
116+
117+
void init(InitContext&)
118+
{
119+
cextable.projectors[0] = (float)factor * aod::track::p * aod::track::p;
120+
}
110121

111122
void process(aod::Tracks const& tracks)
112123
{
@@ -119,7 +130,7 @@ struct SpawnDynamicColumns {
119130
// loop over the joined table <ExTable, DynTable>
120131
struct ProcessExtendedTables {
121132
// join the table ExTable and DynTable
122-
using allinfo = soa::Join<aod::ExTable, aod::DynTable>;
133+
using allinfo = soa::Join<aod::Tracks, aod::ExTableExtension, aod::CExTableCfgExtension, aod::DynTable>;
123134

124135
void process(aod::Collision const&, allinfo const& tracks)
125136
{
@@ -128,6 +139,7 @@ struct ProcessExtendedTables {
128139
if (row.trackType() != 3) {
129140
if (row.index() % 10000 == 0) {
130141
LOGF(info, "E: EXPRESSION P^2 = %.3f, DYNAMIC P^2 = %.3f R^2 = %.3f", row.p2exp(), row.p2dyn(), row.r2dyn());
142+
LOGF(info, "C: CONF EXPRESSION f * P^2 = %.3f", row.cfg());
131143
}
132144
}
133145
}

0 commit comments

Comments
 (0)