File indexing completed on 2023-03-17 10:40:49
0001
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/Framework/interface/ConsumesCollector.h"
0004
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0007
0008
0009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0010 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0011
0012
0013 #include "CondFormats/Alignment/interface/Alignments.h"
0014 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0015
0016 #include "Alignment/TrackerAlignment/interface/TrackerAlignment.h"
0017
0018
0019
0020 TrackerAlignment::TrackerAlignment(const TrackerTopology* tTopo, const TrackerGeometry* tGeom)
0021 : theAlignRecordName("TrackerAlignmentRcd"), theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
0022 theAlignableTracker = new AlignableTracker(tGeom, tTopo);
0023 }
0024
0025
0026
0027 TrackerAlignment::~TrackerAlignment(void) { delete theAlignableTracker; }
0028
0029
0030
0031 void TrackerAlignment::moveAlignablePixelEndCaps(int rawid,
0032 const align::Scalars& local_displacements,
0033 const align::Scalars& local_rotations) {
0034
0035 const align::Alignables& thePixelEndCapsAlignables = theAlignableTracker->pixelEndcapGeomDets();
0036 for (align::Alignables::const_iterator iter = thePixelEndCapsAlignables.begin();
0037 iter != thePixelEndCapsAlignables.end();
0038 ++iter) {
0039
0040 int id = (*iter)->geomDetId().rawId();
0041
0042
0043 if (id == rawid) {
0044
0045 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0046 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0047
0048
0049 (*iter)->move(gvector);
0050
0051
0052 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0053 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0054 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0055 }
0056 }
0057 }
0058
0059
0060 void TrackerAlignment::moveAlignableEndCaps(int rawid,
0061 const align::Scalars& local_displacements,
0062 const align::Scalars& local_rotations) {
0063
0064 const align::Alignables& theEndCapsAlignables = theAlignableTracker->endcapGeomDets();
0065 for (align::Alignables::const_iterator iter = theEndCapsAlignables.begin(); iter != theEndCapsAlignables.end();
0066 ++iter) {
0067
0068 int id = (*iter)->geomDetId().rawId();
0069
0070
0071 if (id == rawid) {
0072
0073 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0074 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0075
0076
0077 (*iter)->move(gvector);
0078
0079
0080 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0081 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0082 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0083 }
0084 }
0085 }
0086
0087
0088 void TrackerAlignment::moveAlignablePixelHalfBarrels(int rawid,
0089 const align::Scalars& local_displacements,
0090 const align::Scalars& local_rotations) {
0091
0092 const align::Alignables& thePixelHalfBarrelsAlignables = theAlignableTracker->pixelHalfBarrelGeomDets();
0093 for (align::Alignables::const_iterator iter = thePixelHalfBarrelsAlignables.begin();
0094 iter != thePixelHalfBarrelsAlignables.end();
0095 ++iter) {
0096
0097 int id = (*iter)->geomDetId().rawId();
0098
0099
0100 if (id == rawid) {
0101
0102 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0103 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0104
0105
0106 (*iter)->move(gvector);
0107
0108
0109 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0110 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0111 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0112 }
0113 }
0114 }
0115
0116
0117 void TrackerAlignment::moveAlignableOuterHalfBarrels(int rawid,
0118 const align::Scalars& local_displacements,
0119 const align::Scalars& local_rotations) {
0120
0121 const align::Alignables& theOuterHalfBarrelsAlignables = theAlignableTracker->outerBarrelGeomDets();
0122 for (align::Alignables::const_iterator iter = theOuterHalfBarrelsAlignables.begin();
0123 iter != theOuterHalfBarrelsAlignables.end();
0124 ++iter) {
0125
0126 int id = (*iter)->geomDetId().rawId();
0127
0128
0129 if (id == rawid) {
0130
0131 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0132 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0133
0134
0135 (*iter)->move(gvector);
0136
0137
0138 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0139 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0140 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0141 }
0142 }
0143 }
0144
0145
0146 void TrackerAlignment::moveAlignableInnerHalfBarrels(int rawid,
0147 const align::Scalars& local_displacements,
0148 const align::Scalars& local_rotations) {
0149
0150 const align::Alignables& theInnerHalfBarrelsAlignables = theAlignableTracker->innerBarrelGeomDets();
0151 for (align::Alignables::const_iterator iter = theInnerHalfBarrelsAlignables.begin();
0152 iter != theInnerHalfBarrelsAlignables.end();
0153 ++iter) {
0154
0155 int id = (*iter)->geomDetId().rawId();
0156
0157
0158 if (id == rawid) {
0159
0160 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0161 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0162
0163
0164 (*iter)->move(gvector);
0165
0166
0167 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0168 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0169 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0170 }
0171 }
0172 }
0173
0174
0175 void TrackerAlignment::moveAlignableTIDs(int rawid,
0176 const align::Scalars& local_displacements,
0177 const align::Scalars& local_rotations) {
0178
0179 const align::Alignables& theTIDsAlignables = theAlignableTracker->TIDGeomDets();
0180 for (align::Alignables::const_iterator iter = theTIDsAlignables.begin(); iter != theTIDsAlignables.end(); ++iter) {
0181
0182 int id = (*iter)->geomDetId().rawId();
0183
0184
0185 if (id == rawid) {
0186
0187 align::LocalVector lvector(local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
0188 align::GlobalVector gvector = ((*iter)->surface()).toGlobal(lvector);
0189
0190
0191 (*iter)->move(gvector);
0192
0193
0194 (*iter)->rotateAroundLocalX(local_rotations.at(0));
0195 (*iter)->rotateAroundLocalY(local_rotations.at(1));
0196 (*iter)->rotateAroundLocalZ(local_rotations.at(2));
0197 }
0198 }
0199 }
0200
0201
0202
0203 void TrackerAlignment::moveAlignableTIBTIDs(int rawId,
0204 const align::Scalars& globalDisplacements,
0205 const align::RotationType& backwardRotation,
0206 const align::RotationType& forwardRotation,
0207 bool toAndFro) {
0208
0209 const align::Alignables& theTIBTIDAlignables = theAlignableTracker->TIBTIDGeomDets();
0210 for (align::Alignables::const_iterator iter = theTIBTIDAlignables.begin(); iter != theTIBTIDAlignables.end();
0211 ++iter) {
0212
0213 int id = (*iter)->geomDetId().rawId();
0214
0215
0216 if (id == rawId) {
0217
0218 align::GlobalVector gvector(globalDisplacements.at(0), globalDisplacements.at(1), globalDisplacements.at(2));
0219 (*iter)->move(gvector);
0220
0221
0222 if (toAndFro) {
0223 align::RotationType theResultRotation = backwardRotation * forwardRotation.transposed();
0224 (*iter)->rotateInGlobalFrame(theResultRotation);
0225 } else {
0226 (*iter)->rotateInGlobalFrame(backwardRotation);
0227 }
0228 }
0229 }
0230 }
0231
0232
0233
0234 void TrackerAlignment::saveToDB(void) {
0235
0236 edm::Service<cond::service::PoolDBOutputService> poolDbService;
0237 if (!poolDbService.isAvailable())
0238 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
0239
0240
0241 Alignments alignments = *(theAlignableTracker->alignments());
0242 AlignmentErrorsExtended alignmentErrors = *(theAlignableTracker->alignmentErrors());
0243
0244
0245
0246
0247
0248
0249
0250
0251 poolDbService->writeOneIOV<Alignments>(alignments, poolDbService->currentTime(), theAlignRecordName);
0252
0253
0254
0255
0256
0257
0258
0259
0260 poolDbService->writeOneIOV<AlignmentErrorsExtended>(
0261 alignmentErrors, poolDbService->currentTime(), theErrorRecordName);
0262 }