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,
  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

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

Definition at line 32 of file Utilities.h.

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

Definition at line 34 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 36 of file Utilities.h.

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

Definition at line 32 of file AlignableIndexer.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 28 of file Utilities.h.

Definition at line 33 of file Definitions.h.

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

Definition at line 29 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 30 of file Utilities.h.

Definition at line 34 of file Definitions.h.

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

Definition at line 31 of file Utilities.h.

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

Definition at line 33 of file Utilities.h.

Definition at line 30 of file Definitions.h.

Definition at line 29 of file Definitions.h.

Definition at line 38 of file Utilities.h.

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

Definition at line 39 of file Utilities.h.

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

Definition at line 40 of file Utilities.h.

typedef double align::Scalar

Definition at line 27 of file Definitions.h.

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

Definition at line 27 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 187 of file Utilities.cc.

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

188 {
189  unsigned int nPoints = theVs.size();
190 
191  GlobalVector CM(0,0,0);
192 
193  for (unsigned int j = 0; j < nPoints; ++j) CM += theVs[j];
194 
195  return CM /= static_cast<Scalar>(nPoints);
196 }
double Scalar
Definition: Definitions.h:27
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(), popcon2dropbox::copy(), MillePedeFileConverter_cfg::e, relativeConstraints::error, mps_fire::i, Alignable::id(), createfilelist::int, SurveyDet::localPoints(), Alignable::mother(), hiPixelPairStep_cff::points, readModuleList(), Alignable::setSurvey(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), create_public_lumi_plots::transform, vertices_cff::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 auto& 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:189
def copy(args, dbName)
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
virtual const Alignables & components() const =0
Return vector of all direct components.
void createPoints(GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:92
float float float z
std::vector< GlobalPoint > GlobalPoints
Definition: Utilities.h:28
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
bool readModuleList(unsigned int, unsigned int, const std::vector< unsigned int > &)
Definition: AlignTools.cc:142
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
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
const align::LocalPoints & localPoints() const
Definition: SurveyDet.h:78
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:94
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(), TrackerGeometryIntoNtuples::analyze(), AlignmentProducerBase::applyAlignmentsToDB(), MuonAlignmentInputDB::newAlignableMuon(), TrackerDigiGeometryESModule::produce(), CSCGeometryESModule::produce(), DTGeometryESModule::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")
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(), 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  const 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:189
T y() const
Definition: PV3DBase.h:63
GlobalVector diffR(const GlobalVectors &current, const GlobalVectors &nominal)
Definition: Utilities.cc:168
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:73
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
T z() const
Definition: PV3DBase.h:64
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:9
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
int k[5][pyjets_maxn]
GlobalVector centerOfMass(const GlobalVectors &theVs)
Find the CM of a set of points.
Definition: Utilities.cc:187
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
std::vector< GlobalVector > GlobalVectors
Definition: Utilities.h:29
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
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 168 of file Utilities.cc.

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

170 {
171  GlobalVector nCM(0,0,0);
172  GlobalVector cCM(0,0,0);
173 
174  unsigned int nPoints = nominal.size();
175 
176  for (unsigned int j = 0; j < nPoints; ++j)
177  {
178  nCM += nominal[j];
179  cCM += current[j];
180  }
181 
182  nCM -= cCM;
183 
184  return nCM /= static_cast<Scalar>(nPoints);
185 }
double Scalar
Definition: Definitions.h:27
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 73 of file Utilities.cc.

References EnergyCorrector::c, KineDebug3::count(), gather_cfg::cout, MillePedeFileConverter_cfg::e, Exhume::I, TkRotation< T >::multiplyInverse(), alignCSCRings::r, makeMuonMisalignmentScenario::rot, RecoTauCleanerPlugins::tolerance, 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().

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

Definition at line 218 of file Utilities.cc.

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

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

220 {
221  const auto beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue;
222  const auto endValue = cond::timeTypeSpecs[cond::runnumber].endValue;
223  RunRanges uniqueRunRanges;
224  if (!runRanges.empty()) {
225  std::map<RunNumber,RunNumber> uniqueFirstRunNumbers;
226  for (const auto& ipset: runRanges) {
227  const auto RunRangeStrings =
228  ipset.getParameter<std::vector<std::string> >("RunRanges");
229  for (const auto& irange: RunRangeStrings) {
230  if (irange.find(':')==std::string::npos) {
231  long int temp{strtol(irange.c_str(), nullptr, 0)};
232  auto first = (temp != -1) ? temp : beginValue;
233  uniqueFirstRunNumbers[first] = first;
234  } else {
235  edm::LogWarning("BadConfig")
236  << "@SUB=align::makeNonOverlappingRunRanges"
237  << "Config file contains old format for 'RunRangeSelection'. Only "
238  << "the start run number is used internally. The number of the last"
239  << " run is ignored and can besafely removed from the config file.";
240  auto tokens = edm::tokenize(irange, ":");
241  long int temp{strtol(tokens[0].c_str(), nullptr, 0)};
242  auto first = (temp != -1) ? temp : beginValue;
243  uniqueFirstRunNumbers[first] = first;
244  }
245  }
246  }
247 
248  for (const auto& iFirst: uniqueFirstRunNumbers) {
249  uniqueRunRanges.push_back(std::make_pair(iFirst.first, endValue));
250  }
251  for (unsigned int i = 0;i<uniqueRunRanges.size()-1;++i) {
252  uniqueRunRanges[i].second = uniqueRunRanges[i+1].first - 1;
253  }
254  } else {
255  uniqueRunRanges.push_back(std::make_pair(defaultRun, endValue));
256  }
257 
258  return uniqueRunRanges;
259 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
Time_t beginValue
Definition: Time.h:45
std::vector< RunRange > RunRanges
Definition: Utilities.h:40
Time_t endValue
Definition: Time.h:46
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
align::RunRanges align::makeUniqueRunRanges ( const edm::VParameterSet runRanges,
const RunNumber defaultRun 
)

Definition at line 263 of file Utilities.cc.

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

Referenced by AlignmentProducerBase::AlignmentProducerBase(), and AlignmentProducerBase::storeAlignmentsToDB().

264  {
265  auto uniqueRunRanges =
266  align::makeNonOverlappingRunRanges(runRanges, defaultRun);
267  if (uniqueRunRanges.empty()) { // create dummy IOV
268  const RunRange runRange(defaultRun,
270  uniqueRunRanges.push_back(runRange);
271  }
272  return uniqueRunRanges;
273 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:218
std::pair< RunNumber, RunNumber > RunRange
Definition: Utilities.h:39
align::PositionType align::motherPosition ( const std::vector< const PositionType * > &  dauPos)

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

Definition at line 53 of file Utilities.cc.

References mps_fire::i, point, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SurveyResidual::calculate().

54 {
55  unsigned int nDau = dauPos.size();
56 
57  Scalar posX(0.), posY(0.), posZ(0.); // position of mother
58 
59  for (unsigned int i = 0; i < nDau; ++i)
60  {
61  const PositionType* point = dauPos[i];
62 
63  posX += point->x();
64  posY += point->y();
65  posZ += point->z();
66  }
67 
68  Scalar inv = 1. / static_cast<Scalar>(nDau);
69 
70  return PositionType(posX *= inv, posY *= inv, posZ *= inv);
71 }
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:42
bool align::readModuleList ( unsigned int  aliId,
unsigned int  motherId,
const std::vector< unsigned int > &  weightByIdVector 
)

Definition at line 142 of file AlignTools.cc.

References mps_fire::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 }
void align::rectify ( RotationType rot)

Correct a rotation matrix for rounding errors.

Definition at line 198 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().

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

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

Definition at line 9 of file Utilities.cc.

References funct::abs(), particleFlowDisplacedVertex_cfi::angles, 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(), MuonGeometryArrange::fillTree(), TrackerGeometryCompare::fillTree(), rectify(), BeamSpotAlignmentParameters::rotation(), SurveyResidual::sensorResidual(), AlignableSurface::toGlobal(), AlignableSurface::toLocal(), SurveyOutput::write(), and MuonAlignmentOutputXML::writeComponents().

10 {
11  const Scalar one = 1; // to ensure same precison is used in comparison
12 
14 
15  if (std::abs( rot.zx() ) > one)
16  {
17  edm::LogWarning("Alignment") << "Rounding errors in\n" << rot;
18  }
19 
20  if (std::abs( rot.zx() ) < one)
21  {
22  angles(1) = -std::atan2( rot.zy(), rot.zz() );
23  angles(2) = std::asin( rot.zx() );
24  angles(3) = -std::atan2( rot.yx(), rot.xx() );
25  }
26  else if (rot.zx() >= one)
27  {
28  angles(1) = std::atan2(rot.xy() + rot.yz(), rot.yy() - rot.xz() );
29  angles(2) = std::asin(one);
30  angles(3) = 0;
31  }
32  else if (rot.zx() <= -one)
33  {
34  angles(1) = std::atan2(rot.xy() - rot.yz(), rot.yy() + rot.xz() );
35  angles(2) = std::asin(-one);
36  angles(3) = 0;
37  }
38 
39  return angles;
40 }
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 42 of file Utilities.cc.

References alignmentValidation::c1, funct::cos(), indexGen::s2, 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().

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