CMS 3D CMS Logo

Classes | Typedefs | Enumerations | Functions
align Namespace Reference

Classes

class  TrackerNameSpace
 

Typedefs

typedef std::vector< Alignable * > Alignables
 
typedef std::vector< std::unique_ptr< AlignmentLevel > > AlignmentLevels
 
typedef math::Vector< 6 >::type AlignParams
 
typedef std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrixCorrelations
 
using Counter = std::function< unsigned int(align::ID)>
 
typedef AlgebraicMatrix Derivatives
 
typedef math::Error< 6 >::type ErrorMatrix
 
typedef AlgebraicVector EulerAngles
 
typedef Point3DBase< Scalar, GlobalTagGlobalPoint
 
typedef std::vector< GlobalPointGlobalPoints
 
typedef Vector3DBase< Scalar, GlobalTagGlobalVector
 
typedef std::vector< GlobalVectorGlobalVectors
 
typedef uint32_t ID
 
typedef Point3DBase< Scalar, LocalTagLocalPoint
 
typedef std::vector< LocalPointLocalPoints
 
typedef Vector3DBase< Scalar, LocalTagLocalVector
 
typedef std::vector< LocalVectorLocalVectors
 
typedef std::vector< AlignmentParameters * > Parameters
 
typedef Point3DBase< Scalar, GlobalTagPositionType
 
typedef TkRotation< ScalarRotationType
 
using RunNumber = cond::RealTimeType< cond::runnumber >::type
 
using RunRange = std::pair< RunNumber, RunNumber >
 
using RunRanges = std::vector< RunRange >
 
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,
  AlignableGEMEndcap, AlignableGEMStation, AlignableGEMRing, AlignableGEMSuperChamber,
  AlignableGEMChamber, AlignableGEMEtaPartition, 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)
 
RunRanges makeNonOverlappingRunRanges (const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
 
RunRanges makeUniqueRunRanges (const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
 
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

◆ Alignables

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

Definition at line 31 of file Utilities.h.

◆ AlignmentLevels

typedef std::vector<std::unique_ptr<AlignmentLevel> > align::AlignmentLevels

Definition at line 33 of file Utilities.h.

◆ AlignParams

Definition at line 36 of file Definitions.h.

◆ Correlations

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

Definition at line 35 of file Utilities.h.

◆ Counter

using align::Counter = typedef std::function<unsigned int(align::ID)>

Definition at line 31 of file AlignableIndexer.h.

◆ Derivatives

Definition at line 35 of file Definitions.h.

◆ ErrorMatrix

Definition at line 37 of file Definitions.h.

◆ EulerAngles

Definition at line 34 of file Definitions.h.

◆ GlobalPoint

Definition at line 29 of file Definitions.h.

◆ GlobalPoints

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

Definition at line 27 of file Utilities.h.

◆ GlobalVector

Definition at line 31 of file Definitions.h.

◆ GlobalVectors

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

Definition at line 28 of file Utilities.h.

◆ ID

typedef uint32_t align::ID

Definition at line 24 of file Definitions.h.

◆ LocalPoint

Definition at line 30 of file Definitions.h.

◆ LocalPoints

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

Definition at line 29 of file Utilities.h.

◆ LocalVector

Definition at line 32 of file Definitions.h.

◆ LocalVectors

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

Definition at line 30 of file Utilities.h.

◆ Parameters

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

Definition at line 32 of file Utilities.h.

◆ PositionType

Definition at line 28 of file Definitions.h.

◆ RotationType

Definition at line 27 of file Definitions.h.

◆ RunNumber

Definition at line 37 of file Utilities.h.

◆ RunRange

using align::RunRange = typedef std::pair<RunNumber, RunNumber>

Definition at line 38 of file Utilities.h.

◆ RunRanges

using align::RunRanges = typedef std::vector<RunRange>

Definition at line 39 of file Utilities.h.

◆ Scalar

typedef double align::Scalar

Definition at line 25 of file Definitions.h.

◆ Scalars

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

Definition at line 26 of file Utilities.h.

Enumeration Type Documentation

◆ StructureType

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 
AlignableGEMEndcap 
AlignableGEMStation 
AlignableGEMRing 
AlignableGEMSuperChamber 
AlignableGEMChamber 
AlignableGEMEtaPartition 
AlignableMuon 
Detector 
Extras 
BeamSpot 

Definition at line 16 of file StructureType.h.

16  {
17  notfound = -1,
18  invalid = 0,
21 
22  // Barrel Pixel
23  TPBModule,
24  TPBLadder,
25  TPBLayer, // = 5
27  TPBBarrel,
28 
29  // Forward Pixel
30  TPEModule,
31  TPEPanel,
32  TPEBlade, // = 10
35  TPEEndcap,
36 
37  // Tracker Inner Barrel
38  TIBModule,
39  TIBString, // = 15
40  TIBSurface,
42  TIBLayer,
44  TIBBarrel, // = 20
45 
46  // Tracker Inner Disks
47  TIDModule,
48  TIDSide,
49  TIDRing,
50  TIDDisk,
51  TIDEndcap, // = 25
52 
53  // Tracker Outer Barrel
54  TOBModule,
55  TOBRod,
56  TOBLayer,
58  TOBBarrel, // = 30
59 
60  // Tracker Endcaps
61  TECModule,
62  TECRing,
63  TECPetal,
64  TECSide,
65  TECDisk, // = 35
66  TECEndcap,
67 
68  Pixel,
69  Strip,
70  Tracker, // = 39
71 
72  // Muon Detector, not touching these now
73  AlignableDTBarrel = 100,
78  AlignableDTLayer, // = 105
83  AlignableCSCLayer, // = 110
91 
92  Detector, // = 112 (what for?)
93 
94  Extras = 1000,
95  BeamSpot
96  };
TBPLayer TOBLayer
Definition: TOBLayer.h:11
CompositeTECPetal TECPetal
Definition: TECPetal.h:7

Function Documentation

◆ centerOfMass()

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

Find the CM of a set of points.

Definition at line 174 of file Utilities.cc.

References dqmiolumiharvest::j.

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

174  {
175  unsigned int nPoints = theVs.size();
176 
177  GlobalVector CM(0, 0, 0);
178 
179  for (unsigned int j = 0; j < nPoints; ++j)
180  CM += theVs[j];
181 
182  return CM /= static_cast<Scalar>(nPoints);
183 }
double Scalar
Definition: Definitions.h:25

◆ createPoints()

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 96 of file AlignTools.cc.

References AlignableDet, AlignableDetUnit, Alignable::alignableObjectId(), AlCaHLTBitMon_QueryRunRegistry::comp, Alignable::components(), filterCSVwithJSON::copy, MillePedeFileConverter_cfg::e, relativeConstraints::error, mps_fire::i, Alignable::id(), createfilelist::int, dqmiolumiharvest::j, SurveyDet::localPoints(), Alignable::mother(), hiPixelPairStep_cff::points, readModuleList(), Alignable::setSurvey(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), HcalDetIdTransform::transform(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

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

100  {
101  std::string copy = weightBy;
102  std::transform(copy.begin(), copy.end(), copy.begin(), (int (*)(int))toupper);
103  if (copy != "SELF") {
104  const auto& comp = ali->components();
105  unsigned int nComp = comp.size();
106  for (unsigned int i = 0; i < nComp; ++i)
107  align::createPoints(Vs, comp[i], weightBy, weightById, weightByIdVector);
108  // double the weight for SS modules if weight by Det
109  if ((ali->alignableObjectId() == align::AlignableDet) && (weightBy == "Det")) {
110  for (unsigned int i = 0; i < nComp; ++i)
111  align::createPoints(Vs, comp[i], weightBy, weightById, weightByIdVector);
112  }
113 
114  //only create points for lowest hiearchical level
116  //check if the raw id or the mother's raw id is on the list
117  bool createPointsForDetUnit = true;
118  if (weightById)
119  createPointsForDetUnit = align::readModuleList(ali->id(), ali->mother()->id(), weightByIdVector);
120  if (createPointsForDetUnit) {
121  //if no survey information, create local points
122  if (!(ali->survey())) {
124  ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
125  }
126  const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
127  for (unsigned int j = 0; j < points.size(); ++j) {
129  Vs->push_back(dummy);
130  }
131  }
132  }
133  } else {
134  bool createPointsForDetUnit = true;
135  if (weightById)
136  createPointsForDetUnit = align::readModuleList(ali->id(), ali->mother()->id(), weightByIdVector);
137  if (createPointsForDetUnit) {
138  //if no survey information, create local points
139  if (!(ali->survey())) {
141  ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
142  }
143  const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
144  for (unsigned int j = 0; j < points.size(); ++j) {
146  Vs->push_back(dummy);
147  }
148  }
149  }
150 }
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
void createPoints(GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:96
float float float z
std::vector< GlobalPoint > GlobalPoints
Definition: Utilities.h:27
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:216
bool readModuleList(unsigned int, unsigned int, const std::vector< unsigned int > &)
Definition: AlignTools.cc:152
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual const Alignables & components() const =0
Return vector of all direct components.
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
float x
const align::LocalPoints & localPoints() const
Definition: SurveyDet.h:64
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:37
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ DetectorGlobalPosition()

const AlignTransform & align::DetectorGlobalPosition ( const Alignments allGlobals,
const DetId id 
)

Definition at line 10 of file DetectorGlobalPosition.cc.

References Exception, and Alignments::m_align.

Referenced by TrackerSystematicMisalignments::analyze(), AlignmentMonitorAsAnalyzer::analyze(), PixelBaryCentreAnalyzer::analyze(), TrackerGeometryIntoNtuples::analyze(), AlignmentProducerBase::applyAlignmentsToDB(), MuonAlignmentInputDB::newAlignableMuon(), TrackerDigiGeometryESModule::produce(), MTDDigiGeometryESModule::produce(), GEMGeometryESModule::produce(), CSCGeometryESModule::produce(), DTGeometryESModule::produce(), DTGeometryESProducer::produce(), and AlignmentProducerBase::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") << "DetId(" << id.rawId() << ") not found in GlobalPositionRcd" << std::endl;
20  }
std::vector< AlignTransform > m_align
Definition: Alignments.h:19

◆ diffAlignables()

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(), Exception, Alignable::globalPosition(), Alignable::id(), dqmdumpme::k, 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().

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

◆ diffR()

align::GlobalVector align::diffR ( const GlobalVectors current,
const GlobalVectors nominal 
)

Definition at line 158 of file Utilities.cc.

References dqmiolumiharvest::j.

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

158  {
159  GlobalVector nCM(0, 0, 0);
160  GlobalVector cCM(0, 0, 0);
161 
162  unsigned int nPoints = nominal.size();
163 
164  for (unsigned int j = 0; j < nPoints; ++j) {
165  nCM += nominal[j];
166  cCM += current[j];
167  }
168 
169  nCM -= cCM;
170 
171  return nCM /= static_cast<Scalar>(nPoints);
172 }
double Scalar
Definition: Definitions.h:25

◆ diffRot()

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 68 of file Utilities.cc.

References HltBtagPostValidation_cff::c, submitPVResolutionJobs::count, gather_cfg::cout, MillePedeFileConverter_cfg::e, Exhume::I, dqmiolumiharvest::j, alignCSCRings::r, makeMuonMisalignmentScenario::rot, tolerance, and toMatrix().

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

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

◆ makeNonOverlappingRunRanges()

align::RunRanges align::makeNonOverlappingRunRanges ( const edm::VParameterSet runRanges,
const RunNumber defaultRun 
)

Definition at line 202 of file Utilities.cc.

References cond::TimeTypeSpecs::beginValue, cond::TimeTypeSpecs::endValue, dqmdumpme::first, mps_fire::i, cond::runnumber, groupFilesInBlocks::temp, cond::timeTypeSpecs, and edm::tokenize().

Referenced by MillePedeAlignmentAlgorithm::areIOVsSpecified(), and makeUniqueRunRanges().

202  {
203  const auto beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue;
204  const auto endValue = cond::timeTypeSpecs[cond::runnumber].endValue;
205  RunRanges uniqueRunRanges;
206  if (!runRanges.empty()) {
207  std::map<RunNumber, RunNumber> uniqueFirstRunNumbers;
208  for (const auto& ipset : runRanges) {
209  const auto RunRangeStrings = ipset.getParameter<std::vector<std::string> >("RunRanges");
210  for (const auto& irange : RunRangeStrings) {
211  if (irange.find(':') == std::string::npos) {
212  long int temp{strtol(irange.c_str(), nullptr, 0)};
213  auto first = (temp != -1) ? temp : beginValue;
214  uniqueFirstRunNumbers[first] = first;
215  } else {
216  edm::LogWarning("BadConfig") << "@SUB=align::makeNonOverlappingRunRanges"
217  << "Config file contains old format for 'RunRangeSelection'. Only "
218  << "the start run number is used internally. The number of the last"
219  << " run is ignored and can besafely removed from the config file.";
220  auto tokens = edm::tokenize(irange, ":");
221  long int temp{strtol(tokens[0].c_str(), nullptr, 0)};
222  auto first = (temp != -1) ? temp : beginValue;
223  uniqueFirstRunNumbers[first] = first;
224  }
225  }
226  }
227 
228  for (const auto& iFirst : uniqueFirstRunNumbers) {
229  uniqueRunRanges.push_back(std::make_pair(iFirst.first, endValue));
230  }
231  for (unsigned int i = 0; i < uniqueRunRanges.size() - 1; ++i) {
232  uniqueRunRanges[i].second = uniqueRunRanges[i + 1].first - 1;
233  }
234  } else {
235  uniqueRunRanges.push_back(std::make_pair(defaultRun, endValue));
236  }
237 
238  return uniqueRunRanges;
239 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
Time_t beginValue
Definition: Time.h:41
std::vector< RunRange > RunRanges
Definition: Utilities.h:39
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:52
Log< level::Warning, false > LogWarning
Time_t endValue
Definition: Time.h:42

◆ makeUniqueRunRanges()

align::RunRanges align::makeUniqueRunRanges ( const edm::VParameterSet runRanges,
const RunNumber defaultRun 
)

Definition at line 241 of file Utilities.cc.

References makeNonOverlappingRunRanges(), cond::runnumber, crab_NZS2018C_1::runRange, and cond::timeTypeSpecs.

Referenced by AlignmentProducerBase::storeAlignmentsToDB().

241  {
242  auto uniqueRunRanges = align::makeNonOverlappingRunRanges(runRanges, defaultRun);
243  if (uniqueRunRanges.empty()) { // create dummy IOV
244  const RunRange runRange(defaultRun, cond::timeTypeSpecs[cond::runnumber].endValue);
245  uniqueRunRanges.push_back(runRange);
246  }
247  return uniqueRunRanges;
248 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:202
std::pair< RunNumber, RunNumber > RunRange
Definition: Utilities.h:38

◆ motherPosition()

align::PositionType align::motherPosition ( const std::vector< const PositionType *> &  dauPos)

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

Definition at line 50 of file Utilities.cc.

References mps_fire::i, point, RecoTauValidation_cfi::posX, and RecoTauValidation_cfi::posY.

Referenced by SurveyResidual::calculate().

50  {
51  unsigned int nDau = dauPos.size();
52 
53  Scalar posX(0.), posY(0.), posZ(0.); // position of mother
54 
55  for (unsigned int i = 0; i < nDau; ++i) {
56  const PositionType* point = dauPos[i];
57 
58  posX += point->x();
59  posY += point->y();
60  posZ += point->z();
61  }
62 
63  Scalar inv = 1. / static_cast<Scalar>(nDau);
64 
65  return PositionType(posX *= inv, posY *= inv, posZ *= inv);
66 }
double Scalar
Definition: Definitions.h:25
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:28
*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

◆ moveAlignable()

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 84 of file AlignTools.cc.

References change_name::diff, HGC3DClusterGenMatchSelector_cfi::dR, Alignable::move(), Alignable::rotateInGlobalFrame(), and toMatrix().

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

84  {
85  GlobalVector dR(diff[0], diff[1], diff[2]);
86  align::EulerAngles dOmega(3);
87  dOmega[0] = diff[3];
88  dOmega[1] = diff[4];
89  dOmega[2] = diff[5];
90  align::RotationType dRot = align::toMatrix(dOmega);
91  ali->move(dR);
92  ali->rotateInGlobalFrame(dRot);
93 }
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
AlgebraicVector EulerAngles
Definition: Definitions.h:34
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:34

◆ readModuleList()

bool align::readModuleList ( unsigned int  aliId,
unsigned int  motherId,
const std::vector< unsigned int > &  weightByIdVector 
)

Definition at line 152 of file AlignTools.cc.

References mps_fire::i, and objects.autophobj::motherId.

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

154  {
155  bool foundId = false;
156 
157  unsigned int sizeVector = weightByIdVector.size();
158 
159  for (unsigned int i = 0; i < sizeVector; ++i) {
160  unsigned int listId = weightByIdVector[i];
161 
162  if (listId == aliId) {
163  foundId = true;
164  break;
165  }
166  if (listId == motherId) {
167  foundId = true;
168  break;
169  }
170  }
171 
172  return foundId;
173 }

◆ rectify()

void align::rectify ( RotationType rot)

Correct a rotation matrix for rounding errors.

Definition at line 185 of file Utilities.cc.

References makeMuonMisalignmentScenario::rot, toAngles(), and toMatrix().

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

185  {
186  // Use ROOT for better numerical precision but slower.
187 
188  // ROOT::Math::Rotation3D temp( rot.xx(), rot.xy(), rot.xz(),
189  // rot.yx(), rot.yy(), rot.yz(),
190  // rot.zx(), rot.zy(), rot.zz() );
191  //
192  // temp.Rectify();
193  //
194  // Scalar elems[9];
195  //
196  // temp.GetComponents(elems);
197  // rot = RotationType(elems);
198 
199  rot = toMatrix(toAngles(rot)); // fast rectification but less precise
200 }
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:8
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:34

◆ toAngles()

align::EulerAngles align::toAngles ( const RotationType rot)

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

Definition at line 8 of file Utilities.cc.

References funct::abs(), particleFlowDisplacedVertex_cfi::angles, SiPixelPI::one, and makeMuonMisalignmentScenario::rot.

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

8  {
9  const Scalar one = 1; // to ensure same precison is used in comparison
10 
12 
13  if (std::abs(rot.zx()) > one) {
14  edm::LogWarning("Alignment") << "Rounding errors in\n" << rot;
15  }
16 
17  if (std::abs(rot.zx()) < one) {
18  angles(1) = -std::atan2(rot.zy(), rot.zz());
19  angles(2) = std::asin(rot.zx());
20  angles(3) = -std::atan2(rot.yx(), rot.xx());
21  } else if (rot.zx() >= one) {
22  angles(1) = std::atan2(rot.xy() + rot.yz(), rot.yy() - rot.xz());
23  angles(2) = std::asin(one);
24  angles(3) = 0;
25  } else if (rot.zx() <= -one) {
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 
31  return angles;
32 }
double Scalar
Definition: Definitions.h:25
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
AlgebraicVector EulerAngles
Definition: Definitions.h:34
Log< level::Warning, false > LogWarning

◆ toMatrix()

align::RotationType align::toMatrix ( const EulerAngles angles)

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

Definition at line 34 of file Utilities.cc.

References particleFlowDisplacedVertex_cfi::angles, alignmentValidation::c1, funct::cos(), and funct::sin().

Referenced by BeamSpotAlignmentParameters::apply(), RigidBodyAlignmentParameters::apply(), BowedSurfaceAlignmentParameters::apply(), TwoBowedSurfacesAlignmentParameters::apply(), PedeSteerer::correctToReferenceSystem(), diffRot(), MuonAlignmentInputXML::do_setposition(), MuonGeometryArrange::fillTree(), moveAlignable(), rectify(), AlignmentParameterStore::setAlignmentPositionError(), TrackerGeometryCompare::setCommonTrackerSystem(), SurveyAlignment::shiftSensors(), AlignmentProducerBase::simpleMisalignment(), AlignableSurface::toGlobal(), and AlignableSurface::toLocal().

34  {
35  Scalar s1 = std::sin(angles[0]), c1 = std::cos(angles[0]);
36  Scalar s2 = std::sin(angles[1]), c2 = std::cos(angles[1]);
37  Scalar s3 = std::sin(angles[2]), c3 = std::cos(angles[2]);
38 
39  return RotationType(c2 * c3,
40  c1 * s3 + s1 * s2 * c3,
41  s1 * s3 - c1 * s2 * c3,
42  -c2 * s3,
43  c1 * c3 - s1 * s2 * s3,
44  s1 * c3 + c1 * s2 * s3,
45  s2,
46  -s1 * c2,
47  c1 * c2);
48 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:27
double Scalar
Definition: Definitions.h:25
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22