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