Project
Loading...
Searching...
No Matches
TrackReaderWorkflow.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
13
19#include "Framework/PartRef.h"
22
29
31
32#include <string>
33#include <stdexcept>
34#include <unordered_map>
35#include <regex>
36
37// we need a global variable to propagate the type the message dispatching of the
38// publisher will trigger on. This is dependent on the input type
40
41void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
42{
44}
45
46// Global variable used to transport data to the completion policy
48
49// add workflow options, note that customization needs to be declared before
50// including Framework/runDataProcessing
51void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
52{
53 using namespace o2::framework;
54
55 std::vector<ConfigParamSpec> options{
56 {"input-type", VariantType::String, "tracks", {"tracks"}},
57 {"dispatching-mode", VariantType::String, "prompt", {"determines when to dispatch: prompt, complete"}},
58 {"configKeyValues", VariantType::String, "", {"semicolon separated key=value strings"}},
59 {"disable-mc", VariantType::Bool, false, {"disable sending of MC information"}}};
61 std::swap(workflowOptions, options);
62}
63
64// customize dispatch policy, dispatch immediately what is ready
65void customize(std::vector<o2::framework::DispatchPolicy>& policies)
66{
68 // we customize all devices to dispatch data immediately
69 auto readerMatcher = [](auto const& spec) {
70 return std::regex_match(spec.name.begin(), spec.name.end(), std::regex(".*-reader"));
71 };
72 auto triggerMatcher = [](auto const& query) {
73 // a bit of a hack but we want this to be configurable from the command line,
74 // however DispatchPolicy is inserted before all other setup. Triggering depending
75 // on the global variable set from the command line option. If scheduled messages
76 // are not triggered they are sent out at the end of the computation
77 return gDispatchTrigger.origin == query.origin && gDispatchTrigger.description == query.description;
78 };
79 policies.push_back({"prompt-for-reader", readerMatcher, DispatchOp::WhenReady, triggerMatcher});
80}
81
82#include "Framework/runDataProcessing.h" // the main driver
83
84using namespace o2::framework;
85
90{
91 WorkflowSpec specs;
92 o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
93 auto inputType = cfgc.options().get<std::string>("input-type");
94 auto dispmode = cfgc.options().get<std::string>("dispatching-mode");
95 if (dispmode == "complete") {
96 // nothing to do we leave the matcher empty which will suppress the dispatch
97 // trigger and all messages will be sent out together at end of computation
98 } else if (inputType == "tracks") {
99 gDispatchTrigger = o2::framework::Output{"TPC", "TRACKS"};
100 }
101
102 bool doMC = not cfgc.options().get<bool>("disable-mc");
103
104 specs.push_back(o2::tpc::getTPCTrackReaderSpec(doMC));
105
106 o2::raw::HBFUtilsInitializer hbfIni(cfgc, specs);
107
108 return std::move(specs);
109}
Helper function to tokenize sequences and ranges of integral numbers.
Workflow definition for the TPC reconstruction.
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
o2::tpc::reco_workflow::CompletionPolicyData gPolicyData
o2::framework::Output gDispatchTrigger
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< framework::InputSpec > CompletionPolicyData
framework::DataProcessorSpec getTPCTrackReaderSpec(bool useMC=true)
header::DataDescription description
Definition Output.h:29
header::DataOrigin origin
Definition Output.h:28
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))