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 usePV, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUsePVInfo(usePV), 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 bool mUsePVInfo = false;
81 TStopwatch mTimer;
82};
83
85{
86 mTimer.Stop();
87 mTimer.Reset();
89 mMatching.setDebugFlag(ic.options().get<int>("debug-tree-flags"));
90 mMatching.setUseMC(mUseMC);
91 mMatching.setUsePVInfo(mUsePVInfo);
92 //
93}
94
96{
97 mTimer.Start(false);
98 RecoContainer recoData;
99 recoData.collectData(pc, *mDataRequest.get());
100 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
101
102 mMatching.process(recoData);
103 pc.outputs().snapshot(Output{"GLO", "COSMICTRC", 0}, mMatching.getCosmicTracks());
104 if (mUseMC) {
105 pc.outputs().snapshot(Output{"GLO", "COSMICTRC_MC", 0}, mMatching.getCosmicTracksLbl());
106 }
107 mTimer.Stop();
108}
109
110void CosmicsMatchingSpec::updateTimeDependentParams(ProcessingContext& pc)
111{
113 mTPCVDriftHelper.extractCCDBInputs(pc);
114 auto const& raw = pc.inputs().get<const char*>("corrMap");
115 mCorrMap = &gpu::TPCFastTransformPOD::get(raw);
116 static bool initOnceDone = false;
117 if (!initOnceDone) { // this params need to be queried only once
118 initOnceDone = true;
120
121 // pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // called by the RecoContainer
122 // also alpParams is called by the RecoContainer
125 if (!grp->isDetContinuousReadOut(DetID::ITS)) {
126 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthTrig / 1.e3); // ITS ROFrame duration in \mus
127 } else {
128 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS * 1e-3); // ITS ROFrame duration in \mus
129 }
130 mMatching.init();
131 }
132 mMatching.setTPCCorrMaps(mCorrMap);
133 if (mTPCVDriftHelper.isUpdated()) {
134 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
135 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
136 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
137 mTPCVDriftHelper.getSourceName());
138 mMatching.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
139 mTPCVDriftHelper.acknowledgeUpdate();
140 }
141}
142
144{
146 return;
147 }
148 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
149 return;
150 }
151 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
152 LOG(info) << "cluster dictionary updated";
153 mMatching.setITSDict((const o2::itsmft::TopologyDictionary*)obj);
154 return;
155 }
156}
157
159{
160 mMatching.end();
161 LOGF(info, "Cosmics matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
162 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
163}
164
166{
167 std::vector<OutputSpec> outputs;
168 Options opts{
169 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
170 {"debug-tree-flags", VariantType::Int, 0, {"DebugFlagTypes bit-pattern for debug tree"}}};
171
172 auto dataRequest = std::make_shared<DataRequest>();
173
174 dataRequest->requestTracks(src, useMC);
175 dataRequest->requestClusters(src, false); // no MC labels for clusters needed for refit only
176 if (usePV) {
177 dataRequest->requestPrimaryVertices(useMC);
178 }
179
180 outputs.emplace_back("GLO", "COSMICTRC", 0, Lifetime::Timeframe);
181 if (useMC) {
182 outputs.emplace_back("GLO", "COSMICTRC_MC", 0, Lifetime::Timeframe);
183 }
184
185 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
186 true, // GRPECS=true
187 false, // GRPLHCIF
188 true, // GRPMagField
189 true, // askMatLUT
191 dataRequest->inputs,
192 true);
193 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
194 dataRequest->inputs.emplace_back("corrMap", o2::header::gDataOriginTPC, "TPCCORRMAP", 0, Lifetime::Timeframe);
195
196 return DataProcessorSpec{
197 "cosmics-matcher",
198 dataRequest->inputs,
199 outputs,
200 AlgorithmSpec{adaptFromTask<CosmicsMatchingSpec>(dataRequest, ggRequest, usePV, useMC)},
201 opts};
202}
203
204} // namespace globaltracking
205} // 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
void run(ProcessingContext &pc) final
CosmicsMatchingSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool usePV, bool useMC)
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 usePV, 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"