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 if (mSrc[GTrackID::TPC]) {
64 mTPCCorrMapsLoader.setLumiScaleType(sclOpts.lumiType);
65 mTPCCorrMapsLoader.setLumiScaleMode(sclOpts.lumiMode);
66 mTPCCorrMapsLoader.setCheckCTPIDCConsistency(sclOpts.checkCTPIDCconsistency);
67 }
68 }
69 ~SecondaryVertexingSpec() override = default;
70 void init(InitContext& ic) final;
71 void run(ProcessingContext& pc) final;
72 void endOfStream(EndOfStreamContext& ec) final;
73 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
74
75 private:
76 void updateTimeDependentParams(ProcessingContext& pc);
77 std::shared_ptr<DataRequest> mDataRequest;
78 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
79 o2::tpc::VDriftHelper mTPCVDriftHelper{};
80 o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
81 GTrackID::mask_t mSrc{};
82 bool mEnableCCDBParams = false;
83 bool mEnableCascades = false;
84 bool mEnable3BodyVertices = false;
85 bool mEnableStrangenessTracking = false;
86 bool mUseMC = false;
89 TStopwatch mTimer;
90};
91
93{
94 mTimer.Stop();
95 mTimer.Reset();
97 //-------- init geometry and field --------//
98 mVertexer.setEnableCascades(mEnableCascades);
99 mVertexer.setEnable3BodyDecays(mEnable3BodyVertices);
100 mVertexer.setNThreads(ic.options().get<int>("threads"));
101 mVertexer.setUseMC(mUseMC);
102 if (mEnableStrangenessTracking) {
105 mStrTracker.setupThreads(ic.options().get<int>("threads"));
106 mStrTracker.setupFitters();
107 mStrTracker.setMCTruthOn(mUseMC);
108 mVertexer.setStrangenessTracker(&mStrTracker);
109 }
110 if (mSrc[GTrackID::TPC]) {
111 mTPCCorrMapsLoader.init(ic);
112 }
113}
114
116{
117 double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
118 mTimer.Start(false);
119 static std::array<size_t, 3> fitCalls{};
120
122 recoData.collectData(pc, *mDataRequest.get());
123 updateTimeDependentParams(pc);
124
125 mVertexer.process(recoData, pc);
126
127 mTimer.Stop();
128 auto calls = mVertexer.getNFitterCalls();
129 LOGP(info, "Found {} V0s ({} fits), {} cascades ({} fits), {} 3-body decays ({} fits), {} strange tracks. Timing: CPU: {:.2f} Real: {:.2f} s",
130 mVertexer.getNV0s(), calls[0] - fitCalls[0], mVertexer.getNCascades(), calls[1] - fitCalls[1], mVertexer.getN3Bodies(), calls[2] - fitCalls[2], mVertexer.getNStrangeTracks(),
131 mTimer.CpuTime() - timeCPU0, mTimer.RealTime() - timeReal0);
132 fitCalls = calls;
133
134 static bool first = true;
135 if (first) {
136 first = false;
139 if (mEnableStrangenessTracking) {
141 }
142 }
143 }
144}
145
147{
148 LOGF(info, "Secondary vertexing total timing: Cpu: %.3e Real: %.3e s in %d slots, nThreads = %d",
149 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1, mVertexer.getNThreads());
150}
151
153{
155 return;
156 }
157 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
158 return;
159 }
160 if (mTPCCorrMapsLoader.accountCCDBInputs(matcher, obj)) {
161 return;
162 }
163 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
164 LOG(info) << "cluster dictionary updated";
166 return;
167 }
168 if (matcher == ConcreteDataMatcher("GLO", "MEANVERTEX", 0)) {
169 LOG(info) << "Imposing new MeanVertex: " << ((const o2::dataformats::MeanVertexObject*)obj)->asString();
171 return;
172 }
173 if (matcher == ConcreteDataMatcher("GLO", "SVPARAM", 0)) {
174 LOG(info) << "SVertexer Params updated from ccdb";
175 return;
176 }
177 if (matcher == ConcreteDataMatcher("ITS", "GEOMTGEO", 0)) {
178 LOG(info) << "ITS GeomtetryTGeo loaded from ccdb";
180 return;
181 }
182#ifdef ENABLE_UPGRADES
183 if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
184 LOG(info) << "cluster dictionary updated";
185 mStrTracker.setClusterDictionaryIT3((const o2::its3::TopologyDictionary*)obj);
186 return;
187 }
188#endif
189}
190
191void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
192{
194 if (mSrc[GTrackID::TPC]) {
195 mTPCVDriftHelper.extractCCDBInputs(pc);
196 mTPCCorrMapsLoader.extractCCDBInputs(pc);
197 }
198 static bool initOnceDone = false;
199 if (!initOnceDone) { // this params need to be queried only once
200 initOnceDone = true;
201 mVertexer.init();
202 if (mEnableCCDBParams) {
203 // for reading the calib objects from the CCDB
204 pc.inputs().get<o2::vertexing::SVertexerParams*>("SVParam");
205 }
206 if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) {
207 // setting and or overwriting the configurable params
209 }
210 if (pc.inputs().getPos("itsTGeo") >= 0) {
211 pc.inputs().get<o2::its::GeometryTGeo*>("itsTGeo");
212 }
213 if (mEnableStrangenessTracking) {
216 }
217
218#ifdef ENABLE_UPGRADES
219 if (o2::GlobalParams::Instance().withITS3) { // hack to trigger loading dictionary
220 pc.inputs().get<o2::its3::TopologyDictionary*>("cldict");
221 }
222#endif
223 }
224 // we may have other params which need to be queried regularly
225 if (mSrc[GTrackID::TPC]) {
226 bool updateMaps = false;
227 if (mTPCCorrMapsLoader.isUpdated()) {
228 mTPCCorrMapsLoader.acknowledgeUpdate();
229 updateMaps = true;
230 }
231 mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
232 if (mTPCVDriftHelper.isUpdated()) {
233 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
234 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
235 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
236 mTPCVDriftHelper.getSourceName());
237 mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
238 mTPCVDriftHelper.acknowledgeUpdate();
239 updateMaps = true;
240 }
241 if (updateMaps) {
242 mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
243 }
244 }
245 if (mEnableStrangenessTracking) {
246 if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) {
247 mStrTracker.setBz(o2::base::Propagator::Instance()->getNominalBz());
248 mStrTracker.setupFitters();
249 }
250 }
251
253}
254
255DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams,
256 bool useMC, bool useGeom, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts)
257{
258 std::vector<OutputSpec> outputs;
259 Options opts{
260 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
261 {"threads", VariantType::Int, 1, {"Number of threads"}}};
262 auto dataRequest = std::make_shared<DataRequest>();
263 if (enableCCDBParams) {
264 dataRequest->inputs.emplace_back("SVParam", "GLO", "SVPARAM", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/SVertexerParam"));
265 }
266 GTrackID::mask_t srcClus{};
267 if (enableStrangenesTracking) {
268 src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS));
269 }
270 if (GTrackID::includesDet(o2::detectors::DetID::TPC, src) && !src[GTrackID::TPC]) {
271 LOGP(warn, "Tracks involving TPC were requested w/o requesting TPC-only tracks, simplified selection will be applied");
272 }
273 if (src[GTrackID::TPC]) {
274 srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
275 }
276 if (srcClus.any()) {
277 dataRequest->requestClusters(srcClus, useMC);
278 }
279#ifdef ENABLE_UPGRADES
280 if (o2::GlobalParams::Instance().withITS3) { // hack to trigger loading dictionary
281 dataRequest->inputs.emplace_back("cldict", "IT3", "CLUSDICT", Lifetime::Condition, ccdbParamSpec("IT3/Calib/ClusterDictionary"));
282 }
283#endif
284 dataRequest->requestTracks(src, useMC);
285 dataRequest->requestPrimaryVertices(useMC);
286 dataRequest->inputs.emplace_back("meanvtx", "GLO", "MEANVERTEX", 0, Lifetime::Condition, ccdbParamSpec("GLO/Calib/MeanVertex", {}, 1));
287 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
288 true, // GRPECS=true
289 false, // GRPLHCIF
290 true, // GRPMagField
291 true, // askMatLUT
292 useGeom || enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
293 dataRequest->inputs,
294 true);
295 if (!useGeom && enableStrangenesTracking) {
296 ggRequest->addInput({"itsTGeo", "ITS", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("ITS/Config/Geometry")}, dataRequest->inputs);
297 }
298 if (src[GTrackID::TPC]) {
299 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
300 o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, sclOpts);
301 }
302 outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
303 outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
304 outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
305
306 outputs.emplace_back("GLO", "CASCS_IDX", 0, Lifetime::Timeframe); // found Cascades indices
307 outputs.emplace_back("GLO", "CASCS", 0, Lifetime::Timeframe); // found Cascades
308 outputs.emplace_back("GLO", "PVTX_CASCREFS", 0, Lifetime::Timeframe); // prim.vertex -> Cascades refs
309
310 outputs.emplace_back("GLO", "DECAYS3BODY_IDX", 0, Lifetime::Timeframe); // found 3 body vertices indices
311 outputs.emplace_back("GLO", "DECAYS3BODY", 0, Lifetime::Timeframe); // found 3 body vertices
312 outputs.emplace_back("GLO", "PVTX_3BODYREFS", 0, Lifetime::Timeframe); // prim.vertex -> 3 body vertices refs
313
314 if (enableStrangenesTracking) {
315 outputs.emplace_back("GLO", "STRANGETRACKS", 0, Lifetime::Timeframe); // found strange track
316 outputs.emplace_back("GLO", "CLUSUPDATES", 0, Lifetime::Timeframe);
317 if (useMC) {
318 outputs.emplace_back("GLO", "STRANGETRACKS_MC", 0, Lifetime::Timeframe);
319 LOG(info) << "Strangeness tracker will use MC";
320 }
321 }
322
323 return DataProcessorSpec{
324 "secondary-vertexing",
325 dataRequest->inputs,
326 outputs,
327 AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, sclOpts, src, enableCasc, enable3body, enableStrangenesTracking, enableCCDBParams, useMC)},
328 opts};
329}
330
331} // namespace vertexing
332} // 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)
static std::string getConfigOutputFileName(const std::string &procName, const std::string &confName="", bool json=true)
Definition NameConf.cxx:115
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:178
void printKeyValues(bool showProv=true, bool useLogger=false, bool withPadding=true, bool showHash=true) const final
static void write(std::string const &filename, std::string const &keyOnly="")
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.
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 ...
std::string name
The name of the associated DataProcessorSpec.
Definition DeviceSpec.h:50
size_t inputTimesliceId
The time pipelining id of this particular device.
Definition DeviceSpec.h:68
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"