Project
Loading...
Searching...
No Matches
tpc-interpolation-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
23
24using namespace o2::framework;
26
27// ------------------------------------------------------------------
28void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
29{
31}
32
33// we need to add workflow options before including Framework/runDataProcessing
34void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
35{
36 // option allowing to set parameters
37 std::vector<o2::framework::ConfigParamSpec> options{
38 {"disable-root-input", VariantType::Bool, false, {"disable root-files input readers"}},
39 {"disable-root-output", VariantType::Bool, false, {"disable root-files output writers"}},
40 {"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}},
41 {"enable-mc", VariantType::Bool, false, {"store the MC truth of the track data (needs MC input and send-track-data)"}},
42 {"vtx-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources used for the vertex finding"}},
43 {"tracking-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use for track inter-/extrapolation"}},
44 {"tracking-sources-map-extraction", VariantType::String, std::string{GID::ALL}, {"can be subset of \"tracking-sources\""}},
45 {"send-track-data", VariantType::Bool, false, {"Send also the track information to the aggregator"}},
46 {"debug-output", VariantType::Bool, false, {"Dump extended tracking information for debugging"}},
47 {"skip-ext-det-residuals", VariantType::Bool, false, {"Do not produce residuals for external detectors"}},
48 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
51 std::swap(workflowOptions, options);
52}
53
54// the matcher process requires the TPC sector completion to trigger and data on
55// all defined routes
56void customize(std::vector<o2::framework::CompletionPolicy>& policies)
57{
58 // the TPC sector completion policy checks when the set of TPC/CLUSTERNATIVE data is complete
59 // in addition we require to have input from all other routes
60 policies.push_back(o2::tpc::TPCSectorCompletionPolicy("tpc-track-interpolation",
62 InputSpec{"cluster", o2::framework::ConcreteDataTypeMatcher{"TPC", "CLUSTERNATIVE"}})());
63 // ordered policies for the writers
64 policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*tpc-residuals-writer.*"));
65}
66
67// ------------------------------------------------------------------
68
70
72{
73 WorkflowSpec specs;
74 GID::mask_t allowedSources = GID::getSourcesMask("ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF");
75 GID::mask_t srcVtx = allowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("vtx-sources"));
76 GID::mask_t srcTracks = allowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("tracking-sources"));
77 GID::mask_t srcTracksMap = allowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("tracking-sources-map-extraction"));
78 if (srcTracks.count() > srcVtx.count()) {
79 LOGP(error, "More sources configured for inter-/extrapolation: {} than for vertexing: {}. Additional sources will be ignored", GID::getSourcesNames(srcTracks), GID::getSourcesNames(srcVtx));
80 srcTracks &= srcVtx;
81 }
82 srcTracksMap &= srcVtx;
83 if (((srcTracksMap | srcTracks) ^ srcTracks).any()) {
84 LOGP(fatal, "tracking-sources-map-extraction ({}) must be a subset of tracking-sources ({}).", GID::getSourcesNames(srcTracksMap), GID::getSourcesNames(srcTracks));
85 } else if (srcTracksMap != srcTracks) {
86 LOGP(info, "Will extract residual from different track types. For vDrift from {} and for distortion map from {}", GID::getSourcesNames(srcTracks), GID::getSourcesNames(srcTracksMap));
87 } else {
88 LOGP(info, "Only a single track source is defined for residuals extraction: {}", GID::getSourcesNames(srcTracks));
89 }
90 LOG(debug) << "Data sources for inter-/extrapolation: " << GID::getSourcesNames(srcTracks);
91 // check first if ITS-TPC tracks were specifically requested from command line
92 bool processITSTPConly = srcTracks[GID::ITSTPC];
93 srcTracks |= GID::getSourcesMask("ITS,TPC,ITS-TPC"); // now add them in any case
94 srcTracksMap |= GID::getSourcesMask("ITS,TPC,ITS-TPC");
95 srcVtx |= srcTracks;
96 GID::mask_t srcClusters = srcTracks;
97 if (srcTracks[GID::ITSTPCTRD] || srcTracks[GID::ITSTPCTRDTOF]) {
98 srcClusters |= GID::getSourcesMask("TRD");
99 }
100 if (srcTracks[GID::ITSTPCTOF] || srcTracks[GID::ITSTPCTRDTOF]) {
101 srcClusters |= GID::getSourcesMask("TOF");
102 }
103 // Update the (declared) parameters if changed from the command line
104 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
105 // write the configuration used for the workflow
106 o2::conf::ConfigurableParam::writeINI("o2tpcinterpolation-workflow_configuration.ini");
107 // MC is opt-in: the residuals workflow is also run on data without passing disable-mc
108 auto useMC = configcontext.options().get<bool>("enable-mc") && !configcontext.options().get<bool>("disable-mc");
110 auto sendTrackData = configcontext.options().get<bool>("send-track-data");
111 auto debugOutput = configcontext.options().get<bool>("debug-output");
112 auto extDetResid = !configcontext.options().get<bool>("skip-ext-det-residuals");
113
114 specs.emplace_back(o2::tpc::getTPCInterpolationSpec(srcClusters, srcVtx, srcTracks, srcTracksMap, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid, doStag));
115 if (!configcontext.options().get<bool>("disable-root-output")) {
116 specs.emplace_back(o2::tpc::getTPCResidualWriterSpec(sendTrackData, debugOutput, useMC && sendTrackData));
117 }
118
119 // MC labels only for the ITS-TPC tracks and their ITS and TPC parts (see getTPCInterpolationSpec)
120 GID::mask_t maskTracksMC = useMC ? GID::getSourcesMask("ITS,TPC,ITS-TPC") : GID::getSourcesMask(GID::NONE);
121 o2::globaltracking::InputHelper::addInputSpecs(configcontext, specs, srcClusters, srcVtx, srcVtx, useMC, GID::getSourcesMask(GID::NONE), maskTracksMC);
122 o2::globaltracking::InputHelper::addInputSpecsPVertex(configcontext, specs, false); // P-vertex is always needed
123
124 // configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
125 o2::raw::HBFUtilsInitializer hbfIni(configcontext, specs);
126
127 return specs;
128}
std::ostringstream debug
Global index for barrel track: provides provenance (detectors combination), index in respective array...
DPL completion policy helper for TPC scetor data.
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 int addInputSpecsPVertex(const o2::framework::ConfigContext &configcontext, o2::framework::WorkflowSpec &specs, bool mc)
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< DataProcessorSpec > WorkflowSpec
framework::DataProcessorSpec getTPCResidualWriterSpec(bool writeTrackData, bool debugOutput, bool writeTrackDataMC)
create a processor spec
framework::DataProcessorSpec getTPCInterpolationSpec(o2::dataformats::GlobalTrackID::mask_t srcCls, o2::dataformats::GlobalTrackID::mask_t srcVtx, o2::dataformats::GlobalTrackID::mask_t srcTrk, o2::dataformats::GlobalTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput, bool extDetResid, bool itsStag)
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 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))
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)