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