Project
Loading...
Searching...
No Matches
SecondaryVertexingSpec.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>
32#include "TStopwatch.h"
38
39using namespace o2::framework;
40
50
51namespace o2
52{
53namespace vertexing
54{
55
56namespace o2d = o2::dataformats;
57
59{
60 public:
61 SecondaryVertexingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts, GTrackID::mask_t src, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool enableCCDBParams, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mSrc(src), mEnableCascades(enabCasc), mEnable3BodyVertices(enable3body), mEnableStrangenessTracking(enableStrangenessTracking), mEnableCCDBParams(enableCCDBParams), mUseMC(useMC)
62 {
63 mTPCCorrMapsLoader.setLumiScaleType(sclOpts.lumiType);
64 mTPCCorrMapsLoader.setLumiScaleMode(sclOpts.lumiMode);
65 mTPCCorrMapsLoader.setCheckCTPIDCConsistency(sclOpts.checkCTPIDCconsistency);
66 }
67 ~SecondaryVertexingSpec() override = default;
68 void init(InitContext& ic) final;
69 void run(ProcessingContext& pc) final;
70 void endOfStream(EndOfStreamContext& ec) final;
71 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
72
73 private:
74 void updateTimeDependentParams(ProcessingContext& pc);
75 std::shared_ptr<DataRequest> mDataRequest;
76 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
77 o2::tpc::VDriftHelper mTPCVDriftHelper{};
78 o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
79 GTrackID::mask_t mSrc{};
80 bool mEnableCCDBParams = false;
81 bool mEnableCascades = false;
82 bool mEnable3BodyVertices = false;
83 bool mEnableStrangenessTracking = false;
84 bool mUseMC = false;
87 TStopwatch mTimer;
88};
89
91{
92 mTimer.Stop();
93 mTimer.Reset();
95 //-------- init geometry and field --------//
96 mVertexer.setEnableCascades(mEnableCascades);
97 mVertexer.setEnable3BodyDecays(mEnable3BodyVertices);
98 mVertexer.setNThreads(ic.options().get<int>("threads"));
99 mVertexer.setUseMC(mUseMC);
100 if (mEnableStrangenessTracking) {
103 mStrTracker.setupThreads(ic.options().get<int>("threads"));
104 mStrTracker.setupFitters();
105 mStrTracker.setMCTruthOn(mUseMC);
106 mVertexer.setStrangenessTracker(&mStrTracker);
107 }
108 if (mSrc[GTrackID::TPC]) {
109 mTPCCorrMapsLoader.init(ic);
110 }
111}
112
114{
115 double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
116 mTimer.Start(false);
117 static std::array<size_t, 3> fitCalls{};
118
120 recoData.collectData(pc, *mDataRequest.get());
121 updateTimeDependentParams(pc);
122
123 mVertexer.process(recoData, pc);
124
125 mTimer.Stop();
126 auto calls = mVertexer.getNFitterCalls();
127 LOGP(info, "Found {} V0s ({} fits), {} cascades ({} fits), {} 3-body decays ({} fits), {} strange tracks. Timing: CPU: {:.2f} Real: {:.2f} s",
128 mVertexer.getNV0s(), calls[0] - fitCalls[0], mVertexer.getNCascades(), calls[1] - fitCalls[1], mVertexer.getN3Bodies(), calls[2] - fitCalls[2], mVertexer.getNStrangeTracks(),
129 mTimer.CpuTime() - timeCPU0, mTimer.RealTime() - timeReal0);
130 fitCalls = calls;
131}
132
134{
135 LOGF(info, "Secondary vertexing total timing: Cpu: %.3e Real: %.3e s in %d slots, nThreads = %d",
136 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1, mVertexer.getNThreads());
137}
138
140{
142 return;
143 }
144 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
145 return;
146 }
147 if (mTPCCorrMapsLoader.accountCCDBInputs(matcher, obj)) {
148 return;
149 }
150 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
151 LOG(info) << "cluster dictionary updated";
153 return;
154 }
155 if (matcher == ConcreteDataMatcher("GLO", "MEANVERTEX", 0)) {
156 LOG(info) << "Imposing new MeanVertex: " << ((const o2::dataformats::MeanVertexObject*)obj)->asString();
158 return;
159 }
160 if (matcher == ConcreteDataMatcher("GLO", "SVPARAM", 0)) {
161 LOG(info) << "SVertexer Params updated from ccdb";
162 return;
163 }
164 if (matcher == ConcreteDataMatcher("ITS", "GEOMTGEO", 0)) {
165 LOG(info) << "ITS GeomtetryTGeo loaded from ccdb";
167 return;
168 }
169#ifdef ENABLE_UPGRADES
170 if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
171 LOG(info) << "cluster dictionary updated";
172 mStrTracker.setClusterDictionaryIT3((const o2::its3::TopologyDictionary*)obj);
173 return;
174 }
175#endif
176}
177
178void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
179{
181 if (mSrc[GTrackID::TPC]) {
182 mTPCVDriftHelper.extractCCDBInputs(pc);
183 mTPCCorrMapsLoader.extractCCDBInputs(pc);
184 }
185 static bool initOnceDone = false;
186 if (!initOnceDone) { // this params need to be queried only once
187 initOnceDone = true;
188 mVertexer.init();
189 if (mEnableCCDBParams) {
190 // for reading the calib objects from the CCDB
191 pc.inputs().get<o2::vertexing::SVertexerParams*>("SVParam");
192 }
193 if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
194 // setting and or overwriting the configurable params
196 }
197 if (pc.inputs().getPos("itsTGeo") >= 0) {
198 pc.inputs().get<o2::its::GeometryTGeo*>("itsTGeo");
199 }
200 if (mEnableStrangenessTracking) {
203 }
204
205#ifdef ENABLE_UPGRADES
206 if (o2::GlobalParams::Instance().withITS3) { // hack to trigger loading dictionary
207 pc.inputs().get<o2::its3::TopologyDictionary*>("cldict");
208 }
209#endif
210 }
211 // we may have other params which need to be queried regularly
212 if (mSrc[GTrackID::TPC]) {
213 bool updateMaps = false;
214 if (mTPCCorrMapsLoader.isUpdated()) {
215 mTPCCorrMapsLoader.acknowledgeUpdate();
216 updateMaps = true;
217 }
218 mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
219 if (mTPCVDriftHelper.isUpdated()) {
220 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
221 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
222 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
223 mTPCVDriftHelper.getSourceName());
224 mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
225 mTPCVDriftHelper.acknowledgeUpdate();
226 updateMaps = true;
227 }
228 if (updateMaps) {
229 mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
230 }
231 }
232 if (mEnableStrangenessTracking) {
233 if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) {
234 mStrTracker.setBz(o2::base::Propagator::Instance()->getNominalBz());
235 mStrTracker.setupFitters();
236 }
237 }
238
240}
241
242DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams,
243 bool useMC, bool useGeom, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts)
244{
245 std::vector<OutputSpec> outputs;
246 Options opts{
247 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
248 {"threads", VariantType::Int, 1, {"Number of threads"}}};
249 auto dataRequest = std::make_shared<DataRequest>();
250 if (enableCCDBParams) {
251 dataRequest->inputs.emplace_back("SVParam", "GLO", "SVPARAM", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/SVertexerParam"));
252 }
253 GTrackID::mask_t srcClus{};
254 if (enableStrangenesTracking) {
255 src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS));
256 }
257 if (GTrackID::includesDet(o2::detectors::DetID::TPC, src) && !src[GTrackID::TPC]) {
258 throw std::runtime_error("Tracks involving TPC were requested w/o requesting TPC-only tracks");
259 }
260 if (src[GTrackID::TPC]) {
261 srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
262 }
263 if (srcClus.any()) {
264 dataRequest->requestClusters(srcClus, useMC);
265 }
266#ifdef ENABLE_UPGRADES
267 if (o2::GlobalParams::Instance().withITS3) { // hack to trigger loading dictionary
268 dataRequest->inputs.emplace_back("cldict", "IT3", "CLUSDICT", Lifetime::Condition, ccdbParamSpec("IT3/Calib/ClusterDictionary"));
269 }
270#endif
271 dataRequest->requestTracks(src, useMC);
272 dataRequest->requestPrimaryVertices(useMC);
273 dataRequest->inputs.emplace_back("meanvtx", "GLO", "MEANVERTEX", 0, Lifetime::Condition, ccdbParamSpec("GLO/Calib/MeanVertex", {}, 1));
274 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
275 true, // GRPECS=true
276 false, // GRPLHCIF
277 true, // GRPMagField
278 true, // askMatLUT
279 useGeom || enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
280 dataRequest->inputs,
281 true);
282 if (!useGeom && enableStrangenesTracking) {
283 ggRequest->addInput({"itsTGeo", "ITS", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("ITS/Config/Geometry")}, dataRequest->inputs);
284 }
285 if (src[GTrackID::TPC]) {
286 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
287 o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, sclOpts);
288 }
289 outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
290 outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
291 outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
292
293 outputs.emplace_back("GLO", "CASCS_IDX", 0, Lifetime::Timeframe); // found Cascades indices
294 outputs.emplace_back("GLO", "CASCS", 0, Lifetime::Timeframe); // found Cascades
295 outputs.emplace_back("GLO", "PVTX_CASCREFS", 0, Lifetime::Timeframe); // prim.vertex -> Cascades refs
296
297 outputs.emplace_back("GLO", "DECAYS3BODY_IDX", 0, Lifetime::Timeframe); // found 3 body vertices indices
298 outputs.emplace_back("GLO", "DECAYS3BODY", 0, Lifetime::Timeframe); // found 3 body vertices
299 outputs.emplace_back("GLO", "PVTX_3BODYREFS", 0, Lifetime::Timeframe); // prim.vertex -> 3 body vertices refs
300
301 if (enableStrangenesTracking) {
302 outputs.emplace_back("GLO", "STRANGETRACKS", 0, Lifetime::Timeframe); // found strange track
303 outputs.emplace_back("GLO", "CLUSUPDATES", 0, Lifetime::Timeframe);
304 if (useMC) {
305 outputs.emplace_back("GLO", "STRANGETRACKS_MC", 0, Lifetime::Timeframe);
306 LOG(info) << "Strangeness tracker will use MC";
307 }
308 }
309
310 return DataProcessorSpec{
311 "secondary-vertexing",
312 dataRequest->inputs,
313 outputs,
314 AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, sclOpts, src, enableCasc, enable3body, enableStrangenesTracking, enableCCDBParams, useMC)},
315 opts};
316}
317
318} // namespace vertexing
319} // namespace o2
Helper class to access load maps from CCDB.
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Definition of the Names Generator class.
Secondary vertex finder.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Helper class to extract VDrift from different sources.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:143
void printKeyValues(bool showProv=true, bool useLogger=false, bool withPadding=true, bool showHash=true) const final
TO BE DONE: extend to generic N body vertex.
Definition Decay3Body.h:26
static constexpr ID TPC
Definition DetID.h:64
ConfigParamRegistry const & options()
Definition InitContext.h:33
int getPos(const char *name) const
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
static void adopt(GeometryTGeo *raw, bool canDelete=false)
void setConfigParams(const StrangenessTrackingParamConfig *params)
void setCorrType(const o2::base::PropagatorImpl< float >::MatCorrType &type)
void setClusterDictionaryITS(const o2::itsmft::TopologyDictionary *d)
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
void setEnableCascades(bool v)
Definition SVertexer.h:117
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper *maph)
std::array< size_t, 3 > getNFitterCalls() const
void setEnable3BodyDecays(bool v)
Definition SVertexer.h:118
void process(const o2::globaltracking::RecoContainer &recoTracks, o2::framework::ProcessingContext &pc)
Definition SVertexer.cxx:42
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setMeanVertex(const o2::dataformats::MeanVertexObject *v)
Definition SVertexer.h:127
void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker *tracker)
Definition SVertexer.h:147
int getNStrangeTracks() const
Definition SVertexer.h:125
SecondaryVertexingSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, const o2::tpc::CorrectionMapsLoaderGloOpts &sclOpts, GTrackID::mask_t src, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool enableCCDBParams, bool useMC)
~SecondaryVertexingSpec() override=default
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(ProcessingContext &pc) final
GLenum src
Definition glcorearb.h:1767
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getSecondaryVertexingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams, bool useMC, bool useGeom, 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
static constexpr int T2G
Definition Cartesian.h:56
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"