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 }
TrackerAlignment::TrackerAlignment
TrackerAlignment(const edm::EventSetup &setup)
Definition: TrackerAlignment.cc:20
Vector3DBase
Definition: Vector3DBase.h:8
AlignmentErrorsExtended.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TkRotation< Scalar >
AlignableTracker::outerBarrelGeomDets
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
Definition: AlignableTracker.h:57
align::Scalars
std::vector< Scalar > Scalars
Definition: Utilities.h:26
ESHandle.h
TrackerAlignment::moveAlignableOuterHalfBarrels
void moveAlignableOuterHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:124
TrackerTopology
Definition: TrackerTopology.h:16
AlignableTracker::innerBarrelGeomDets
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
Definition: AlignableTracker.h:55
Alignments.h
TrackerAlignment::saveToDB
void saveToDB()
Definition: TrackerAlignment.cc:241
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
AlignableTracker::pixelHalfBarrelGeomDets
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
Definition: AlignableTracker.h:59
AlignableTracker::endcapGeomDets
Alignables & endcapGeomDets()
Return endcap GeomDets.
Definition: AlignableTracker.h:61
PoolDBOutputService.h
TrackerTopologyRcd.h
AlignableTracker::alignmentErrors
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
Definition: AlignableTracker.cc:59
Service.h
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerTopology >
AlignableTracker
Definition: AlignableTracker.h:17
TrackerAlignment::theErrorRecordName
std::string theErrorRecordName
Definition: TrackerAlignment.h:48
TrackerDigiGeometryRecord.h
TrackerAlignment::moveAlignablePixelHalfBarrels
void moveAlignablePixelHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:95
edm::Service< cond::service::PoolDBOutputService >
TrackerAlignment.h
TrackerAlignment::theAlignableTracker
AlignableTracker * theAlignableTracker
Definition: TrackerAlignment.h:46
TrackerAlignment::theAlignRecordName
std::string theAlignRecordName
Definition: TrackerAlignment.h:48
edm::EventSetup
Definition: EventSetup.h:58
AlignableTracker::TIBTIDGeomDets
Alignables TIBTIDGeomDets()
Return inner barrel and TID GeomDets together.
Definition: AlignableTracker.h:53
TrackerAlignment::moveAlignableTIDs
void moveAlignableTIDs(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:182
get
#define get
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
TrackerAlignment::moveAlignableTIBTIDs
void moveAlignableTIBTIDs(int rawId, const align::Scalars &globalDisplacements, const align::RotationType &backwardRotation, const align::RotationType &forwardRotation, bool toAndFro)
Definition: TrackerAlignment.cc:210
TrackerAlignment::~TrackerAlignment
~TrackerAlignment()
Definition: TrackerAlignment.cc:34
AlignableTracker::alignments
Alignments * alignments() const override
Return alignments, sorted by DetId.
Definition: AlignableTracker.cc:42
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
AlignableTracker::TIDGeomDets
Alignables & TIDGeomDets()
Return TID GeomDets.
Definition: AlignableTracker.h:63
TkRotation::transposed
TkRotation transposed() const
Definition: extTkRotation.h:161
cms::Exception
Definition: Exception.h:70
TrackerAlignment::moveAlignablePixelEndCaps
void moveAlignablePixelEndCaps(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:38
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
TrackerAlignment::moveAlignableEndCaps
void moveAlignableEndCaps(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:67
TrackerAlignment::moveAlignableInnerHalfBarrels
void moveAlignableInnerHalfBarrels(int rawId, const align::Scalars &localDisplacements, const align::Scalars &localRotations)
Definition: TrackerAlignment.cc:153
Alignments
Definition: Alignments.h:10
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
AlignableTracker::pixelEndcapGeomDets
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
Definition: AlignableTracker.h:65