|
| 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