Skip to content

Commit 50e8f86

Browse files
committed
Tutorial add a test task for ccdb table
1 parent 1722826 commit 50e8f86

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

Tutorials/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ o2physics_add_dpl_workflow(ccdbaccess
122122
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::CCDB O2::Framework O2Physics::AnalysisCore
123123
COMPONENT_NAME AnalysisTutorial)
124124

125+
o2physics_add_dpl_workflow(ccdbtableaccess
126+
SOURCES src/ccdbtableaccess.cxx
127+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::CCDB O2::Framework O2Physics::AnalysisCore
128+
COMPONENT_NAME AnalysisTutorial)
129+
125130
o2physics_add_dpl_workflow(weak-decay-iteration
126131
SOURCES src/weakDecayIteration.cxx
127132
COMPONENT_NAME AnalysisTutorial)

Tutorials/src/ccdbtableaccess.cxx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
/// \brief A tutorial task to retrieve objects from CCDB given a time stamp.
13+
/// \author Daiki Sekihata
14+
/// \since 2026-03-01
15+
16+
#include "Framework/runDataProcessing.h"
17+
#include "Framework/AnalysisTask.h"
18+
#include "CCDB/BasicCCDBManager.h"
19+
#include "DataFormatsCalibration/MeanVertexObject.h"
20+
#include "DataFormatsParameters/GRPMagField.h"
21+
#include "DataFormatsParameters/GRPObject.h"
22+
23+
#include <chrono>
24+
25+
using namespace o2::framework;
26+
using namespace o2::header;
27+
using namespace o2;
28+
29+
namespace o2::aod
30+
{
31+
namespace testccdb
32+
{
33+
DECLARE_SOA_CCDB_COLUMN(GRPMagField, grpMagField, o2::parameters::GRPMagField, "GLO/Config/GRPMagField"); //!
34+
DECLARE_SOA_CCDB_COLUMN(MeanVertex, meanVertex, o2::dataformats::MeanVertexObject, "GLO/Calib/MeanVertex"); //!
35+
} // namespace testccdb
36+
37+
DECLARE_SOA_TIMESTAMPED_TABLE(MyCCDBObjects, aod::Timestamps, o2::aod::timestamp::Timestamp, 1, "MYCCDBOBJ", //!
38+
testccdb::GRPMagField, testccdb::MeanVertex);
39+
} // namespace o2::aod
40+
41+
struct TestCCDBTable {
42+
void init(o2::framework::InitContext&) {}
43+
44+
using MyBCs = soa::Join<aod::BCsWithTimestamps, aod::MyCCDBObjects>;
45+
46+
void process(MyBCs const& bcs)
47+
{
48+
int i = 0;
49+
for (const auto& bc: bcs) {
50+
if (i >= 5) {
51+
return;
52+
}
53+
float l3current = bc.grpMagField().getL3Current();
54+
float zvtx = bc.meanVertex().getZ();
55+
LOGF(info, "bc.globalBC() = %llu, bc.timestamp() = %llu, L3 current = %f A, mean zvtx = %f cm", bc.globalBC(), bc.timestamp(), l3current, zvtx);
56+
i++;
57+
}
58+
}
59+
60+
};
61+
62+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
63+
{
64+
return WorkflowSpec{
65+
adaptAnalysisTask<TestCCDBTable>(cfgc),
66+
};
67+
}

0 commit comments

Comments
 (0)