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"
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, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC)
66 {
67 mTPCCorrMapsLoader.setLumiScaleType(sclOpts.lumiType);
68 mTPCCorrMapsLoader.setLumiScaleMode(sclOpts.lumiMode);
69 }
70 ~CosmicsMatchingSpec() override = default;
71 void init(InitContext& ic) final;
72 void run(ProcessingContext& pc) final;
74 void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
75
76 private:
77 void updateTimeDependentParams(ProcessingContext& pc);
78 std::shared_ptr<DataRequest> mDataRequest;
79 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
80 o2::tpc::VDriftHelper mTPCVDriftHelper{};
81 o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
82 o2::globaltracking::MatchCosmics mMatching; // matching engine
83 bool mUseMC = true;
84 TStopwatch mTimer;
85};
86
88{
89 mTimer.Stop();
90 mTimer.Reset();
92 mMatching.setDebugFlag(ic.options().get<int>("debug-tree-flags"));
93 mMatching.setUseMC(mUseMC);
94 mTPCCorrMapsLoader.init(ic);
95 //
96}
97
99{
100 mTimer.Start(false);
101 RecoContainer recoData;
102 recoData.collectData(pc, *mDataRequest.get());
103 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
104
105 mMatching.process(recoData);
106 pc.outputs().snapshot(Output{"GLO", "COSMICTRC", 0}, mMatching.getCosmicTracks());
107 if (mUseMC) {
108 pc.outputs().snapshot(Output{"GLO", "COSMICTRC_MC", 0}, mMatching.getCosmicTracksLbl());
109 }
110 mTimer.Stop();
111}
112
113void CosmicsMatchingSpec::updateTimeDependentParams(ProcessingContext& pc)
114{
116 mTPCVDriftHelper.extractCCDBInputs(pc);
117 mTPCCorrMapsLoader.extractCCDBInputs(pc);
118 static bool initOnceDone = false;
119 if (!initOnceDone) { // this params need to be queried only once
120 initOnceDone = true;
122
123 // pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // called by the RecoContainer
124 // also alpParams is called by the RecoContainer
127 if (!grp->isDetContinuousReadOut(DetID::ITS)) {
128 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthTrig / 1.e3); // ITS ROFrame duration in \mus
129 } else {
130 mMatching.setITSROFrameLengthMUS(alpParams.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS * 1e-3); // ITS ROFrame duration in \mus
131 }
132 mMatching.init();
133 }
134 bool updateMaps = false;
135 if (mTPCCorrMapsLoader.isUpdated()) {
136 mTPCCorrMapsLoader.acknowledgeUpdate();
137 updateMaps = true;
138 }
139 mMatching.setTPCCorrMaps(&mTPCCorrMapsLoader);
140 if (mTPCVDriftHelper.isUpdated()) {
141 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
142 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
143 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
144 mTPCVDriftHelper.getSourceName());
145 mMatching.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
146 mTPCVDriftHelper.acknowledgeUpdate();
147 updateMaps = true;
148 }
149 if (updateMaps) {
150 mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
151 }
152}
153
155{
157 return;
158 }
159 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
160 return;
161 }
162 if (mTPCCorrMapsLoader.accountCCDBInputs(matcher, obj)) {
163 return;
164 }
165 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
166 LOG(info) << "cluster dictionary updated";
167 mMatching.setITSDict((const o2::itsmft::TopologyDictionary*)obj);
168 return;
169 }
170}
171
173{
174 mMatching.end();
175 LOGF(info, "Cosmics matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
176 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
177}
178
180{
181 std::vector<OutputSpec> outputs;
182 Options opts{
183 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
184 {"debug-tree-flags", VariantType::Int, 0, {"DebugFlagTypes bit-pattern for debug tree"}}};
185
186 auto dataRequest = std::make_shared<DataRequest>();
187
188 dataRequest->requestTracks(src, useMC);
189 dataRequest->requestClusters(src, false); // no MC labels for clusters needed for refit only
190
191 outputs.emplace_back("GLO", "COSMICTRC", 0, Lifetime::Timeframe);
192 if (useMC) {
193 outputs.emplace_back("GLO", "COSMICTRC_MC", 0, Lifetime::Timeframe);
194 }
195
196 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
197 true, // GRPECS=true
198 false, // GRPLHCIF
199 true, // GRPMagField
200 true, // askMatLUT
202 dataRequest->inputs,
203 true);
204 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
205 o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, sclOpts);
206
207 return DataProcessorSpec{
208 "cosmics-matcher",
209 dataRequest->inputs,
210 outputs,
211 AlgorithmSpec{adaptFromTask<CosmicsMatchingSpec>(dataRequest, ggRequest, sclOpts, useMC)},
212 opts};
213}
214
215} // namespace globaltracking
216} // 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.
Helper class to access load maps from CCDB.
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.
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.
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
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
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, const o2::tpc::CorrectionMapsLoaderGloOpts &sclOpts, bool useMC)
void run(ProcessingContext &pc) final
void setITSROFrameLengthMUS(float fums)
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper *maph)
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 process(const o2::globaltracking::RecoContainer &data)
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
void extractCCDBInputs(o2::framework::ProcessingContext &pc)
void updateVDrift(float vdriftCorr, float vdrifRef, float driftTimeOffset=0)
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, std::vector< o2::framework::ConfigParamSpec > &options, const CorrectionMapsLoaderGloOpts &gloOpts)
recalculate inverse correction
void init(o2::framework::InitContext &ic)
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 double LHCBunchSpacingNS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getCosmicsMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts &sclOpts)
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
int lumiType
what estimator to used for corrections scaling: 0: no scaling, 1: CTP, 2: IDC
int lumiMode
what corrections method to use: 0: classical scaling, 1: Using of the derivative map,...
float refTimeOffset
additive time offset reference (\mus)
float refVDrift
reference vdrift for which factor was extracted
float getTimeOffset() const
float timeOffsetCorr
additive time offset correction (\mus)
float corrFact
drift velocity correction factor (multiplicative)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"