Skip to content

Commit 40f542c

Browse files
authored
[QC-810] Integration with GrpGeomHelper for GRP access in Tasks (#1586)
* [QC-810] Integration with GrpGeomHelper for GRP access in Tasks * Create the GRP Geom Request if any field is enabled
1 parent a5dd5a9 commit 40f542c

11 files changed

Lines changed: 153 additions & 2 deletions

Framework/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ target_link_libraries(O2QualityControl
113113
O2::Mergers
114114
O2::DataSampling
115115
O2::DataFormatsQualityControl
116+
O2::DetectorsBase
116117
PRIVATE Boost::system
117118
ROOT::Gui
118119
CURL::libcurl)

Framework/include/QualityControl/InfrastructureSpecReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "QualityControl/DataSourceSpec.h"
2323
#include "QualityControl/CheckSpec.h"
2424
#include "QualityControl/PostProcessingTaskSpec.h"
25+
#include "QualityControl/RecoRequestSpecs.h"
2526
#include <boost/property_tree/ptree_fwd.hpp>
2627

2728
namespace o2::quality_control::core
@@ -53,6 +54,8 @@ postprocessing::PostProcessingTaskSpec readSpecEntry<postprocessing::PostProcess
5354
template <>
5455
ExternalTaskSpec readSpecEntry<ExternalTaskSpec>(std::string entryID, const boost::property_tree::ptree& entryTree, const boost::property_tree::ptree& wholeTree);
5556
template <>
57+
GRPGeomRequestSpec readSpecEntry<GRPGeomRequestSpec>(std::string entryID, const boost::property_tree::ptree& entryTree, const boost::property_tree::ptree& wholeTree);
58+
template <>
5659
CommonSpec readSpecEntry<CommonSpec>(std::string entryID, const boost::property_tree::ptree& entryTree, const boost::property_tree::ptree& wholeTree);
5760

5861
// todo: section names should be enum.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
#ifndef QUALITYCONTROL_RECOREQUESTSPECS_H
13+
#define QUALITYCONTROL_RECOREQUESTSPECS_H
14+
15+
///
16+
/// \file RecoRequestSpecs.h
17+
/// \author Piotr Konopka
18+
///
19+
20+
//#include <DetectorsBase/GRPGeomHelper.h>
21+
#include <string>
22+
23+
namespace o2::quality_control::core
24+
{
25+
26+
// this reflects the GRPGeomRequest struct, but allows us to gather the values and fill the input specs at different stages
27+
struct GRPGeomRequestSpec {
28+
std::string geomRequest = "None";
29+
30+
bool askGRPECS = false;
31+
bool askGRPLHCIF = false;
32+
bool askGRPMagField = false;
33+
bool askMatLUT = false;
34+
bool askTime = false; // need orbit reset time for precise timestamp calculation
35+
bool askOnceAllButField = false; // for all entries but field query only once
36+
bool needPropagatorD = false; // init also PropagatorD
37+
38+
bool anyRequestEnabled() const
39+
{
40+
return geomRequest != "None" || askGRPECS || askGRPLHCIF || askGRPMagField || askMatLUT || askTime || askOnceAllButField || needPropagatorD;
41+
}
42+
};
43+
44+
struct RecoDataRequestSpec {
45+
};
46+
} // namespace o2::quality_control::core
47+
48+
#endif // QUALITYCONTROL_RECOREQUESTSPECS_H

Framework/include/QualityControl/TaskRunner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class TaskRunner : public framework::Task
8787
void init(framework::InitContext& iCtx) override;
8888
/// \brief TaskRunner's process callback
8989
void run(framework::ProcessingContext& pCtx) override;
90+
/// \brief TaskRunner's finaliseCCDB callback
91+
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) override;
9092

9193
/// \brief TaskRunner's completion policy callback
9294
static framework::CompletionPolicy::CompletionOp completionPolicyCallback(o2::framework::InputSpan const& inputs);

Framework/include/QualityControl/TaskRunnerConfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@
1919

2020
#include <string>
2121
#include <unordered_map>
22+
#include <memory>
2223

2324
#include <Framework/DataProcessorSpec.h>
2425
#include "QualityControl/Activity.h"
2526
#include "QualityControl/DiscardFileParameters.h"
2627

28+
namespace o2::base
29+
{
30+
class GRPGeomRequest;
31+
}
32+
2733
namespace o2::quality_control::core
2834
{
2935

@@ -48,6 +54,7 @@ struct TaskRunnerConfig {
4854
int resetAfterCycles = 0;
4955
core::DiscardFileParameters infologgerDiscardParameters;
5056
Activity fallbackActivity;
57+
std::shared_ptr<o2::base::GRPGeomRequest> grpGeomRequest;
5158
};
5259

5360
} // namespace o2::quality_control::core

Framework/include/QualityControl/TaskSpec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <unordered_map>
2323

2424
#include "QualityControl/DataSourceSpec.h"
25+
#include "QualityControl/RecoRequestSpecs.h"
2526

2627
namespace o2::quality_control::core
2728
{
@@ -70,6 +71,7 @@ struct TaskSpec {
7071
std::string mergingMode = "delta"; // todo as enum?
7172
int mergerCycleMultiplier = 1;
7273
std::vector<size_t> mergersPerLayer{ 1 };
74+
GRPGeomRequestSpec grpGeomRequestSpec;
7375
};
7476

7577
} // namespace o2::quality_control::core

Framework/src/InfrastructureSpecReader.cxx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ TaskSpec InfrastructureSpecReader::readSpecEntry<TaskSpec>(std::string taskID, c
138138
}
139139
}
140140

141+
if (taskTree.count("grpGeomRequest") > 0) {
142+
ts.grpGeomRequestSpec = readSpecEntry<GRPGeomRequestSpec>(ts.taskName, taskTree.get_child("grpGeomRequest"), wholeTree);
143+
}
144+
141145
return ts;
142146
}
143147

@@ -322,6 +326,23 @@ ExternalTaskSpec
322326
return ets;
323327
}
324328

329+
template <>
330+
GRPGeomRequestSpec
331+
InfrastructureSpecReader::readSpecEntry<GRPGeomRequestSpec>(std::string, const boost::property_tree::ptree& grpGeomRequestTree, const boost::property_tree::ptree&)
332+
{
333+
GRPGeomRequestSpec grpSpec;
334+
grpSpec.geomRequest = grpGeomRequestTree.get<std::string>("geomRequest", grpSpec.geomRequest);
335+
grpSpec.askGRPECS = grpGeomRequestTree.get<bool>("askGRPECS", grpSpec.askGRPECS);
336+
grpSpec.askGRPLHCIF = grpGeomRequestTree.get<bool>("askGRPLHCIF", grpSpec.askGRPLHCIF);
337+
grpSpec.askGRPMagField = grpGeomRequestTree.get<bool>("askGRPMagField", grpSpec.askGRPMagField);
338+
grpSpec.askMatLUT = grpGeomRequestTree.get<bool>("askMatLUT", grpSpec.askMatLUT);
339+
grpSpec.askTime = grpGeomRequestTree.get<bool>("askTime", grpSpec.askTime);
340+
grpSpec.askOnceAllButField = grpGeomRequestTree.get<bool>("askOnceAllButField", grpSpec.askOnceAllButField);
341+
grpSpec.needPropagatorD = grpGeomRequestTree.get<bool>("needPropagatorD", grpSpec.needPropagatorD);
342+
343+
return grpSpec;
344+
}
345+
325346
std::string InfrastructureSpecReader::validateDetectorName(std::string name)
326347
{
327348
// name must be a detector code from DetID or one of the few allowed general names

Framework/src/TaskRunner.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <Framework/DataRefUtils.h>
3232
#include <Framework/EndOfStreamContext.h>
3333
#include <CommonUtils/ConfigurableParam.h>
34+
#include <DetectorsBase/GRPGeomHelper.h>
3435

3536
#include "QualityControl/QcInfoLogger.h"
3637
#include "QualityControl/TaskFactory.h"
@@ -54,6 +55,7 @@ namespace o2::quality_control::core
5455

5556
using namespace o2::framework;
5657
using namespace o2::header;
58+
using namespace o2::base;
5759
using namespace o2::configuration;
5860
using namespace o2::monitoring;
5961
using namespace std::chrono;
@@ -169,6 +171,10 @@ void TaskRunner::init(InitContext& iCtx)
169171
if (!ConfigParamGlo::keyValues.empty()) {
170172
conf::ConfigurableParam::updateFromString(ConfigParamGlo::keyValues);
171173
}
174+
// load reco helpers
175+
if (mTaskConfig.grpGeomRequest) {
176+
GRPGeomHelper::instance().setRequest(mTaskConfig.grpGeomRequest);
177+
}
172178

173179
// init user's task
174180
mTask->setCcdbUrl(mTaskConfig.conditionUrl);
@@ -190,6 +196,10 @@ void TaskRunner::run(ProcessingContext& pCtx)
190196
startCycle();
191197
}
192198

199+
if (mTaskConfig.grpGeomRequest) {
200+
GRPGeomHelper::instance().checkUpdates(pCtx);
201+
}
202+
193203
auto [dataReady, timerReady] = validateInputs(pCtx.inputs());
194204

195205
if (dataReady) {
@@ -210,6 +220,15 @@ void TaskRunner::run(ProcessingContext& pCtx)
210220
}
211221
}
212222

223+
void TaskRunner::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
224+
{
225+
if (mTaskConfig.grpGeomRequest) {
226+
if (!GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
227+
ILOG(Warning, Devel) << "Could not update CCDB objects requested by GRPGeomHelper" << ENDM;
228+
}
229+
}
230+
}
231+
213232
CompletionPolicy::CompletionOp TaskRunner::completionPolicyCallback(o2::framework::InputSpan const& inputs)
214233
{
215234
// fixme: we assume that there is one timer input and the rest are data inputs. If some other implicit inputs are

Framework/src/TaskRunnerFactory.cxx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <Headers/DataHeader.h>
2828
#include <Framework/O2ControlLabels.h>
2929
#include <Framework/DataProcessorLabel.h>
30+
#include <DetectorsBase/GRPGeomHelper.h>
3031

3132
namespace o2::quality_control::core
3233
{
@@ -72,6 +73,19 @@ TaskRunnerConfig TaskRunnerFactory::extractConfig(const CommonSpec& globalConfig
7273
0,
7374
Lifetime::Timer);
7475

76+
static std::unordered_map<std::string, o2::base::GRPGeomRequest::GeomRequest> const geomRequestFromString = {
77+
{ "None", o2::base::GRPGeomRequest::GeomRequest::None },
78+
{ "Aligned", o2::base::GRPGeomRequest::GeomRequest::Aligned },
79+
{ "Ideal", o2::base::GRPGeomRequest::GeomRequest::Ideal },
80+
{ "Alignments", o2::base::GRPGeomRequest::GeomRequest::Alignments }
81+
};
82+
const auto& grp = taskSpec.grpGeomRequestSpec;
83+
auto grpGeomRequest = grp.anyRequestEnabled() //
84+
? nullptr //
85+
: std::make_shared<o2::base::GRPGeomRequest>( //
86+
grp.askTime, grp.askGRPECS, grp.askGRPLHCIF, grp.askGRPMagField, grp.askMatLUT, //
87+
geomRequestFromString.at(grp.geomRequest), inputs, grp.askOnceAllButField, grp.needPropagatorD);
88+
7589
OutputSpec monitorObjectsSpec{ { "mo" },
7690
TaskRunner::createTaskDataOrigin(taskSpec.detectorName),
7791
TaskRunner::createTaskDataDescription(taskSpec.taskName),
@@ -112,7 +126,8 @@ TaskRunnerConfig TaskRunnerFactory::extractConfig(const CommonSpec& globalConfig
112126
taskSpec.saveObjectsToFile,
113127
resetAfterCycles.value_or(taskSpec.resetAfterCycles),
114128
globalConfig.infologgerDiscardParameters,
115-
fallbackActivity
129+
fallbackActivity,
130+
grpGeomRequest
116131
};
117132
}
118133

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ For a general overview of our (O2) software, organization and processes, please
7373
* [Solving performance issues](doc/Advanced.md#solving-performance-issues)
7474
* [CCDB / QCDB](doc/Advanced.md#ccdb--qcdb)
7575
* [Access run conditions and calibrations from the CCDB](doc/Advanced.md#access-run-conditions-and-calibrations-from-the-ccdb)
76+
* [Access GRP objects with GRP Geom Helper](doc/Advanced.md#access-grp-objects-with-grp-geom-helper)
7677
* [Custom metadata](doc/Advanced.md#custom-metadata)
7778
* [Details on the data storage format in the CCDB](doc/Advanced.md#details-on-the-data-storage-format-in-the-ccdb)
7879
* [Local CCDB setup](doc/Advanced.md#local-ccdb-setup)

0 commit comments

Comments
 (0)