-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathO2GPUDPLDisplay.cxx
More file actions
209 lines (180 loc) · 8.62 KB
/
O2GPUDPLDisplay.cxx
File metadata and controls
209 lines (180 loc) · 8.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "GPUWorkflow/O2GPUDPLDisplay.h"
#include "Framework/ConfigParamSpec.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "CommonUtils/NameConf.h"
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsBase/GRPGeomHelper.h"
#include "TRDBase/GeometryFlat.h"
#include "TRDBase/Geometry.h"
#include "TOFBase/Geo.h"
#include "ITSBase/GeometryTGeo.h"
#include "DetectorsBase/Propagator.h"
#include "GPUO2InterfaceDisplay.h"
#include "GPUO2InterfaceUtils.h"
#include "GPUO2InterfaceConfiguration.h"
#include "TPCFastTransform.h"
#include "TPCReconstruction/TPCFastTransformHelperO2.h"
#include "CorrectionMapsHelper.h"
#include "TPCCalibration/CorrectionMapsLoader.h"
#include "GlobalTrackingWorkflowHelpers/InputHelper.h"
#include "DataFormatsTPC/WorkflowHelper.h"
#include "DataFormatsTRD/RecoInputContainer.h"
#include "GPUWorkflowHelper/GPUWorkflowHelper.h"
#include "DataFormatsITSMFT/TopologyDictionary.h"
#include "DetectorsRaw/HBFUtils.h"
using namespace o2::framework;
using namespace o2::dataformats;
using namespace o2::globaltracking;
using namespace o2::base;
using namespace o2::gpu;
using namespace o2::tpc;
using namespace o2::trd;
void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
std::vector<o2::framework::ConfigParamSpec> options{
{"enable-mc", o2::framework::VariantType::Bool, false, {"enable visualization of MC data"}},
{"disable-mc", o2::framework::VariantType::Bool, false, {"disable visualization of MC data"}}, // for compatibility, overrides enable-mc
{"display-clusters", VariantType::String, "ITS,TPC,TRD,TOF", {"comma-separated list of clusters to display"}},
{"display-tracks", VariantType::String, "TPC,ITS,ITS-TPC,TPC-TRD,ITS-TPC-TRD,TPC-TOF,ITS-TPC-TOF", {"comma-separated list of tracks to display"}},
{"read-from-files", o2::framework::VariantType::Bool, false, {"Automatically create readers for input"}},
{"disable-root-input", o2::framework::VariantType::Bool, false, {"Disable root input overriding read-from-files"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
std::swap(workflowOptions, options);
}
#include "Framework/runDataProcessing.h"
void O2GPUDPLDisplaySpec::init(InitContext& ic)
{
GRPGeomHelper::instance().setRequest(mGGR);
mConfig.reset(new GPUO2InterfaceConfiguration);
mConfig->configGRP.solenoidBzNominalGPU = 0;
mConfParam.reset(new GPUSettingsO2(mConfig->ReadConfigurableParam()));
mFastTransformHelper.reset(new o2::tpc::CorrectionMapsLoader());
mFastTransform = std::move(TPCFastTransformHelperO2::instance()->create(0));
mFastTransformRef = std::move(TPCFastTransformHelperO2::instance()->create(0));
mFastTransformMShape = std::move(TPCFastTransformHelperO2::instance()->create(0));
mFastTransformHelper->setCorrMap(mFastTransform.get());
mFastTransformHelper->setCorrMapRef(mFastTransformRef.get());
mFastTransformHelper->setCorrMapMShape(mFastTransformMShape.get());
mConfig->configCalib.fastTransform = mFastTransformHelper->getCorrMap();
mConfig->configCalib.fastTransformRef = mFastTransformHelper->getCorrMapRef();
mConfig->configCalib.fastTransformMShape = mFastTransformHelper->getCorrMapMShape();
mConfig->configCalib.fastTransformHelper = mFastTransformHelper.get();
mTrdGeo.reset(new o2::trd::GeometryFlat());
mConfig->configCalib.trdGeometry = mTrdGeo.get();
mITSDict = std::make_unique<o2::itsmft::TopologyDictionary>();
mConfig->configCalib.itsPatternDict = mITSDict.get();
mConfig->configProcessing.runMC = mUseMC;
mTFSettings.reset(new o2::gpu::GPUSettingsTF);
mTFSettings->hasSimStartOrbit = 1;
auto& hbfu = o2::raw::HBFUtils::Instance();
mTFSettings->simStartOrbit = hbfu.getFirstIRofTF(o2::InteractionRecord(0, hbfu.orbitFirstSampled)).orbit;
mAutoContinuousMaxTimeBin = mConfig->configGRP.grpContinuousMaxTimeBin < -1;
mDisplay.reset(new GPUO2InterfaceDisplay(mConfig.get()));
}
void O2GPUDPLDisplaySpec::run(ProcessingContext& pc)
{
GRPGeomHelper::instance().checkUpdates(pc);
if (GRPGeomHelper::instance().getGRPECS()->isDetReadOut(o2::detectors::DetID::TPC) && mConfParam->tpcTriggeredMode ^ !GRPGeomHelper::instance().getGRPECS()->isDetContinuousReadOut(o2::detectors::DetID::TPC)) {
LOG(fatal) << "configKeyValue tpcTriggeredMode does not match GRP isDetContinuousReadOut(TPC) setting";
}
if (mDisplayShutDown) {
return;
}
mTFSettings->tfStartOrbit = pc.services().get<o2::framework::TimingInfo>().firstTForbit;
mTFSettings->hasTfStartOrbit = 1;
mTFSettings->hasNHBFPerTF = 1;
mTFSettings->nHBFPerTF = mConfParam->overrideNHbfPerTF ? mConfParam->overrideNHbfPerTF : GRPGeomHelper::instance().getGRPECS()->getNHBFPerTF();
mTFSettings->hasRunStartOrbit = 0;
if (mGRPGeomUpdated) {
mGRPGeomUpdated = false;
mConfig->configGRP.solenoidBzNominalGPU = GPUO2InterfaceUtils::getNominalGPUBz(*GRPGeomHelper::instance().getGRPMagField());
if (mAutoContinuousMaxTimeBin) {
mConfig->configGRP.grpContinuousMaxTimeBin = GPUO2InterfaceUtils::getTpcMaxTimeBinFromNHbf(mTFSettings->nHBFPerTF);
}
mDisplay->UpdateGRP(&mConfig->configGRP);
if (mGeometryCreated == 0) {
auto gm = o2::trd::Geometry::instance();
gm->createPadPlaneArray();
gm->createClusterMatrixArray();
mTrdGeo.reset(new o2::trd::GeometryFlat(*gm));
mConfig->configCalib.trdGeometry = mTrdGeo.get();
mGeometryCreated = true;
mUpdateCalib = true;
o2::tof::Geo::Init();
o2::its::GeometryTGeo::Instance()->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2GRot, o2::math_utils::TransformType::T2G, o2::math_utils::TransformType::L2G, o2::math_utils::TransformType::T2L));
}
}
if (mUpdateCalib) {
mDisplay->UpdateCalib(&mConfig->configCalib);
}
if (mDisplayStarted == false) {
if (mDisplay->startDisplay()) {
throw std::runtime_error("Error starting event display");
}
mDisplayStarted = true;
}
o2::globaltracking::RecoContainer recoData;
recoData.collectData(pc, *mDataRequest);
GPUTrackingInOutPointers ptrs;
auto tmpContainer = GPUWorkflowHelper::fillIOPtr(ptrs, recoData, mUseMC, &(mConfig->configCalib), mClMask, mTrkMask, mTrkMask);
ptrs.settingsTF = mTFSettings.get();
if (mDisplay->show(&ptrs)) {
mDisplay->endDisplay();
mDisplayShutDown = true;
}
}
void O2GPUDPLDisplaySpec::endOfStream(EndOfStreamContext& ec)
{
if (mDisplayShutDown) {
return;
}
mDisplay->endDisplay();
mDisplayShutDown = true;
}
void O2GPUDPLDisplaySpec::finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj)
{
if (matcher == o2::framework::ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
mConfig->configCalib.itsPatternDict = (const o2::itsmft::TopologyDictionary*)obj;
mUpdateCalib = true;
return;
}
if (GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
mGRPGeomUpdated = true;
return;
}
}
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
WorkflowSpec specs;
o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
bool useMC = cfgc.options().get<bool>("enable-mc") && !cfgc.options().get<bool>("disable-mc");
GlobalTrackID::mask_t srcTrk = GlobalTrackID::getSourcesMask(cfgc.options().get<std::string>("display-tracks"));
GlobalTrackID::mask_t srcCl = GlobalTrackID::getSourcesMask(cfgc.options().get<std::string>("display-clusters"));
if (!srcTrk.any() && !srcCl.any()) {
throw std::runtime_error("No input configured");
}
std::shared_ptr<DataRequest> dataRequest = std::make_shared<DataRequest>();
dataRequest->requestTracks(srcTrk, useMC);
dataRequest->requestClusters(srcCl, useMC);
if (cfgc.options().get<bool>("read-from-files")) {
InputHelper::addInputSpecs(cfgc, specs, srcCl, srcTrk, srcTrk, useMC);
}
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, true, false, true, false, o2::base::GRPGeomRequest::Aligned, dataRequest->inputs, true);
specs.emplace_back(DataProcessorSpec{
"o2-gpu-display",
dataRequest->inputs,
{},
AlgorithmSpec{adaptFromTask<O2GPUDPLDisplaySpec>(useMC, srcTrk, srcCl, dataRequest, ggRequest)}});
return specs;
}