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