Skip to content

Commit 0071844

Browse files
ddobrigkalibuild
andauthored
Add CCDB integration tester (#3540)
* Add CCDB integration tester * Please consider the following formatting changes (#173) --------- Co-authored-by: David Dobrigkeit Chinellato <david.dobrigkeit.chinellato.cern.ch> Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent 3bd0163 commit 0071844

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

Common/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ o2physics_add_dpl_workflow(integrationtest
2424
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
2525
COMPONENT_NAME Analysis)
2626

27+
o2physics_add_dpl_workflow(integrationtestccdb
28+
SOURCES integrationTestCCDB.cxx
29+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
30+
COMPONENT_NAME Analysis)
31+
2732
o2physics_add_dpl_workflow(validation
2833
SOURCES validation.cxx
2934
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
13+
//
14+
// Integration tester for CCDB access
15+
// This task is meant to attempt accessing typical CCDB objects
16+
// but to do no actual analysis. It will then allow for systematic
17+
// studies of CCDB access performance for the various objects it queries.
18+
//
19+
// The task allows for some basic configuration of which CCDB objects
20+
// are to be queried (from B field to material LUT and others).
21+
// For now: magnetic field is required, matlut is optional
22+
//
23+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24+
25+
#include "Framework/AnalysisDataModel.h"
26+
#include "Framework/AnalysisTask.h"
27+
#include "Framework/HistogramRegistry.h"
28+
#include "Common/DataModel/TrackSelectionTables.h"
29+
#include "Common/Core/TrackSelection.h"
30+
#include "Common/Core/TrackSelectionDefaults.h"
31+
#include "ReconstructionDataFormats/Track.h"
32+
#include "Common/Core/trackUtilities.h"
33+
#include "CCDB/BasicCCDBManager.h"
34+
#include "DataFormatsParameters/GRPObject.h"
35+
#include "DataFormatsParameters/GRPMagField.h"
36+
#include "DetectorsBase/Propagator.h"
37+
#include "DetectorsBase/GeometryManager.h"
38+
39+
using namespace o2;
40+
using namespace o2::framework;
41+
using namespace o2::framework::expressions;
42+
43+
#include "Framework/runDataProcessing.h"
44+
45+
struct integrationTestCCDB {
46+
// this is anyway what this is all about
47+
Service<o2::ccdb::BasicCCDBManager> ccdb;
48+
49+
Configurable<bool> loadMatLut{"loadMatLut", true, "load material look-up table"};
50+
51+
// CCDB paths for access
52+
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
53+
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
54+
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
55+
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
56+
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
57+
58+
int mRunNumber;
59+
60+
void initMagneticFieldCCDB(aod::BCsWithTimestamps::iterator const& bc)
61+
{
62+
if (mRunNumber == bc.runNumber()) {
63+
return;
64+
}
65+
LOG(info) << "Starting MagField initialization...";
66+
67+
float d_bz = 0.0f; // to store value for printouts only, unused
68+
auto run3grp_timestamp = bc.timestamp();
69+
o2::parameters::GRPObject* grpo = 0x0;
70+
o2::parameters::GRPMagField* grpmag = 0x0;
71+
grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, run3grp_timestamp);
72+
if (grpo) {
73+
o2::base::Propagator::initFieldFromGRP(grpo);
74+
// Fetch magnetic field from ccdb for current collision
75+
d_bz = grpo->getNominalL3Field();
76+
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG";
77+
} else {
78+
grpmag = ccdb->getForTimeStamp<o2::parameters::GRPMagField>(grpmagPath, run3grp_timestamp);
79+
if (!grpmag) {
80+
LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp;
81+
}
82+
o2::base::Propagator::initFieldFromGRP(grpmag);
83+
// Fetch magnetic field from ccdb for current collision
84+
d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
85+
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG";
86+
}
87+
mRunNumber = bc.runNumber();
88+
89+
// Known magnetic field
90+
float magneticField = o2::base::Propagator::Instance()->getNominalBz();
91+
LOG(info) << "Finished MagField init! Magnetic field set in Propagator Instance for inspection: " << magneticField;
92+
}
93+
94+
void init(InitContext& context)
95+
{
96+
// Empty for the time being
97+
}
98+
99+
void process(aod::BCsWithTimestamps const& bcs)
100+
{
101+
mRunNumber = 0;
102+
103+
auto bc = bcs.begin(); // first element
104+
105+
ccdb->setURL(ccdburl);
106+
ccdb->setCaching(true);
107+
ccdb->setLocalObjectValidityChecking();
108+
ccdb->setFatalWhenNull(false);
109+
if (loadMatLut) {
110+
LOG(info) << "Loading material LUT...";
111+
o2::base::MatLayerCylSet* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
112+
LOG(info) << "Material LUT successfully loaded!";
113+
LOG(info) << "Material LUT min R: " << lut->getRMin() << " max R: " << lut->getRMax();
114+
}
115+
initMagneticFieldCCDB(bc);
116+
}
117+
};
118+
119+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
120+
{
121+
return WorkflowSpec{
122+
adaptAnalysisTask<integrationTestCCDB>(cfgc)};
123+
}

0 commit comments

Comments
 (0)