CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SurveyAlignment.cc
Go to the documentation of this file.
4 
6 
7 using namespace align;
8 
10  const std::vector<StructureType>& levels):
11  theSensors(sensors),
12  theLevels(levels)
13 {
14 }
15 
17 {
18  unsigned int nSensor = theSensors.size();
19 
20  for (unsigned int i = 0; i < nSensor; ++i)
21  {
22  Alignable* ali = theSensors[i];
23 
24  const AlignableSurface& surf = ali->surface();
25  const AlgebraicVector& pars = ali->alignmentParameters()->parameters();
26 
27  EulerAngles angles(3);
28 
29  angles(1) = pars[3]; angles(2) = pars[4]; angles(3) = pars[5];
30 
31  RotationType rot = surf.toGlobal( toMatrix(angles) );
32 
33  rectify(rot); // correct for rounding errors
34 
35  ali->move( surf.toGlobal( align::LocalVector(pars[0], pars[1], pars[2]) ) );
36  ali->rotateInGlobalFrame(rot);
37  }
38 }
39 
40 void SurveyAlignment::iterate(unsigned int nIteration,
41  const std::string& fileName,
42  bool bias)
43 {
44  static const double tolerance = 1e-4; // convergence criteria
45 
46  SurveyOutput out(theSensors, fileName);
47 
48  out.write(0);
49 
50  for (unsigned int i = 1; i <= nIteration; ++i)
51  {
52  std::cout << "***** Iteration " << i << " *****\n";
53  findAlignPars(bias);
54  shiftSensors();
55  out.write(i);
56 
57  // Check convergence
58 
59  double parChi2 = 0.;
60 
61  unsigned int nSensor = theSensors.size();
62 
63  for (unsigned int j = 0; j < nSensor; ++j)
64  {
65  AlignmentParameters* alignPar = theSensors[j]->alignmentParameters();
66 
67  const AlgebraicVector& par = alignPar->parameters();
68  const AlgebraicSymMatrix& cov = alignPar->covariance();
69 
70  int dummy;
71 
72  parChi2 += cov.inverse(dummy).similarity(par);
73  }
74 
75  parChi2 /= static_cast<double>(nSensor);
76  std::cout << "chi2 = " << parChi2 << std::endl;
77  if (parChi2 < tolerance) break; // converges, so exit loop
78  }
79 }
int i
Definition: DBlmapReader.cc:9
void iterate(unsigned int nIteration, const std::string &fileName, bool bias=false)
Run the iteration: find residuals, write to output, shift sensors.
const align::Alignables & theSensors
virtual void findAlignPars(bool bias=false)=0
Find the alignment parameters for all sensors.
std::vector< Alignable * > Alignables
Definition: Alignable.h:251
void write(unsigned int iter)
write out variables
Definition: SurveyOutput.cc:17
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
virtual void shiftSensors()
Apply the alignment parameters to all sensors.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
const AlgebraicVector & parameters(void) const
Get alignment parameters.
SurveyAlignment(const align::Alignables &sensors, const std::vector< align::StructureType > &levels)
Constructor to set the sensors and residual levels.
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:196
int j
Definition: DBlmapReader.cc:9
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:131
tuple out
Definition: dbtoconf.py:99
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
CLHEP::HepSymMatrix AlgebraicSymMatrix
tuple cout
Definition: gather_cfg.py:121
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.