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"
34#include "TPCFastTransformPOD.h"
37
38using namespace o2::framework;
39
49
50namespace o2
51{
52namespace vertexing
53{
54
55namespace o2d = o2::dataformats;
56
58{
59 public:
60 SecondaryVertexingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, 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) {}
61 ~SecondaryVertexingSpec() override = default;
62 void init(InitContext& ic) final;
63 void run(ProcessingContext& pc) final;
64 void endOfStream(EndOfStreamContext& ec) final;
65 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
66
67 private:
68 void updateTimeDependentParams(ProcessingContext& pc);
69 std::shared_ptr<DataRequest> mDataRequest;
70 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
71 o2::tpc::VDriftHelper mTPCVDriftHelper{};
72 const o2::gpu::TPCFastTransformPOD* mTPCCorrMaps{nullptr};
73 GTrackID::mask_t mSrc{};
74 bool mEnableCCDBParams = false;
75 bool mEnableCascades = false;
76 bool mEnable3BodyVertices = false;
77 bool mEnableStrangenessTracking = false;
78 bool mUseMC = false;
81 TStopwatch mTimer;
82};
83
85{
86 mTimer.Stop();
87 mTimer.Reset();
89 //-------- init geometry and field --------//
90 mVertexer.setEnableCascades(mEnableCascades);
91 mVertexer.setEnable3BodyDecays(mEnable3BodyVertices);
92 mVertexer.setNThreads(ic.options().get<int>("threads"));
93 mVertexer.setUseMC(mUseMC);
94 if (mEnableStrangenessTracking) {
97 mStrTracker.setupThreads(ic.options().get<int>("threads"));
98 mStrTracker.setupFitters();
99 mStrTracker.setMCTruthOn(mUseMC);
100 mVertexer.setStrangenessTracker(&mStrTracker);
101 }
102}
103
105{
106 double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
107 mTimer.Start(false);
108 static std::array<size_t, 3> fitCalls{};
109
111 recoData.collectData(pc, *mDataRequest.get());
112 updateTimeDependentParams(pc);
113
114 mVertexer.process(recoData, pc);
115
116 mTimer.Stop();
117 auto calls = mVertexer.getNFitterCalls();
118 LOGP(info, "Found {} V0s ({} fits), {} cascades ({} fits), {} 3-body decays ({} fits), {} strange tracks. Timing: CPU: {:.2f} Real: {:.2f} s",
119 mVertexer.getNV0s(), calls[0] - fitCalls[0], mVertexer.getNCascades(), calls[1] - fitCalls[1], mVertexer.getN3Bodies(), calls[2] - fitCalls[2], mVertexer.getNStrangeTracks(),
120 mTimer.CpuTime() - timeCPU0, mTimer.RealTime() - timeReal0);
121 fitCalls = calls;
122
123 static bool first = true;
124 if (first) {
125 first = false;
128 if (mEnableStrangenessTracking) {
130 }
131 }
132 }
133}
134
136{
137 LOGF(info, "Secondary vertexing total timing: Cpu: %.3e Real: %.3e s in %d slots, nThreads = %d",
138 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1, mVertexer.getNThreads());
139}
140
142{
144 return;
145 }
146 if (mTPCVDriftHelper.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 auto const& raw = pc.inputs().get<const char*>("corrMap");
183 mTPCCorrMaps = &gpu::TPCFastTransformPOD::get(raw);
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 mVertexer.setTPCCorrMaps(mTPCCorrMaps);
214
215 if (mTPCVDriftHelper.isUpdated()) {
216 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
217 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
218 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
219 mTPCVDriftHelper.getSourceName());
220 mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
221 mTPCVDriftHelper.acknowledgeUpdate();
222 }
223 }
224 if (mEnableStrangenessTracking) {
225 if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) {
226 mStrTracker.setBz(o2::base::Propagator::Instance()->getNominalBz());
227 mStrTracker.setupFitters();
228 }
229 }
230
232}
233
234DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams,
235 bool useMC, bool useGeom)
236{
237 std::vector<OutputSpec> outputs;
238 Options opts{
239 {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}},
240 {"threads", VariantType::Int, 1, {"Number of threads"}}};
241 auto dataRequest = std::make_shared<DataRequest>();
242 if (enableCCDBParams) {
243 dataRequest->inputs.emplace_back("SVParam", "GLO", "SVPARAM", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/SVertexerParam"));
244 }
245 GTrackID::mask_t srcClus{};
246 if (enableStrangenesTracking) {
247 src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS));
248 }
249 if (GTrackID::includesDet(o2::detectors::DetID::TPC, src) && !src[GTrackID::TPC]) {
250 LOGP(warn, "Tracks involving TPC were requested w/o requesting TPC-only tracks, simplified selection will be applied");
251 }
252 if (src[GTrackID::TPC]) {
253 srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
254 }
255 if (srcClus.any()) {
256 dataRequest->requestClusters(srcClus, useMC);
257 }
258#ifdef ENABLE_UPGRADES
259 if (o2::GlobalParams::Instance().withITS3) { // hack to trigger loading dictionary
260 dataRequest->inputs.emplace_back("cldict", "IT3", "CLUSDICT", Lifetime::Condition, ccdbParamSpec("IT3/Calib/ClusterDictionary"));
261 }
262#endif
263 dataRequest->requestTracks(src, useMC);
264 dataRequest->requestPrimaryVertices(useMC);
265 dataRequest->inputs.emplace_back("meanvtx", "GLO", "MEANVERTEX", 0, Lifetime::Condition, ccdbParamSpec("GLO/Calib/MeanVertex", {}, 1));
266 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
267 true, // GRPECS=true
268 false, // GRPLHCIF
269 true, // GRPMagField
270 true, // askMatLUT
271 useGeom || enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
272 dataRequest->inputs,
273 true);
274 if (!useGeom && enableStrangenesTracking) {
275 ggRequest->addInput({"itsTGeo", "ITS", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("ITS/Config/Geometry")}, dataRequest->inputs);
276 }
277 if (src[GTrackID::TPC]) {
278 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
279 dataRequest->inputs.emplace_back("corrMap", o2::header::gDataOriginTPC, "TPCCORRMAP", 0, Lifetime::Timeframe);
280 }
281 outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
282 outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
283 outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
284
285 outputs.emplace_back("GLO", "CASCS_IDX", 0, Lifetime::Timeframe); // found Cascades indices
286 outputs.emplace_back("GLO", "CASCS", 0, Lifetime::Timeframe); // found Cascades
287 outputs.emplace_back("GLO", "PVTX_CASCREFS", 0, Lifetime::Timeframe); // prim.vertex -> Cascades refs
288
289 outputs.emplace_back("GLO", "DECAYS3BODY_IDX", 0, Lifetime::Timeframe); // found 3 body vertices indices
290 outputs.emplace_back("GLO", "DECAYS3BODY", 0, Lifetime::Timeframe); // found 3 body vertices
291 outputs.emplace_back("GLO", "PVTX_3BODYREFS", 0, Lifetime::Timeframe); // prim.vertex -> 3 body vertices refs
292
293 if (enableStrangenesTracking) {
294 outputs.emplace_back("GLO", "STRANGETRACKS", 0, Lifetime::Timeframe); // found strange track
295 outputs.emplace_back("GLO", "CLUSUPDATES", 0, Lifetime::Timeframe);
296 if (useMC) {
297 outputs.emplace_back("GLO", "STRANGETRACKS_MC", 0, Lifetime::Timeframe);
298 LOG(info) << "Strangeness tracker will use MC";
299 }
300 }
301
302 return DataProcessorSpec{
303 "secondary-vertexing",
304 dataRequest->inputs,
305 outputs,
306 AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, src, enableCasc, enable3body, enableStrangenesTracking, enableCCDBParams, useMC)},
307 opts};
308}
309
310} // namespace vertexing
311} // namespace o2
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
o2::raw::RawFileWriter * raw
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.
POD correction map.
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)
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:116
std::array< size_t, 3 > getNFitterCalls() const
void setEnable3BodyDecays(bool v)
Definition SVertexer.h:117
void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD *maph)
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:126
void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker *tracker)
Definition SVertexer.h:146
int getNStrangeTracks() const
Definition SVertexer.h:124
~SecondaryVertexingSpec() override=default
SecondaryVertexingSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, GTrackID::mask_t src, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool enableCCDBParams, bool useMC)
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
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:576
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
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)
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
float refTimeOffset
additive time offset reference (\mus)
float refVDrift
reference vdrift for which factor was extracted
float timeOffsetCorr
additive time offset correction (\mus)
float corrFact
drift velocity correction factor (multiplicative)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"