CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SurveyResidual Class Reference

#include <SurveyResidual.h>

Public Member Functions

AlgebraicSymMatrix inverseCovariance () const
 Get inverse of survey covariance wrt given structure type in constructor. More...
 
align::LocalVectors pointsResidual () const
 
AlgebraicVector sensorResidual () const
 
 SurveyResidual (const Alignable &, align::StructureType, bool bias=false)
 
bool valid () const
 

Private Member Functions

void calculate (const Alignable &)
 Find the nominal and current vectors. More...
 
void findSisters (const Alignable *, bool bias)
 

Private Attributes

align::ErrorMatrix theCovariance
 
align::GlobalVectors theCurrentVs
 
const AlignabletheMother
 
align::GlobalVectors theNominalVs
 
const std::vector< bool > & theSelector
 
std::vector< const Alignable * > theSisters
 
const AlignableSurfacetheSurface
 

Detailed Description

Class to find the residuals for survey constraint alignment.

For more info, please refer to http://www.pha.jhu.edu/~gritsan/cms/cms-note-survey.pdf

Date
2007/11/09 07:45:04
Revision
1.6
Author
Chung Khim Lae

Definition at line 22 of file SurveyResidual.h.

Constructor & Destructor Documentation

◆ SurveyResidual()

SurveyResidual::SurveyResidual ( const Alignable ali,
align::StructureType  type,
bool  bias = false 
)

Constructor from an alignable whose residuals are to be found. The type of residuals (panel, disc etc.) is given by StructureType. Set bias to true for biased residuals. Default is to find unbiased residuals.

Definition at line 11 of file SurveyResidual.cc.

12  : theMother(nullptr), theSurface(ali.surface()), theSelector(ali.alignmentParameters()->selector()) {
13  // Find mother matching given type
14 
15  theMother = &ali; // start finding from this alignable
16 
17  while (theMother->alignableObjectId() != type) {
18  theMother = theMother->mother(); // move up a level
19 
20  if (!theMother)
21  return;
22  // {
23  // throw cms::Exception("ConfigError")
24  // << "Alignable (id = " << ali.geomDetId().rawId()
25  // << ") does not belong to a composite of type " << type;
26  // }
27  }
28 
29  if (!theMother->mother()) {
30  throw cms::Exception("ConfigError") << "The type " << type << " does not have a survey residual defined!\n"
31  << "You have probably set the highest hierarchy. Choose a lower level.";
32  }
33 
34  findSisters(theMother, bias);
35 
36  if (theSisters.empty()) {
37  throw cms::Exception("ConfigError") << "You are finding an unbiased residual of an alignable "
38  << " (id = " << ali.geomDetId().rawId() << ") which has no sister. Abort!";
39  }
40 
41  calculate(ali);
42 }

References Alignable::alignableObjectId(), calculate(), Exception, findSisters(), Alignable::geomDetId(), Alignable::mother(), DetId::rawId(), theMother, and theSisters.

Member Function Documentation

◆ calculate()

void SurveyResidual::calculate ( const Alignable ali)
private

Find the nominal and current vectors.

Definition at line 152 of file SurveyResidual.cc.

152  {
153  unsigned int nSister = theSisters.size();
154 
155  // First get sisters' positions
156 
157  std::vector<const PositionType*> nominalSisPos; // nominal sisters' pos
158  std::vector<const PositionType*> currentSisPos; // current sisters' pos
159 
160  nominalSisPos.reserve(nSister);
161  currentSisPos.reserve(nSister);
162 
163  for (unsigned int i = 0; i < nSister; ++i) {
164  const Alignable* sis = theSisters[i];
165  const SurveyDet* survey = sis->survey();
166 
167  if (!survey) {
168  throw cms::Exception("ConfigError") << "No survey info is found for Alignable "
169  << " (id = " << sis->geomDetId().rawId() << "). Abort!";
170  }
171 
172  nominalSisPos.push_back(&survey->position());
173  currentSisPos.push_back(&sis->globalPosition());
174  }
175 
176  // Then find mother's position using sisters' positions
177 
178  PositionType nominalMomPos = motherPosition(nominalSisPos);
179  PositionType currentMomPos = motherPosition(currentSisPos);
180 
181  // Now find rotation from nominal mother to current mother
182 
183  GlobalVectors nominalSisVs; // nominal sisters' pos from mother's pos
184  GlobalVectors currentSisVs; // current sisters' pos from mother's pos
185 
186  for (unsigned int i = 0; i < nSister; ++i) {
187  const Alignable* sis = theSisters[i];
188 
189  const GlobalPoints& nominalSisPoints = sis->survey()->globalPoints();
190  const GlobalPoints& currentSisPoints = sis->surface().toGlobal(sis->survey()->localPoints());
191 
192  for (unsigned int j = 0; j < nominalSisPoints.size(); ++j) {
193  nominalSisVs.push_back(nominalSisPoints[j] - *nominalSisPos[i]);
194  currentSisVs.push_back(currentSisPoints[j] - *currentSisPos[i]);
195  // nominalSisVs.push_back(nominalSisPoints[j] - nominalMomPos);
196  // currentSisVs.push_back(currentSisPoints[j] - currentMomPos);
197  }
198  }
199 
200  RotationType toCurrent = diffRot(currentSisVs, nominalSisVs);
201 
202  // Finally shift and rotate nominal sensor to current sensor
203 
204  const SurveyDet* survey = ali.survey();
205 
206  if (!survey) {
207  throw cms::Exception("ConfigError") << "No survey info is found for Alignable "
208  << " (id = " << ali.geomDetId().rawId() << "). Abort!";
209  }
210 
211  const GlobalPoints& nominalPoints = survey->globalPoints();
212  const GlobalPoints& currentPoints = theSurface.toGlobal(survey->localPoints());
213 
214  for (unsigned int j = 0; j < nominalPoints.size(); ++j) {
215  align::GlobalVector nv = nominalPoints[j] - nominalMomPos;
216 
217  theNominalVs.push_back(align::GlobalVector(toCurrent * nv.basicVector()));
218  theCurrentVs.push_back(currentPoints[j] - currentMomPos);
219  }
220 
221  // Find the covariance
222 
223  const RotationType& currentFrame = ali.globalRotation();
224 
225  for (const Alignable* a = &ali; a != theMother->mother(); a = a->mother()) {
226  RotationType deltaR = currentFrame * a->survey()->rotation().transposed();
227 
228  math::Matrix<6, 6>::type jac; // 6 by 6 Jacobian init to 0
229 
230  jac(0, 0) = deltaR.xx();
231  jac(0, 1) = deltaR.xy();
232  jac(0, 2) = deltaR.xz();
233  jac(1, 0) = deltaR.yx();
234  jac(1, 1) = deltaR.yy();
235  jac(1, 2) = deltaR.yz();
236  jac(2, 0) = deltaR.zx();
237  jac(2, 1) = deltaR.zy();
238  jac(2, 2) = deltaR.zz();
239  jac(3, 3) = deltaR.xx();
240  jac(3, 4) = deltaR.xy();
241  jac(3, 5) = deltaR.xz();
242  jac(4, 3) = deltaR.yx();
243  jac(4, 4) = deltaR.yy();
244  jac(4, 5) = deltaR.yz();
245  jac(5, 3) = deltaR.zx();
246  jac(5, 4) = deltaR.zy();
247  jac(5, 5) = deltaR.zz();
248 
249  theCovariance += ROOT::Math::Similarity(jac, a->survey()->errors());
250  }
251 }

References a, PV3DBase< T, PVType, FrameType >::basicVector(), PbPb_ZMuSkimMuonDPG_cff::deltaR, align::diffRot(), Exception, Alignable::geomDetId(), SurveyDet::globalPoints(), Alignable::globalPosition(), Alignable::globalRotation(), mps_fire::i, dqmiolumiharvest::j, SurveyDet::localPoints(), Alignable::mother(), align::motherPosition(), SurveyDet::position(), DetId::rawId(), Alignable::surface(), Alignable::survey(), theCovariance, theCurrentVs, theMother, theNominalVs, theSisters, theSurface, and AlignableSurface::toGlobal().

Referenced by SurveyResidual().

◆ findSisters()

void SurveyResidual::findSisters ( const Alignable ali,
bool  bias 
)
private

Find the terminal sisters of an alignable. bias = true to include itself in the list.

Definition at line 135 of file SurveyResidual.cc.

135  {
136  theSisters.clear();
137  theSisters.reserve(1000);
138 
139  const auto& comp = ali->mother()->components();
140 
141  unsigned int nComp = comp.size();
142 
143  for (unsigned int i = 0; i < nComp; ++i) {
144  const Alignable* dau = comp[i];
145 
146  if (dau != ali || bias)
147  theSisters.insert(theSisters.end(), dau->deepComponents().begin(), dau->deepComponents().end());
148  // if (dau != ali || bias) theSisters.push_back(dau);
149  }
150 }

References AlCaHLTBitMon_QueryRunRegistry::comp, Alignable::components(), Alignable::deepComponents(), mps_fire::i, Alignable::mother(), and theSisters.

Referenced by SurveyResidual().

◆ inverseCovariance()

AlgebraicSymMatrix SurveyResidual::inverseCovariance ( ) const

Get inverse of survey covariance wrt given structure type in constructor.

Definition at line 106 of file SurveyResidual.cc.

106  {
107  if (theSelector.size() != ErrorMatrix::kRows) {
108  throw cms::Exception("LogicError") << "Mismatched number of dof between ErrorMatrix and Selector.";
109  }
110 
111  std::vector<unsigned int> indices; // selected indices
112 
113  indices.reserve(ErrorMatrix::kRows);
114 
115  for (unsigned int i = 0; i < ErrorMatrix::kRows; ++i)
116  if (theSelector[i])
117  indices.push_back(i);
118 
119  AlgebraicSymMatrix invCov(indices.size());
120 
121  for (unsigned int i = 0; i < indices.size(); ++i)
122  for (unsigned int j = 0; j <= i; ++j)
123  invCov.fast(i + 1, j + 1) = theCovariance(indices[i], indices[j]);
124 
125  int fail(0);
126  invCov.invert(fail);
127 
128  if (fail) {
129  throw cms::Exception("ConfigError") << "Cannot invert survey error " << invCov;
130  }
131 
132  return invCov;
133 }

References Exception, mps_fire::i, bTagCombinedSVVariables_cff::indices, dqmiolumiharvest::j, theCovariance, and theSelector.

◆ pointsResidual()

LocalVectors SurveyResidual::pointsResidual ( ) const

Find residuals in local frame for points on the alignable (current - nominal vectors).

Definition at line 92 of file SurveyResidual.cc.

92  {
93  LocalVectors residuals;
94 
95  unsigned int nPoint = theNominalVs.size();
96 
97  residuals.reserve(nPoint);
98 
99  for (unsigned int j = 0; j < nPoint; ++j) {
100  residuals.push_back(theSurface.toLocal(theCurrentVs[j] - theNominalVs[j]));
101  }
102 
103  return residuals;
104 }

References dqmiolumiharvest::j, theCurrentVs, theNominalVs, theSurface, and AlignableSurface::toLocal().

◆ sensorResidual()

AlgebraicVector SurveyResidual::sensorResidual ( ) const

Find residual for the alignable in local frame. Returns a vector based on the alignable's dof.

Definition at line 44 of file SurveyResidual.cc.

44  {
45  std::vector<Scalar> pars; // selected parameters
46 
47  pars.reserve(AlignParams::kSize);
48 
49  // Find linear displacements.
50 
52 
53  if (theSelector[0])
54  pars.push_back(deltaR.x());
55  if (theSelector[1])
56  pars.push_back(deltaR.y());
57  if (theSelector[2])
58  pars.push_back(deltaR.z());
59 
60  // Match the centers of current and nominal surfaces to find the angular
61  // displacements about the center. Only do this if angular dof are selected.
62 
63  if (theSelector[3] || theSelector[4] || theSelector[5]) {
64  GlobalVectors nominalVs = theNominalVs;
65  GlobalVectors currentVs = theCurrentVs;
66 
67  for (unsigned int j = 0; j < nominalVs.size(); ++j) {
68  nominalVs[j] -= theNominalVs[0]; // move to nominal pos
69  currentVs[j] -= theCurrentVs[0]; // move to current pos
70  }
71 
72  RotationType rot = diffRot(nominalVs, currentVs); // frame rotation
73 
75 
76  if (theSelector[3])
77  pars.push_back(deltaW(1));
78  if (theSelector[4])
79  pars.push_back(deltaW(2));
80  if (theSelector[5])
81  pars.push_back(deltaW(3));
82  }
83 
84  AlgebraicVector deltaRW(pars.size()); // (deltaR, deltaW)
85 
86  for (unsigned int j = 0; j < pars.size(); ++j)
87  deltaRW(j + 1) = pars[j];
88 
89  return deltaRW;
90 }

References PbPb_ZMuSkimMuonDPG_cff::deltaR, align::diffRot(), dqmiolumiharvest::j, makeMuonMisalignmentScenario::rot, theCurrentVs, theNominalVs, theSelector, theSurface, align::toAngles(), and AlignableSurface::toLocal().

Referenced by AlignmentMonitorSurvey::book().

◆ valid()

bool SurveyResidual::valid ( ) const
inline

Check if survey residual is valid (theMother != 0). This check must be done before calling the other methods so that calculations can be performed correctly.

Definition at line 75 of file SurveyResidual.h.

75 { return theMother != nullptr; }

References theMother.

Member Data Documentation

◆ theCovariance

align::ErrorMatrix SurveyResidual::theCovariance
private

Definition at line 72 of file SurveyResidual.h.

Referenced by calculate(), and inverseCovariance().

◆ theCurrentVs

align::GlobalVectors SurveyResidual::theCurrentVs
private

Definition at line 70 of file SurveyResidual.h.

Referenced by calculate(), pointsResidual(), and sensorResidual().

◆ theMother

const Alignable* SurveyResidual::theMother
private

Definition at line 59 of file SurveyResidual.h.

Referenced by calculate(), SurveyResidual(), and valid().

◆ theNominalVs

align::GlobalVectors SurveyResidual::theNominalVs
private

Definition at line 69 of file SurveyResidual.h.

Referenced by calculate(), pointsResidual(), and sensorResidual().

◆ theSelector

const std::vector<bool>& SurveyResidual::theSelector
private

Definition at line 64 of file SurveyResidual.h.

Referenced by inverseCovariance(), and sensorResidual().

◆ theSisters

std::vector<const Alignable*> SurveyResidual::theSisters
private

Definition at line 66 of file SurveyResidual.h.

Referenced by calculate(), findSisters(), and SurveyResidual().

◆ theSurface

const AlignableSurface& SurveyResidual::theSurface
private

Definition at line 62 of file SurveyResidual.h.

Referenced by calculate(), pointsResidual(), and sensorResidual().

Vector3DBase< Scalar, GlobalTag >
align::toAngles
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:8
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
TkRotation< Scalar >
mps_fire.i
i
Definition: mps_fire.py:428
Alignable
Definition: Alignable.h:27
SurveyDet::position
const align::PositionType & position() const
Definition: SurveyDet.h:58
align::LocalVectors
std::vector< LocalVector > LocalVectors
Definition: Utilities.h:30
AlignableSurface::toLocal
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
Definition: AlignableSurface.cc:35
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
SurveyResidual::theCovariance
align::ErrorMatrix theCovariance
Definition: SurveyResidual.h:72
SurveyDet
Definition: SurveyDet.h:15
SurveyResidual::theSisters
std::vector< const Alignable * > theSisters
Definition: SurveyResidual.h:66
math::Matrix::type
ROOT::Math::SMatrix< double, N, M > type
Definition: Matrix.h:9
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
SurveyResidual::findSisters
void findSisters(const Alignable *, bool bias)
Definition: SurveyResidual.cc:135
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
SurveyResidual::theSurface
const AlignableSurface & theSurface
Definition: SurveyResidual.h:62
AlignableSurface::toGlobal
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
Definition: AlignableSurface.cc:15
Alignable::surface
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
Point3DBase< Scalar, GlobalTag >
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
a
double a
Definition: hdecay.h:119
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
SurveyResidual::theCurrentVs
align::GlobalVectors theCurrentVs
Definition: SurveyResidual.h:70
Alignable::geomDetId
const DetId & geomDetId() const
Definition: Alignable.h:177
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
align::motherPosition
PositionType motherPosition(const std::vector< const PositionType * > &dauPos)
Find mother's position from the average of its daughters' positions.
Definition: Utilities.cc:50
align::GlobalVectors
std::vector< GlobalVector > GlobalVectors
Definition: Utilities.h:28
align::EulerAngles
AlgebraicVector EulerAngles
Definition: Definitions.h:34
align::diffRot
RotationType diffRot(const GlobalVectors &current, const GlobalVectors &nominal)
Definition: Utilities.cc:68
SurveyDet::localPoints
const align::LocalPoints & localPoints() const
Definition: SurveyDet.h:64
SurveyResidual::theMother
const Alignable * theMother
Definition: SurveyResidual.h:59
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
SurveyResidual::calculate
void calculate(const Alignable &)
Find the nominal and current vectors.
Definition: SurveyResidual.cc:152
SurveyDet::globalPoints
align::GlobalPoints globalPoints() const
Definition: SurveyDet.h:66
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Alignable::deepComponents
const Alignables & deepComponents() const
Definition: Alignable.h:72
Exception
Definition: hltDiff.cc:246
SurveyResidual::theNominalVs
align::GlobalVectors theNominalVs
Definition: SurveyResidual.h:69
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
AlignmentParameters::selector
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
Definition: AlignmentParameters.cc:48
SurveyResidual::theSelector
const std::vector< bool > & theSelector
Definition: SurveyResidual.h:64
align::GlobalPoints
std::vector< GlobalPoint > GlobalPoints
Definition: Utilities.h:27
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Alignable::globalPosition
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
Alignable::components
virtual const Alignables & components() const =0
Return vector of all direct components.
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Alignable::survey
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:216
Alignable::globalRotation
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
Alignable::mother
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91