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