ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
SimpleConstraintPointMinimizer Class Reference

#include <SimpleConstraintPointMinimizer.h>

Collaboration diagram for SimpleConstraintPointMinimizer:

Public Member Functions

 SimpleConstraintPointMinimizer (double proximity)
 
 ~SimpleConstraintPointMinimizer ()=default
 
double findMinimum (const std::vector< SurveyConstraintPoint > &points, Amg::Vector3D &aRotat, Amg::Vector3D &translate)
 
double secondMinimum (const std::vector< SurveyConstraintPoint > &points, Amg::Vector3D &aRotat1, Amg::Vector3D &translate1, Amg::Vector3D &aRotat2, Amg::Vector3D &translate2)
 

Private Attributes

double m_proximity
 

Detailed Description

Definition at line 20 of file SimpleConstraintPointMinimizer.h.

Constructor & Destructor Documentation

◆ SimpleConstraintPointMinimizer()

SimpleConstraintPointMinimizer::SimpleConstraintPointMinimizer ( double  proximity)

Definition at line 18 of file SimpleConstraintPointMinimizer.cxx.

18  :
19  m_proximity(proximity)
20 {;}

◆ ~SimpleConstraintPointMinimizer()

SimpleConstraintPointMinimizer::~SimpleConstraintPointMinimizer ( )
default

Member Function Documentation

◆ findMinimum()

double SimpleConstraintPointMinimizer::findMinimum ( const std::vector< SurveyConstraintPoint > &  points,
Amg::Vector3D aRotat,
Amg::Vector3D translate 
)

Definition at line 25 of file SimpleConstraintPointMinimizer.cxx.

27 {
28  aRotat = Amg::Vector3D(0,0,0);
29  translate = Amg::Vector3D(0,0,0);
30  Amg::Vector3D aRotat2(0,0,0),translate2(0,0,0);
31  double delta1,delta2,delta3;
32  double retval = -1.0;
33  double retval_old = 100.0;
34  double retval_min = retval_old;
35  unsigned niterat(0);
36  do {
37  // cout << "SimpleConstraintPointMinimizer().findMinimum: niterat " << niterat+1 << ", entering secondMinimum" << endl;
38  retval = secondMinimum(points,aRotat,translate,aRotat2,translate2);
39  // diagnostics
40  delta1=translate2.mag();
41  delta2=aRotat2.mag();
42  delta3=retval_old-retval;
43  if(delta3<-0.001){
44  cout<<" findMinimum: bad goodness step, > 10 un "<<endl;
45  }
46  if(retval<retval_min){retval_min=retval;}
47 // cout << "SimpleConstraintPointMinimizer().findMinimum: niterat " << niterat + 1
48 // <<", trans, rot: "<<delta1<<","<<delta2
49 // <<", retval_min: "<<retval_min
50 // <<", retval_old: "<<retval_old
51 // <<", retval: "<<retval
52 // << endl;
53  retval_old = retval;
54  // accumulate
55  translate+=translate2;
56  aRotat+=aRotat2;
57  niterat++;
58  } while ( (niterat<10) & ((delta1>0.00001)|(delta2>0.00001)) );
59  // print diagnostics
60  if(niterat==10){
61  cout<<" findMinimum: 10 iterations, not converging "<<endl;
62  }
63  if( (retval>retval_min) & (retval>0.00001) & ((retval-retval_min)/retval>0.1)){
64  cout<<" findMinimum: bad goodness, not converging: "
65  <<retval<<" > "<<retval_min<<endl;
66  }
67  //
68  // cout<<" findMinimum: "<<niterat<<" iterations "<<retval<<endl;
69  // cout<<" trans, rot: "<<delta1<<" "<<delta2<<endl;
70  // cout<<" "<<endl;
71  //
72  return retval;
73 }

◆ secondMinimum()

double SimpleConstraintPointMinimizer::secondMinimum ( const std::vector< SurveyConstraintPoint > &  points,
Amg::Vector3D aRotat1,
Amg::Vector3D translate1,
Amg::Vector3D aRotat2,
Amg::Vector3D translate2 
)

Definition at line 77 of file SimpleConstraintPointMinimizer.cxx.

80 {
81  Amg::Vector3D Vect;
82  Amg::Vector3D Rota;
83  translate2 = Amg::Vector3D(0,0,0);
84 
85  Amg::Translation3D amgtranslation(translate1);
86  Amg::Transform3D Transform = amgtranslation * Amg::RotationMatrix3D::Identity();
87  Transform *= Amg::AngleAxis3D(aRotat1[2], Amg::Vector3D(0.,0.,1.));
88  Transform *= Amg::AngleAxis3D(aRotat1[1], Amg::Vector3D(0.,1.,0.));
89  Transform *= Amg::AngleAxis3D(aRotat1[0], Amg::Vector3D(1.,0.,0.));
90 
91 
92  // loop over the points, use the ones within the proximity
93  // find the center point (weight point) and translation
94  unsigned ipoint, ngood(0);
95  unsigned npoints = points.size();
96  Amg::Vector3D wPoint(0,0,0);
97  for(ipoint=0;ipoint<npoints;ipoint++){
98  if(points[ipoint].survey().mag() <= m_proximity){
99  const Amg::Vector3D& cur = points[ipoint].current();
100  Amg::Vector3D dummy = points[ipoint].survey();
101  Amg::Vector3D sur = Transform * dummy;
102  Amg::Vector3D cPoint = Amg::Vector3D(cur.x(),cur.y(),cur.z());
103  Amg::Vector3D sPoint = Amg::Vector3D(sur.x(),sur.y(),sur.z());
104  wPoint += sPoint;
105  translate2 += cPoint-sPoint;
106  ngood++;
107 
108  // cout
109 // <<"SimpleConstraintPointMinimizer().secondMinimum: points[ipoint].survey().mag(): "<<points[ipoint].survey().mag()
110 // <<", wPoint.mag(): "<<wPoint.mag()
111 // <<", translate2.mag(): "<<translate2.mag()
112 // <<", ngood: "<<ngood
113 // << endl;
114 
115  }
116  }
117  if(ngood>=1){
118  wPoint *= 1.0/ngood;
119  translate2 *= 1.0/ngood;
120  // accumulate momentum and tensor
121  Amg::MatrixX Tens(3,3);
122  Amg::Vector3D theLcm(0,0,0);
123  for(ipoint=0;ipoint<npoints;ipoint++){
124  if(points[ipoint].survey().mag() <= m_proximity){
125  const Amg::Vector3D& cur = points[ipoint].current();
126  Amg::Vector3D dummy = points[ipoint].survey();
127  Amg::Vector3D sur = Transform * dummy;
128  Amg::Vector3D cPoint = Amg::Vector3D(cur.x(),cur.y(),cur.z());
129  Amg::Vector3D sPoint = Amg::Vector3D(sur.x(),sur.y(),sur.z());
130  Amg::Vector3D thePoint = sPoint-wPoint;
131  Amg::Vector3D theDelta = cPoint-sPoint-translate2;
132  theLcm += thePoint.cross(theDelta);
133  Vect[0] = thePoint.x();
134  Vect[1] = thePoint.y();
135  Vect[2] = thePoint.z();
136  AmgSymMatrix(3) temp; temp.setIdentity();
137  Tens += thePoint.mag2()*temp;//- Vect.transpose() * Vect;
138 
139  // cout
140  // <<"SimpleConstraintPointMinimizer().secondMinimum: theDelta.mag(): "<<theDelta.mag()
141  // <<", theLcm.mag(): "<<theLcm.mag()
142  // << endl;
143 
144  }
145  }
146  // find rotation angles and translation
147  Vect[0] = theLcm.x();
148  Vect[1] = theLcm.y();
149  Vect[2] = theLcm.z();
150  Rota= Tens.inverse() * Vect;
151  aRotat2 = Amg::Vector3D(Rota[0],Rota[1],Rota[2]);
152  translate2 -= aRotat2.cross(wPoint);
153  }else{
154  aRotat2.setZero();
155  translate2.setZero();
156  }
157  // now compute the 'goodness of fit' as average distance/point
158  double retval = -1.0;
159  double distsum(0.0);
160  Amg::Vector3D aRotat=aRotat1+aRotat2;
161  Amg::Vector3D translate=translate1+translate2;
162 
163  Amg::Translation3D amgtranslate(translate);
164  Amg::Transform3D transform2 = amgtranslate * Amg::RotationMatrix3D::Identity();
165  transform2 *= Amg::AngleAxis3D(aRotat[2], Amg::Vector3D(0.,0.,1.));
166  transform2 *= Amg::AngleAxis3D(aRotat[1], Amg::Vector3D(0.,1.,0.));
167  transform2 *= Amg::AngleAxis3D(aRotat[0], Amg::Vector3D(1.,0.,0.));
168 
169 
170  for(ipoint=0;ipoint<npoints;ipoint++){
171  if(points[ipoint].survey().mag() <= m_proximity){
172  const Amg::Vector3D& cur = points[ipoint].current();
173  Amg::Vector3D dummy = points[ipoint].survey();
175  distsum += (cur - sur).mag();
176  }
177  }
178  if (ngood!=0){
179  retval = distsum/ngood;
180  } else {
181  retval = std::numeric_limits<double>::infinity();
182  }
183 // cout
184 // <<"SimpleConstraintPointMinimizer().secondMinimum: aRotat2.mag(): "<<aRotat2.mag()
185 // <<", (aRotat2.cross(wPoint)).mag(): "<<(aRotat2.cross(wPoint)).mag()
186 // <<", translate2.mag(): "<<translate2.mag()
187 // <<", aRotat.mag(): "<<aRotat.mag()
188 // <<", translate.mag(): "<<translate.mag()
189 // <<", distsum: "<<distsum
190 // <<", ngood: "<<ngood
191 // <<", retval: "<<retval
192 // << endl;
193  return retval;
194 }

Member Data Documentation

◆ m_proximity

double SimpleConstraintPointMinimizer::m_proximity
private

Definition at line 35 of file SimpleConstraintPointMinimizer.h.


The documentation for this class was generated from the following files:
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
SimpleConstraintPointMinimizer::m_proximity
double m_proximity
Definition: SimpleConstraintPointMinimizer.h:35
beamspotman.cur
def cur
Definition: beamspotman.py:671
yodamerge_tmp.npoints
npoints
Definition: yodamerge_tmp.py:250
x
#define x
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
LArCellBinning_test.retval
def retval
Definition: LArCellBinning_test.py:112
SimpleConstraintPointMinimizer::secondMinimum
double secondMinimum(const std::vector< SurveyConstraintPoint > &points, Amg::Vector3D &aRotat1, Amg::Vector3D &translate1, Amg::Vector3D &aRotat2, Amg::Vector3D &translate2)
Definition: SimpleConstraintPointMinimizer.cxx:77
z
#define z
MuonR4::inverse
CalibratedSpacePoint::Covariance_t inverse(const CalibratedSpacePoint::Covariance_t &mat)
Inverts the parsed matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:65
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
generateBunchGroupSetFromOldKey.transform2
def transform2(oldbgs, bgsname, bgnames)
Definition: generateBunchGroupSetFromOldKey.py:37
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
y
#define y
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:31
Transform
Transform(const Vector3d &translation)
Affine Transform constuctors construct an augmented Matrix R R R T R R R T R R R T 0 0 0 1 Where R is...
Definition: AmgTransformPlugin.h:24
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97