Project
Loading...
Searching...
No Matches
trd-tracking-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
19#include "TRDPID/PIDBase.h"
29
30using namespace o2::framework;
32
33// ------------------------------------------------------------------
34void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
35{
37}
38
39void customize(std::vector<o2::framework::CompletionPolicy>& policies)
40{
41 // ordered policies for the writers
42 policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*(?:TRD|trd).*[W,w]riter.*"));
43}
44
45// we need to add workflow options before including Framework/runDataProcessing
46void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
47{
48 // option allowing to set parameters
49 std::vector<o2::framework::ConfigParamSpec> options{
50 {"disable-mc", VariantType::Bool, false, {"Disable MC labels"}},
51 {"disable-root-input", VariantType::Bool, false, {"disable root-files input readers"}},
52 {"disable-root-output", VariantType::Bool, false, {"disable root-files output writers"}},
53 {"enable-vdexb-calib", VariantType::Bool, false, {"enable vDrift and ExB calibration based on tracking output"}},
54 {"enable-gain-calib", VariantType::Bool, false, {"enable collection of dEdx histos for gain calibration"}},
55 {"enable-qc", VariantType::Bool, false, {"enable tracking QC"}},
56 {"enable-pid", VariantType::Bool, false, {"Enable PID"}},
57 {"enable-ph", VariantType::Bool, false, {"Enable creation of PH plots"}},
58 {"trd-digits-spec", VariantType::Int, 0, {"Input digits subspec, ignored if disable-root-input is false"}},
59 {"track-sources", VariantType::String, std::string{GTrackID::ALL}, {"comma-separated list of sources to use for tracking"}},
60 {"filter-trigrec", VariantType::Bool, false, {"ignore interaction records without ITS data"}},
61 {"strict-matching", VariantType::Bool, false, {"High purity preliminary matching"}},
62 {"disable-ft0-pileup-tagging", VariantType::Bool, false, {"Do not request FT0 for pile-up determination"}},
63 {"policy", VariantType::String, "default", {"Pick PID policy (=default)"}},
64 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
67 std::swap(workflowOptions, options);
68}
69
70// ------------------------------------------------------------------
71
73
75{
76 GTrackID::mask_t allowedSources = GTrackID::getSourcesMask("ITS-TPC,TPC");
77 // Update the (declared) parameters if changed from the command line
78 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
79 // write the configuration used for the workflow
80 o2::conf::ConfigurableParam::writeINI("o2trdtracking-workflow_configuration.ini");
81 auto useMC = !configcontext.options().get<bool>("disable-mc");
82 auto pid = configcontext.options().get<bool>("enable-pid");
83 auto strict = configcontext.options().get<bool>("strict-matching");
84 auto trigRecFilterActive = configcontext.options().get<bool>("filter-trigrec");
85 auto vdexb = configcontext.options().get<bool>("enable-vdexb-calib");
86 auto gain = configcontext.options().get<bool>("enable-gain-calib");
87 auto pulseHeight = configcontext.options().get<bool>("enable-ph");
88 auto digitsSpec = configcontext.options().get<int>("trd-digits-spec");
90 bool rootInput = !configcontext.options().get<bool>("disable-root-input");
91 GTrackID::mask_t srcTRD = allowedSources & GTrackID::getSourcesMask(configcontext.options().get<std::string>("track-sources"));
92 if (strict && (srcTRD & ~GTrackID::getSourcesMask("TPC")).any()) {
93 LOGP(warning, "In strict matching mode only TPC source allowed, {} asked, redefining", GTrackID::getSourcesNames(srcTRD));
94 srcTRD = GTrackID::getSourcesMask("TPC");
95 }
96 if (!configcontext.options().get<bool>("disable-ft0-pileup-tagging")) {
97 srcTRD |= GTrackID::getSourcesMask("FT0");
98 }
99 if (sclOpt.requestCTPLumi) {
100 srcTRD = srcTRD | GTrackID::getSourcesMask("CTP");
101 }
102 // Parse PID policy string
104 if (pid) {
105 auto policyStr = configcontext.options().get<std::string>("policy");
106 auto policyIt = o2::trd::PIDPolicyString.find(policyStr);
107 if (policyIt == o2::trd::PIDPolicyString.end()) {
108 throw std::runtime_error(fmt::format("No PID model named {:s} available!", policyStr));
109 }
110 policy = policyIt->second;
111 LOGF(info, "Using PID policy %s(%u)", policyStr, static_cast<unsigned int>(policy));
112 }
113
114 // processing devices
116 if (sclOpt.needTPCScalersWorkflow() && !configcontext.options().get<bool>("disable-root-input")) {
117 specs.emplace_back(o2::tpc::getTPCScalerSpec(sclOpt.lumiType == 2, sclOpt.enableMShapeCorrection));
118 }
119 specs.emplace_back(o2::trd::getTRDGlobalTrackingSpec(useMC, srcTRD, trigRecFilterActive, strict, pid, policy, sclOpt));
120 if (vdexb || gain) {
121 specs.emplace_back(o2::trd::getTRDTrackBasedCalibSpec(srcTRD, vdexb, gain));
122 }
123 if (configcontext.options().get<bool>("enable-qc")) {
124 specs.emplace_back(o2::trd::getTRDGlobalTrackingQCSpec(srcTRD));
125 }
126 if (pulseHeight) {
127 if (rootInput) {
128 specs.emplace_back(o2::trd::getTRDDigitReaderSpec(useMC));
129 }
130 specs.emplace_back(o2::framework::getTRDPulseHeightSpec(srcTRD, rootInput ? 1 : digitsSpec));
131 }
132
133 // output devices
134 if (!configcontext.options().get<bool>("disable-root-output")) {
135 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, srcTRD)) {
136 specs.emplace_back(o2::trd::getTRDGlobalTrackWriterSpec(useMC));
137 }
138 if (GTrackID::includesSource(GTrackID::Source::TPC, srcTRD)) {
139 specs.emplace_back(o2::trd::getTRDTPCTrackWriterSpec(useMC, strict));
140 }
141 if (vdexb || gain || pulseHeight) {
142 specs.emplace_back(o2::trd::getTRDCalibWriterSpec(vdexb, gain, pulseHeight));
143 }
144 if (configcontext.options().get<bool>("enable-qc")) {
145 specs.emplace_back(o2::trd::getTRDTrackingQCWriterSpec());
146 }
147 }
148
149 // input
150 auto maskClusters = GTrackID::getSourcesMask("TRD,TPC");
151 auto maskTracks = srcTRD | GTrackID::getSourcesMask("TPC"); // we always need the TPC tracks for the refit
152 if (GTrackID::includesDet(GTrackID::DetID::ITS, srcTRD)) {
153 maskClusters |= GTrackID::getSourcesMask("ITS");
154 maskTracks |= GTrackID::getSourcesMask("ITS");
155 }
156 auto maskMatches = GTrackID::getSourcesMask(GTrackID::NONE);
157 o2::globaltracking::InputHelper::addInputSpecs(configcontext, specs, maskClusters, maskMatches, maskTracks, useMC);
158
159 // configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
160 o2::raw::HBFUtilsInitializer hbfIni(configcontext, specs);
161
162 return specs;
163}
Helper class to access load maps from CCDB.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
This file provides the base interface for pid policies.
uint16_t pid
Definition RawData.h:2
Quality control for global tracking (residuals etc)
DPL device for creating a pulse height spectrum with digits on tracks.
Steers the creation of calibration input based on tracks.
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void updateFromString(std::string const &)
static mask_t getSourcesMask(const std::string_view srcList)
static std::string getSourcesNames(mask_t srcm)
static constexpr std::string_view NONE
keywork for no sources
static constexpr std::string_view ALL
keywork for all sources
ConfigParamRegistry & options() const
static int addInputSpecs(const o2::framework::ConfigContext &configcontext, o2::framework::WorkflowSpec &specs, GID::mask_t maskClusters, GID::mask_t maskMatches, GID::mask_t maskTracks, bool useMC=true, GID::mask_t maskClustersMC=GID::getSourcesMask(GID::ALL), GID::mask_t maskTracksMC=GID::getSourcesMask(GID::ALL), bool subSpecStrict=false)
static void addGlobalOptions(std::vector< o2::framework::ConfigParamSpec > &options)
static CorrectionMapsLoaderGloOpts parseGlobalOptions(const o2::framework::ConfigParamRegistry &opts)
GLuint GLuint end
Definition glcorearb.h:469
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMShape)
DataProcessorSpec getTRDTrackingQCWriterSpec()
framework::DataProcessorSpec getTRDTPCTrackWriterSpec(bool useMC, bool strictMode=false)
writer for matches with TPC-only tracks
framework::DataProcessorSpec getTRDGlobalTrackWriterSpec(bool useMC)
writer for matches to ITS-TPC tracks
DataProcessorSpec getTRDGlobalTrackingQCSpec(o2::dataformats::GlobalTrackID::mask_t src)
PIDPolicy
Option for available PID policies.
Definition PID.h:29
@ DEFAULT
The default option.
framework::DataProcessorSpec getTRDTrackBasedCalibSpec(o2::dataformats::GlobalTrackID::mask_t src, bool vdexb, bool gain)
create a processor spec
o2::framework::DataProcessorSpec getTRDDigitReaderSpec(bool useMC, bool trigRec=true, int dataSubspec=1)
o2::framework::DataProcessorSpec getTRDCalibWriterSpec(bool vdexb, bool gain, bool ph)
framework::DataProcessorSpec getTRDGlobalTrackingSpec(bool useMC, o2::dataformats::GlobalTrackID::mask_t src, bool trigRecFilterActive, bool strict, bool withPID, PIDPolicy policy, const o2::tpc::CorrectionMapsLoaderGloOpts &sclOpts)
create a processor spec
static CompletionPolicy consumeWhenAllOrdered(const char *name, CompletionPolicy::Matcher matcher)
as consumeWhenAll, but ensures that records are processed with incremental timeSlice (DataHeader::sta...
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))
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)