CMS 3D CMS Logo

AlignableSiStripDet.cc
Go to the documentation of this file.
1 /*
2  * $Date: 2011/09/05 16:59:07 $
3  * $Revision: 1.9 $
4  */
5 
7 
9 
12 
20 
23 
24 #include <cmath>
25 
27  : AlignableDet(gluedDet, true), // true: adding DetUnits
28  theMonoBounds(gluedDet->monoDet()->surface().bounds().clone()),
29  theStereoBounds(gluedDet->stereoDet()->surface().bounds().clone()),
30  theMonoType(static_cast<const StripGeomDetUnit*>(gluedDet->monoDet())->specificType()),
31  theStereoType(static_cast<const StripGeomDetUnit*>(gluedDet->stereoDet())->specificType()) {
32  // It is not allowed to store a pointer to GeomDet within objects with a life time
33  // longer than an Event:
34  // GeomDet comes from TrackerGeometry that is created from GeometricDet that depends on
35  // IdealGeometryRecord from EventSetup, so it could change in next event!
36  // ==> Need to store directly what I need from it.
37  // Unfortunately the current way with references for the type does not solve that,
38  // either. But currently no way out, see header file.
39 
40  // check order mono/stereo
41  const Alignables units(this->components());
42  if (units.size() != 2 || gluedDet->monoDet()->geographicalId() != units[0]->geomDetId() ||
43  gluedDet->stereoDet()->geographicalId() != units[1]->geomDetId()) {
44  throw cms::Exception("LogicError") << "[AlignableSiStripDet] "
45  << "Either != 2 components or "
46  << "mono/stereo in wrong order for consistifyAlignments.";
47  }
48 }
49 
50 //__________________________________________________________________________________________________
52  delete theMonoBounds;
53  delete theStereoBounds;
54 }
55 
56 //__________________________________________________________________________________________________
58  const_cast<AlignableSiStripDet*>(this)->consistifyAlignments();
59 
60  return this->AlignableDet::alignments();
61 }
62 
63 //__________________________________________________________________________________________________
65  // make alignments consistent with daughters, calling method from geometry
66 
67  // The aim of all this gymnastics is to have the alignments calculated by
68  // PlaneBuilderForGluedDet::plane(const std::vector<const GeomDetUnit*> &detComps);
69  //
70  // So we take the (new) position and orientation from the AligableDetUnits,
71  // but bounds and GeomDetType from original GeomDetUnits to create new GeomDetUnits
72  // that are passed to that routine.
73 
74  const Alignables aliUnits(this->components()); // order mono==0, stereo==1 checked in ctr.
75 
77  BoundPlane::build(aliUnits[0]->globalPosition(), aliUnits[0]->globalRotation(), theMonoBounds->clone());
78  // Fortunately we do not seem to need a GeometricDet pointer and can use 0:
79  const StripGeomDetUnit monoDet(&(*monoPlane), &theMonoType, 0);
80 
81  BoundPlane::BoundPlanePointer stereoPlane =
82  BoundPlane::build(aliUnits[1]->globalPosition(), aliUnits[1]->globalRotation(), theStereoBounds->clone());
83  // Fortunately we do not seem to need a GeometricDet pointer and can use 0:
84  const StripGeomDetUnit stereoDet(&(*stereoPlane), &theStereoType, 0);
85 
86  std::vector<const GeomDetUnit*> detComps;
87  detComps.push_back(&monoDet); // order mono first, stereo second should be as in...
88  detComps.push_back(&stereoDet); // ...TrackerGeomBuilderFromGeometricDet::buildGeomDet
89 
90  // Now we have all to calculate new position and rotation via PlaneBuilderForGluedDet.
91  const PositionType oldPos(theSurface.position()); // From old surface for keeping...
92  const RotationType oldRot(theSurface.rotation()); // ...track of changes.
93 
94  PlaneBuilderForGluedDet planeBuilder;
95  theSurface = AlignableSurface(*planeBuilder.plane(detComps));
96 
97  // But do not forget to keep track of movements/rotations:
98  const GlobalVector movement(theSurface.position().basicVector() - oldPos.basicVector());
99  // Seems to be correct down to delta angles 4.*1e-8:
100  const RotationType rotation(oldRot.multiplyInverse(theSurface.rotation()));
101  this->addDisplacement(movement);
102  this->addRotation(rotation);
103 
104  // this->dumpCompareEuler(oldRot, theSurface.rotation());
105 
106  // if (movement.mag2()) { // > 1.e-10) {
107  // edm::LogWarning("Alignment") << "@SUB=consistifyAlignments"
108  // << "Delta: " << movement.x() << " " << movement.y() << " " << movement.z()
109  // << "\nPos: " << oldPos.perp() << " " << oldPos.phi() << " " << oldPos.z();
110  // }
111 }
112 
113 // #include "CLHEP/Vector/EulerAngles.h"
114 // #include "CLHEP/Vector/Rotation.h"
115 // //__________________________________________________________________________________________________
116 // void AlignableSiStripDet::dumpCompareEuler(const RotationType &oldRot,
117 // const RotationType &newRot) const
118 // {
119 // //
120 // const HepRotation oldClhep(HepRep3x3(oldRot.xx(), oldRot.xy(), oldRot.xz(),
121 // oldRot.yx(), oldRot.yy(), oldRot.yz(),
122 // oldRot.zx(), oldRot.zy(), oldRot.zz()));
123 //
124 // const HepRotation newClhep(HepRep3x3(newRot.xx(), newRot.xy(), newRot.xz(),
125 // newRot.yx(), newRot.yy(), newRot.yz(),
126 // newRot.zx(), newRot.zy(), newRot.zz()));
127 //
128 // const RotationType rotationGlob(oldRot.multiplyInverse(newRot));
129 // const RotationType rotation(theSurface.toLocal(rotationGlob)); // not 100% correct: new global...
130 // const HepRotation diff(HepRep3x3(rotation.xx(), rotation.xy(), rotation.xz(),
131 // rotation.yx(), rotation.yy(), rotation.yz(),
132 // rotation.zx(), rotation.zy(), rotation.zz()));
133 //
134 // edm::LogWarning("Alignment") << "@SUB=dumpCompareEuler"
135 // << "oldEuler " << oldClhep.eulerAngles()
136 // << "\nnewEuler " << newClhep.eulerAngles()
137 // << "\n diff_euler " << diff.eulerAngles()
138 // << "\n diff_diag (" << diff.xx() << ", " << diff.yy()
139 // << ", " << diff.zz() << ")";
140 // }
Vector3DBase< Scalar, GlobalTag >
AlignmentErrorsExtended.h
TkRotation< Scalar >
AlignableSiStripDet::theStereoType
const StripGeomDetType & theStereoType
Definition: AlignableSiStripDet.h:48
StripGeomDetUnit.h
MessageLogger.h
Alignable::Alignables
align::Alignables Alignables
Definition: Alignable.h:34
PlaneBuilderForGluedDet
Definition: PlaneBuilderForGluedDet.h:15
AlignableComposite::components
const Alignables & components() const override
Return vector of direct components.
Definition: AlignableComposite.h:45
AlignableSiStripDet::alignments
Alignments * alignments() const override
first consistify with component detunits, then call method from AlignableDet
Definition: AlignableSiStripDet.cc:57
GluedGeomDet::monoDet
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
GluedGeomDet.h
ReferenceCountingPointer< Plane >
newFWLiteAna.build
build
Definition: newFWLiteAna.py:126
watchdog.const
const
Definition: watchdog.py:83
AlignableSiStripDet::consistifyAlignments
void consistifyAlignments()
make alignments consistent with daughters
Definition: AlignableSiStripDet.cc:64
units
TString units(TString variable, Char_t axis)
AlignableDet
Definition: AlignableDet.h:8
AlignableSiStripDet.h
AlignableSiStripDet::AlignableSiStripDet
AlignableSiStripDet(const GluedGeomDet *geomDet)
Constructor.
Definition: AlignableSiStripDet.cc:26
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
Bounds::clone
virtual Bounds * clone() const =0
Alignable::addRotation
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:193
Bounds.h
Point3DBase< Scalar, GlobalTag >
AlignableSurface.h
GluedGeomDet
Definition: GluedGeomDet.h:7
AlignableDet::alignments
Alignments * alignments() const override
Return vector of alignment data.
Definition: AlignableDet.cc:135
AlignableSiStripDet::theMonoType
const StripGeomDetType & theMonoType
Definition: AlignableSiStripDet.h:47
funct::true
true
Definition: Factorize.h:173
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Alignable::rotation
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:144
AlignTransformErrorExtended.h
GlobalError.h
Alignable::theSurface
AlignableSurface theSurface
Definition: Alignable.h:237
AlignableSiStripDet::theStereoBounds
const Bounds * theStereoBounds
Definition: AlignableSiStripDet.h:46
AlignableSiStripDet::theMonoBounds
const Bounds * theMonoBounds
Definition: AlignableSiStripDet.h:45
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
PlaneBuilderForGluedDet.h
GluedGeomDet::stereoDet
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
AlignableSiStripDet::~AlignableSiStripDet
~AlignableSiStripDet() override
reduntantly make destructor virtual
Definition: AlignableSiStripDet.cc:51
AlignableSurface
Definition: AlignableSurface.h:20
Exception
Definition: hltDiff.cc:245
Alignable::addDisplacement
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:190
AlignmentPositionError.h
Exception.h
BoundPlane.h
GloballyPositioned::rotation
const RotationType & rotation() const
Definition: GloballyPositioned.h:38
Alignable::globalPosition
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
Alignments
Definition: Alignments.h:10
Alignable::globalRotation
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15