CMS 3D CMS Logo

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