Skip to content

Commit d0ce780

Browse files
committed
Merge pull request cms-sw#2296 from VinInn/TrackGeom
Track geom
2 parents 25bf603 + 0631742 commit d0ce780

File tree

178 files changed

+2111
-2201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+2111
-2201
lines changed

DataFormats/GeometrySurface/interface/GloballyPositioned.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ class GloballyPositioned {
5959
ToLocal(GloballyPositioned const & frame) :
6060
thePos(frame.position()), theRot(frame.rotation().transposed()){}
6161

62+
LocalPoint operator()(const GlobalPoint& gp) const {
63+
return toLocal(gp);
64+
}
65+
66+
LocalVector operator()(const GlobalVector& gv) const {
67+
return toLocal(gv);
68+
}
69+
6270
LocalPoint toLocal( const GlobalPoint& gp) const {
6371
return LocalPoint( theRot.multiplyInverse( gp.basicVector() -
6472
thePos.basicVector())
@@ -69,7 +77,7 @@ class GloballyPositioned {
6977
return LocalVector(theRot.multiplyInverse(gv.basicVector()));
7078
}
7179

72-
private:
80+
// private:
7381
PositionType thePos;
7482
RotationType theRot;
7583

DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h

+18-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class RectangularPlaneBounds GCC11_FINAL : public Bounds {
1717
/// Construct from half width (extension in local X),
1818
/// half length (Y) and half thickness (Z)
1919
RectangularPlaneBounds( float w, float h, float t);
20+
~RectangularPlaneBounds();
2021

2122
/// Lenght along local Y
2223
virtual float length() const { return 2*halfLength;}
@@ -26,11 +27,25 @@ class RectangularPlaneBounds GCC11_FINAL : public Bounds {
2627
virtual float thickness() const { return 2*halfThickness;}
2728

2829
// basic bounds function
29-
virtual bool inside( const Local2DPoint& p) const;
30+
virtual bool inside( const Local2DPoint& p) const {
31+
return
32+
(std::abs(p.x()) < halfWidth) &
33+
(std::abs(p.y()) < halfLength);
34+
}
3035

31-
virtual bool inside( const Local3DPoint& p) const;
36+
virtual bool inside( const Local3DPoint& p) const {
37+
return
38+
(std::abs(p.x()) < halfWidth) &
39+
(std::abs(p.y()) < halfLength) &
40+
(std::abs(p.z()) < halfThickness);
41+
}
3242

33-
virtual bool inside(const Local2DPoint& p, float tollerance) const;
43+
44+
45+
virtual bool inside(const Local2DPoint& p, float tollerance) const {
46+
return (std::abs(p.x()) < (halfWidth + tollerance) ) &
47+
(std::abs(p.y()) < (halfLength + tollerance) );
48+
}
3449

3550

3651
virtual bool inside( const Local3DPoint& p, const LocalError& err,

DataFormats/GeometrySurface/interface/SimpleDiskBounds.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ class SimpleDiskBounds GCC11_FINAL : public Bounds {
2020
virtual float width() const { return 2*theRmax;}
2121
virtual float thickness() const { return theZmax-theZmin;}
2222

23-
virtual bool inside( const Local3DPoint& p) const;
23+
virtual bool inside( const Local3DPoint& p) const {
24+
return ((p.z() > theZmin) & (p.z() < theZmax)) &&
25+
( (p.perp2() > theRmin*theRmin) & (p.perp2() < theRmax*theRmax) );
26+
}
2427

2528
virtual bool inside( const Local3DPoint& p, const LocalError& err, float scale) const;
2629

@@ -32,6 +35,9 @@ class SimpleDiskBounds GCC11_FINAL : public Bounds {
3235
float innerRadius() const {return theRmin;}
3336
float outerRadius() const {return theRmax;}
3437

38+
float minZ() const { return theZmin;}
39+
float maxZ() const { return theZmax;}
40+
3541
private:
3642
float theRmin;
3743
float theRmax;

DataFormats/GeometrySurface/src/RectangularPlaneBounds.cc

+6-32
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,23 @@ RectangularPlaneBounds::RectangularPlaneBounds( float w, float h, float t) :
66
halfWidth(w), halfLength(h), halfThickness(t) {}
77

88

9-
bool RectangularPlaneBounds::inside( const Local2DPoint& p) const {
10-
return std::abs(p.x()) <= halfWidth && std::abs(p.y()) <= halfLength;
11-
}
12-
13-
bool RectangularPlaneBounds::inside( const Local3DPoint& p) const {
14-
return
15-
std::abs(p.x()) < halfWidth &&
16-
std::abs(p.y()) < halfLength &&
17-
std::abs(p.z()) < halfThickness;
18-
}
19-
20-
bool RectangularPlaneBounds::inside(const Local2DPoint& p, float tollerance) const {
21-
return std::abs(p.x()) < halfWidth + tollerance &&
22-
std::abs(p.y()) < halfLength + tollerance;
23-
24-
}
9+
RectangularPlaneBounds::~RectangularPlaneBounds(){}
2510

2611
bool RectangularPlaneBounds::inside(const Local3DPoint& p, const LocalError& err,
2712
float scale) const {
28-
if(scale >=0){
29-
return
30-
std::abs(p.z()) < halfThickness &&
31-
(std::abs(p.x()) < halfWidth || std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
32-
(std::abs(p.y()) < halfLength || std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
33-
}else{
34-
return
35-
std::abs(p.z()) < halfThickness &&
13+
if( (scale >=0) && inside(p) ) return true;
14+
return
15+
std::abs(p.z()) < halfThickness &&
3616
(std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
3717
(std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
38-
}
3918
}
4019

4120
bool RectangularPlaneBounds::inside( const Local2DPoint& p, const LocalError& err,
4221
float scale) const {
43-
if(scale >=0){
44-
return
45-
(std::abs(p.x()) < halfWidth || std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
46-
(std::abs(p.y()) < halfLength || std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
47-
}else{
48-
return
22+
if( (scale >=0) && inside(p) ) return true;
23+
return
4924
(std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
5025
(std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
51-
}
5226
}
5327

5428

DataFormats/GeometrySurface/src/SimpleDiskBounds.cc

-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ SimpleDiskBounds::SimpleDiskBounds( float rmin, float rmax, float zmin, float zm
1111
if ( theZmin > theZmax) std::swap( theZmin, theZmax);
1212
}
1313

14-
bool SimpleDiskBounds::inside( const Local3DPoint& p) const {
15-
return p.z() > theZmin && p.z() < theZmax &&
16-
p.perp() > theRmin && p.perp() < theRmax;
17-
}
1814

1915
bool SimpleDiskBounds::inside( const Local2DPoint& p, const LocalError& err) const {
2016
return Bounds::inside(p,err);

DataFormats/GeometrySurface/src/TrapezoidalPlaneBounds.cc

+10-12
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,30 @@ TrapezoidalPlaneBounds::TrapezoidalPlaneBounds( float be, float te,
1212
// angle of the trapezoid for faster inside() implementation.
1313

1414
offset = a * (te+be) / (te-be); // check sign if te < be !!!
15-
tan_a = te / fabs(offset + a);
15+
tan_a = te / std::abs(offset + a);
1616
}
1717

1818

1919
int TrapezoidalPlaneBounds::yAxisOrientation() const {
20-
int yAx = 1;
21-
if(hbotedge>htopedge) yAx = -1;
22-
return yAx;
20+
return (hbotedge>htopedge) ? -1 : 1;
2321
}
2422

2523
bool TrapezoidalPlaneBounds::inside( const Local2DPoint& p) const {
26-
return fabs(p.y()) < hapothem &&
27-
fabs(p.x())/fabs(p.y()+offset) < tan_a;
24+
return (std::abs(p.y()) < hapothem) &
25+
(std::abs(p.x()) < tan_a*std::abs(p.y()+offset));
2826
}
2927

3028
bool TrapezoidalPlaneBounds::inside( const Local3DPoint& p) const {
31-
return fabs(p.y()) < hapothem &&
32-
fabs(p.x())/fabs(p.y()+offset) < tan_a &&
33-
fabs(p.z()) < hthickness;
29+
return ((std::abs(p.y()) < hapothem) & (std::abs(p.z()) < hthickness)) && std::abs(p.x()) < tan_a*std::abs(p.y()+offset);
3430
}
3531

3632
bool TrapezoidalPlaneBounds::inside( const Local3DPoint& p,
3733
const LocalError& err, float scale) const {
38-
TrapezoidalPlaneBounds tmp( hbotedge + sqrt(err.xx())*scale,
39-
htopedge + sqrt(err.xx())*scale,
40-
hapothem + sqrt(err.yy())*scale,
34+
if (scale>=0 && inside(p)) return true;
35+
36+
TrapezoidalPlaneBounds tmp( hbotedge + std::sqrt(err.xx())*scale,
37+
htopedge + std::sqrt(err.xx())*scale,
38+
hapothem + std::sqrt(err.yy())*scale,
4139
hthickness);
4240
return tmp.inside(p);
4341
}

DataFormats/GeometryVector/interface/VectorUtil.h

+5-58
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,22 @@
44

55

66
#include "DataFormats/GeometryVector/interface/Pi.h"
7-
#include "Math/VectorUtil.h"
7+
#include "DataFormats/Math/interface/deltaR.h"
88
#include <cmath>
99

1010

1111
namespace Geom {
12+
using reco::deltaPhi;
13+
using reco::deltaR2;
14+
using reco::deltaR;
1215

13-
/**
14-
Find aximutal Angle difference between two generic vectors ( v2.Phi() - v1.Phi() )
15-
The only requirements on the Vector classes is that they implement the Phi() method
16-
\param v1 Vector of any type implementing the Phi() operator
17-
\param v2 Vector of any type implementing the Phi() operator
18-
\return Phi difference
19-
\f[ \Delta \phi = \phi_2 - \phi_1 \f]
20-
*/
21-
inline double deltaBarePhi(double phi1, double phi2) {
22-
double dphi = phi2-phi1;
23-
if ( dphi > M_PI ) {
24-
dphi -= 2.0*M_PI;
25-
} else if ( dphi <= -M_PI ) {
26-
dphi += 2.0*M_PI;
27-
}
28-
return dphi;
29-
}
30-
inline double deltaPhi(float phi1, float phi2) {
31-
using ROOT::Math::VectorUtil::Phi_mpi_pi;
32-
return deltaBarePhi(Phi_mpi_pi(phi2),Phi_mpi_pi(phi1));
33-
}
34-
inline double deltaPhi(double phi1, double phi2) {
35-
using ROOT::Math::VectorUtil::Phi_mpi_pi;
36-
return deltaBarePhi(Phi_mpi_pi(phi2),Phi_mpi_pi(phi1));
37-
}
38-
template <class Vector1, class Vector2>
39-
double deltaPhi( const Vector1 & v1, const Vector2 & v2) {
40-
return deltaBarePhi(v1.phi(),v2.phi());
41-
}
4216

4317

4418
/** Definition of ordering of azimuthal angles.
4519
* phi1 is less than phi2 if the angle covered by a point going from
4620
* phi1 to phi2 in the counterclockwise direction is smaller than pi.
4721
* It makes sense only if ALL phis are in a single hemisphere...
4822
*/
49-
/*
50-
inline bool phiLess( float phi1, float phi2) {
51-
float diff = fmod(phi2 - phi1, 2.0*M_PI);
52-
// float diff = phi2-phi1;
53-
if ( diff < 0) diff += 2*M_PI;
54-
return diff < M_PI;
55-
}
56-
*/
5723
inline bool phiLess(float phi1, float phi2) {
5824
return deltaPhi(phi1,phi2)<0;
5925
}
@@ -62,29 +28,10 @@ namespace Geom {
6228
}
6329
template <class Vector1, class Vector2>
6430
bool phiLess(const Vector1 & v1, const Vector2 & v2) {
65-
return deltaPhi(v1,v2)<0.;
31+
return deltaPhi(v1.phi(),v2.phi())<0.;
6632
}
6733

6834

69-
/**
70-
Find difference in pseudorapidity (Eta) and Phi betwen two generic vectors
71-
The only requirements on the Vector classes is that they implement the Phi() and Eta() method
72-
\param v1 Vector 1
73-
\param v2 Vector 2
74-
\return Angle between the two vectors
75-
\f[ \Delta R = \sqrt{ ( \Delta \phi )^2 + ( \Delta \eta )^2 } \f]
76-
*/
77-
template <class Vector1, class Vector2>
78-
double deltaR2( const Vector1 & v1, const Vector2 & v2) {
79-
double dphi = deltaPhi(v1,v2);
80-
double deta = v2.eta() - v1.eta();
81-
return dphi*dphi + deta*deta;
82-
}
83-
template <class Vector1, class Vector2>
84-
double deltaR( const Vector1 & v1, const Vector2 & v2) {
85-
return std::sqrt( deltaR2(v1,v2));
86-
}
87-
8835
}
8936

9037
#endif
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<use name="DataFormats/GeometryVector"/>
2-
<bin file="BasicVector_t.cpp" name="DataFormatsBasicVector_t">
3-
</bin>
2+
<bin file="BasicVector_t.cpp" name="DataFormatsBasicVector_t"/>
3+
<bin file="phiLess_t.cpp" name="GeomVectPhiLess_t"/>
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "DataFormats/GeometryVector/interface/VectorUtil.h"
2+
3+
#include <cassert>
4+
5+
6+
int main() {
7+
8+
assert(Geom::phiLess(0.f,2.f));
9+
assert(Geom::phiLess(6.f,0.f));
10+
assert(Geom::phiLess(3.2f,0.f));
11+
assert(Geom::phiLess(3.0f,3.2f));
12+
13+
assert(Geom::phiLess(-0.3f,0.f));
14+
assert(Geom::phiLess(-0.3f,0.1f));
15+
assert(Geom::phiLess(-3.0f,0.f));
16+
assert(Geom::phiLess(3.0f,-3.0f));
17+
assert(Geom::phiLess(0.f,-3.4f));
18+
19+
20+
21+
}
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<use name="FWCore/MessageLogger"/>
22
<use name="Utilities/General"/>
3+
<use name="vdt"/>
34
<export>
45
<lib name="1"/>
56
</export>
6-
# <flags CXXFLAGS="-O3 -fno-math-errno -funsafe-loop-optimizations -ftree-loop-if-convert-stores --param max-completely-peel-times=1"/>
7+
# <flags CXXFLAGS="-O3 -ffast-math -funsafe-loop-optimizations -ftree-loop-if-convert-stores"/>

Geometry/CommonTopologies/interface/TkRadialStripTopology.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ class TkRadialStripTopology GCC11_FINAL : public RadialStripTopology {
119119
* whereas values 1, 2, ... nstrips correspond to the upper phi edges of
120120
* the strips.
121121
*/
122-
float stripAngle(float strip) const;
122+
float stripAngle(float strip) const { return yAxisOrientation() * (phiOfOneEdge() + strip * angularWidth()) ;}
123+
123124

124125
/**
125126
* Total number of strips
@@ -246,6 +247,8 @@ class TkRadialStripTopology GCC11_FINAL : public RadialStripTopology {
246247
float theTanOfOneEdge; // the positive tangent of the above...
247248
float theYAxisOrientation; // 1 means y axis going from smaller to larger side, -1 means opposite direction
248249
float yCentre; // Non-zero if offset in local y between midpoint of detector (strip plane) extent and local origin.
250+
double theRadialSigma; // radial sigma^2( uniform prob density along strip)
251+
249252
};
250253

251254
#endif

0 commit comments

Comments
 (0)