Project
Loading...
Searching...
No Matches
cosmics-match-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
38
39using namespace o2::framework;
42// ------------------------------------------------------------------
43void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
44{
46}
47
48// we need to add workflow options before including Framework/runDataProcessing
49void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
50{
51 // option allowing to set parameters
52 std::vector<o2::framework::ConfigParamSpec> options{
53 {"disable-mc", o2::framework::VariantType::Bool, false, {"disable MC propagation even if available"}},
54 {"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input reader"}},
55 {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writer"}},
56 {"use-pv-info", o2::framework::VariantType::Bool, false, {"request primary vertex for relevant cuts in the collision/cosmics interleaved data"}},
57 {"pv-contributor-sources", VariantType::String, "", {"global track sources loaded only to reject the TPC track of a primary-vertex contributor as a leg (cosmicsMatch.discardPVContributors, implies --use-pv-info); sources without TPC are ignored, so the vertexing sources can be passed as they are"}},
58 {"enable-cluster-output", o2::framework::VariantType::Bool, false, {"collect the raw clusters of the cosmics (legs + road around them) and write them with the cosmics"}},
59 {"road-detectors", VariantType::String, "ITS,TOF,TRD", {"with --enable-cluster-output: detectors whose hits along the cosmic are collected besides the TPC road"}},
60 {"cosmics-preset", VariantType::String, "", {"named set of cosmicsMatch settings applied before --configKeyValues (which can override single keys): physics-v1 = cosmics in collision data"}},
61 {"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use"}},
62 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
66 std::swap(workflowOptions, options);
67}
68
69// RS FIXME Is this needed ?
70// the matcher process requires the TPC sector completion to trigger and data on
71// all defined routes
72void customize(std::vector<o2::framework::CompletionPolicy>& policies)
73{
74 // the TPC sector completion policy checks when the set of TPC/CLUSTERNATIVE data is complete
75 // in addition we require to have input from all other routes
76 policies.push_back(o2::tpc::TPCSectorCompletionPolicy("cosmics-matcher",
78 InputSpec{"cluster", o2::framework::ConcreteDataTypeMatcher{"TPC", "CLUSTERNATIVE"}})());
79 policies.push_back(o2::tpc::TPCSectorCompletionPolicy("cosmics-cluster-collector",
81 InputSpec{"cluster", o2::framework::ConcreteDataTypeMatcher{"TPC", "CLUSTERNATIVE"}})());
82 policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*cosm.*[W,w]riter.*"));
83}
84
85// ------------------------------------------------------------------
86
88
90{
91 WorkflowSpec specs;
92 GID::mask_t alowedSources = GID::getSourcesMask("ITS,TPC,ITS-TPC,TPC-TRD,TPC-TOF,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF");
93
94 // Update the (declared) parameters if changed from the command line: first an eventual preset, then the explicit key=values
95 auto preset = configcontext.options().get<std::string>("cosmics-preset");
96 if (!preset.empty()) {
98 }
99 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
100 // write the configuration used for the workflow
101 o2::conf::ConfigurableParam::writeINI("o2match-cosmics-workflow_configuration.ini");
102 auto sclOpt = o2::tpc::CorrectionMapsOptions::parseGlobalOptions(configcontext.options());
103 auto useMC = !configcontext.options().get<bool>("disable-mc");
105 auto disableRootOut = configcontext.options().get<bool>("disable-root-output");
106
107 GID::mask_t src = alowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("track-sources"));
108 if (GID::includesDet(DetID::TPC, src)) {
109 src |= GID::getSourceMask(GID::TPC);
110 }
111 if (GID::includesDet(DetID::TRD, src)) {
112 src |= GID::getSourceMask(GID::TRD);
113 }
114 if (GID::includesDet(DetID::TOF, src)) {
115 src |= GID::getSourceMask(GID::TOF);
116 }
117 if (sclOpt.requestCTPLumi) {
118 src = src | GID::getSourcesMask("CTP");
119 }
120
121 // legs with an ITS part need the ITS tracks and clusters for their refit, also if standalone ITS tracks are no legs (not added to src)
123 GID::mask_t srcCl = src | srcITS;
124 const bool useTOFClusters = o2::globaltracking::MatchCosmicsParams::Instance().tofFlightSelection;
125 if (useTOFClusters) {
126 srcCl |= GID::getSourceMask(GID::TOF);
127 }
128 GID::mask_t dummy;
129 if (!configcontext.options().get<bool>("disable-root-input")) {
130 specs.emplace_back(o2::tpc::getTPCScalerSpec(sclOpt));
131 }
132 bool usePV = configcontext.options().get<bool>("use-pv-info");
133 GID::mask_t srcPV = GID::getSourcesMask("ITS-TPC,TPC-TRD,TPC-TOF,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF") &
134 GID::getSourcesMask(configcontext.options().get<std::string>("pv-contributor-sources"));
135 if (srcPV.any() && !o2::globaltracking::MatchCosmicsParams::Instance().discardPVContributors) {
136 LOG(warning) << "--pv-contributor-sources ignored: cosmicsMatch.discardPVContributors is off";
137 srcPV.reset();
138 }
139 usePV |= srcPV.any();
140 specs.emplace_back(o2::globaltracking::getCosmicsMatchingSpec(src, usePV, useMC, doStag, useTOFClusters, srcPV));
141 const auto srcPVLoaded = o2::globaltracking::addPVContributorParents(srcPV); // with the parents needed to resolve the contributors
142 bool clusterOutput = configcontext.options().get<bool>("enable-cluster-output");
143 if (clusterOutput) {
144 if (!src[GID::TPC]) {
145 LOG(fatal) << "--enable-cluster-output needs TPC tracks in --track-sources";
146 }
147 const auto roadDets = DetID::getMask(configcontext.options().get<std::string>("road-detectors")) & DetID::getMask("ITS,TOF,TRD");
148 for (auto det : {DetID::ITS, DetID::TOF, DetID::TRD}) {
149 if (roadDets[det]) {
150 srcCl |= GID::getSourceMask(det == DetID::ITS ? GID::ITS : (det == DetID::TOF ? GID::TOF : GID::TRD));
151 }
152 }
153 specs.emplace_back(o2::globaltracking::getCosmicsClusterCollectorSpec(src, useMC, doStag, roadDets));
154 }
155
156 o2::globaltracking::InputHelper::addInputSpecs(configcontext, specs, srcCl, src | srcPVLoaded | srcITS, src | srcPVLoaded | srcITS, useMC, dummy); // clusters MC is not needed
157 if (usePV) {
158 o2::globaltracking::InputHelper::addInputSpecsPVertex(configcontext, specs, useMC); // P-vertex is always needed
159 }
160
161 if (!disableRootOut) {
162 specs.emplace_back(o2::globaltracking::getTrackCosmicsWriterSpec(useMC));
163 if (clusterOutput) {
165 }
166 }
167
168 // configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
169 o2::raw::HBFUtilsInitializer hbfIni(configcontext, specs);
170
171 return std::move(specs);
172}
Device to produce TPC clusters sharing map.
Helper class to parse options for correction maps.
Collects the raw clusters of matched cosmics (attached + road around the legs) for offline refits.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Configurable params for cosmics matching.
Helper function to tokenize sequences and ranges of integral numbers.
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 constexpr std::string_view ALL
keywork for all sources
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:60
static mask_t getMask(const std::string_view detList)
detector masks from any non-alpha-num delimiter-separated list (empty if NONE is supplied)
Definition DetID.cxx:42
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)
static void addGlobalOptions(std::vector< o2::framework::ConfigParamSpec > &options)
static CorrectionMapsGloOpts parseGlobalOptions(const o2::framework::ConfigParamRegistry &opts)
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)
GLenum src
Definition glcorearb.h:1767
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< DataProcessorSpec > WorkflowSpec
o2::dataformats::GlobalTrackID::mask_t getLegITSSources(o2::dataformats::GlobalTrackID::mask_t src)
std::string getMatchCosmicsPreset(const std::string &name)
framework::DataProcessorSpec getTrackCosmicsWriterSpec(bool useMC)
o2::dataformats::GlobalTrackID::mask_t addPVContributorParents(o2::dataformats::GlobalTrackID::mask_t srcPVContributors)
srcPVContributors plus the parent matches needed to resolve their single-detector parts (RecoContaine...
framework::DataProcessorSpec getCosmicsMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool usePV, bool useMC, bool itsStag, bool useTOFClusters=false, o2::dataformats::GlobalTrackID::mask_t srcPVContributors={})
framework::DataProcessorSpec getCosmicsClusterCollectorSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool itsStag, o2::detectors::DetID::mask_t roadDets)
framework::DataProcessorSpec getCosmicsFullWriterSpec()
write cosmics with their raw clusters (cosmics-cluster-collector output) to a root file
o2::framework::DataProcessorSpec getTPCScalerSpec(const o2::tpc::CorrectionMapsGloOpts &sclOpts)
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"