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
25
26namespace o2::its
27{
28
29template <int nLayers>
31{
32 if (!mTraits) {
33 LOG(fatal) << "nullptr passed to ITS vertexer construction.";
34 }
35 mVertParams.resize(1);
36}
37
38template <int nLayers>
40{
41 LogFunc evalLog = [](const std::string&) {};
42
43 if (mTimeFrame->hasMCinformation() && mVertParams[0].useTruthSeeding) {
44 return evaluateTask(&Vertexer::addTruthSeeds, StateNames[mCurState = TruthSeeding], 0, evalLog);
45 }
46
47 TrackingParameters trkPars;
49 mTraits->updateVertexingParameters(mVertParams, tfGPUpar);
50
51 auto handleException = [&](const auto& err) {
52 LOGP(error, "Encountered critical error in step {}, stopping further processing of this TF: {}", StateNames[mCurState], err.what());
53 if (!mVertParams[0].DropTFUponFailure) {
54 throw err;
55 } else {
56 LOGP(error, "Dropping this TF!");
57 mTimeFrame->resetTracklets();
58 }
59 };
60
61 float timeTracklet{0.f}, timeSelection{0.f}, timeVertexing{0.f}, timeInit{0.f};
62 try {
63 for (int iteration = 0; iteration < std::min(mVertParams[0].nIterations, (int)mVertParams.size()); ++iteration) {
64 mMemoryPool->setMaxMemory(mVertParams[iteration].MaxMemory);
65 unsigned int nTracklets01{0}, nTracklets12{0};
66 logger(fmt::format("=== ITS {} Seeding vertexer iteration {} summary:", mTraits->getName(), iteration));
67 trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins;
68 trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins;
69 auto timeInitIteration = evaluateTask(&Vertexer::initialiseVertexer, StateNames[mCurState = Init], iteration, evalLog, trkPars, iteration);
70 auto timeTrackletIteration = evaluateTask(&Vertexer::findTracklets, StateNames[mCurState = Trackleting], iteration, evalLog, iteration);
71 nTracklets01 = mTimeFrame->getTotalTrackletsTF(0);
72 nTracklets12 = mTimeFrame->getTotalTrackletsTF(1);
73 auto timeSelectionIteration = evaluateTask(&Vertexer::validateTracklets, StateNames[mCurState = Validating], iteration, evalLog, iteration);
74 auto timeVertexingIteration = evaluateTask(&Vertexer::findVertices, StateNames[mCurState = Finding], iteration, evalLog, iteration);
75 printEpilog(logger, nTracklets01, nTracklets12, mTimeFrame->getNLinesTotal(), mTimeFrame->getTotVertIteration()[iteration], timeInitIteration, timeTrackletIteration, timeSelectionIteration, timeVertexingIteration);
76 timeInit += timeInitIteration;
77 timeTracklet += timeTrackletIteration;
78 timeSelection += timeSelectionIteration;
79 timeVertexing += timeVertexingIteration;
80 }
82 handleException(err);
83 } catch (const std::bad_alloc& err) {
84 handleException(err);
85 } catch (...) {
86 LOGP(fatal, "Uncaught exception!");
87 }
88
89 return timeInit + timeTracklet + timeSelection + timeVertexing;
90}
91
92template <int nLayers>
94{
95 mTimeFrame = &tf;
96 mTraits->adoptTimeFrame(&tf);
97}
98
99template <int nLayers>
101 const unsigned int trackletN01, const unsigned int trackletN12,
102 const unsigned selectedN, const unsigned int vertexN, const float initT,
103 const float trackletT, const float selecT, const float vertexT)
104{
105 logger(fmt::format(" - {} Vertexer: found {} | {} tracklets in: {} ms", mTraits->getName(), trackletN01, trackletN12, trackletT));
106 logger(fmt::format(" - {} Vertexer: selected {} tracklets in: {} ms", mTraits->getName(), selectedN, selecT));
107 logger(fmt::format(" - {} Vertexer: found {} vertices in: {} ms", mTraits->getName(), vertexN, vertexT));
108 if (mVertParams[0].PrintMemory) {
109 mTimeFrame->printArtefactsMemory();
110 mMemoryPool->print();
111 }
112}
113
114template class Vertexer<7>;
115
116} // namespace o2::its
Class to compute the primary vertex in ITS from tracklets.
void findVertices(T &&... args)
Definition Vertexer.h:74
void addTruthSeeds()
Definition Vertexer.h:79
void findTracklets(T &&... args)
Definition Vertexer.h:64
void initialiseVertexer(T &&... args)
Definition Vertexer.h:82
Vertexer(VertexerTraitsN *traits)
Definition Vertexer.cxx:30
void validateTracklets(T &&... args)
Definition Vertexer.h:69
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:100
float clustersToVertices(LogFunc=[](const std::string &s) { std::cout<< s<< '\n';})
Definition Vertexer.cxx:39
void adoptTimeFrame(TimeFrameN &tf)
Definition Vertexer.cxx:93
std::unique_ptr< GPUReconstructionTimeframe > tf
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"