Project
Loading...
Searching...
No Matches
Vertexer.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.
15
18#include "ITStracking/Cluster.h"
19#include "ITStracking/ROframe.h"
24
25namespace o2::its
26{
27
28Vertexer::Vertexer(VertexerTraits* traits) : mTraits(traits)
29{
30 if (!mTraits) {
31 LOG(fatal) << "nullptr passed to ITS vertexer construction.";
32 }
33 mVertParams.resize(1);
34}
35
36float Vertexer::clustersToVertices(LogFunc logger)
37{
38 LogFunc evalLog = [](const std::string&) {};
39 TrackingParameters trkPars;
41 mTraits->updateVertexingParameters(mVertParams, tfGPUpar);
42
43 auto handleException = [&](const auto& err) {
44 LOGP(error, "Encountered critical error in step {}, stopping further processing of this TF: {}", StateNames[mCurState], err.what());
45 if (!mVertParams[0].DropTFUponFailure) {
46 throw err;
47 } else {
48 LOGP(error, "Dropping this TF!");
49 mTimeFrame->resetTracklets();
50 }
51 };
52
53 float timeTracklet{0.f}, timeSelection{0.f}, timeVertexing{0.f}, timeInit{0.f};
54 try {
55 for (int iteration = 0; iteration < std::min(mVertParams[0].nIterations, (int)mVertParams.size()); ++iteration) {
56 mMemoryPool->setMaxMemory(mVertParams[iteration].MaxMemory);
57 unsigned int nTracklets01{0}, nTracklets12{0};
58 logger(fmt::format("=== ITS {} Seeding vertexer iteration {} summary:", mTraits->getName(), iteration));
59 trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins;
60 trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins;
61 auto timeInitIteration = evaluateTask(
62 &Vertexer::initialiseVertexer, StateNames[mCurState = Init], iteration, evalLog, trkPars, iteration);
63 auto timeTrackletIteration = evaluateTask(
64 &Vertexer::findTracklets, StateNames[mCurState = Trackleting], iteration, evalLog, iteration);
65 nTracklets01 = mTimeFrame->getTotalTrackletsTF(0);
66 nTracklets12 = mTimeFrame->getTotalTrackletsTF(1);
67 auto timeSelectionIteration = evaluateTask(
68 &Vertexer::validateTracklets, StateNames[mCurState = Validating], iteration, evalLog, iteration);
69 auto timeVertexingIteration = evaluateTask(&Vertexer::findVertices, StateNames[mCurState = Finding], iteration, evalLog, iteration);
70 printEpilog(logger, nTracklets01, nTracklets12, mTimeFrame->getNLinesTotal(), mTimeFrame->getTotVertIteration()[iteration], timeInitIteration, timeTrackletIteration, timeSelectionIteration, timeVertexingIteration);
71 timeInit += timeInitIteration;
72 timeTracklet += timeTrackletIteration;
73 timeSelection += timeSelectionIteration;
74 timeVertexing += timeVertexingIteration;
75 }
77 handleException(err);
78 } catch (const std::bad_alloc& err) {
79 handleException(err);
80 } catch (...) {
81 LOGP(fatal, "Uncaught exception!");
82 }
83
84 return timeInit + timeTracklet + timeSelection + timeVertexing;
85}
86
88{
91
92 // This is odd: we override only the parameters for the first iteration.
93 // Variations for the next iterations are set in the trackingInterfrace.
94 mVertParams[0].nIterations = vc.nIterations;
95 mVertParams[0].deltaRof = vc.deltaRof;
96 mVertParams[0].allowSingleContribClusters = vc.allowSingleContribClusters;
97 mVertParams[0].zCut = vc.zCut;
98 mVertParams[0].phiCut = vc.phiCut;
99 mVertParams[0].pairCut = vc.pairCut;
100 mVertParams[0].clusterCut = vc.clusterCut;
101 mVertParams[0].histPairCut = vc.histPairCut;
102 mVertParams[0].tanLambdaCut = vc.tanLambdaCut;
103 mVertParams[0].lowMultBeamDistCut = vc.lowMultBeamDistCut;
104 mVertParams[0].vertNsigmaCut = vc.vertNsigmaCut;
105 mVertParams[0].vertRadiusSigma = vc.vertRadiusSigma;
106 mVertParams[0].trackletSigma = vc.trackletSigma;
107 mVertParams[0].maxZPositionAllowed = vc.maxZPositionAllowed;
108 mVertParams[0].clusterContributorsCut = vc.clusterContributorsCut;
109 mVertParams[0].maxTrackletsPerCluster = vc.maxTrackletsPerCluster;
110 mVertParams[0].phiSpan = vc.phiSpan;
111 mVertParams[0].nThreads = vc.nThreads;
112 mVertParams[0].ZBins = vc.ZBins;
113 mVertParams[0].PhiBins = vc.PhiBins;
114 mVertParams[0].SaveTimeBenchmarks = vc.saveTimeBenchmarks;
115}
116
118{
119 mTimeFrame = &tf;
120 mTraits->adoptTimeFrame(&tf);
121}
122
123void Vertexer::printEpilog(LogFunc& logger,
124 const unsigned int trackletN01, const unsigned int trackletN12,
125 const unsigned selectedN, const unsigned int vertexN, const float initT,
126 const float trackletT, const float selecT, const float vertexT)
127{
128 float total = initT + trackletT + selecT + vertexT;
129 logger(fmt::format(" - {} Vertexer: found {} | {} tracklets in: {} ms", mTraits->getName(), trackletN01, trackletN12, trackletT));
130 logger(fmt::format(" - {} Vertexer: selected {} tracklets in: {} ms", mTraits->getName(), selectedN, selecT));
131 logger(fmt::format(" - {} Vertexer: found {} vertices in: {} ms", mTraits->getName(), vertexN, vertexT));
132 if (mVertParams[0].PrintMemory) {
133 mTimeFrame->printArtefactsMemory();
134 mMemoryPool->print();
135 }
136}
137
138} // namespace o2::its
Class to compute the primary vertex in ITS from tracklets.
virtual void adoptTimeFrame(TimeFrame7 *tf) noexcept
virtual const char * getName() const noexcept
virtual void updateVertexingParameters(const std::vector< VertexingParameters > &vrtPar, const TimeFrameGPUParameters &gpuTfPar)
void findTracklets(T &&... args)
Definition Vertexer.h:120
void initialiseVertexer(T &&... args)
Definition Vertexer.h:114
void validateTracklets(T &&... args)
Definition Vertexer.h:126
void findVertices(T &&... args)
Definition Vertexer.h:132
void adoptTimeFrame(TimeFrame7 &tf)
Definition Vertexer.cxx:117
float evaluateTask(void(Vertexer::*task)(T...), std::string_view taskName, int iteration, LogFunc &logger, T &&... args)
Definition Vertexer.h:138
float clustersToVertices(LogFunc=[](const std::string &s) { std::cout<< s<< '\n';})
Definition Vertexer.cxx:36
Vertexer(VertexerTraits *traits)
Definition Vertexer.cxx:28
void getGlobalConfiguration()
Definition Vertexer.cxx:87
void printEpilog(LogFunc &logger, const unsigned int trackletN01, const unsigned int trackletN12, const unsigned selectedN, const unsigned int vertexN, const float initT, const float trackletT, const float selecT, const float vertexT)
Definition Vertexer.cxx:123
std::unique_ptr< GPUReconstructionTimeframe > tf
int getNLinesTotal() const
Definition TimeFrame.h:202
auto & getTotVertIteration()
Definition TimeFrame.h:96
void printArtefactsMemory() const
uint32_t getTotalTrackletsTF(const int iLayer)
Definition TimeFrame.h:212
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"