Project
Loading...
Searching...
No Matches
Tracker.h
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
16#ifndef TRACKINGITSU_INCLUDE_TRACKER_H_
17#define TRACKINGITSU_INCLUDE_TRACKER_H_
18
19#include <array>
20#include <chrono>
21#include <cmath>
22#include <fstream>
23#include <iomanip>
24#include <iosfwd>
25#include <memory>
26#include <utility>
27#include <sstream>
28
32#include "ITStracking/ROframe.h"
35#include "ITStracking/Road.h"
36
39
40namespace o2
41{
42
43namespace gpu
44{
45class GPUChainITS;
46}
47namespace its
48{
49class TrackerTraits;
50
52{
53 using LogFunc = std::function<void(const std::string& s)>;
54
55 public:
56 Tracker(TrackerTraits* traits);
57
59
60 void clustersToTracks(LogFunc = [](std::string s) { std::cout << s << std::endl; }, LogFunc = [](std::string s) { std::cerr << s << std::endl; });
61
62 void setParameters(const std::vector<TrackingParameters>&);
63 std::vector<TrackingParameters>& getParameters() { return mTrkParams; }
65 void setBz(float);
67 bool isMatLUT() const;
68 void setNThreads(int n);
69 int getNThreads() const;
70 void printSummary() const;
71
72 private:
73 void initialiseTimeFrame(int& iteration);
74 void computeTracklets(int& iteration, int& iROFslice, int& iVertex);
75 void computeCells(int& iteration);
76 void findCellsNeighbours(int& iteration);
77 void findRoads(int& iteration);
78 void findShortPrimaries();
79 void extendTracks(int& iteration);
80
81 // MC interaction
82 void computeRoadsMClabels();
83 void computeTracksMClabels();
84 void rectifyClusterIndices();
85
86 template <typename... T>
87 float evaluateTask(void (Tracker::*)(T...), const char*, LogFunc logger, T&&... args);
88
89 TrackerTraits* mTraits = nullptr;
90 TimeFrame* mTimeFrame = nullptr;
91
92 std::vector<TrackingParameters> mTrkParams;
93 o2::gpu::GPUChainITS* mRecoChain = nullptr;
94
95 unsigned int mNumberOfDroppedTFs{0};
96 unsigned int mTimeFrameCounter{0};
97 double mTotalTime{0};
98};
99
100inline void Tracker::setParameters(const std::vector<TrackingParameters>& trkPars)
101{
102 mTrkParams = trkPars;
103}
104
105template <typename... T>
106float Tracker::evaluateTask(void (Tracker::*task)(T...), const char* taskName, LogFunc logger, T&&... args)
107{
108 float diff{0.f};
109
110 if constexpr (constants::DoTimeBenchmarks) {
111 auto start = std::chrono::high_resolution_clock::now();
112 (this->*task)(std::forward<T>(args)...);
113 auto end = std::chrono::high_resolution_clock::now();
114
115 std::chrono::duration<double, std::milli> diff_t{end - start};
116 diff = diff_t.count();
117
118 std::stringstream sstream;
119 if (taskName == nullptr) {
120 sstream << diff << "\t";
121 } else {
122 sstream << std::setw(2) << " - " << taskName << " completed in: " << diff << " ms";
123 }
124 logger(sstream.str());
125
126 if (mTrkParams[0].SaveTimeBenchmarks) {
127 std::stringstream str2file;
128 std::string taskNameStr(taskName);
129 std::transform(taskNameStr.begin(), taskNameStr.end(), taskNameStr.begin(),
130 [](unsigned char c) { return std::tolower(c); });
131 std::replace(taskNameStr.begin(), taskNameStr.end(), ' ', '_');
132 str2file << taskNameStr << "\t" << diff;
133 std::ofstream file;
134 file.open("its_time_benchmarks.txt", std::ios::app);
135 file << str2file.str() << std::endl;
136 file.close();
137 }
138
139 } else {
140 (this->*task)(std::forward<T>(args)...);
141 }
142
143 return diff;
144}
145
146} // namespace its
147} // namespace o2
148
149#endif /* TRACKINGITSU_INCLUDE_TRACKER_H_ */
useful math constants
uint32_t c
Definition RawData.h:2
Definition of the ITS track.
void adoptTimeFrame(TimeFrame &tf)
Definition Tracker.cxx:430
void setCorrType(const o2::base::PropagatorImpl< float >::MatCorrType type)
Definition Tracker.cxx:441
void setParameters(const std::vector< TrackingParameters > &)
Definition Tracker.h:100
void printSummary() const
Definition Tracker.cxx:461
bool isMatLUT() const
Definition Tracker.cxx:446
std::vector< TrackingParameters > & getParameters()
Definition Tracker.h:63
void getGlobalConfiguration()
Definition Tracker.cxx:363
int getNThreads() const
Definition Tracker.cxx:456
void setBz(float)
Definition Tracker.cxx:436
void setNThreads(int n)
Definition Tracker.cxx:451
void clustersToTracks(LogFunc=[](std::string s) { std::cout<< s<< std::endl;}, LogFunc=[](std::string s) { std::cerr<< s<< std::endl;})
Definition Tracker.cxx:45
GLdouble n
Definition glcorearb.h:1982
GLuint GLuint end
Definition glcorearb.h:469
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint start
Definition glcorearb.h:469
constexpr bool DoTimeBenchmarks
Definition Constants.h:40
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf