ATLAS Offline Software
GeoUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace NSWL1{
8 
9 float eta(float x,float y,float z){
10  ROOT::Math::XYZVector V(x,y,z);
11  return V.Eta();
12 }
13 
14 float phi(float x, float y, float z){
15  ROOT::Math::XYZVector V(x,y,z);
16  return V.Phi();
17 }
18 
19 Polygon Project(const Polygon& p,float Zinit,float Zfin){
20  //loop over vertices
21  Vertices vt;
22  for(const auto& v : boost::geometry::exterior_ring(p)){
23  float x=coordinate<0>(v);
24  float y=coordinate<1>(v);
25  ROOT::Math::XYZVector vec(x, y, Zinit);
26  float phi=vec.Phi();
27  float theta=vec.Theta();
28  vec.SetZ(Zfin);
29  ROOT::Math::Polar3DVector projectedVec(vec.R(), theta, phi);
30  vt.push_back(Vertex(projectedVec.X(), projectedVec.Y()));
31  }
32  return buildPolygon(vt);
33 }
34 
35 int nVertices(const Polygon& p){
36  return boost::geometry::num_points(p);
37 }
38 
39 Vertex getVertex(const Polygon& p,unsigned int i){
40  return boost::geometry::exterior_ring(p)[i];
41 }
42 
43 
45  Polygon shape;
46  Vertices vts=pts;
47  //to complete the loop...
48  vts.push_back(vts[0]);
49 
50  boost::geometry::assign_points(shape, pts);
51  boost::geometry::correct(shape);
52  return shape;
53 }
54 
55 float area(const Polygon& p){
56  return boost::geometry::area(p);
57 }
58 
60  Vertex v;
62  return v;
63 }
64 
65  std::vector<Polygon> allIntersections(const Polygon& p1, const Polygon& p2){
66  std::vector<Polygon> out;
68  return out;
69 
70 }
71 
72 
74  std::vector<Polygon> pols=allIntersections(p1,p2);
75  //we have to return something
76  if(pols.empty()) return NilPolygon();
77  return allIntersections(p1,p2).at(0);
78 }
79 
81  std::vector<Polygon> pols=allIntersections(p1,p2);
82  if(pols.empty()) return NilPolygon();
83 
84  std::sort(pols.begin(),pols.end(),[](const Polygon& a,const Polygon& b){return area(a)>area(b);});
85  return pols[0];
86 
87 }
88 
89 
90 
91 Polygon intersectionRegion(const std::vector<Polygon>& polygons){
92  Polygon ovl=polygons[0];
93  for(unsigned int i=1;i<polygons.size();i++){
94  Polygon curr=polygons[i];
95  Polygon overlap=largestIntersection(curr,ovl);
96  ovl=overlap;
97  }
98  return ovl;
99 }
100 
101 
102 
103 Polygon globalToLocal(const Polygon& pol,float z,const Trk::PlaneSurface & surf ){
104 
105  Vertices local_vertices;
106  for(const auto& v : boost::geometry::exterior_ring(pol)){
107  float x=coordinate<0>(v);
108  float y=coordinate<1>(v);
109  Amg::Vector2D local_corner;
110  surf.globalToLocal(Amg::Vector3D(x,y,z),Amg::Vector3D(),local_corner);
111  local_vertices.emplace_back(Vertex(local_corner.x(),local_corner.y()));
112  }
113  return buildPolygon(local_vertices);
114 }
115 
116 
117 
119  Vertices nil={
120  Vertex(0,0),
121  Vertex(0,0),
122  Vertex(0,0),
123  Vertex(0,0),
124  Vertex(0,0)
125  };
126  return buildPolygon(nil);
127 }
128 
129 }
Trk::PlaneSurface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
Definition: PlaneSurface.cxx:213
NSWL1::eta
float eta(float x, float y, float z)
Definition: GeoUtils.cxx:9
NSWL1::nVertices
int nVertices(const Polygon &p)
Definition: GeoUtils.cxx:35
EgEfficiencyCorr_testFixedInput.pts
list pts
Definition: EgEfficiencyCorr_testFixedInput.py:10
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
NSWL1::Vertex
boost::geometry::model::d2::point_xy< double > Vertex
Definition: GeoUtils.h:17
GeoUtils.h
NSWL1::Polygon
boost::geometry::model::polygon< Vertex > Polygon
Definition: GeoUtils.h:18
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
NSWL1::largestIntersection
Polygon largestIntersection(const Polygon &p1, const Polygon &p2)
Definition: GeoUtils.cxx:80
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
NSWL1::allIntersections
std::vector< Polygon > allIntersections(const Polygon &p1, const Polygon &p2)
Definition: GeoUtils.cxx:65
NSWL1::NilPolygon
Polygon NilPolygon()
Definition: GeoUtils.cxx:118
NSWL1::Project
Polygon Project(const Polygon &p, float Zinit, float Zfin)
Definition: GeoUtils.cxx:19
x
#define x
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
NSWL1::area
float area(const Polygon &p)
Definition: GeoUtils.cxx:55
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
NSWL1::getVertex
Vertex getVertex(const Polygon &p, unsigned int i)
Definition: GeoUtils.cxx:39
NSWL1::firstIntersection
Polygon firstIntersection(const Polygon &p1, const Polygon &p2)
Definition: GeoUtils.cxx:73
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
validateBDTTau.vt
vt
Definition: validateBDTTau.py:43
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
Trk::PlaneSurface
Definition: PlaneSurface.h:64
NSWL1::intersectionRegion
Polygon intersectionRegion(const std::vector< Polygon > &polygons)
Definition: GeoUtils.cxx:91
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
NSWL1::phi
float phi(float x, float y, float z)
Definition: GeoUtils.cxx:14
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:9
NSWL1::globalToLocal
Polygon globalToLocal(const Polygon &pol, float z, const Trk::PlaneSurface &surf)
Definition: GeoUtils.cxx:103
NSWL1::Vertices
std::vector< Vertex > Vertices
Definition: GeoUtils.h:19
NSWL1::centroid
Vertex centroid(const Polygon &p)
Definition: GeoUtils.cxx:59
NSWL1::buildPolygon
Polygon buildPolygon(const Vertices &pts)
Definition: GeoUtils.cxx:44