CMS 3D CMS Logo

TrackerAlignment.cc
Go to the documentation of this file.
1 // Framework
4 // Conditions database
7 
8 // Geometry
11 
12 // Alignment
15 
17 
18 //__________________________________________________________________
19 //
21  : theAlignRecordName("TrackerAlignmentRcd"), theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
22  theAlignableTracker = new AlignableTracker(tGeom, tTopo);
23 }
24 
25 //__________________________________________________________________
26 //
28 
29 //__________________________________________________________________
30 //
32  const align::Scalars& local_displacements,
33  const align::Scalars& local_rotations) {
34  // Displace and rotate pixelEndCaps
35  const align::Alignables& thePixelEndCapsAlignables = theAlignableTracker->pixelEndcapGeomDets();
36  for (align::Alignables::const_iterator iter = thePixelEndCapsAlignables.begin();
37  iter != thePixelEndCapsAlignables.end();
38  ++iter) {
39  // Get the raw ID of the associated GeomDet
40  int id = (*iter)->geomDetId().rawId();
41 
42  // Select the given module
43  if (id == rawid) {
44  // Convert local to global diplacements
45  align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
46  align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
47 
48  // global displacement
49  (*iter)->move(gvector);
50 
51  // local rotation
52  (*iter)->rotateAroundLocalX(local_rotations.at(0)); // Local X axis rotation
53  (*iter)->rotateAroundLocalY(local_rotations.at(1)); // Local Y axis rotation
54  (*iter)->rotateAroundLocalZ(local_rotations.at(2)); // Local Z axis rotation
55  }
56  }
57 }
58 //__________________________________________________________________
59 //
61  const align::Scalars& local_displacements,
62  const align::Scalars& local_rotations) {
63  // Displace and rotate EndCaps
64  const align::Alignables& theEndCapsAlignables = theAlignableTracker->endcapGeomDets();
65  for (align::Alignables::const_iterator iter = theEndCapsAlignables.begin(); iter != theEndCapsAlignables.end();
66  ++iter) {
67  // Get the raw ID of the associated GeomDet
68  int id = (*iter)->geomDetId().rawId();
69 
70  // Select the given module
71  if (id == rawid) {
72  // Convert local to global diplacements
73  align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
74  align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
75 
76  // global displacement
77  (*iter)->move(gvector);
78 
79  // local rotation
80  (*iter)->rotateAroundLocalX(local_rotations.at(0)); // Local X axis rotation
81  (*iter)->rotateAroundLocalY(local_rotations.at(1)); // Local Y axis rotation
82  (*iter)->rotateAroundLocalZ(local_rotations.at(2)); // Local Z axis rotation
83  }
84  }
85 }
86 //__________________________________________________________________
87 //
89  const align::Scalars& local_displacements,
90  const align::Scalars& local_rotations) {
91  // Displace and rotate PixelHalfBarrels
92  const align::Alignables& thePixelHalfBarrelsAlignables = theAlignableTracker->pixelHalfBarrelGeomDets();
93  for (align::Alignables::const_iterator iter = thePixelHalfBarrelsAlignables.begin();
94  iter != thePixelHalfBarrelsAlignables.end();
95  ++iter) {
96  // Get the raw ID of the associated GeomDet
97  int id = (*iter)->geomDetId().rawId();
98 
99  // Select the given module
100  if (id == rawid) {
101  // Convert local to global diplacements
102  align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
103  align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
104 
105  // global displacement
106  (*iter)->move(gvector);
107 
108  // local rotation
109  (*iter)->rotateAroundLocalX(local_rotations.at(0)); // Local X axis rotation
110  (*iter)->rotateAroundLocalY(local_rotations.at(1)); // Local Y axis rotation
111  (*iter)->rotateAroundLocalZ(local_rotations.at(2)); // Local Z axis rotation
112  }
113  }
114 }
115 //__________________________________________________________________
116 //
118  const align::Scalars& local_displacements,
119  const align::Scalars& local_rotations) {
120  // Displace and rotate OuterHalfBarrels
121  const align::Alignables& theOuterHalfBarrelsAlignables = theAlignableTracker->outerBarrelGeomDets();
122  for (align::Alignables::const_iterator iter = theOuterHalfBarrelsAlignables.begin();
123  iter != theOuterHalfBarrelsAlignables.end();
124  ++iter) {
125  // Get the raw ID of the associated GeomDet
126  int id = (*iter)->geomDetId().rawId();
127 
128  // Select the given module
129  if (id == rawid) {
130  // Convert local to global diplacements
131  align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
132  align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
133 
134  // global displacement
135  (*iter)->move(gvector);
136 
137  // local rotation
138  (*iter)->rotateAroundLocalX(local_rotations.at(0)); // Local X axis rotation
139  (*iter)->rotateAroundLocalY(local_rotations.at(1)); // Local Y axis rotation
140  (*iter)->rotateAroundLocalZ(local_rotations.at(2)); // Local Z axis rotation
141  }
142  }
143 }
144 //__________________________________________________________________
145 //
147  const align::Scalars& local_displacements,
148  const align::Scalars& local_rotations) {
149  // Displace and rotate InnerHalfBarrels
150  const align::Alignables& theInnerHalfBarrelsAlignables = theAlignableTracker->innerBarrelGeomDets();
151  for (align::Alignables::const_iterator iter = theInnerHalfBarrelsAlignables.begin();
152  iter != theInnerHalfBarrelsAlignables.end();
153  ++iter) {
154  // Get the raw ID of the associated GeomDet
155  int id = (*iter)->geomDetId().rawId();
156 
157  // Select the given module
158  if (id == rawid) {
159  // Convert local to global diplacements
160  align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
161  align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
162 
163  // global displacement
164  (*iter)->move(gvector);
165 
166  // local rotation
167  (*iter)->rotateAroundLocalX(local_rotations.at(0)); // Local X axis rotation
168  (*iter)->rotateAroundLocalY(local_rotations.at(1)); // Local Y axis rotation
169  (*iter)->rotateAroundLocalZ(local_rotations.at(2)); // Local Z axis rotation
170  }
171  }
172 }
173 //__________________________________________________________________
174 //
176  const align::Scalars& local_displacements,
177  const align::Scalars& local_rotations) {
178  // Displace and rotate TIDs
179  const align::Alignables& theTIDsAlignables = theAlignableTracker->TIDGeomDets();
180  for (align::Alignables::const_iterator iter = theTIDsAlignables.begin(); iter != theTIDsAlignables.end(); ++iter) {
181  // Get the raw ID of the associated GeomDet
182  int id = (*iter)->geomDetId().rawId();
183 
184  // Select the given module
185  if (id == rawid) {
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 //
204  const align::Scalars& globalDisplacements,
205  const align::RotationType& backwardRotation,
206  const align::RotationType& forwardRotation,
207  bool toAndFro) {
208  // Displace and rotate TIB and TID
209  const align::Alignables& theTIBTIDAlignables = theAlignableTracker->TIBTIDGeomDets();
210  for (align::Alignables::const_iterator iter = theTIBTIDAlignables.begin(); iter != theTIBTIDAlignables.end();
211  ++iter) {
212  // Get the raw ID of the associated GeomDet
213  int id = (*iter)->geomDetId().rawId();
214 
215  // Select the given module
216  if (id == rawId) {
217  // global displacement
218  align::GlobalVector gvector(globalDisplacements.at(0), globalDisplacements.at(1), globalDisplacements.at(2));
219  (*iter)->move(gvector);
220 
221  // global rotation
222  if (toAndFro) {
223  align::RotationType theResultRotation = backwardRotation * forwardRotation.transposed();
224  (*iter)->rotateInGlobalFrame(theResultRotation);
225  } else {
226  (*iter)->rotateInGlobalFrame(backwardRotation);
227  }
228  }
229  }
230 }
231 
232 //__________________________________________________________________
233 //
235  // Output POOL-ORA objects
237  if (!poolDbService.isAvailable()) // Die if not available
238  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
239 
240  // Retrieve and store
243 
244  // if ( poolDbService->isNewTagRequest(theAlignRecordName) )
245  // poolDbService->createOneIOV<Alignments>( alignments, poolDbService->endOfTime(),
246  // theAlignRecordName );
247  // else
248  // poolDbService->appendOneIOV<Alignments>( alignments, poolDbService->currentTime(),
249  // theAlignRecordName );
250  // In the two calls below it is assumed that the delete of "theAlignableTracker" is also deleting the two concerned payloads...
251  poolDbService->writeOneIOV<Alignments>(alignments, poolDbService->currentTime(), theAlignRecordName);
252  // if ( poolDbService->isNewTagRequest(theErrorRecordName) )
253  // poolDbService->createOneIOV<AlignmentErrorsExtended>( alignmentErrors,
254  // poolDbService->endOfTime(),
255  // theErrorRecordName );
256  // else
257  // poolDbService->appendOneIOV<AlignmentErrorsExtended>( alignmentErrors,
258  // poolDbService->currentTime(),
259  // theErrorRecordName );
260  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
261  alignmentErrors, poolDbService->currentTime(), theErrorRecordName);
262 }
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
Alignments * alignments() const override
Return alignments, sorted by DetId.
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.
TkRotation transposed() const
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
std::vector< Scalar > Scalars
Definition: Utilities.h:26
Alignables & TIDGeomDets()
Return TID GeomDets.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
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.
void moveAlignableEndCaps(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
TrackerAlignment(const TrackerTopology *tTopo, const TrackerGeometry *tGeom)
AlignableTracker * theAlignableTracker
bool isAvailable() const
Definition: Service.h:40