CMS 3D CMS Logo

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