Project
Loading...
Searching...
No Matches
utils.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.
11
16
17#ifndef UTILS_H
18#define UTILS_H
19
21#include "MathUtils/Utils.h"
23
24namespace o2
25{
26namespace align
27{
28
30using value_t = typename trackParam_t::value_t;
31using dim2_t = typename trackParam_t::dim2_t;
32using dim3_t = typename trackParam_t::dim3_t;
33using params_t = typename trackParam_t::params_t;
34using covMat_t = typename trackParam_t::covMat_t;
35
36namespace utils
37{
38constexpr double AlmostZeroD = 1e-15;
39constexpr float AlmostZeroF = 1e-11;
40constexpr double AlmostOneD = 1. - AlmostZeroD;
41constexpr float AlmostOneF = 1. - AlmostZeroF;
42constexpr double TinyDist = 1.e-7; // ignore distances less that this
43
44//_________________________________________________________________________________
45enum { Coll,
48
49//_________________________________________________________________________________
50template <typename F>
51inline constexpr bool smallerAbs(F d, F tolD) noexcept
52{
53 return std::abs(d) < tolD;
54};
55
56//_________________________________________________________________________________
57template <typename F>
58inline constexpr bool smaller(F d, F tolD) noexcept
59{
60 return d < tolD;
61}
62
63inline constexpr bool isZeroAbs(double d) noexcept { return smallerAbs(d, AlmostZeroD); };
64inline constexpr bool isZeroAbs(float f) noexcept { return smallerAbs(f, AlmostZeroF); }
65inline constexpr bool isZeroPos(double d) noexcept { return smaller(d, AlmostZeroD); }
66inline constexpr bool isZeroPos(float f) noexcept { return smaller(f, AlmostZeroF); }
67
68//__________________________________________
69inline constexpr int findKeyIndex(int key, const int* arr, int n) noexcept
70{
71 // finds index of key in the array
72 int imn = 0;
73 int imx = n - 1;
74 while (imx >= imn) {
75 const int mid = (imx + imn) >> 1;
76 if (arr[mid] == key) {
77 return mid;
78 }
79
80 if (arr[mid] < key) {
81 imn = mid + 1;
82 } else {
83 imx = mid - 1;
84 }
85 }
86 return -1;
87}
88
89//_______________________________________________________________
90inline void printBits(size_t patt, int maxBits)
91{
92 // print maxBits of the pattern
93 maxBits = std::min(64, maxBits);
94 for (int i = 0; i < maxBits; i++) {
95 printf("%c", ((patt >> i) & 0x1) ? '+' : '-');
96 }
97};
98
99} // namespace utils
100} // namespace align
101} // namespace o2
102#endif
General auxilliary methods.
Base track model for the Barrel, params only, w/o covariance.
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
useful math constants
StringRef key
GLdouble n
Definition glcorearb.h:1982
GLdouble f
Definition glcorearb.h:310
constexpr bool smallerAbs(F d, F tolD) noexcept
Definition utils.h:51
constexpr bool isZeroAbs(double d) noexcept
Definition utils.h:63
constexpr double AlmostOneD
Definition utils.h:40
constexpr float AlmostOneF
Definition utils.h:41
constexpr bool isZeroPos(double d) noexcept
Definition utils.h:65
constexpr float AlmostZeroF
Definition utils.h:39
constexpr double TinyDist
Definition utils.h:42
void printBits(size_t patt, int maxBits)
Definition utils.h:90
constexpr int findKeyIndex(int key, const int *arr, int n) noexcept
Definition utils.h:69
constexpr double AlmostZeroD
Definition utils.h:38
constexpr bool smaller(F d, F tolD) noexcept
Definition utils.h:58
typename trackParam_t::params_t params_t
Definition utils.h:33
typename trackParam_t::dim3_t dim3_t
Definition utils.h:32
typename trackParam_t::covMat_t covMat_t
Definition utils.h:34
typename trackParam_t::dim2_t dim2_t
Definition utils.h:31
typename trackParam_t::value_t value_t
Definition utils.h:30
typename track::TrackParametrizationWithError< double > trackParam_t
Definition utils.h:29
void align(gsl::span< ElinkEncoder< BareFormat, CHARGESUM > > elinks)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.