Project
Loading...
Searching...
No Matches
tpc-raw-to-digits-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
12#include <fmt/format.h>
16#include "Framework/Logger.h"
24#include "TPCBase/Sector.h"
25#include <vector>
26#include <string>
27
28#include <thread> // to detect number of hardware threads
29
30using namespace o2::framework;
31
32// customize the completion policy
33void customize(std::vector<o2::framework::CompletionPolicy>& policies)
34{
36 policies.push_back(CompletionPolicyHelpers::defineByName("tpc-raw-to-digits-.*", CompletionPolicy::CompletionOp::Consume));
37}
38
39// we need to add workflow options before including Framework/runDataProcessing
40void customize(std::vector<ConfigParamSpec>& workflowOptions)
41{
42 // for the TPC it is useful to take at most half of the available (logical) cores due to memory requirements
43 int defaultlanes = std::max(1u, std::thread::hardware_concurrency() / 2);
44 const std::string laneshelp("Number of tpc processing lanes. A lane is a pipeline of algorithms.");
45
46 const std::string sectorshelp("List of TPC sectors, comma separated ranges, e.g. 0-3,7,9-15");
47 const std::string sectorDefault = "0-" + std::to_string(o2::tpc::Sector::MAXSECTOR - 1);
48 const std::string tpcrthelp("Run TPC reco workflow to specified output type, currently supported: 'digits,clusters,tracks'");
49
50 std::vector<ConfigParamSpec> options{
51 {"input-spec", VariantType::String, "A:TPC/RAWDATA", {"selection string input specs"}},
52 {"tpc-lanes", VariantType::Int, defaultlanes, {laneshelp}},
53 {"tpc-sectors", VariantType::String, sectorDefault.c_str(), {sectorshelp}},
54 {"tpc-reco-output", VariantType::String, "", {tpcrthelp}},
55 {"ignore-dist-stf", VariantType::Bool, false, {"do not subscribe to FLP/DISTSUBTIMEFRAME/0 message (no lost TF recovery)"}},
56 {"send-ce-digits", VariantType::Bool, false, {"filter CE digits and publish them for analysis on a separate stream"}},
57 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings (e.g.: 'TPCCalibPedestal.FirstTimeBin=10;...')"}},
58 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}}};
59
60 std::swap(workflowOptions, options);
61}
62
64
65// extract num TPC lanes, a lane is a streaming line of processors (digitizer-clusterizer-etc)
66// by default this will be std::max(the number of physical cores, numberofsectors)
67// as a temporary means to fully use a machine and as a way to play with different topologies
68int getNumTPCLanes(std::vector<int> const& sectors, ConfigContext const& configcontext)
69{
70 auto lanes = configcontext.options().get<int>("tpc-lanes");
71 if (lanes < 0) {
72 LOG(fatal) << "tpc-lanes needs to be positive\n";
73 return 0;
74 }
75 // crosscheck with sectors
76 return std::min(lanes, (int)sectors.size());
77}
78
80{
81
82 // set up configuration
83 o2::conf::ConfigurableParam::updateFromFile(configcontext.options().get<std::string>("configFile"));
84 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
85 o2::conf::ConfigurableParam::writeINI("o2-tpc-raw-reco-workflow_configuration.ini");
86
87 WorkflowSpec specs;
88
89 // for the moment no parallel workflow, so just one lane hard coded
90 auto tpcSectors = o2::RangeTokenizer::tokenize<int>(configcontext.options().get<std::string>("tpc-sectors"));
91 auto lanes = 1; // getNumTPCLanes(tpcSectors, configcontext);
92 const bool sendCEdigits = configcontext.options().get<bool>("send-ce-digits");
93
94 int fanoutsize = 0;
95 for (int l = 0; l < lanes; ++l) {
96 specs.emplace_back(o2::tpc::getRawToDigitsSpec(fanoutsize, configcontext.options().get<std::string>("input-spec"), configcontext.options().get<bool>("ignore-dist-stf"), tpcSectors, sendCEdigits));
97 fanoutsize++;
98 }
99
100 // ===| attach the TPC reco workflow |========================================
101 // default is to dump digits
102 std::string_view recoOuput = "digits";
103 const auto tpcRecoOutputType = configcontext.options().get<std::string>("tpc-reco-output");
104 if (!tpcRecoOutputType.empty()) {
105 recoOuput = tpcRecoOutputType.c_str();
106 }
107
108 return specs;
109}
Helper function to tokenize sequences and ranges of integral numbers.
Processor spec for running TPC GBT raw frame to digit converter.
Workflow definition for the TPC reconstruction.
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
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
o2::framework::DataProcessorSpec getRawToDigitsSpec(int channel, const std::string inputSpec, bool ignoreDistStf, std::vector< int > const &tpcSectors, bool sendCEdigits=false)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static CompletionPolicy defineByName(std::string const &name, CompletionPolicy::CompletionOp op)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
int getNumTPCLanes(std::vector< int > const &sectors, ConfigContext const &configcontext)
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< o2::framework::CompletionPolicy > &policies)