Project
Loading...
Searching...
No Matches
VertexTrackMatcherSpec.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
15
27#include "TStopwatch.h"
28
29using namespace o2::framework;
33
34namespace o2
35{
36namespace vertexing
37{
38
40{
41 public:
42 VertexTrackMatcherSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr) : mDataRequest(dr), mGGCCDBRequest(gr){};
43 ~VertexTrackMatcherSpec() override = default;
44 void init(InitContext& ic) final;
45 void run(ProcessingContext& pc) final;
46 void endOfStream(EndOfStreamContext& ec) final;
47 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
48
49 private:
50 void updateTimeDependentParams(ProcessingContext& pc);
51 std::shared_ptr<DataRequest> mDataRequest;
52 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
53 o2::tpc::VDriftHelper mTPCVDriftHelper{};
55 TStopwatch mTimer;
56};
57
59{
60 //-------- init geometry and field --------//
61 mTimer.Stop();
62 mTimer.Reset();
63 mMatcher.setPrescaleLogs(ic.options().get<int>("prescale-logs"));
65}
66
68{
69 double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
70 mTimer.Start(false);
71
73 recoData.collectData(pc, *mDataRequest.get());
74 updateTimeDependentParams(pc); // make sure called after recoData.collectData as some objects might be fetched there
75
76 std::vector<o2::dataformats::VtxTrackIndex> trackIndex;
77 std::vector<o2::dataformats::VtxTrackRef> vtxRefs;
78
79 mMatcher.process(recoData, trackIndex, vtxRefs);
80
81 pc.outputs().snapshot(Output{"GLO", "PVTX_TRMTC", 0}, trackIndex);
82 pc.outputs().snapshot(Output{"GLO", "PVTX_TRMTCREFS", 0}, vtxRefs);
83
84 mTimer.Stop();
85 LOG(info) << "Made " << trackIndex.size() << " track associations for " << recoData.getPrimaryVertices().size()
86 << " vertices, timing: CPU: " << mTimer.CpuTime() - timeCPU0 << " Real: " << mTimer.RealTime() - timeReal0 << " s";
87}
88
89void VertexTrackMatcherSpec::updateTimeDependentParams(ProcessingContext& pc)
90{
92 mTPCVDriftHelper.extractCCDBInputs(pc);
93 static bool initOnceDone = false;
94 if (!initOnceDone) { // this params need to be queried only once
95 initOnceDone = true;
96 // put here init-once stuff
98 mMatcher.setITSROFrameLengthMUS(o2::base::GRPGeomHelper::instance().getGRPECS()->isDetContinuousReadOut(o2::detectors::DetID::ITS) ? alpParamsITS.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingMUS : alpParamsITS.roFrameLengthTrig * 1.e-3);
100 mMatcher.setMFTROFrameLengthMUS(o2::base::GRPGeomHelper::instance().getGRPECS()->isDetContinuousReadOut(o2::detectors::DetID::MFT) ? alpParamsMFT.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingMUS : alpParamsMFT.roFrameLengthTrig * 1.e-3);
101 LOGP(info, "VertexTrackMatcher ITSROFrameLengthMUS:{} MFTROFrameLengthMUS:{}", mMatcher.getITSROFrameLengthMUS(), mMatcher.getMFTROFrameLengthMUS());
102 }
103 // we may have other params which need to be queried regularly
104 // VDrift may change from time to time
105 if (mTPCVDriftHelper.isUpdated()) {
107 auto& detParam = o2::tpc::ParameterDetector::Instance();
108 mMatcher.setTPCBin2MUS(elParam.ZbinWidth);
109 auto& vd = mTPCVDriftHelper.getVDriftObject();
110 mMatcher.setMaxTPCDriftTimeMUS(detParam.TPClength / (vd.refVDrift * vd.corrFact));
111 mMatcher.setTPCTDriftOffset(vd.getTimeOffset());
112 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
113 vd.corrFact, vd.refVDrift, vd.timeOffsetCorr, vd.refTimeOffset, mTPCVDriftHelper.getSourceName());
114 mTPCVDriftHelper.acknowledgeUpdate();
115 }
116}
117
119{
121 return;
122 }
123 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
124 return;
125 }
126 if (matcher == ConcreteDataMatcher("ITS", "ALPIDEPARAM", 0)) {
127 LOG(info) << "ITS Alpide param updated";
129 par.printKeyValues();
130 return;
131 }
132 if (matcher == ConcreteDataMatcher("MFT", "ALPIDEPARAM", 0)) {
133 LOG(info) << "MFT Alpide param updated";
135 par.printKeyValues();
136 return;
137 }
138}
139
141{
142 LOGF(info, "Primary vertex - track matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
143 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
144}
145
147{
148 std::vector<OutputSpec> outputs;
149 auto dataRequest = std::make_shared<DataRequest>();
150
151 dataRequest->requestTracks(src, false);
152 dataRequest->requestClusters(src & GTrackID::getSourcesMask("EMC,PHS,CPV"), false);
153 dataRequest->requestPrimaryVerticesTMP(false);
154
155 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
156 true, // GRPECS=true
157 true, // GRPLHCIF
158 false, // GRPMagField
159 false, // askMatLUT
161 dataRequest->inputs,
162 true);
163 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
164
165 outputs.emplace_back("GLO", "PVTX_TRMTC", 0, Lifetime::Timeframe);
166 outputs.emplace_back("GLO", "PVTX_TRMTCREFS", 0, Lifetime::Timeframe);
167
168 return DataProcessorSpec{
169 "pvertex-track-matching",
170 dataRequest->inputs,
171 outputs,
172 AlgorithmSpec{adaptFromTask<VertexTrackMatcherSpec>(dataRequest, ggRequest)},
173 Options{{"prescale-logs", VariantType::Int, 50, {"print vertex logs for each n-th TF"}}}};
174}
175
176} // namespace vertexing
177} // namespace o2
Wrapper container for different reconstructed object types.
Helper for geometry and GRP related CCDB requests.
Definition of the Names Generator class.
Definition of the parameter class for the detector.
Definition of the parameter class for the detector electronics.
Helper class to extract VDrift from different sources.
Specs for vertex track association device.
Class for vertex track association.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static mask_t getSourcesMask(const std::string_view srcList)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID ITS
Definition DetID.h:63
static constexpr ID MFT
Definition DetID.h:71
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.
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
VertexTrackMatcherSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr)
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
~VertexTrackMatcherSpec() override=default
void process(const o2::globaltracking::RecoContainer &recoData, std::vector< VTIndex > &trackIndex, std::vector< VRef > &vtxRefs)
GLenum src
Definition glcorearb.h:1767
constexpr double LHCBunchSpacingMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getVertexTrackMatcherSpec(o2::dataformats::GlobalTrackID::mask_t src)
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)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"