ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPhysValMonitoringUtilities.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef INDETPHYSVALMONITORINGUTILITIES
6#define INDETPHYSVALMONITORINGUTILITIES
12
13 #include <cmath>
14 #include <vector>
15namespace IDPVM {
17 constexpr float
18 operator "" _GeV (long double energy) {
19 return energy * 0.001;
20 }
21
22 constexpr float
23 operator "" _GeV (unsigned long long energy) {
24 return energy * 0.001;
25 }
26
28 template <class T>
29 inline bool
30 inRange(const T& value, const T& minVal, const T& maxVal) {
31 return not ((value < minVal)or(value > maxVal));
32 }
33
34 template<class T>
35 inline bool
36 inRange(const T& value, const T& absoluteMax) {
37 return not (std::abs(value) > absoluteMax);
38 }
39
41 template <class T>
42 unsigned int
43 binIndex(const T& val, const std::vector<T>& partitions) {// signature should allow other containers
44 unsigned int i(0);
45 bool nf = true;
46
47 while (nf and i != partitions.size()) {
48 nf = (val > partitions[i++]);
49 }
50 return nf ? i : i - 1;
51 }
52
54 template <class T>
55 inline float
56 safelyGetEta(const T& pTrk, const float safePtThreshold = 0.1) {
57 return (pTrk.pt() > safePtThreshold) ? (pTrk.eta()) : std::nan("");
58 }
59
60 template <class T>
61 inline float
62 safelyGetEta(const T* pTrk, const float safePtThreshold = 0.1) {
63 return (pTrk->pt() > safePtThreshold) ? (pTrk->eta()) : std::nan("");
64 }
65}
66
67 #endif
Class to retrieve associated truth from a track, implementing a cached response.
bool inRange(const T &value, const T &minVal, const T &maxVal)
general utility function to check value is in range
float safelyGetEta(const T &pTrk, const float safePtThreshold=0.1)
Safely get eta.
unsigned int binIndex(const T &val, const std::vector< T > &partitions)
general utility function to return bin index given a value and the upper endpoints of each bin