Project
Loading...
Searching...
No Matches
RecoWorkflowSpec.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
12#include "TOFWorkflow/RecoWorkflowSpec.h"
17#include "Framework/Lifetime.h"
18#include "Framework/Task.h"
20#include "Headers/DataHeader.h"
28#include <gsl/span>
29#include "TStopwatch.h"
31
32// from FIT
34
35#include <memory> // for make_shared, make_unique, unique_ptr
36#include <vector>
37
38using namespace o2::framework;
39
40namespace o2
41{
42namespace tof
43{
44
45// use the tasking system of DPL
46// just need to implement 2 special methods init + run (there is no need to inherit from anything)
48{
50 using MatchOutputType = std::vector<o2::dataformats::MatchInfoTOF>;
51
52 bool mUseMC = true;
53 bool mUseFIT = false;
54
55 public:
56 explicit TOFDPLRecoWorkflowTask(std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC, bool useFIT) : mGGCCDBRequest(gr), mUseMC(useMC), mUseFIT(useFIT) {}
57
59 {
61 mTimer.Stop();
62 mTimer.Reset();
63 }
64
66 {
67 mTimer.Start(false);
69 //>>>---------- attach input data --------------->>>
70 const auto clustersRO = pc.inputs().get<gsl::span<o2::tof::Cluster>>("tofcluster");
71 const auto tracksRO = pc.inputs().get<gsl::span<o2::dataformats::TrackTPCITS>>("globaltrack");
72
73 if (mUseFIT) {
74 // Note: the particular variable will go out of scope, but the span is passed by copy to the
75 // worker and the underlying memory is valid throughout the whole computation
76 auto recPoints = std::move(pc.inputs().get<gsl::span<o2::ft0::RecPoints>>("fitrecpoints"));
77 mMatcher.setFITRecPoints(recPoints);
78 LOG(info) << "TOF Reco Workflow pulled " << recPoints.size() << " FIT RecPoints";
79 }
80
81 // we do a copy of the input but we are looking for a way to avoid it (current problem in conversion form unique_ptr to *)
82
83 gsl::span<const o2::MCCompLabel> itstpclab;
85 if (mUseMC) {
86 const auto toflabel = pc.inputs().get<o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("tofclusterlabel");
87 itstpclab = pc.inputs().get<gsl::span<o2::MCCompLabel>>("itstpclabel");
88 toflab = std::move(*toflabel);
89 }
90
91 mMatcher.run(tracksRO, clustersRO, toflab, itstpclab);
92
93 // in run_match_tof aggiugnere esplicitamente la chiamata a fill del tree (nella classe MatchTOF) e il metodo per leggere i vettori di output
94
95 //...
96 // LOG(info) << "TOF CLUSTERER : TRANSFORMED " << digits->size()
97 // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS";
98
99 // send matching-info
100 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MTC_ITSTPC", 0}, mMatcher.getMatchedTrackVector());
101 if (mUseMC) {
103 }
104 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0}, mMatcher.getCalibVector());
105 mTimer.Stop();
106 }
107
109 {
110 LOGF(info, "TOF Matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
111 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
112 }
113
115 {
117 mTPCVDriftHelper.extractCCDBInputs(pc);
118 static bool initOnceDone = false;
119 if (!initOnceDone) { // this params need to be queried only once
120 initOnceDone = true;
121 // put here init-once stuff
122 }
123 // we may have other params which need to be queried regularly
124 if (mTPCVDriftHelper.isUpdated()) {
125 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} from source {}",
126 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getSourceName());
127 mMatcher.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
128 mTPCVDriftHelper.acknowledgeUpdate();
129 }
130 }
131
132 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
133 {
135 return;
136 }
137 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
138 return;
139 }
140 }
141
142 private:
144 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
145 o2::tpc::VDriftHelper mTPCVDriftHelper{};
146 TStopwatch mTimer;
147};
148
150{
151 std::vector<InputSpec> inputs;
152 std::vector<OutputSpec> outputs;
153 inputs.emplace_back("tofcluster", o2::header::gDataOriginTOF, "CLUSTERS", 0, Lifetime::Timeframe);
154 inputs.emplace_back("globaltrack", "GLO", "TPCITS", 0, Lifetime::Timeframe);
155 if (useMC) {
156 inputs.emplace_back("tofclusterlabel", o2::header::gDataOriginTOF, "CLUSTERSMCTR", 0, Lifetime::Timeframe);
157 inputs.emplace_back("itstpclabel", "GLO", "TPCITS_MC", 0, Lifetime::Timeframe);
158 }
159
160 if (useFIT) {
161 inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe);
162 }
163 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
164 true, // GRPECS=true
165 false, // GRPLHCIF
166 true, // GRPMagField
167 true, // askMatLUT
169 inputs,
170 true);
172
173 outputs.emplace_back(o2::header::gDataOriginTOF, "MTC_ITSTPC", 0, Lifetime::Timeframe);
174 if (useMC) {
175 outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe);
176 }
177 outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe);
178
179 return DataProcessorSpec{
180 "TOFRecoWorkflow",
181 inputs,
182 outputs,
183 AlgorithmSpec{adaptFromTask<TOFDPLRecoWorkflowTask>(ggRequest, useMC, useFIT)},
184 Options{
185 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}}}};
186}
187
188} // end namespace tof
189} // end namespace o2
Definition of the TOF cluster.
Definition of the GeometryManager class.
Definition of the FIT RecPoints class.
Helper for geometry and GRP related CCDB requests.
Class to perform TOF matching to global tracks.
Definition of the Names Generator class.
Type wrappers for enfording a specific serialization method.
Result of refitting TPC-ITS matched track.
Helper class to extract VDrift from different sources.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
A container to hold and manage MC truth information/labels.
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
Definition MatchTOF.cxx:249
std::vector< o2::MCCompLabel > & getMatchedTOFLabelsVector(trkType index)
get vector of TOF labels of matched tracks
Definition MatchTOF.h:152
std::vector< o2::dataformats::CalibInfoTOF > & getCalibVector()
Definition MatchTOF.h:148
std::vector< o2::dataformats::MatchInfoTOF > & getMatchedTrackVector(trkType index)
Definition MatchTOF.h:147
void run(const o2::globaltracking::RecoContainer &inp, unsigned long firstTForbit=0)
< perform matching for provided input
Definition MatchTOF.cxx:67
void updateTimeDependentParams(ProcessingContext &pc)
void run(framework::ProcessingContext &pc)
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
void init(framework::InitContext &ic)
TOFDPLRecoWorkflowTask(std::shared_ptr< o2::base::GRPGeomRequest > gr, bool useMC, bool useFIT)
void endOfStream(EndOfStreamContext &ec)
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, bool laser=true, bool itstpcTgl=true)
void extractCCDBInputs(o2::framework::ProcessingContext &pc, bool laser=true, bool itstpcTgl=true)
const VDriftCorrFact & getVDriftObject() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
static std::string_view getSourceName(Source s)
bool isUpdated() const
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:566
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:575
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getTOFRecoWorkflowSpec(bool useMC, bool useFIT)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
float refVDrift
reference vdrift for which factor was extracted
float corrFact
drift velocity correction factor (multiplicative)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"