Project
Loading...
Searching...
No Matches
gpu-reco-workflow.cxx
Go to the documentation of this file.
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
14
27#include "TPCBase/Sector.h"
32
33#include <unordered_map>
34#include <numeric>
35
36using namespace o2::framework;
37using namespace o2::dataformats;
38using namespace o2::gpu;
39using CompletionPolicyData = std::vector<InputSpec>;
41static constexpr uint64_t gTpcSectorMask = 0xFFFFFFFFF;
42static std::function<bool(o2::framework::DataProcessingHeader::StartTime)>* gPolicyOrderCheck;
43static std::shared_ptr<GPURecoWorkflowSpec> gTask;
44
45void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
46{
48}
49
50void customize(std::vector<ConfigParamSpec>& workflowOptions)
51{
52
53 std::vector<ConfigParamSpec> options{
54 {"input-type", VariantType::String, "digits", {"digits, zsraw, zsonthefly, clusters, compressed-clusters-root, compressed-clusters-flat, trd-tracklets, its-clusters, its-mean-vertex"}},
55 {"output-type", VariantType::String, "tracks", {"cluster, tracks, compressed-clusters-root, compressed-clusters-flat, qa, error-qa, no-shared-cluster-map, send-clusters-per-sector, trd-tracks, tpc-triggers, its-tracks"}},
56 {"disable-root-input", VariantType::Bool, true, {"disable root-files input reader"}},
57 {"disable-mc", VariantType::Bool, false, {"disable sending of MC information"}},
58 {"ignore-dist-stf", VariantType::Bool, false, {"do not subscribe to FLP/DISTSUBTIMEFRAME/0 message (no lost TF recovery)"}},
59 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings (e.g.: 'TPCHwClusterer.peakChargeThreshold=4;...')"}},
60 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}},
61 {"enableDoublePipeline", VariantType::Bool, false, {"enable GPU double pipeline mode"}},
62 {"tpc-deadMap-sources", VariantType::Int, -1, {"Sources to consider for TPC dead channel map creation; -1=all, 0=deactivated"}},
63 {"tpc-mc-time-gain", VariantType::Bool, false, {"use time gain calibration for MC (true) or for data (false)"}},
64 {"filtered-output-specs", VariantType::Bool, false, {"use filtered output specs for output DataDescriptions"}},
65 {"disable-ctp-lumi-request", o2::framework::VariantType::Bool, false, {"do not request CTP lumi"}},
66 };
69 std::swap(workflowOptions, options);
70}
71
72// customize dispatch policy, dispatch immediately what is ready
73void customize(std::vector<DispatchPolicy>& policies)
74{
75 using DispatchOp = DispatchPolicy::DispatchOp;
76 policies.push_back({"prompt-for-gpu-reco", [](auto const& spec) { return true; }, DispatchOp::WhenReady});
77}
78
79void customize(std::vector<CompletionPolicy>& policies)
80{
81 policies.push_back(o2::tpc::TPCSectorCompletionPolicy("gpu-reconstruction.*", o2::tpc::TPCSectorCompletionPolicy::Config::RequireAll, &gPolicyData, &gTpcSectorMask, &gPolicyOrderCheck)());
82}
83
85{
86 hook = [](const char* idstring) {
87 if (gTask) {
88 gTask->deinitialize();
89 }
90 };
91}
92
93#include "Framework/runDataProcessing.h" // the main driver
94
95using namespace o2::framework;
96
114
115static const std::unordered_map<std::string, ioType> InputMap{
116 {"digits", ioType::Digits},
117 {"clusters", ioType::Clusters},
118 {"zsraw", ioType::ZSRaw},
119 {"zsonthefly", ioType::ZSRawOTF},
120 {"compressed-clusters-root", ioType::CompClustROOT},
121 {"compressed-clusters-flat", ioType::CompClustFlat},
122 {"trd-tracklets", ioType::TRDTracklets},
123 {"its-clusters", ioType::ITSClusters},
124 {"its-mean-vertex", ioType::MeanVertex},
125};
126
127static const std::unordered_map<std::string, ioType> OutputMap{
128 {"clusters", ioType::Clusters},
129 {"tracks", ioType::Tracks},
130 {"compressed-clusters-flat", ioType::CompClustFlat},
131 {"compressed-clusters-root", ioType::CompClustROOT},
132 {"qa", ioType::QA},
133 {"error-qa", ioType::ErrorQA},
134 {"no-shared-cluster-map", ioType::NoSharedMap},
135 {"send-clusters-per-sector", ioType::SendClustersPerSector},
136 {"trd-tracks", ioType::TRDTracks},
137 {"its-tracks", ioType::ITSTracks},
138 {"tpc-triggers", ioType::TPCTriggers}};
139
141{
142 WorkflowSpec specs;
143 std::vector<int32_t> tpcSectors(o2::tpc::Sector::MAXSECTOR);
144 std::iota(tpcSectors.begin(), tpcSectors.end(), 0);
145
146 auto inputType = cfgc.options().get<std::string>("input-type");
147 bool doMC = !cfgc.options().get<bool>("disable-mc");
148 auto requestCTPLumi = !cfgc.options().get<bool>("disable-ctp-lumi-request");
149 o2::conf::ConfigurableParam::updateFromFile(cfgc.options().get<std::string>("configFile"));
150 o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
151 o2::conf::ConfigurableParam::writeINI("o2gpurecoworkflow_configuration.ini");
152
153 std::vector<ioType> outputTypes, inputTypes;
154 try {
155 outputTypes = o2::RangeTokenizer::tokenize<ioType>(cfgc.options().get<std::string>("output-type"), [](std::string const& token) { return OutputMap.at(token); });
156 inputTypes = o2::RangeTokenizer::tokenize<ioType>(cfgc.options().get<std::string>("input-type"), [](std::string const& token) { return InputMap.at(token); });
157 } catch (std::out_of_range&) {
158 throw std::invalid_argument("invalid input / output type");
159 }
160
161 auto isEnabled = [](auto& list, ioType type) {
162 return std::find(list.begin(), list.end(), type) != list.end();
163 };
164
166 cfg.runTPCTracking = true;
167 cfg.enableCTPLumi = requestCTPLumi;
168 cfg.decompressTPCFromROOT = isEnabled(inputTypes, ioType::CompClustROOT);
169 cfg.decompressTPC = isEnabled(inputTypes, ioType::CompClustFlat) || cfg.decompressTPCFromROOT;
170 cfg.zsDecoder = isEnabled(inputTypes, ioType::ZSRaw);
171 cfg.zsOnTheFly = isEnabled(inputTypes, ioType::ZSRawOTF);
172 cfg.caClusterer = cfg.zsDecoder || cfg.zsOnTheFly || isEnabled(inputTypes, ioType::Digits);
173 cfg.outputTracks = isEnabled(outputTypes, ioType::Tracks);
174 cfg.outputCompClustersRoot = isEnabled(outputTypes, ioType::CompClustROOT);
175 cfg.outputCompClustersFlat = isEnabled(outputTypes, ioType::CompClustFlat);
176 cfg.outputCAClusters = isEnabled(outputTypes, ioType::Clusters);
177 cfg.outputQA = isEnabled(outputTypes, ioType::QA);
178 cfg.outputErrorQA = isEnabled(outputTypes, ioType::ErrorQA);
179 cfg.outputSharedClusterMap = (cfg.outputCAClusters || cfg.caClusterer || isEnabled(inputTypes, ioType::Clusters)) && cfg.outputTracks && !isEnabled(outputTypes, ioType::NoSharedMap);
180 cfg.processMC = doMC;
181 cfg.sendClustersPerSector = isEnabled(outputTypes, ioType::SendClustersPerSector);
182 cfg.askDISTSTF = !cfgc.options().get<bool>("ignore-dist-stf");
183 cfg.readTRDtracklets = isEnabled(inputTypes, ioType::TRDTracklets);
184 cfg.runTRDTracking = isEnabled(outputTypes, ioType::TRDTracks);
185 cfg.tpcTriggerHandling = isEnabled(outputTypes, ioType::TPCTriggers) || cfg.caClusterer;
186 cfg.enableDoublePipeline = cfgc.options().get<bool>("enableDoublePipeline");
187 cfg.tpcDeadMapSources = cfgc.options().get<int32_t>("tpc-deadMap-sources");
188 cfg.tpcUseMCTimeGain = cfgc.options().get<bool>("tpc-mc-time-gain");
189 cfg.runITSTracking = isEnabled(outputTypes, ioType::ITSTracks);
191 cfg.itsOverrBeamEst = isEnabled(inputTypes, ioType::MeanVertex);
192 cfg.useFilteredOutputSpecs = cfgc.options().get<bool>("filtered-output-specs");
193
194 Inputs ggInputs;
195 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, true, false, true, true, o2::base::GRPGeomRequest::Aligned, ggInputs, true);
196
197 auto task = std::make_shared<GPURecoWorkflowSpec>(&gPolicyData, cfg, tpcSectors, gTpcSectorMask, ggRequest, &gPolicyOrderCheck);
198 Inputs taskInputs = task->inputs();
199 std::move(ggInputs.begin(), ggInputs.end(), std::back_inserter(taskInputs));
200 gTask = task;
201
202 specs.emplace_back(DataProcessorSpec{
203 "gpu-reconstruction",
204 taskInputs,
205 task->outputs(),
206 AlgorithmSpec{adoptTask<GPURecoWorkflowSpec>(task)},
207 task->options()});
208
209 if (cfg.enableDoublePipeline) {
210 cfg.enableDoublePipeline = 2;
211 Inputs ggInputsPrepare;
212 auto ggRequestPrepare = std::make_shared<o2::base::GRPGeomRequest>(false, true, false, false, false, o2::base::GRPGeomRequest::None, ggInputsPrepare, true);
213 auto taskPrepare = std::make_shared<GPURecoWorkflowSpec>(&gPolicyData, cfg, tpcSectors, gTpcSectorMask, ggRequestPrepare);
214 Inputs taskInputsPrepare = taskPrepare->inputs();
215 std::move(ggInputsPrepare.begin(), ggInputsPrepare.end(), std::back_inserter(taskInputsPrepare));
216 specs.emplace_back(DataProcessorSpec{
217 "gpu-reconstruction-prepare",
218 taskInputsPrepare,
219 taskPrepare->outputs(),
220 AlgorithmSpec{adoptTask<GPURecoWorkflowSpec>(taskPrepare)},
221 taskPrepare->options()});
222 }
223
224 // configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
225 o2::raw::HBFUtilsInitializer hbfIni(cfgc, specs);
226
227 return specs;
228}
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Helper function to tokenize sequences and ranges of integral numbers.
DPL completion policy helper for TPC scetor data.
std::vector< InputSpec > CompletionPolicyData
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void updateFromFile(std::string const &, std::string const &paramsList="", bool unchangedOnly=false)
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
static constexpr int MAXSECTOR
Definition Sector.h:44
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
@ TRDTracklets
@ TPCTriggers
@ CompClustFlat
@ CompClustROOT
@ ITSClusters
@ SendClustersPerSector
@ NoSharedMap
@ MeanVertex
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)
const std::unordered_map< std::string, OutputType > OutputMap
const std::unordered_map< std::string, InputType > InputMap
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::function< void(const char *)> OnWorkflowTerminationHook
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > Inputs
static bool isITSStaggeringEnabled(o2::framework::ConfigContext const &cfgc)
static void addITSConfigOption(std::vector< o2::framework::ConfigParamSpec > &opts)
static void addNewTimeSliceCallback(std::vector< o2::framework::CallbacksPolicy > &policies)
static void addConfigOption(std::vector< o2::framework::ConfigParamSpec > &opts, const std::string &defOpt=std::string(o2::base::NameConf::DIGITIZATIONCONFIGFILE))
std::vector< InputSpec > gPolicyData
unsigned long gTpcSectorMask