Project
Loading...
Searching...
No Matches
CosmicsMatchingSpec.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
14#include <vector>
15#include <string>
16#include "TStopwatch.h"
40#include "Headers/DataHeader.h"
45#include "Framework/Task.h"
50#include "TPCFastTransformPOD.h"
51
52using namespace o2::framework;
53using MCLabelsTr = gsl::span<const o2::MCCompLabel>;
56
57namespace o2
58{
59namespace globaltracking
60{
61
63{
64 public:
65 CosmicsMatchingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC) {}
66 ~CosmicsMatchingSpec() override = default;
67 void init(InitContext& ic) final;
68 void run(ProcessingContext& pc) final;
70 void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
71
72 private:
73 void updateTimeDependentParams(ProcessingContext& pc);
74 std::shared_ptr<DataRequest> mDataRequest;
75 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
76 o2::tpc::VDriftHelper mTPCVDriftHelper{};
77 const o2::gpu::TPCFastTransformPOD* mCorrMap{nullptr};
78 o2::globaltracking::MatchCosmics mMatching; // matching engine
79 bool mUseMC = true;
80 TStopwatch mTimer;
81};
82
84{
85 mTimer.Stop();
86 mTimer.Reset();
88 mMatching.setDebugFlag(ic.options().get<int>("debug-tree-flags"));
89 mMatching.setUseMC(mUseMC);
90 //
91}
92
94{
95 mTimer.Start(false);
96 RecoContainer recoData;
97 recoData.collectData(pc, *mDataRequest.get());
98 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
99
100 mMatching.process(recoData);
101 pc.outputs().snapshot(Output{"GLO", "COSMICTRC", 0}, mMatching.getCosmicTracks());
102 if (mUseMC) {
103 pc.outputs().snapshot(Output{"GLO", "COSMICTRC_MC", 0}, mMatching.getCosmicTracksLbl());
104 }
105 mTimer.Stop();
106}
107
108void CosmicsMatchingSpec::updateTimeDependentParams(ProcessingContext& pc)
109{
111 mTPCVDriftHelper.extractCCDBInputs(pc);
112 auto const& raw = pc.inputs().get<const char*>("corrMap");
113 mCorrMap = &gpu::TPCFastTransformPOD::get(raw);
114 static bool initOnceDone = false;
115 if (!initOnceDone) { // this params need to be queried only once
116 initOnceDone = true;
118
119 // pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // called by the RecoContainer
120 // also alpParams is called by the RecoContainer
123 if (!grp->isDetContinuousReadOut(DetID::ITS)) {
124 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthTrig / 1.e3); // ITS ROFrame duration in \mus
125 } else {
126 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS * 1e-3); // ITS ROFrame duration in \mus
127 }
128 mMatching.init();
129 }
130 mMatching.setTPCCorrMaps(mCorrMap);
131 if (mTPCVDriftHelper.isUpdated()) {
132 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
133 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
134 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
135 mTPCVDriftHelper.getSourceName());
136 mMatching.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
137 mTPCVDriftHelper.acknowledgeUpdate();
138 }
139}
140
142{
144 return;
145 }
146 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
147 return;
148 }
149 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
150 LOG(info) << "cluster dictionary updated";
151 mMatching.setITSDict((const o2::itsmft::TopologyDictionary*)obj);
152 return;
153 }
154}
155
157{
158 mMatching.end();
159 LOGF(info, "Cosmics matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
160 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
161}
162
164{
165 std::vector<OutputSpec> outputs;
166 Options opts{
167 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
168 {"debug-tree-flags", VariantType::Int, 0, {"DebugFlagTypes bit-pattern for debug tree"}}};
169
170 auto dataRequest = std::make_shared<DataRequest>();
171
172 dataRequest->requestTracks(src, useMC);
173 dataRequest->requestClusters(src, false); // no MC labels for clusters needed for refit only
174
175 outputs.emplace_back("GLO", "COSMICTRC", 0, Lifetime::Timeframe);
176 if (useMC) {
177 outputs.emplace_back("GLO", "COSMICTRC_MC", 0, Lifetime::Timeframe);
178 }
179
180 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
181 true, // GRPECS=true
182 false, // GRPLHCIF
183 true, // GRPMagField
184 true, // askMatLUT
186 dataRequest->inputs,
187 true);
188 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
189 dataRequest->inputs.emplace_back("corrMap", o2::header::gDataOriginTPC, "TPCCORRMAP", 0, Lifetime::Timeframe);
190
191 return DataProcessorSpec{
192 "cosmics-matcher",
193 dataRequest->inputs,
194 outputs,
195 AlgorithmSpec{adaptFromTask<CosmicsMatchingSpec>(dataRequest, ggRequest, useMC)},
196 opts};
197}
198
199} // namespace globaltracking
200} // namespace o2
Class of a TPC cluster in TPC-native coordinates (row, time)
Definition of the ITS/MFT clusterer settings.
Definition of the ITSMFT compact cluster.
gsl::span< const o2::MCCompLabel > MCLabelsTr
Wrapper container for different reconstructed object types.
Definition of the ClusterTopology class.
Definition of the Names Generator class.
Definition of the GeometryManager class.
o2::raw::RawFileWriter * raw
Helper for geometry and GRP related CCDB requests.
Header of the General Run Parameters object.
Accessor for TrackParCov derived objects from multiple containers.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Definition of the GeometryTGeo class.
Definition of the ITSMFT ROFrame (trigger) record.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Class to perform matching/refit of cosmic tracks legs.
Class to store the output of the matching to TOF.
POD correction map.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Result of refitting TPC with TOF match constraint.
Helper class to extract VDrift from different sources.
Helper class to obtain TPC clusters / digits / labels from DPL.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID ITS
Definition DetID.h:63
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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 endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
CosmicsMatchingSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool useMC)
void run(ProcessingContext &pc) final
void setITSROFrameLengthMUS(float fums)
void setITSDict(const o2::itsmft::TopologyDictionary *dict)
void setDebugFlag(UInt_t flag, bool on=true)
set the name of output debug file
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD *maph)
void process(const o2::globaltracking::RecoContainer &data)
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
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
GLenum src
Definition glcorearb.h:1767
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:576
constexpr double LHCBunchSpacingNS
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getCosmicsMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
static constexpr int T2L
Definition Cartesian.h:55
static constexpr int T2GRot
Definition Cartesian.h:57
float refTimeOffset
additive time offset reference (\mus)
float refVDrift
reference vdrift for which factor was extracted
float timeOffsetCorr
additive time offset correction (\mus)
float corrFact
drift velocity correction factor (multiplicative)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"