Project
Loading...
Searching...
No Matches
tpc-integrate-idc.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 <vector>
13#include <string>
14#include <thread>
23#include "TPCBase/Sector.h"
24
25using namespace o2::framework;
26
27// we need to add workflow options before including Framework/runDataProcessing
28void customize(std::vector<ConfigParamSpec>& workflowOptions)
29{
30 const std::string sectorDefault = "0-" + std::to_string(o2::tpc::Sector::MAXSECTOR - 1);
31 const int defaultlanes = std::max(1u, std::thread::hardware_concurrency() / 2);
32
33 std::vector<ConfigParamSpec> options{
34 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
35 {"nOrbits", VariantType::Int, 12, {"number of orbits for which the IDCs are integrated"}},
36 {"outputFormat", VariantType::String, "Sim", {"setting the output format type: 'Sim'=IDC simulation format, 'Real'=real output format of CRUs (not implemented yet)"}},
37 {"debug", VariantType::Bool, false, {"create debug tree"}},
38 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}},
39 {"lanes", VariantType::Int, defaultlanes, {"Number of parallel processing lanes."}},
40 {"sectors", VariantType::String, sectorDefault.c_str(), {"List of TPC sectors, comma separated ranges, e.g. 0-3,7,9-15"}},
41 {"hbfutils-config", VariantType::String, std::string(o2::base::NameConf::DIGITIZATIONCONFIGFILE), {"config file for HBFUtils (or none) to get number of orbits per TF"}}};
42
43 std::swap(workflowOptions, options);
44}
45
47
49{
50 using namespace o2::tpc;
51
52 // set up configuration
53 o2::conf::ConfigurableParam::updateFromFile(config.options().get<std::string>("configFile"));
54 std::string confDig = config.options().get<std::string>("hbfutils-config");
55 if (!confDig.empty() && confDig != "none") {
57 }
58 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
59 o2::conf::ConfigurableParam::writeINI("o2tpcintegrateidc_configuration.ini");
60
61 const auto& hbfu = o2::raw::HBFUtils::Instance();
62 LOGP(info, "Setting {} orbits per TF", hbfu.getNOrbitsPerTF());
63 o2::tpc::IDCSim::setNOrbitsPerTF(hbfu.getNOrbitsPerTF());
64
65 const auto nOrbits = config.options().get<int>("nOrbits");
66 const auto outputFormatStr = config.options().get<std::string>("outputFormat");
67 const TPCIntegrateIDCDevice::IDCFormat outputFormat = outputFormatStr.compare("Sim") ? TPCIntegrateIDCDevice::IDCFormat::Real : TPCIntegrateIDCDevice::IDCFormat::Sim;
68 const auto debug = config.options().get<bool>("debug");
69 const auto tpcsectors = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("sectors"));
70 const auto nSectors = tpcsectors.size();
71 const auto nLanes = std::min(static_cast<unsigned long>(config.options().get<int>("lanes")), nSectors);
72 const auto sectorsPerLane = nSectors / nLanes + ((nSectors % nLanes) != 0);
73
74 WorkflowSpec workflow;
75 if (nLanes <= 0) {
76 return workflow;
77 }
78
79 for (int ilane = 0; ilane < nLanes; ++ilane) {
80 const auto first = tpcsectors.begin() + ilane * sectorsPerLane;
81 if (first >= tpcsectors.end()) {
82 break;
83 }
84 const auto last = std::min(tpcsectors.end(), first + sectorsPerLane);
85 const std::vector<unsigned int> rangeSectors(first, last);
86 workflow.emplace_back(getTPCIntegrateIDCSpec(ilane, rangeSectors, nOrbits, outputFormat, debug));
87 }
88
89 return workflow;
90}
class for integration of IDCs
Definition of the Names Generator class.
Helper function to tokenize sequences and ranges of integral numbers.
TPC integration of IDCs processor.
std::ostringstream debug
static constexpr std::string_view DIGITIZATIONCONFIGFILE
Definition NameConf.h:89
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 void setNOrbitsPerTF(const unsigned int nOrbitsPerTF)
Definition IDCSim.h:57
static constexpr int MAXSECTOR
Definition Sector.h:44
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
Global TPC definitions and constants.
Definition SimTraits.h:167
DataProcessorSpec getTPCIntegrateIDCSpec(const int ilane, const std::vector< unsigned int > &sectors, const int nOrbits=12, const TPCIntegrateIDCDevice::IDCFormat outputFormat=TPCIntegrateIDCDevice::IDCFormat::Sim, const bool debug=false)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< ConfigParamSpec > &workflowOptions)