Skip to content

Commit 86bb6f5

Browse files
committed
add comparison of calib functions
1 parent ae6d149 commit 86bb6f5

File tree

7 files changed

+284
-18
lines changed

7 files changed

+284
-18
lines changed

Benchmarks/CMakeLists.txt

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2-
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
1+
# Copyright 2019-2020 CERN and copyright holders of ALICE O2. See
2+
# https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
# All rights not expressly granted are reserved.
44
#
5-
# This software is distributed under the terms of the GNU General Public
6-
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
5+
# This software is distributed under the terms of the GNU General Public License
6+
# v3 (GPL Version 3), copied verbatim in the file "COPYING".
77
#
88
# In applying this license CERN does not waive the privileges and immunities
9-
# granted to it by virtue of its status as an Intergovernmental Organization
10-
# or submit itself to any jurisdiction.
9+
# granted to it by virtue of its status as an Intergovernmental Organization or
10+
# submit itself to any jurisdiction.
1111

1212
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
1313

14-
o2physics_add_dpl_workflow(dynamic
15-
SOURCES src/dynamic-column.cxx
16-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
17-
COMPONENT_NAME AnalysisBenchmark)
14+
o2physics_add_dpl_workflow(produce-dynamic-extension
15+
SOURCES src/produce-dynamic-extension.cxx
16+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
17+
COMPONENT_NAME AnalysisBenchmark)
1818

19-
o2physics_add_dpl_workflow(dynamic-func
20-
SOURCES src/dynamic-column-func.cxx
21-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
22-
COMPONENT_NAME AnalysisBenchmark)
19+
o2physics_add_dpl_workflow(produce-dynamic-extension-func
20+
SOURCES src/produce-dynamic-extension-func.cxx
21+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
22+
COMPONENT_NAME AnalysisBenchmark)
2323

24-
o2physics_add_dpl_workflow(configurable-expression
25-
SOURCES src/configurable-expression-column.cxx
26-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
27-
COMPONENT_NAME AnalysisBenchmark)
24+
o2physics_add_dpl_workflow(produce-expression
25+
SOURCES src/produce-expression.cxx
26+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
27+
COMPONENT_NAME AnalysisBenchmark)
28+
29+
o2physics_add_dpl_workflow(produce-dynamic-extension-calib
30+
SOURCES src/produce-dynamic-extension-calib.cxx
31+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB
32+
COMPONENT_NAME AnalysisBenchmark)
33+
34+
o2physics_add_dpl_workflow(produce-expression-calib
35+
SOURCES src/produce-expression-calib.cxx
36+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB
37+
COMPONENT_NAME AnalysisBenchmark)

Benchmarks/include/tables.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,61 @@
1111
#ifndef O2PHYSICS_BENCHMARKS_INCLUDE_TABLES_H_
1212
#define O2PHYSICS_BENCHMARKS_INCLUDE_TABLES_H_
1313
#include <Framework/AnalysisDataModel.h>
14+
#include <Common/DataModel/TrackSelectionTables.h>
1415

1516
namespace o2::aod
1617
{
1718
namespace extensions
1819
{
20+
// example generic functions
21+
// 1. simple dynamic column and a column to be filled with the result
1922
DECLARE_SOA_DYNAMIC_COLUMN(Direct, direct, [](float x, float y, float z, float t) -> float { return t * (x * x + y * y + z * z); });
2023
DECLARE_SOA_COLUMN(DirectM, directm, float);
2124

25+
// 2. arbitrary function dynamic column and a column to be filled with the result
2226
DECLARE_SOA_DYNAMIC_COLUMN(Indirect, indirect, [](float phi, float x, float y, float z, std::function<float(float, float, float, float)> const& f) -> float { return f(phi, x, y, z); });
2327
DECLARE_SOA_COLUMN(IndirectM, indirectm, float);
2428

29+
// 3. arbitrary expression column placeholder
2530
DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(Expr, expr, float, "Expr");
31+
32+
// 4. example realistic values - corrected dE/dx
33+
DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(RealTPCSignalN, realTPCSignalN, float, "fRealTPCSignalN");
34+
DECLARE_SOA_COLUMN(RealTPCSignalNC, realTPCSignalNC, float);
2635
} // namespace extensions
2736

37+
// tables with simple and arbitrary function dynamic columns
2838
DECLARE_SOA_TABLE(ExtTracksD, "AOD", "TRKD", extensions::Direct<aod::track::X, aod::track::Y, aod::track::Z>);
2939
DECLARE_SOA_TABLE(ExtTracksID, "AOD", "TRKID", extensions::Indirect<aod::track::Phi, aod::track::X, aod::track::Y, aod::track::Z>);
3040

41+
// tables to be filled with the results of the above
3142
DECLARE_SOA_TABLE(ExtTracksDM, "AOD", "TRKDM", extensions::DirectM);
3243
DECLARE_SOA_TABLE(ExtTracksIDM, "AOD", "TRKIDM", extensions::IndirectM);
3344

45+
// extended table with an arbitrary expression column
3446
DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(TracksE, TracksIU, "TRKE", extensions::Expr);
3547

48+
// intermediate values for the realistic calculation
49+
namespace intermediate {
50+
DECLARE_SOA_COLUMN(HRate, hRate, float);
51+
DECLARE_SOA_COLUMN(ClampedTPCMult, clampedTPCmult, float);
52+
DECLARE_SOA_COLUMN(Occupancy, occupancy, float);
53+
DECLARE_SOA_COLUMN(Correction0, correction0, float);
54+
}
55+
56+
// intermediate table
57+
DECLARE_SOA_TABLE(TracksTemporaryExtra, "AOD", "TRKTEMPEX",
58+
intermediate::HRate, intermediate::ClampedTPCMult, intermediate::Occupancy, intermediate::Correction0,
59+
aod::track::TPCSignal, aod::track::Signed1Pt, aod::track::Tgl);
60+
using TracksQAEx = soa::Join<TracksQAVersion, TracksTemporaryExtra>;
61+
62+
// final table
63+
DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(TracksQACorrectedE, TracksQAEx, "TRKWTPCE", extensions::RealTPCSignalN);
64+
using MoreTracksFinal = soa::Join<TracksQAVersion, TracksQACorrectedECfgExtension>;
65+
66+
// final table for direct calculation
67+
DECLARE_SOA_TABLE(TracksQACorrected, "AOD", "TPCEXT", extensions::RealTPCSignalNC);
68+
3669
using TracksD = soa::Join<TracksIU, ExtTracksD>;
3770
using TracksID = soa::Join<TracksIU, ExtTracksID>;
3871
} // namespace o2::aod
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include <CCDB/BasicCCDBManager.h>
13+
#include "Common/CCDB/ctpRateFetcher.h"
14+
#include "Common/DataModel/EventSelection.h"
15+
#include "Common/DataModel/Multiplicity.h"
16+
#include "tables.h"
17+
18+
#include "Framework/AnalysisTask.h"
19+
#include "Framework/runDataProcessing.h"
20+
21+
22+
using namespace o2;
23+
using namespace o2::framework;
24+
using namespace o2::framework::expressions;
25+
26+
float fReal_fTPCSignalN(float mbb0R, float a1pt, float atgl, float side, float occ, float fOccTPCN, float fTrackOccMeanN)
27+
{
28+
return ((0.019869f * mbb0R) + (0.0012031f * a1pt) + (-0.0031766f * atgl) + (-0.0058023f * atgl * mbb0R) + (0.00087494f * a1pt * mbb0R) + (0.0020074f * side) + (-0.0010434f * a1pt * a1pt) + (0.011812f)) * occ / 1.e3f + //
29+
((0.009032f * mbb0R) + (0.0011737f * a1pt) + (-0.0010241f * atgl) + (-0.0075789f * atgl * mbb0R) + (0.00029324f * a1pt * mbb0R) + (0.00052475f * side) + (-0.00045413f * a1pt * a1pt) + (0.0024879f)) * fOccTPCN + //
30+
((0.004255f * mbb0R) + (0.0011954f * a1pt) + (0.0054092f * atgl) + (-0.0033655f * atgl * mbb0R) + (0.00052243f * a1pt * mbb0R) + (-0.0002969f * side) + (-0.00074909f * a1pt * a1pt) + (-0.0075754f)) * fTrackOccMeanN + //
31+
((-0.07925f * mbb0R) + (-0.03737f * a1pt) + (0.0017054f * atgl) + (0.093686f * atgl * mbb0R) + (0.023925f * a1pt * mbb0R) + (-0.0083407f * side) + (0.00336f * a1pt * a1pt) + (1.0461f));
32+
};
33+
34+
float clamp(float value, float lo, float hi)
35+
{
36+
return value < lo ? lo : (value > hi ? hi : value);
37+
}
38+
39+
struct ProduceDynamicExtensionCalib {
40+
Produces<aod::TracksQACorrected> tpcex;
41+
Service<o2::ccdb::BasicCCDBManager> ccdb;
42+
ctpRateFetcher fetcher;
43+
44+
Preslice<aod::Tracks> perColl = aod::track::collisionId;
45+
46+
using BCs = soa::Join<aod::BCs, aod::Timestamps>;
47+
using Collisions = soa::Join<aod::Collisions, aod::Mults, aod::EvSels>;
48+
using Tracks = soa::Join<aod::Tracks, aod::TracksExtra>;
49+
50+
int runNumber{0};
51+
int colId{-100};
52+
int bcId{-100};
53+
int trkId{-100};
54+
Collisions::iterator col;
55+
BCs::iterator bc;
56+
Tracks::iterator track;
57+
58+
void process(Collisions const& collisions, BCs const& bcs, /*aod::FT0s const& ft0s,*/ Tracks const& tracks, aod::TracksQAVersion const& tracksQA)
59+
{
60+
col = collisions.begin();
61+
bc = bcs.begin();
62+
runNumber = bc.runNumber();
63+
track = tracks.begin();
64+
tpcex.reserve(tracksQA.size());
65+
for (auto& trackqa : tracksQA) {
66+
if (!trackqa.has_track()) {
67+
tpcex(0);
68+
continue;
69+
}
70+
if (trackqa.trackId() != trkId) {
71+
track.setCursor(trackqa.trackId());
72+
}
73+
if (!track.has_collision()) {
74+
tpcex(0);
75+
continue;
76+
}
77+
if (track.collisionId() != colId) {
78+
colId = track.collisionId();
79+
col.setCursor(colId);
80+
}
81+
if (!col.has_foundBC()) {
82+
tpcex(0);
83+
continue;
84+
}
85+
if (col.foundBCId() != bcId) {
86+
bc.setCursor(col.foundBCId());
87+
if (bc.runNumber() != runNumber) {
88+
runNumber = bc.runNumber();
89+
}
90+
}
91+
92+
float rate = fetcher.fetch(ccdb.service, bc.timestamp(), runNumber, "ZNC hadronic") * 1.e-3;
93+
float occ = col.trackOccupancyInTimeRange();
94+
float fOccTPCN = clamp(col.multTPC() / 1100.f, 0.f, 12.f);
95+
96+
float correction0 = fReal_fTPCSignalN(clamp(50.f / track.tpcSignal(), 0.05f, 1.05f), std::abs(track.signed1Pt()), std::abs(track.tgl()), track.tgl() > 0 ? 1.f : 0.f, occ, fOccTPCN, rate / 5.f);
97+
float correction1 = fReal_fTPCSignalN(clamp(correction0 * 50.f / track.tpcSignal(), 0.05f, 1.05f), std::abs(track.signed1Pt()), std::abs(track.tgl()), track.tgl() > 0 ? 1.f : 0.f, occ, fOccTPCN, rate / 5.);
98+
99+
tpcex(track.tpcSignal() / correction1);
100+
}
101+
}
102+
};
103+
104+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
105+
{
106+
return {adaptAnalysisTask<ProduceDynamicExtensionCalib>(cfgc)};
107+
}
File renamed without changes.
File renamed without changes.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include <CCDB/BasicCCDBManager.h>
13+
#include "Common/CCDB/ctpRateFetcher.h"
14+
#include "Common/DataModel/EventSelection.h"
15+
#include "Common/DataModel/Multiplicity.h"
16+
#include "tables.h"
17+
18+
#include "Framework/AnalysisTask.h"
19+
#include "Framework/runDataProcessing.h"
20+
21+
using namespace o2;
22+
using namespace o2::framework;
23+
using namespace o2::framework::expressions;
24+
25+
float fReal_fTPCSignalN(float mbb0R, float a1pt, float atgl, float side, float occ, float fOccTPCN, float fTrackOccMeanN)
26+
{
27+
return ((0.019869f * mbb0R) + (0.0012031f * a1pt) + (-0.0031766f * atgl) + (-0.0058023f * atgl * mbb0R) + (0.00087494f * a1pt * mbb0R) + (0.0020074f * side) + (-0.0010434f * a1pt * a1pt) + (0.011812f)) * occ / 1.e3f + //
28+
((0.009032f * mbb0R) + (0.0011737f * a1pt) + (-0.0010241f * atgl) + (-0.0075789f * atgl * mbb0R) + (0.00029324f * a1pt * mbb0R) + (0.00052475f * side) + (-0.00045413f * a1pt * a1pt) + (0.0024879f)) * fOccTPCN + //
29+
((0.004255f * mbb0R) + (0.0011954f * a1pt) + (0.0054092f * atgl) + (-0.0033655f * atgl * mbb0R) + (0.00052243f * a1pt * mbb0R) + (-0.0002969f * side) + (-0.00074909f * a1pt * a1pt) + (-0.0075754f)) * fTrackOccMeanN + //
30+
((-0.07925f * mbb0R) + (-0.03737f * a1pt) + (0.0017054f * atgl) + (0.093686f * atgl * mbb0R) + (0.023925f * a1pt * mbb0R) + (-0.0083407f * side) + (0.00336f * a1pt * a1pt) + (1.0461f));
31+
};
32+
33+
float clamp(float value, float lo, float hi)
34+
{
35+
return value < lo ? lo : (value > hi ? hi : value);
36+
}
37+
38+
struct LeftJoin {
39+
Produces<aod::TracksTemporaryExtra> interm;
40+
Service<o2::ccdb::BasicCCDBManager> ccdb;
41+
ctpRateFetcher fetcher;
42+
43+
Preslice<aod::Tracks> perColl = aod::track::collisionId;
44+
45+
using BCs = soa::Join<aod::BCs, aod::Timestamps>;
46+
using Collisions = soa::Join<aod::Collisions, aod::Mults, aod::EvSels>;
47+
using Tracks = soa::Join<aod::Tracks, aod::TracksExtra>;
48+
49+
int runNumber{0};
50+
int colId{-100};
51+
int bcId{-100};
52+
int trkId{-100};
53+
Collisions::iterator col;
54+
BCs::iterator bc;
55+
Tracks::iterator track;
56+
57+
void process(BCs const& bcs, Collisions const& collisions, Tracks const& tracks, aod::TracksQAVersion const& tracksQA)
58+
{
59+
interm.reserve(tracksQA.size());
60+
col = collisions.begin();
61+
bc = bcs.begin();
62+
runNumber = bc.runNumber();
63+
track = tracks.begin();
64+
for (auto& trackqa : tracksQA) {
65+
if (!trackqa.has_track()) {
66+
interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0);
67+
continue;
68+
}
69+
if (trackqa.trackId() != trkId) {
70+
track.setCursor(trackqa.trackId());
71+
}
72+
if (!track.has_collision()) {
73+
interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0);
74+
continue;
75+
}
76+
if (track.collisionId() != colId) {
77+
colId = track.collisionId();
78+
col.setCursor(colId);
79+
}
80+
if (!col.has_foundBC()) {
81+
interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0);
82+
continue;
83+
}
84+
if (col.foundBCId() != bcId) {
85+
bc.setCursor(col.foundBCId());
86+
if (bc.runNumber() != runNumber) {
87+
runNumber = bc.runNumber();
88+
}
89+
}
90+
float rate = fetcher.fetch(ccdb.service, bc.timestamp(), runNumber, "ZNC hadronic") * 1.e-3;
91+
float occ = col.trackOccupancyInTimeRange();
92+
float fOccTPCN = clamp(col.multTPC() / 1100.f, 0.f, 12.f);
93+
interm(rate, fOccTPCN, occ, fReal_fTPCSignalN(clamp(50.f / track.tpcSignal(), 0.05f, 1.05f), std::abs(track.signed1Pt()), std::abs(track.tgl()), track.tgl() > 0 ? 1.f : 0.f, occ, fOccTPCN, rate / 5.f), track.tpcSignal(), track.signed1Pt(), track.tgl());
94+
}
95+
}
96+
};
97+
98+
struct ProduceExpressionCalib {
99+
Defines<aod::TracksQACorrectedE> tpcextra;
100+
101+
void init(InitContext&) {
102+
tpcextra.projectors[0] = ifnode(aod::track::tpcSignal < o2::constants::math::Almost0,
103+
LiteralNode{0.f},
104+
aod::track::tpcSignal / (
105+
((0.019869f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0012031f * nabs(aod::track::signed1Pt)) + (-0.0031766f * nabs(aod::track::tgl)) + (-0.0058023f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00087494f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0020074f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.0010434f * aod::track::signed1Pt * aod::track::signed1Pt) + (0.011812f)) * aod::intermediate::occupancy / 1.e3f + //
106+
((0.009032f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0011737f * nabs(aod::track::signed1Pt)) + (-0.0010241f * nabs(aod::track::tgl)) + (-0.0075789f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00029324f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00052475f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.00045413f * aod::track::signed1Pt * aod::track::signed1Pt) + (0.0024879f)) * aod::intermediate::clampedTPCmult + //
107+
((0.004255f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0011954f * nabs(aod::track::signed1Pt)) + (0.0054092f * nabs(aod::track::tgl)) + (-0.0033655f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00052243f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.0002969f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.00074909f * aod::track::signed1Pt * aod::track::signed1Pt) + (-0.0075754f)) * aod::intermediate::hRate / 5.f + //
108+
((-0.07925f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.03737f * nabs(aod::track::signed1Pt)) + (0.0017054f * nabs(aod::track::tgl)) + (0.093686f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.023925f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.0083407f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (0.00336f * aod::track::signed1Pt * aod::track::signed1Pt) + (1.0461f))//
109+
));
110+
}
111+
};
112+
113+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
114+
{
115+
return {adaptAnalysisTask<LeftJoin>(cfgc), adaptAnalysisTask<ProduceExpressionCalib>(cfgc)};
116+
}
File renamed without changes.

0 commit comments

Comments
 (0)