CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Namespaces | Typedefs | Enumerations | Functions
align Namespace Reference

Namespaces

 tec
 
 tib
 
 tid
 
 tob
 
 tpb
 
 tpe
 

Typedefs

typedef std::vector< Alignable * > Alignables
 
typedef math::Vector< 6 >::type AlignParams
 
typedef std::map< std::pair
< Alignable *, Alignable * >
, AlgebraicMatrix
Correlations
 
typedef unsigned int(* Counter )(align::ID, const TrackerTopology *)
 
typedef AlgebraicMatrix Derivatives
 
typedef math::Error< 6 >::type ErrorMatrix
 
typedef AlgebraicVector EulerAngles
 
typedef Point3DBase< Scalar,
GlobalTag
GlobalPoint
 
typedef std::vector< GlobalPointGlobalPoints
 
typedef Vector3DBase< Scalar,
GlobalTag
GlobalVector
 
typedef std::vector< GlobalVectorGlobalVectors
 
typedef uint32_t ID
 
typedef Point3DBase< Scalar,
LocalTag
LocalPoint
 
typedef std::vector< LocalPointLocalPoints
 
typedef Vector3DBase< Scalar,
LocalTag
LocalVector
 
typedef std::vector< LocalVectorLocalVectors
 
typedef std::vector
< AlignmentParameters * > 
Parameters
 
typedef Point3DBase< Scalar,
GlobalTag
PositionType
 
typedef TkRotation< ScalarRotationType
 
typedef double Scalar
 
typedef std::vector< ScalarScalars
 

Enumerations

enum  StructureType {
  notfound = -1, invalid = 0, AlignableDetUnit, AlignableDet,
  TPBModule, TPBLadder, TPBLayer, TPBHalfBarrel,
  TPBBarrel, TPEModule, TPEPanel, TPEBlade,
  TPEHalfDisk, TPEHalfCylinder, TPEEndcap, TIBModule,
  TIBString, TIBSurface, TIBHalfShell, TIBLayer,
  TIBHalfBarrel, TIBBarrel, TIDModule, TIDSide,
  TIDRing, TIDDisk, TIDEndcap, TOBModule,
  TOBRod, TOBLayer, TOBHalfBarrel, TOBBarrel,
  TECModule, TECRing, TECPetal, TECSide,
  TECDisk, TECEndcap, Pixel, Strip,
  Tracker, AlignableDTBarrel = 100, AlignableDTWheel, AlignableDTStation,
  AlignableDTChamber, AlignableDTSuperLayer, AlignableDTLayer, AlignableCSCEndcap,
  AlignableCSCStation, AlignableCSCRing, AlignableCSCChamber, AlignableCSCLayer,
  AlignableMuon, Detector, Extras = 1000, BeamSpot
}
 

Functions

GlobalVector centerOfMass (const GlobalVectors &theVs)
 Find the CM of a set of points. More...
 
void createPoints (GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
 
const AlignTransformDetectorGlobalPosition (const Alignments &allGlobals, const DetId &id)
 
AlgebraicVector diffAlignables (Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
 
GlobalVector diffR (const GlobalVectors &current, const GlobalVectors &nominal)
 
RotationType diffRot (const GlobalVectors &current, const GlobalVectors &nominal)
 
PositionType motherPosition (const std::vector< const PositionType * > &dauPos)
 Find mother's position from the average of its daughters' positions. More...
 
void moveAlignable (Alignable *ali, AlgebraicVector diff)
 Moves the alignable by the AlgebraicVector. More...
 
bool readModuleList (unsigned int, unsigned int, const std::vector< unsigned int > &)
 
void rectify (RotationType &)
 Correct a rotation matrix for rounding errors. More...
 
EulerAngles toAngles (const RotationType &)
 Convert rotation matrix to angles about x-, y-, z-axes (frame rotation). More...
 
RotationType toMatrix (const EulerAngles &)
 Convert rotation angles about x-, y-, z-axes to matrix. More...
 

Detailed Description

Tools for comparing alignables

Date:
2008/06/17 12:46:54
Revision:
1.5
Author
Nhan Tran

Namespace for common calculations in alignment.

Date:
2007/10/08 15:22:08
Revision:
1.10
Author
Chung Khim Lae

Namespace for common type definitions used in alignment.

Date:
2007/04/09 00:26:08
Revision:
1.2
Author
Chung Khim Lae

Typedef Documentation

typedef std::vector<Alignable*> align::Alignables

Definition at line 28 of file Utilities.h.

Definition at line 38 of file Definitions.h.

typedef std::map<std::pair<Alignable*, Alignable*>, AlgebraicMatrix> align::Correlations

Definition at line 31 of file Utilities.h.

typedef unsigned int(* align::Counter)(align::ID, const TrackerTopology *)

Definition at line 27 of file Counters.h.

Definition at line 37 of file Definitions.h.

Definition at line 39 of file Definitions.h.

Definition at line 36 of file Definitions.h.

Definition at line 31 of file Definitions.h.

typedef std::vector<GlobalPoint> align::GlobalPoints

Definition at line 23 of file Utilities.h.

Definition at line 33 of file Definitions.h.

typedef std::vector<GlobalVector> align::GlobalVectors

Definition at line 24 of file Utilities.h.

typedef uint32_t align::ID

Definition at line 26 of file Definitions.h.

Definition at line 32 of file Definitions.h.

typedef std::vector<LocalPoint> align::LocalPoints

Definition at line 25 of file Utilities.h.

Definition at line 34 of file Definitions.h.

typedef std::vector< LocalVector > align::LocalVectors

Definition at line 26 of file Utilities.h.

typedef std::vector<AlignmentParameters*> align::Parameters

Definition at line 29 of file Utilities.h.

Definition at line 30 of file Definitions.h.

Definition at line 29 of file Definitions.h.

typedef double align::Scalar

Definition at line 27 of file Definitions.h.

typedef std::vector<Scalar> align::Scalars

Definition at line 22 of file Utilities.h.

Enumeration Type Documentation

Enumerate the types of structure an alignable can be.

Basically list the levels in the detector's hierarchy.

Date:
2010/09/10 10:28:38
Revision:
1.5
Author
Chung Khim Lae
Enumerator
notfound 
invalid 
AlignableDetUnit 
AlignableDet 
TPBModule 
TPBLadder 
TPBLayer 
TPBHalfBarrel 
TPBBarrel 
TPEModule 
TPEPanel 
TPEBlade 
TPEHalfDisk 
TPEHalfCylinder 
TPEEndcap 
TIBModule 
TIBString 
TIBSurface 
TIBHalfShell 
TIBLayer 
TIBHalfBarrel 
TIBBarrel 
TIDModule 
TIDSide 
TIDRing 
TIDDisk 
TIDEndcap 
TOBModule 
TOBRod 
TOBLayer 
TOBHalfBarrel 
TOBBarrel 
TECModule 
TECRing 
TECPetal 
TECSide 
TECDisk 
TECEndcap 
Pixel 
Strip 
Tracker 
AlignableDTBarrel 
AlignableDTWheel 
AlignableDTStation 
AlignableDTChamber 
AlignableDTSuperLayer 
AlignableDTLayer 
AlignableCSCEndcap 
AlignableCSCStation 
AlignableCSCRing 
AlignableCSCChamber 
AlignableCSCLayer 
AlignableMuon 
Detector 
Extras 
BeamSpot 

Definition at line 17 of file StructureType.h.

18  {
19  notfound = -1,
20  invalid = 0,
23 
24  // Barrel Pixel
25  TPBModule,
26  TPBLadder,
27  TPBLayer, // = 5
29  TPBBarrel,
30 
31  // Forward Pixel
32  TPEModule,
33  TPEPanel,
34  TPEBlade, // = 10
37  TPEEndcap,
38 
39  // Tracker Inner Barrel
40  TIBModule,
41  TIBString, // = 15
42  TIBSurface,
44  TIBLayer,
46  TIBBarrel, // = 20
47 
48  // Tracker Inner Disks
49  TIDModule,
50  TIDSide,
51  TIDRing,
52  TIDDisk,
53  TIDEndcap, // = 25
54 
55  // Tracker Outer Barrel
56  TOBModule,
57  TOBRod,
58  TOBLayer,
60  TOBBarrel, // = 30
61 
62  // Tracker Endcaps
63  TECModule,
64  TECRing,
65  TECPetal,
66  TECSide,
67  TECDisk, // = 35
68  TECEndcap,
69 
70  Pixel,
71  Strip,
72  Tracker, // = 39
73 
74  // Muon Detector, not touching these now
75  AlignableDTBarrel = 100,
80  AlignableDTLayer, // = 105
85  AlignableCSCLayer, // = 110
87 
88  Detector, // = 112 (what for?)
89 
90  Extras = 1000,
91  BeamSpot
92  };
TBPLayer TOBLayer
Definition: TOBLayer.h:12
CompositeTECPetal TECPetal
Definition: TECPetal.h:8

Function Documentation

align::GlobalVector align::centerOfMass ( const GlobalVectors &  theVs)

Find the CM of a set of points.

Definition at line 185 of file Utilities.cc.

References j.

Referenced by MuonGeometryArrange::compareGeometries(), and diffAlignables().

186 {
187  unsigned int nPoints = theVs.size();
188 
189  GlobalVector CM(0,0,0);
190 
191  for (unsigned int j = 0; j < nPoints; ++j) CM += theVs[j];
192 
193  return CM /= static_cast<Scalar>(nPoints);
194 }
double Scalar
Definition: Definitions.h:27
int j
Definition: DBlmapReader.cc:9
void align::createPoints ( align::GlobalVectors Vs,
Alignable ali,
const std::string &  weightBy,
bool  weightById,
const std::vector< unsigned int > &  weightByIdVector 
)

Creates the points which are used in diffAlignables A set of points corresponding to lowest daughters

Definition at line 92 of file AlignTools.cc.

References AlignableDet, AlignableDetUnit, Alignable::alignableObjectId(), AlCaHLTBitMon_QueryRunRegistry::comp, Alignable::components(), filterCSVwithJSON::copy, alignCSCRings::e, relativeConstraints::error, i, Alignable::id(), j, SurveyDet::localPoints(), Alignable::mother(), readModuleList(), Alignable::setSurvey(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), create_public_lumi_plots::transform, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by MuonGeometryArrange::compareGeometries(), and diffAlignables().

92  {
93 
94  std::string copy=weightBy;
95  std::transform(copy.begin(), copy.end(), copy.begin(), (int(*)(int)) toupper);
96  if(copy != "SELF"){
97  const align::Alignables& comp = ali->components();
98  unsigned int nComp = comp.size();
99  for (unsigned int i = 0; i < nComp; ++i) align::createPoints(Vs, comp[i], weightBy, weightById, weightByIdVector);
100  // double the weight for SS modules if weight by Det
101  if ((ali->alignableObjectId() == align::AlignableDet)&&(weightBy == "Det")){
102  for (unsigned int i = 0; i < nComp; ++i) align::createPoints(Vs, comp[i], weightBy, weightById, weightByIdVector);
103  }
104 
105  //only create points for lowest hiearchical level
107  //check if the raw id or the mother's raw id is on the list
108  bool createPointsForDetUnit = true;
109  if (weightById) createPointsForDetUnit = align::readModuleList( ali->id(), ali->mother()->id(), weightByIdVector);
110  if (createPointsForDetUnit){
111  //if no survey information, create local points
112  if(!(ali->survey())){
114  ali->setSurvey( new SurveyDet (ali->surface(), error*1e-6) );
115  }
116  const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
117  for (unsigned int j = 0; j < points.size(); ++j){
118  align::GlobalVector dummy(points[j].x(),points[j].y(),points[j].z());
119  Vs->push_back(dummy);
120  }
121  }
122  }
123  }
124  else{
125  bool createPointsForDetUnit = true;
126  if (weightById) createPointsForDetUnit = align::readModuleList( ali->id(), ali->mother()->id(), weightByIdVector);
127  if (createPointsForDetUnit){
128  //if no survey information, create local points
129  if(!(ali->survey())){
131  ali->setSurvey( new SurveyDet (ali->surface(), error*1e-6) );
132  }
133  const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
134  for (unsigned int j = 0; j < points.size(); ++j){
135  align::GlobalVector dummy(points[j].x(),points[j].y(),points[j].z());
136  Vs->push_back(dummy);
137  }
138  }
139  }
140 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
int i
Definition: DBlmapReader.cc:9
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:205
void createPoints(GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:92
virtual Alignables components() const =0
Return vector of all direct components.
float float float z
std::vector< GlobalPoint > GlobalPoints
Definition: Utilities.h:23
bool readModuleList(unsigned int, unsigned int, const std::vector< unsigned int > &)
Definition: AlignTools.cc:142
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
int j
Definition: DBlmapReader.cc:9
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:268
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
Definition: DDAxes.h:10
const align::LocalPoints & localPoints() const
Definition: SurveyDet.h:78
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:85
const AlignTransform & align::DetectorGlobalPosition ( const Alignments allGlobals,
const DetId id 
)

Definition at line 10 of file DetectorGlobalPosition.cc.

References edm::hlt::Exception, getDQMSummary::iter, and Alignments::m_align.

Referenced by AlignmentMonitorAsAnalyzer::analyze(), TrackerGeometryIntoNtuples::analyze(), AlignmentProducer::beginOfJob(), TrackerGeometryCompare::createROOTGeometry(), MuonAlignmentInputDB::newAlignableMuon(), TrackerDigiGeometryESModule::produce(), CSCGeometryESModule::produce(), DTGeometryESModule::produce(), and AlignmentProducer::writeForRunRange().

10  {
11  for (std::vector<AlignTransform>::const_iterator iter = allGlobals.m_align.begin();
12  iter != allGlobals.m_align.end();
13  ++iter) {
14  if (iter->rawId() == id.rawId()) {
15  return *iter;
16  }
17  }
18 
19  throw cms::Exception("RecordNotFound")
20  << "DetId(" << id.rawId() << ") not found in GlobalPositionRcd" << std::endl;
21  }
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
AlgebraicVector align::diffAlignables ( Alignable refAli,
Alignable curAli,
const std::string &  weightBy,
bool  weightById,
const std::vector< unsigned int > &  weightByIdVector 
)

Finds the TR between two alignables - first alignable is reference. Returns a vector with 12 components. First six are global, second six are local.

Definition at line 10 of file AlignTools.cc.

References Alignable::alignableObjectId(), centerOfMass(), createPoints(), diffR(), diffRot(), edm::hlt::Exception, Alignable::globalPosition(), Alignable::id(), gen::k, TkRotation< T >::multiplyInverse(), makeMuonMisalignmentScenario::rot, Alignable::surface(), theW, toAngles(), AlignableSurface::toLocal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonGeometryArrange::compareGeometries(), TrackerGeometryCompare::compareGeometries(), and TrackerGeometryCompare::diffCommonTrackerSystem().

10  {
11 
12  //check they are the same
13  if (refAli->alignableObjectId() != curAli->alignableObjectId()){
14  if (refAli->id() != curAli->id()){
15  throw cms::Exception("Geometry Error")
16  << "[AlignTools] Error, Alignables do not match";
17  }
18  }
19 
20  //create points
23  align::createPoints(&refVs, refAli, weightBy, weightById, weightByIdVector);
24  align::createPoints(&curVs, curAli, weightBy, weightById, weightByIdVector);
25 
26  //redefine the set of points
27  //find the translational difference
28  align::GlobalVector theR = align::diffR(curVs,refVs);
29 
30  //CM difference (needed below in rotational transformation)
31  align::GlobalVector pointsCM = align::centerOfMass(curVs);
32  align::PositionType alignableCM = curAli->globalPosition();
33  align::GlobalVector cmdiff(alignableCM.x()-pointsCM.x(), alignableCM.y()-pointsCM.y(), alignableCM.z()-pointsCM.z());
34 
35  //readjust points before finding rotation
38  for (unsigned int k = 0; k < refVs.size(); ++k){
39  refVs[k] -= CMref;
40  curVs[k] -= CMcur;
41  }
42 
43  //find rotational difference (global)
44  align::RotationType rot = align::diffRot(curVs, refVs);
46  //convert to local rotation
47  align::RotationType localrot = refAli->surface().toLocal(rot);
48  align::EulerAngles theLocalW = align::toAngles( localrot );
49 
50  //adjust translational difference factoring in different rotational CM
51  //needed because rotateInGlobalFrame is about CM of alignable, not points
52  align::GlobalVector::BasicVectorType lpvgf = cmdiff.basicVector();
53  align::GlobalVector moveV( rot.multiplyInverse(lpvgf) - lpvgf);
54  align::GlobalVector theRprime(theR + moveV);
55  //convert to local movement
56  align::LocalVector theLocalRprime = refAli->surface().toLocal(theRprime);
57 
58  AlgebraicVector deltaRW(12);
59  // global values
60  deltaRW(1) = theRprime.x();
61  deltaRW(2) = theRprime.y();
62  deltaRW(3) = theRprime.z();
63  deltaRW(4) = theW(1);
64  deltaRW(5) = theW(2);
65  deltaRW(6) = theW(3);
66  // local values
67  deltaRW(7) = theLocalRprime.x();
68  deltaRW(8) = theLocalRprime.y();
69  deltaRW(9) = theLocalRprime.z();
70  deltaRW(10) = theLocalW(1);
71  deltaRW(11) = theLocalW(2);
72  deltaRW(12) = theLocalW(3);
73 
74  refVs.clear();
75  curVs.clear();
76 
77  return deltaRW;
78 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
T y() const
Definition: PV3DBase.h:63
GlobalVector diffR(const GlobalVectors &current, const GlobalVectors &nominal)
Definition: Utilities.cc:166
T theW
void createPoints(GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:92
RotationType diffRot(const GlobalVectors &current, const GlobalVectors &nominal)
Definition: Utilities.cc:71
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
T z() const
Definition: PV3DBase.h:64
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
int k[5][pyjets_maxn]
GlobalVector centerOfMass(const GlobalVectors &theVs)
Find the CM of a set of points.
Definition: Utilities.cc:185
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
std::vector< GlobalVector > GlobalVectors
Definition: Utilities.h:24
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
T x() const
Definition: PV3DBase.h:62
align::GlobalVector align::diffR ( const GlobalVectors &  current,
const GlobalVectors &  nominal 
)

Definition at line 166 of file Utilities.cc.

References j.

Referenced by diffAlignables(), and CreateSurveyRcds::setGeometry().

168 {
169  GlobalVector nCM(0,0,0);
170  GlobalVector cCM(0,0,0);
171 
172  unsigned int nPoints = nominal.size();
173 
174  for (unsigned int j = 0; j < nPoints; ++j)
175  {
176  nCM += nominal[j];
177  cCM += current[j];
178  }
179 
180  nCM -= cCM;
181 
182  return nCM /= static_cast<Scalar>(nPoints);
183 }
double Scalar
Definition: Definitions.h:27
int j
Definition: DBlmapReader.cc:9
align::RotationType align::diffRot ( const GlobalVectors &  current,
const GlobalVectors &  nominal 
)

Find matrix to rotate from nominal to current vectors. Assume both sets of vectors have the same size and order.

Definition at line 71 of file Utilities.cc.

References trackerHits::c, prof2calltree::count, gather_cfg::cout, cond::rpcobimon::current, alignCSCRings::e, Exhume::I, j, TkRotation< T >::multiplyInverse(), alignCSCRings::r, makeMuonMisalignmentScenario::rot, toMatrix(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SurveyResidual::calculate(), MuonGeometryArrange::compareGeometries(), diffAlignables(), and SurveyResidual::sensorResidual().

73 {
74 // Find the matrix needed to rotate the nominal surface to the current one
75 // using small angle approximation through the equation:
76 //
77 // I * dOmega = dr * r (sum over points)
78 //
79 // where dOmega is a vector of small rotation angles about (x, y, z)-axes,
80 // and I is the inertia tensor defined as
81 //
82 // I_ij = delta_ij * r^2 - r_i * r_j (sum over points)
83 //
84 // delta_ij is the identity matrix. i, j are indices for (x, y, z).
85 //
86 // On the rhs of the first eq, r * dr is the cross product of r and dr.
87 // In this case, r is the nominal vector and dr is the displacement of the
88 // current point from its nominal point (current vector - nominal vector).
89 //
90 // Since the solution of dOmega (by inverting I) gives angles that are small,
91 // we rotate the current surface by -dOmega and repeat the process until the
92 // dOmega^2 is less than a certain tolerance value.
93 // (In other words, we move the current surface by small angular steps till
94 // it matches the nominal surface.)
95 // The full rotation is found by adding up the rotations (given by dOmega)
96 // in each step. (More precisely, the product of all the matrices.)
97 //
98 // Note that, in some cases, if the angular displacement between current and
99 // nominal is pi, the algorithm can return an identity (no rotation).
100 // This is because dr = -r and r * dr is all zero.
101 // This is not a problem since we are dealing with small angles in alignment.
102 
103  static const double tolerance = 1e-12;
104 
105  RotationType rot; // rotation from nominal to current; init to identity
106 
107 // Initial values for dr and I; I is always the same in each step
108 
109  AlgebraicSymMatrix I(3); // inertia tensor
110 
111  GlobalVectors rotated = current; // rotated current vectors in each step
112 
113  unsigned int nPoints = nominal.size();
114 
115  for (unsigned int j = 0; j < nPoints; ++j)
116  {
117  const GlobalVector& r = nominal[j];
118  // Inertial tensor: I_ij = delta_ij * r^2 - r_i * r_j (sum over points)
119 
120  I.fast(1, 1) += r.y() * r.y() + r.z() * r.z();
121  I.fast(2, 2) += r.x() * r.x() + r.z() * r.z();
122  I.fast(3, 3) += r.y() * r.y() + r.x() * r.x();
123  I.fast(2, 1) -= r.x() * r.y(); // row index must be >= col index
124  I.fast(3, 1) -= r.x() * r.z();
125  I.fast(3, 2) -= r.y() * r.z();
126  }
127  int count=0;
128  while (true)
129  {
130  AlgebraicVector rhs(3); // sum of dr * r
131 
132  for (unsigned int j = 0; j < nPoints; ++j)
133  {
134  const GlobalVector& r = nominal[j];
135  const GlobalVector& c = rotated[j];
136 
137  // Cross product of dr * r = c * r (sum over points)
138 
139  rhs(1) += c.y() * r.z() - c.z() * r.y();
140  rhs(2) += c.z() * r.x() - c.x() * r.z();
141  rhs(3) += c.x() * r.y() - c.y() * r.x();
142  }
143 
144  EulerAngles dOmega = CLHEP::solve(I, rhs);
145 
146  rot *= toMatrix(dOmega); // add to rotation
147 
148  if (dOmega.normsq() < tolerance) break; // converges, so exit loop
149  count++;
150  if(count>100000){
151  std::cout<<"diffRot infinite loop: dOmega is "<<dOmega.normsq()<<"\n";
152  break;
153  }
154 
155  // Not yet converge; move current vectors to new positions and find dr
156 
157  for (unsigned int j = 0; j < nPoints; ++j)
158  {
159  rotated[j] = GlobalVector( rot.multiplyInverse( current[j].basicVector() ) );
160  }
161  }
162 
163  return rot;
164 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
const std::complex< double > I
Definition: I.h:8
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
std::vector< GlobalVector > GlobalVectors
Definition: Utilities.h:24
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
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10
align::PositionType align::motherPosition ( const std::vector< const PositionType * > &  dauPos)

Find mother's position from the average of its daughters' positions.

Definition at line 51 of file Utilities.cc.

References i, python.tagInventory::inv, point, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SurveyResidual::calculate().

52 {
53  unsigned int nDau = dauPos.size();
54 
55  Scalar posX(0.), posY(0.), posZ(0.); // position of mother
56 
57  for (unsigned int i = 0; i < nDau; ++i)
58  {
59  const PositionType* point = dauPos[i];
60 
61  posX += point->x();
62  posY += point->y();
63  posZ += point->z();
64  }
65 
66  Scalar inv = 1. / static_cast<Scalar>(nDau);
67 
68  return PositionType(posX *= inv, posY *= inv, posZ *= inv);
69 }
int i
Definition: DBlmapReader.cc:9
double Scalar
Definition: Definitions.h:27
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void align::moveAlignable ( Alignable ali,
AlgebraicVector  diff 
)

Moves the alignable by the AlgebraicVector.

Finds the TR between 2 sets of alignables For example, if TIB/TID were to move as one unit

Definition at line 81 of file AlignTools.cc.

References PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, Alignable::move(), Alignable::rotateInGlobalFrame(), and toMatrix().

Referenced by MuonGeometryArrange::compareGeometries(), TrackerGeometryCompare::compareGeometries(), and TrackerGeometryCompare::setCommonTrackerSystem().

81  {
82 
83  GlobalVector dR(diff[0],diff[1],diff[2]);
84  align::EulerAngles dOmega(3); dOmega[0] = diff[3]; dOmega[1] = diff[4]; dOmega[2] = diff[5];
85  align::RotationType dRot = align::toMatrix(dOmega);
86  ali->move(dR);
87  ali->rotateInGlobalFrame(dRot);
88 
89 }
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
AlgebraicVector EulerAngles
Definition: Definitions.h:36
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
bool align::readModuleList ( unsigned int  aliId,
unsigned int  motherId,
const std::vector< unsigned int > &  weightByIdVector 
)

Definition at line 142 of file AlignTools.cc.

References i.

Referenced by MuonGeometryArrange::compareGeometries(), and createPoints().

142  {
143 
144  bool foundId = false;
145 
146  unsigned int sizeVector = weightByIdVector.size();
147 
148  for (unsigned int i = 0; i < sizeVector; ++i){
149 
150  unsigned int listId = weightByIdVector[i];
151 
152  if (listId == aliId){ foundId = true; break; }
153  if (listId == motherId){ foundId = true; break; }
154  }
155 
156  return foundId;
157 }
int i
Definition: DBlmapReader.cc:9
void align::rectify ( RotationType &  rot)

Correct a rotation matrix for rounding errors.

Definition at line 196 of file Utilities.cc.

References toAngles(), and toMatrix().

Referenced by BeamSpotAlignmentParameters::apply(), RigidBodyAlignmentParameters::apply(), BowedSurfaceAlignmentParameters::apply(), TwoBowedSurfacesAlignmentParameters::apply(), AlignmentParameterStore::applyAlignableAbsolutePositions(), MuonAlignmentInputXML::set_one_position(), and SurveyAlignment::shiftSensors().

197 {
198 // Use ROOT for better numerical precision but slower.
199 
200 // ROOT::Math::Rotation3D temp( rot.xx(), rot.xy(), rot.xz(),
201 // rot.yx(), rot.yy(), rot.yz(),
202 // rot.zx(), rot.zy(), rot.zz() );
203 //
204 // temp.Rectify();
205 //
206 // Scalar elems[9];
207 //
208 // temp.GetComponents(elems);
209 // rot = RotationType(elems);
210 
211  rot = toMatrix( toAngles(rot) ); // fast rectification but less precise
212 }
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
align::EulerAngles align::toAngles ( const RotationType &  rot)

Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).

Definition at line 7 of file Utilities.cc.

References funct::abs(), makeMuonMisalignmentScenario::rot, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

Referenced by AlignmentParameterStore::acquireRelativeParameters(), MuonGeometryArrange::compareGeometries(), diffAlignables(), RigidBodyAlignmentParameters::displacementFromAlignable(), MuonAlignmentInputXML::do_setposition(), KalmanAlignmentUserVariables::extractTrueParameters(), MuonGeometryArrange::fillTree(), TrackerGeometryCompare::fillTree(), KalmanAlignmentUserVariables::histogramParameters(), rectify(), BeamSpotAlignmentParameters::rotation(), SurveyResidual::sensorResidual(), AlignableSurface::toGlobal(), AlignableSurface::toLocal(), KalmanAlignmentUserVariables::update(), SurveyOutput::write(), and MuonAlignmentOutputXML::writeComponents().

8 {
9  const Scalar one = 1; // to ensure same precison is used in comparison
10 
11  EulerAngles angles(3);
12 
13  if (std::abs( rot.zx() ) > one)
14  {
15  edm::LogWarning("Alignment") << "Rounding errors in\n" << rot;
16  }
17 
18  if (std::abs( rot.zx() ) < one)
19  {
20  angles(1) = -std::atan2( rot.zy(), rot.zz() );
21  angles(2) = std::asin( rot.zx() );
22  angles(3) = -std::atan2( rot.yx(), rot.xx() );
23  }
24  else if (rot.zx() >= one)
25  {
26  angles(1) = std::atan2(rot.xy() + rot.yz(), rot.yy() - rot.xz() );
27  angles(2) = std::asin(one);
28  angles(3) = 0;
29  }
30  else if (rot.zx() <= -one)
31  {
32  angles(1) = std::atan2(rot.xy() - rot.yz(), rot.yy() + rot.xz() );
33  angles(2) = std::asin(-one);
34  angles(3) = 0;
35  }
36 
37  return angles;
38 }
double Scalar
Definition: Definitions.h:27
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
AlgebraicVector EulerAngles
Definition: Definitions.h:36
align::RotationType align::toMatrix ( const EulerAngles &  angles)

Convert rotation angles about x-, y-, z-axes to matrix.

Definition at line 40 of file Utilities.cc.

References alignmentValidation::c1, funct::cos(), indexGen::s2, and funct::sin().

Referenced by BeamSpotAlignmentParameters::apply(), RigidBodyAlignmentParameters::apply(), BowedSurfaceAlignmentParameters::apply(), TwoBowedSurfacesAlignmentParameters::apply(), KalmanAlignmentAlgorithm::applyAlignmentParameters(), PedeSteerer::correctToReferenceSystem(), diffRot(), MuonAlignmentInputXML::do_setposition(), MuonGeometryArrange::fillTree(), KalmanAlignmentUserVariables::histogramParameters(), KalmanAlignmentAlgorithm::initializeAlignmentParameters(), moveAlignable(), rectify(), AlignmentParameterStore::setAlignmentPositionError(), TrackerGeometryCompare::setCommonTrackerSystem(), SurveyAlignment::shiftSensors(), AlignmentProducer::simpleMisalignment_(), AlignableSurface::toGlobal(), AlignableSurface::toLocal(), and KalmanAlignmentUserVariables::update().

41 {
42  Scalar s1 = std::sin(angles[0]), c1 = std::cos(angles[0]);
43  Scalar s2 = std::sin(angles[1]), c2 = std::cos(angles[1]);
44  Scalar s3 = std::sin(angles[2]), c3 = std::cos(angles[2]);
45 
46  return RotationType( c2 * c3, c1 * s3 + s1 * s2 * c3, s1 * s3 - c1 * s2 * c3,
47  -c2 * s3, c1 * c3 - s1 * s2 * s3, s1 * c3 + c1 * s2 * s3,
48  s2, -s1 * c2, c1 * c2);
49 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
double Scalar
Definition: Definitions.h:27
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
tuple s2
Definition: indexGen.py:106
Cos< T >::type cos(const T &t)
Definition: Cos.h:22