ATLAS Offline Software
Loading...
Searching...
No Matches
HyPERUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "TMath.h"
6
7namespace EventReco {
8
9// Definition of the standalone HyPER message level (default: INFO)
10thread_local MSG::Level g_hyper_msg_level = MSG::INFO;
11
12std::vector<std::vector<int64_t>> transpose(
13 const std::vector<std::vector<int64_t>>& vecs) {
14 if (vecs.empty() || vecs[0].empty())
15 return {};
16
17 std::size_t rows = vecs.size();
18 std::size_t cols = vecs[0].size();
19 std::vector<std::vector<int64_t>> transposed(cols,
20 std::vector<int64_t>(rows));
21 for (std::size_t i = 0; i < rows; ++i) {
22 for (std::size_t j = 0; j < cols; ++j) {
23 transposed[j][i] = vecs[i][j];
24 }
25 }
26 return transposed;
27}
28
29std::vector<int64_t> range(int64_t n) {
30 std::vector<int64_t> result;
31 for (int64_t i{0}; i < n; ++i)
32 result.push_back(i);
33 return result;
34}
35
36// @enum HyPERTopology
38 if (str == "TtbarLJets")
40 if (str == "TtbarLJetsNoBTag")
42 if (str == "TtbarAllHadronic")
44 if (str == "TtbarDiLepton")
47}
48
49std::size_t getIndexFromLabel(const std::vector<std::string>& vec,
50 const std::string& label) {
51 auto it = std::find(vec.begin(), vec.end(), label);
52 if (it == vec.end()) {
53 throw std::runtime_error(
54 "HyPERAlg or VyPERAlg:: Could not find the label: " + label);
55 } else {
56 return std::distance(vec.begin(), it);
57 }
58}
59
60// Calculate delta phi between two angles in radians from -pi/2 to pi/2
61float deltaPhi(float phi1, float phi2) {
62 float PI = static_cast<float>(TMath::Pi());
63
64 float dphi = phi1 - phi2;
65 while (dphi > PI)
66 dphi -= 2 * PI;
67 while (dphi <= -PI)
68 dphi += 2 * PI;
69
70 return dphi;
71}
72
73} // namespace EventReco
std::vector< size_t > vec
std::string label(const std::string &format, int i)
Definition label.h:19
HyPERTopology strToHyPERTopology(const std::string &str)
std::size_t getIndexFromLabel(const std::vector< std::string > &vec, const std::string &label)
MSG::Level g_hyper_msg_level
std::vector< int64_t > range(int64_t n)
float deltaPhi(float phi1, float phi2)
std::vector< std::vector< int64_t > > transpose(const std::vector< std::vector< int64_t > > &vecs)
const float PI