ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Coordinate.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef TRIGTOOLS_TRIG_VSI_COORD
5#define TRIGTOOLS_TRIG_VSI_COORD
6
19
20#include "TMath.h"
21#include "TH3D.h"
22#include "TVector3.h"
23
24#include <cmath>
25
26namespace TrigVSI{
27
29namespace Coordinate{
30
34class Cartesian {
35 public :
38 static inline TVector3 X123toXYZ( double x1, double x2, double x3) {
39 return TVector3(x1, x2, x3);
40 };
41
42 static inline TVector3 X123toXYZ( const KDPoint<double,3>& p ) {
43 return TVector3(p.at(0),p.at(1),p.at(2));
44 };
45
46 static inline KDPoint<double,3> XYZtoX123( const TVector3& v ) {
47 return KDPoint<double,3>({v.x(), v.y(), v.z()});
48 };
49
50
53 static inline KDPoint<double,3> Proj(const KDPoint<double,3>& p) {
54 return p;
55 };
56
57
60 static inline KDPoint<int,3> ProjBin(const KDPoint<int,3>& ibin, const std::unique_ptr<TH3D>&) {
61 return ibin;
62 };
63
64};
65
66
67
71class Pseudo {
72 public :
75 static inline TVector3 X123toXYZ( double x1, double x2, double x3) {
76 TVector3 tmp;
77 tmp.SetPtEtaPhi(x1,x2,x3);
78 return tmp;
79 };
80
81 static inline TVector3 X123toXYZ( const KDPoint<double,3>& p ) {
82 TVector3 tmp;
83 tmp.SetPtEtaPhi(p.at(0),p.at(1),p.at(2));
84 return tmp;
85 };
86
87 static inline KDPoint<double,3> XYZtoX123( const TVector3& v ) {
88 return KDPoint<double,3>({v.Perp(), v.Eta(), v.Phi()});
89 };
90
91
94 static inline KDPoint<double,3> Proj(const KDPoint<double,3>& p) {
95 KDPoint<double,3> tmp = p;
96 tmp[2] = std::fmod( p[2] + TMath::Pi(), 2. * TMath::Pi() ) - TMath::Pi();
97 return tmp;
98 };
99
100
103 static inline KDPoint<int,3> ProjBin(const KDPoint<int,3>& ibin, const std::unique_ptr<TH3D>& map) {
104 KDPoint<int,3> tmp = ibin;
105 tmp[2] = (ibin[2] - 1) % (map->GetNbinsZ() - 1 + 1) + 1;
106 return tmp;
107 };
108
109};
110
111
112
116template<typename T>
117struct is_coord {
118 static auto check(...) -> std::false_type;
119
120 template<typename _Coord>
121 static auto check(_Coord*) ->
122 decltype( static_cast<TVector3(*)(const KDPoint<double,3>&)>(&_Coord::X123toXYZ),
123 static_cast<KDPoint<double,3>(*)(const TVector3&)>(&_Coord::XYZtoX123),
124 static_cast<KDPoint<double,3>(*)(const KDPoint<double,3>&)>(&_Coord::Proj),
125 static_cast<KDPoint<int,3>(*)(const KDPoint<int,3>&, const std::unique_ptr<TH3D>&)>(&_Coord::ProjBin),
126 std::true_type() );
127
128 static constexpr T* insPolicy = nullptr;
129 static constexpr bool value = decltype(check(insPolicy))::value;
130};
131
132} // end of namespace Coordinate
133
134} // end of namespace TrigVSI
135
136#endif
point classes for clustering
static KDPoint< double, 3 > Proj(const KDPoint< double, 3 > &p)
static KDPoint< int, 3 > ProjBin(const KDPoint< int, 3 > &ibin, const std::unique_ptr< TH3D > &)
static TVector3 X123toXYZ(double x1, double x2, double x3)
static KDPoint< double, 3 > Proj(const KDPoint< double, 3 > &p)
static KDPoint< int, 3 > ProjBin(const KDPoint< int, 3 > &ibin, const std::unique_ptr< TH3D > &map)
Class for k-dimensional point.
Definition KDPoint.h:29
STL class.
Namespace for Coordinate policy used in TrigVSI::VtxMap.
===========================================================================
static auto check(...) -> std::false_type
static auto check(_Coord *) -> decltype(static_cast< TVector3(*)(const KDPoint< double, 3 > &)>(&_Coord::X123toXYZ), static_cast< KDPoint< double, 3 >(*)(const TVector3 &)>(&_Coord::XYZtoX123), static_cast< KDPoint< double, 3 >(*)(const KDPoint< double, 3 > &)>(&_Coord::Proj), static_cast< KDPoint< int, 3 >(*)(const KDPoint< int, 3 > &, const std::unique_ptr< TH3D > &)>(&_Coord::ProjBin), std::true_type())