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