Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "Alignment/TrackerAlignment/interface/AlignableSiStripDet.h"
00007
00008 #include "Alignment/CommonAlignment/interface/AlignableSurface.h"
00009
00010 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00011 #include "CondFormats/Alignment/interface/AlignTransformError.h"
00012
00013 #include "DataFormats/GeometrySurface/interface/Bounds.h"
00014 #include "DataFormats/TrackingRecHit/interface/AlignmentPositionError.h"
00015 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
00016 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00017 #include "DataFormats/GeometrySurface/interface/OpenBounds.h"
00018 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00019 #include "DataFormats/GeometrySurface/interface/MediumProperties.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/PlaneBuilderForGluedDet.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00022 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00023
00024 #include "FWCore/Utilities/interface/Exception.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026
00027 #include <math.h>
00028
00029 AlignableSiStripDet::AlignableSiStripDet(const GluedGeomDet *gluedDet)
00030 : AlignableDet(gluedDet, true),
00031 theMonoBounds (gluedDet->monoDet() ->surface().bounds().clone()),
00032 theStereoBounds(gluedDet->stereoDet()->surface().bounds().clone()),
00033 theMonoType (static_cast<const StripGeomDetUnit*>(gluedDet->monoDet()) ->specificType()),
00034 theStereoType(static_cast<const StripGeomDetUnit*>(gluedDet->stereoDet())->specificType())
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 const Alignables units(this->components());
00046 if (units.size() != 2
00047 || gluedDet->monoDet()->geographicalId() != units[0]->geomDetId()
00048 || gluedDet->stereoDet()->geographicalId() != units[1]->geomDetId()) {
00049 throw cms::Exception("LogicError")
00050 << "[AlignableSiStripDet] " << "Either != 2 components or "
00051 << "mono/stereo in wrong order for consistifyAlignments.";
00052 }
00053 }
00054
00055
00056 AlignableSiStripDet::~AlignableSiStripDet()
00057 {
00058 delete theMonoBounds;
00059 delete theStereoBounds;
00060 }
00061
00062
00063 Alignments* AlignableSiStripDet::alignments() const
00064 {
00065 const_cast<AlignableSiStripDet*>(this)->consistifyAlignments();
00066
00067 return this->AlignableDet::alignments();
00068 }
00069
00070
00071 void AlignableSiStripDet::consistifyAlignments()
00072 {
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 const PositionType oldPos(theSurface.position());
00083 const RotationType oldRot(theSurface.rotation());
00084
00085 const Alignables aliUnits(this->components());
00086
00087 BoundPlane::BoundPlanePointer monoPlane
00088 = BoundPlane::build(aliUnits[0]->globalPosition(), aliUnits[0]->globalRotation(),
00089 *theMonoBounds);
00090
00091 BoundPlane::BoundPlanePointer stereoPlane
00092 = BoundPlane::build(aliUnits[1]->globalPosition(), aliUnits[1]->globalRotation(),
00093 *theStereoBounds);
00094
00095 Surface::PositionType::BasicVectorType posSum = monoPlane->position().basicVector();
00096 posSum += stereoPlane->position().basicVector();
00097 Surface::PositionType meanPos(posSum/(float)aliUnits.size());
00098 Surface::RotationType rotation = monoPlane->rotation();
00099
00100 BoundPlane::BoundPlanePointer tmpPlane = BoundPlane::build(meanPos, rotation, OpenBounds());
00101
00102 const MediumProperties* mp = monoPlane->mediumProperties();
00103 MediumProperties newmp(0,0);
00104 if (mp != 0) newmp = MediumProperties(mp->radLen()*2.0,mp->xi()*2.0);
00105
00106 std::vector<GlobalPoint> corners;
00107 std::vector<GlobalPoint> monoDC = BoundingBox().corners(*monoPlane);
00108 corners.insert(corners.end(), monoDC.begin(), monoDC.end());
00109 std::vector<GlobalPoint> stereoDC = BoundingBox().corners(*stereoPlane);
00110 corners.insert(corners.end(), stereoDC.begin(), stereoDC.end());
00111
00112 float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
00113 for (std::vector<GlobalPoint>::const_iterator i=corners.begin();
00114 i!=corners.end();
00115 ++i) {
00116 LocalPoint p = tmpPlane->toLocal(*i);
00117 if (p.x() < xmin) xmin = p.x();
00118 if (p.x() > xmax) xmax = p.x();
00119 if (p.y() < ymin) ymin = p.y();
00120 if (p.y() > ymax) ymax = p.y();
00121 if (p.z() < zmin) zmin = p.z();
00122 if (p.z() > zmax) zmax = p.z();
00123 }
00124
00125 LocalVector localOffset((xmin+xmax)/2., (ymin+ymax)/2., (zmin+zmax)/2.);
00126 GlobalVector offset(tmpPlane->toGlobal(localOffset));
00127
00128 theSurface = AlignableSurface(BoundPlane(meanPos+offset, rotation,
00129 RectangularPlaneBounds((xmax-xmin)/2, (ymax-ymin)/2, (zmax-zmin)/2),
00130 &newmp));
00131
00132
00133 const GlobalVector theMovement(theSurface.position().basicVector() - oldPos.basicVector());
00134
00135 const RotationType theRotation(oldRot.multiplyInverse(theSurface.rotation()));
00136 this->addDisplacement(theMovement);
00137 this->addRotation(theRotation);
00138
00139
00140
00141
00142
00143
00144
00145
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175