CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerAlignment.cc
Go to the documentation of this file.
1 // Framework
3 
4 // Conditions database
7 
8 // Geometry
10 
11 // Alignment
14 
16 
17 //__________________________________________________________________
18 //
20  theAlignRecordName( "TrackerAlignmentRcd" ),
21  theErrorRecordName( "TrackerAlignmentErrorRcd" )
22 {
23 
24  edm::ESHandle<TrackerGeometry> trackerGeometry;
25  setup.get<TrackerDigiGeometryRecord>().get( trackerGeometry );
26  theAlignableTracker = new AlignableTracker( &(*trackerGeometry) );
27 
28 }
29 
30 
31 //__________________________________________________________________
32 //
34 {
35 
36  delete theAlignableTracker;
37 
38 }
39 
40 
41 //__________________________________________________________________
42 //
44  const align::Scalars& local_displacements,
45  const align::Scalars& local_rotations )
46 {
47 
48  // Displace and rotate pixelEndCaps
49  const align::Alignables& thePixelEndCapsAlignables = theAlignableTracker->pixelEndcapGeomDets();
50  for ( align::Alignables::const_iterator iter = thePixelEndCapsAlignables.begin();
51  iter != thePixelEndCapsAlignables.end(); ++iter )
52  {
53 
54  // Get the raw ID of the associated GeomDet
55  int id = (*iter)->geomDetId().rawId();
56 
57  // Select the given module
58  if ( id == rawid ){
59 
60  // Convert local to global diplacements
61  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
62  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
63 
64  // global displacement
65  (*iter)->move( gvector );
66 
67  // local rotation
68  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
69  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
70  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
71 
72  }
73  }
74 }
75 //__________________________________________________________________
76 //
77 void TrackerAlignment::moveAlignableEndCaps( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
78 
79  // Displace and rotate EndCaps
80  const align::Alignables& theEndCapsAlignables = theAlignableTracker->endcapGeomDets();
81  for ( align::Alignables::const_iterator iter = theEndCapsAlignables.begin();
82  iter != theEndCapsAlignables.end(); ++iter ){
83 
84  // Get the raw ID of the associated GeomDet
85  int id = (*iter)->geomDetId().rawId();
86 
87  // Select the given module
88  if ( id == rawid ){
89 
90  // Convert local to global diplacements
91  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
92  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
93 
94  // global displacement
95  (*iter)->move( gvector );
96 
97  // local rotation
98  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
99  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
100  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
101 
102  }
103  }
104 }
105 //__________________________________________________________________
106 //
107 void TrackerAlignment::moveAlignablePixelHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
108 
109  // Displace and rotate PixelHalfBarrels
110  const align::Alignables& thePixelHalfBarrelsAlignables = theAlignableTracker->pixelHalfBarrelGeomDets();
111  for ( align::Alignables::const_iterator iter = thePixelHalfBarrelsAlignables.begin();
112  iter != thePixelHalfBarrelsAlignables.end(); ++iter ){
113 
114  // Get the raw ID of the associated GeomDet
115  int id = (*iter)->geomDetId().rawId();
116 
117  // Select the given module
118  if ( id == rawid ){
119 
120  // Convert local to global diplacements
121  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
122  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
123 
124  // global displacement
125  (*iter)->move( gvector );
126 
127  // local rotation
128  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
129  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
130  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
131 
132  }
133  }
134 }
135 //__________________________________________________________________
136 //
137 void TrackerAlignment::moveAlignableOuterHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
138 
139  // Displace and rotate OuterHalfBarrels
140  const align::Alignables& theOuterHalfBarrelsAlignables = theAlignableTracker->outerBarrelGeomDets();
141  for ( align::Alignables::const_iterator iter = theOuterHalfBarrelsAlignables.begin();
142  iter != theOuterHalfBarrelsAlignables.end(); ++iter ){
143 
144  // Get the raw ID of the associated GeomDet
145  int id = (*iter)->geomDetId().rawId();
146 
147  // Select the given module
148  if ( id == rawid ){
149 
150  // Convert local to global diplacements
151  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
152  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
153 
154  // global displacement
155  (*iter)->move( gvector );
156 
157  // local rotation
158  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
159  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
160  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
161 
162  }
163  }
164 }
165 //__________________________________________________________________
166 //
167 void TrackerAlignment::moveAlignableInnerHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
168 
169  // Displace and rotate InnerHalfBarrels
170  const align::Alignables& theInnerHalfBarrelsAlignables = theAlignableTracker->innerBarrelGeomDets();
171  for ( align::Alignables::const_iterator iter = theInnerHalfBarrelsAlignables.begin();
172  iter != theInnerHalfBarrelsAlignables.end(); ++iter ){
173 
174  // Get the raw ID of the associated GeomDet
175  int id = (*iter)->geomDetId().rawId();
176 
177  // Select the given module
178  if ( id == rawid ){
179 
180  // Convert local to global diplacements
181  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
182  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
183 
184  // global displacement
185  (*iter)->move( gvector );
186 
187  // local rotation
188  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
189  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
190  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
191 
192  }
193  }
194 }
195 //__________________________________________________________________
196 //
197 void TrackerAlignment::moveAlignableTIDs( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
198 
199  // Displace and rotate TIDs
200  const align::Alignables& theTIDsAlignables = theAlignableTracker->TIDGeomDets();
201  for ( align::Alignables::const_iterator iter = theTIDsAlignables.begin();
202  iter != theTIDsAlignables.end(); ++iter ){
203 
204  // Get the raw ID of the associated GeomDet
205  int id = (*iter)->geomDetId().rawId();
206 
207  // Select the given module
208  if ( id == rawid ){
209 
210  // Convert local to global diplacements
211  align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
212  align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
213 
214  // global displacement
215  (*iter)->move( gvector );
216 
217  // local rotation
218  (*iter)->rotateAroundLocalX( local_rotations.at(0) ); // Local X axis rotation
219  (*iter)->rotateAroundLocalY( local_rotations.at(1) ); // Local Y axis rotation
220  (*iter)->rotateAroundLocalZ( local_rotations.at(2) ); // Local Z axis rotation
221 
222  }
223  }
224 }
225 
226 //__________________________________________________________________
227 //
228 void TrackerAlignment::moveAlignableTIBTIDs( int rawId, const align::Scalars& globalDisplacements, const align::RotationType& backwardRotation, const align::RotationType& forwardRotation, bool toAndFro ){
229 
230  // Displace and rotate TIB and TID
231  const align::Alignables& theTIBTIDAlignables = theAlignableTracker->TIBTIDGeomDets();
232  for ( align::Alignables::const_iterator iter = theTIBTIDAlignables.begin();
233  iter != theTIBTIDAlignables.end(); ++iter )
234  {
235 
236  // Get the raw ID of the associated GeomDet
237  int id = (*iter)->geomDetId().rawId();
238 
239  // Select the given module
240  if ( id == rawId ){
241 
242  // global displacement
243  align::GlobalVector gvector (globalDisplacements.at(0), globalDisplacements.at(1), globalDisplacements.at(2));
244  (*iter)->move( gvector );
245 
246  // global rotation
247  if (toAndFro) {
248  align::RotationType theResultRotation = backwardRotation*forwardRotation.transposed();
249  (*iter)->rotateInGlobalFrame( theResultRotation );
250  } else {
251  (*iter)->rotateInGlobalFrame( backwardRotation );
252  }
253  }
254  }
255 }
256 
257 
258 //__________________________________________________________________
259 //
261 
262  // Output POOL-ORA objects
264  if( !poolDbService.isAvailable() ) // Die if not available
265  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
266 
267  // Retrieve and store
268  Alignments* alignments = theAlignableTracker->alignments();
270 
271 // if ( poolDbService->isNewTagRequest(theAlignRecordName) )
272 // poolDbService->createNewIOV<Alignments>( alignments, poolDbService->endOfTime(),
273 // theAlignRecordName );
274 // else
275 // poolDbService->appendSinceTime<Alignments>( alignments, poolDbService->currentTime(),
276 // theAlignRecordName );
277  poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(),
279 // if ( poolDbService->isNewTagRequest(theErrorRecordName) )
280 // poolDbService->createNewIOV<AlignmentErrors>( alignmentErrors,
281 // poolDbService->endOfTime(),
282 // theErrorRecordName );
283 // else
284 // poolDbService->appendSinceTime<AlignmentErrors>( alignmentErrors,
285 // poolDbService->currentTime(),
286 // theErrorRecordName );
287  poolDbService->writeOne<AlignmentErrors>(alignmentErrors, poolDbService->currentTime(),
289 }
290 
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
void moveAlignableTIDs(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
void moveAlignablePixelEndCaps(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
void moveAlignableInnerHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
void moveAlignablePixelHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
std::string theAlignRecordName
Alignables TIBTIDGeomDets()
Return inner barrel and TID GeomDets together.
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
std::vector< Scalar > Scalars
Definition: Utilities.h:22
Alignables & TIDGeomDets()
Return TID GeomDets.
bool isAvailable() const
Definition: Service.h:47
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
TrackerAlignment(const edm::EventSetup &setup)
void moveAlignableOuterHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
void moveAlignableTIBTIDs(int rawId, const align::Scalars &globalDisplacements, const align::RotationType &backwardRotation, const align::RotationType &forwardRotation, bool toAndFro)
std::string theErrorRecordName
Alignables & endcapGeomDets()
Return endcap GeomDets.
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
const T & get() const
Definition: EventSetup.h:55
void moveAlignableEndCaps(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
TkRotation transposed() const
AlignableTracker * theAlignableTracker
Alignments * alignments() const
Return alignments, sorted by DetId.