Skip to content

Commit 72d4bcd

Browse files
committed
Tutorial add a test task for ccdb table
1 parent 1722826 commit 72d4bcd

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
#include "CommonDataFormat/InteractionRecord.h"
23+
24+
#include <chrono>
25+
26+
using namespace o2::framework;
27+
using namespace o2::header;
28+
using namespace o2;
29+
30+
namespace o2::aod
31+
{
32+
namespace testccdb
33+
{
34+
DECLARE_SOA_CCDB_COLUMN(GRPObject, grpObject, o2::parameters::GRPObject, "GLO/GRP/GRP"); //!
35+
DECLARE_SOA_CCDB_COLUMN(GRPMagField, grpMagField, o2::parameters::GRPMagField, "GLO/Config/GRPMagField"); //!
36+
} // namespace testccdb
37+
38+
DECLARE_SOA_TIMESTAMPED_TABLE(MyCCDBObjects, aod::Timestamps, o2::aod::timestamp::Timestamp, 1, "MYCCDBOBJ", //!
39+
testccdb::GRPObject, testccdb::GRPMagField);
40+
} // namespace o2::aod
41+
42+
struct TestCCDBTable {
43+
44+
void init(o2::framework::InitContext&) {}
45+
46+
using MyBCs = soa::Join<aod::BCsWithTimestamps, aod::MyCCDBObjects>;
47+
// using MyBCs = soa::Join<aod::BCs, aod::MyCCDBObjects>;
48+
49+
void process(MyBCs const& bcs)
50+
{
51+
for (const auto& bc: bcs) {
52+
float bz = bc.grpObject().getNominalL3Field();
53+
float l3current = bc.grpMagField().getL3Current();
54+
LOGF(info, "bc.timestamp() = %lld, bz = %f kG, %f A", bc.timestamp(), bz, l3current);
55+
}
56+
}
57+
};
58+
59+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
60+
{
61+
return WorkflowSpec{
62+
adaptAnalysisTask<TestCCDBTable>(cfgc),
63+
};
64+
}

0 commit comments

Comments
 (0)