Project
Loading...
Searching...
No Matches
bench_Tracker.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
16
17#include "benchmark/benchmark.h"
18#include <random>
21#include "MIDBase/HitFinder.h"
22#include "MIDBase/Mapping.h"
23#include "MIDBase/MpArea.h"
25#include "MIDTracking/Tracker.h"
26
27std::vector<o2::mid::Cluster> generateTestData(int nTracks, o2::mid::TrackGenerator& trackGen,
28 const o2::mid::HitFinder& hitFinder, const o2::mid::Mapping& mapping)
29{
31 o2::mid::MpArea area;
32 std::vector<o2::mid::Cluster> clusters;
34 std::vector<o2::mid::Track> tracks = trackGen.generate(nTracks);
35 for (auto& track : tracks) {
36 for (int ich = 0; ich < 4; ++ich) {
37 auto hits = hitFinder.getLocalPositions(track, ich);
38 bool isFired = false;
39 for (auto& hit : hits) {
40 int deId = hit.deId;
41 float xPos = hit.xCoor;
42 float yPos = hit.yCoor;
43 stripIndex = mapping.stripByPosition(xPos, yPos, 0, deId, false);
44 if (!stripIndex.isValid()) {
45 continue;
46 }
47 cl.deId = deId;
48 area = mapping.stripByLocation(stripIndex.strip, 0, stripIndex.line, stripIndex.column, deId);
49 cl.yCoor = area.getCenterY();
50 cl.yErr = area.getHalfSizeY() / std::sqrt(3.);
51 stripIndex = mapping.stripByPosition(xPos, yPos, 1, deId, false);
52 area = mapping.stripByLocation(stripIndex.strip, 1, stripIndex.line, stripIndex.column, deId);
53 cl.xCoor = area.getCenterX();
54 cl.xErr = area.getHalfSizeX() / std::sqrt(3.);
55 clusters.push_back(cl);
56 } // loop on fired pos
57 } // loop on chambers
58 } // loop on tracks
59 return clusters;
60}
61
62static void BM_TRACKER(benchmark::State& state)
63{
66 o2::mid::HitFinder hitFinder(geoTrans);
67 o2::mid::Mapping mapping;
68 o2::mid::Tracker tracker(geoTrans);
69
70 int nTracksPerEvent = state.range(0);
71 tracker.init((state.range(1) == 1));
72 double num{0};
73
74 std::vector<o2::mid::Cluster> inputData;
75
76 for (auto _ : state) {
77 state.PauseTiming();
78 inputData = generateTestData(nTracksPerEvent, trackGen, hitFinder, mapping);
79 state.ResumeTiming();
80 tracker.process(inputData);
81 ++num;
82 }
83
84 state.counters["num"] = benchmark::Counter(num, benchmark::Counter::kIsRate);
85}
86
87static void CustomArguments(benchmark::internal::Benchmark* bench)
88{
89 for (int itrack = 1; itrack <= 8; ++itrack) {
90 for (int imethod = 0; imethod < 2; ++imethod) {
91 bench->Args({itrack, imethod});
92 }
93 }
94}
95
96BENCHMARK(BM_TRACKER)->Apply(CustomArguments)->Unit(benchmark::kNanosecond);
97
benchmark::State & state
Reconstructed MID cluster.
Reconstructed MID track.
Hit finder for MID.
Mapping for MID.
Track reconstruction algorithm for MID.
Mapping area for MID.
Fast track generator for MID.
std::vector< o2::mid::ColumnData > inputData
double num
std::vector< o2::mid::Cluster > generateTestData(int nTracks, o2::mid::TrackGenerator &trackGen, const o2::mid::HitFinder &hitFinder, const o2::mid::Mapping &mapping)
BENCHMARK_MAIN()
BENCHMARK(BM_TRACKER) -> Apply(CustomArguments) ->Unit(benchmark::kNanosecond)
Class to find the impact point of a track on the chamber.
Definition HitFinder.h:31
std::vector< Cluster > getLocalPositions(const Track &track, int chamber, bool withUncertainties=false) const
MpStripIndex stripByPosition(double xPos, double yPos, int cathode, int deId, bool warn=true) const
Definition Mapping.cxx:592
MpArea stripByLocation(int strip, int cathode, int line, int column, int deId, bool warn=true) const
Definition Mapping.cxx:487
Class to generate tracks for MID.
std::vector< Track > generate()
Tracking algorithm for MID.
Definition Tracker.h:34
GeometryTransformer createDefaultTransformer()
cluster structure for MID
Definition Cluster.h:30
float yErr
Cluster resolution along y.
Definition Cluster.h:35
float yCoor
y coordinate
Definition Cluster.h:32
float xErr
Cluster resolution along x.
Definition Cluster.h:34
float xCoor
x coordinate
Definition Cluster.h:31
uint8_t deId
Detection element ID.
Definition Cluster.h:36
Indexes required to define a strip in the detection element.
Definition Mapping.h:34
int strip
Line of the local board in the column.
Definition Mapping.h:39
bool isValid()
Check if Strip is Valid.
Definition Mapping.h:36
int line
Column in the DE.
Definition Mapping.h:38
std::vector< Cluster > clusters