Project
Loading...
Searching...
No Matches
tpc-calib-pad-raw.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
15//
16#include <fmt/format.h>
23#include "Framework/Logger.h"
27#include "DPLUtils/RawParser.h"
28#include "Headers/DataHeader.h"
32#include <vector>
33#include <string>
35#include "TPCBase/RDHUtils.h"
38
39using namespace o2::framework;
41
42const std::string DEFAULTINPUT = "A:TPC/RAWDATA";
43
44// customize the completion policy
45void customize(std::vector<o2::framework::CompletionPolicy>& policies)
46{
48 policies.push_back(CompletionPolicyHelpers::defineByName("calib-tpc-raw.*", CompletionPolicy::CompletionOp::Consume));
49}
50
51// we need to add workflow options before including Framework/runDataProcessing
52void customize(std::vector<ConfigParamSpec>& workflowOptions)
53{
54 std::string sectorDefault = "0-" + std::to_string(o2::tpc::Sector::MAXSECTOR - 1);
55 int defaultlanes = std::max(1u, std::thread::hardware_concurrency() / 2);
56
57 std::vector<ConfigParamSpec> options{
58 {"input-spec", VariantType::String, DEFAULTINPUT, {"selection string input specs"}},
59 {"publish-after-tfs", VariantType::UInt32, 0u, {"number of time frames after which to force publishing the objects"}},
60 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings (e.g.: 'TPCCalibPedestal.FirstTimeBin=10;...')"}},
61 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}},
62 {"calib-type", VariantType::String, "pedestal", {"Calibration type to run: pedestal, pulser, ce"}},
63 {"no-write-ccdb", VariantType::Bool, false, {"skip sending the calibration output to CCDB"}},
64 {"lanes", VariantType::Int, defaultlanes, {"Number of parallel processing lanes."}},
65 {"sectors", VariantType::String, sectorDefault.c_str(), {"List of TPC sectors, comma separated ranges, e.g. 0-3,7,9-15"}},
66 };
67
68 std::swap(workflowOptions, options);
69}
70
72
74
76{
77 using namespace o2::tpc;
78
79 // set up configuration
80 o2::conf::ConfigurableParam::updateFromFile(config.options().get<std::string>("configFile"));
81 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
82 o2::conf::ConfigurableParam::writeINI("o2tpccalibration_configuration.ini");
83
84 std::string inputSpec = config.options().get<std::string>("input-spec");
85 const auto skipCCDB = config.options().get<bool>("no-write-ccdb");
86 const auto publishAfterTFs = config.options().get<uint32_t>("publish-after-tfs");
87
88 const auto tpcsectors = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("sectors"));
89 const auto nSectors = (uint32_t)tpcsectors.size();
90 auto nLanes = std::min((uint32_t)config.options().get<int>("lanes"), nSectors);
91 const auto sectorsPerLane = nSectors / nLanes + ((nSectors % nLanes) != 0);
92
93 CDBType rawType;
94 try {
95 rawType = CalibRawTypeMap.at(config.options().get<std::string>("calib-type"));
96 if ((rawType == CDBType::CalCE) && (inputSpec == DEFAULTINPUT)) {
97 inputSpec = "tpcdigits:TPC/CEDIGITS";
98 }
99 } catch (std::out_of_range&) {
100 throw std::invalid_argument(std::string("invalid writer-type type: ") + config.options().get<std::string>("calib-type"));
101 }
102
103 WorkflowSpec workflow;
104
105 if (nLanes <= 0) {
106 return workflow;
107 }
108
109 const bool digitInput = inputSpec.find("DIGITS") != std::string::npos;
110 if (digitInput && nLanes != 1) {
111 LOGP(info, "only one lane allowed for DIGIT type input");
112 nLanes = 1;
113 }
114 for (int ilane = 0; ilane < nLanes; ++ilane) {
115 auto first = tpcsectors.begin() + ilane * sectorsPerLane;
116 if (first >= tpcsectors.end()) {
117 break;
118 }
119 auto last = std::min(tpcsectors.end(), first + sectorsPerLane);
120 std::vector<int> range(first, last);
121 workflow.emplace_back(getTPCCalibPadRawSpec(inputSpec, ilane, range, publishAfterTFs, rawType));
122 }
123
124 workflow.emplace_back(getCalDetMergerPublisherSpec(nLanes, skipCCDB, publishAfterTFs > 0));
125
126 return workflow;
127}
TPC CalDet merger and CCDB publisher.
A helper class to iteratate over all parts of all input routes.
Helper function to tokenize sequences and ranges of integral numbers.
Generic parser for consecutive raw pages.
TPC Pad-wise raw data calibration processor.
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
GLenum GLint * range
Definition glcorearb.h:1899
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
RAWDataHeaderV7 RAWDataHeader
Global TPC definitions and constants.
Definition SimTraits.h:167
DataProcessorSpec getTPCCalibPadRawSpec(const std::string inputSpec, uint32_t ilane=0, std::vector< int > sectors={}, uint32_t publishAfterTFs=0, CDBType rawType=CDBType::CalPedestalNoise)
const std::unordered_map< std::string, CDBType > CalibRawTypeMap
o2::framework::DataProcessorSpec getCalDetMergerPublisherSpec(uint32_t lanes, bool skipCCDB, bool dumpAfterComplete=false)
CDBType
Calibration and parameter types for CCDB.
Definition CDBTypes.h:26
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static CompletionPolicy defineByName(std::string const &name, CompletionPolicy::CompletionOp op)
const std::string DEFAULTINPUT
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< o2::framework::CompletionPolicy > &policies)