Go to the documentation of this file.00001
00002 #include "FWCore/Framework/interface/ESHandle.h"
00003
00004
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00007
00008
00009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00010
00011
00012 #include "CondFormats/Alignment/interface/Alignments.h"
00013 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00014
00015 #include "Alignment/TrackerAlignment/interface/TrackerAlignment.h"
00016
00017
00018
00019 TrackerAlignment::TrackerAlignment( const edm::EventSetup& setup ):
00020 theAlignRecordName( "TrackerAlignmentRcd" ),
00021 theErrorRecordName( "TrackerAlignmentErrorRcd" )
00022 {
00023
00024 edm::ESHandle<TrackerGeometry> trackerGeometry;
00025 setup.get<TrackerDigiGeometryRecord>().get( trackerGeometry );
00026 theAlignableTracker = new AlignableTracker( &(*trackerGeometry) );
00027
00028 }
00029
00030
00031
00032
00033 TrackerAlignment::~TrackerAlignment( void )
00034 {
00035
00036 delete theAlignableTracker;
00037
00038 }
00039
00040
00041
00042
00043 void TrackerAlignment::moveAlignablePixelEndCaps( int rawid ,
00044 const align::Scalars& local_displacements,
00045 const align::Scalars& local_rotations )
00046 {
00047
00048
00049 const align::Alignables& thePixelEndCapsAlignables = theAlignableTracker->pixelEndcapGeomDets();
00050 for ( align::Alignables::const_iterator iter = thePixelEndCapsAlignables.begin();
00051 iter != thePixelEndCapsAlignables.end(); ++iter )
00052 {
00053
00054
00055 int id = (*iter)->geomDetId().rawId();
00056
00057
00058 if ( id == rawid ){
00059
00060
00061 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00062 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00063
00064
00065 (*iter)->move( gvector );
00066
00067
00068 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00069 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00070 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00071
00072 }
00073 }
00074 }
00075
00076
00077 void TrackerAlignment::moveAlignableEndCaps( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
00078
00079
00080 const align::Alignables& theEndCapsAlignables = theAlignableTracker->endcapGeomDets();
00081 for ( align::Alignables::const_iterator iter = theEndCapsAlignables.begin();
00082 iter != theEndCapsAlignables.end(); ++iter ){
00083
00084
00085 int id = (*iter)->geomDetId().rawId();
00086
00087
00088 if ( id == rawid ){
00089
00090
00091 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00092 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00093
00094
00095 (*iter)->move( gvector );
00096
00097
00098 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00099 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00100 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00101
00102 }
00103 }
00104 }
00105
00106
00107 void TrackerAlignment::moveAlignablePixelHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
00108
00109
00110 const align::Alignables& thePixelHalfBarrelsAlignables = theAlignableTracker->pixelHalfBarrelGeomDets();
00111 for ( align::Alignables::const_iterator iter = thePixelHalfBarrelsAlignables.begin();
00112 iter != thePixelHalfBarrelsAlignables.end(); ++iter ){
00113
00114
00115 int id = (*iter)->geomDetId().rawId();
00116
00117
00118 if ( id == rawid ){
00119
00120
00121 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00122 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00123
00124
00125 (*iter)->move( gvector );
00126
00127
00128 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00129 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00130 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00131
00132 }
00133 }
00134 }
00135
00136
00137 void TrackerAlignment::moveAlignableOuterHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
00138
00139
00140 const align::Alignables& theOuterHalfBarrelsAlignables = theAlignableTracker->outerBarrelGeomDets();
00141 for ( align::Alignables::const_iterator iter = theOuterHalfBarrelsAlignables.begin();
00142 iter != theOuterHalfBarrelsAlignables.end(); ++iter ){
00143
00144
00145 int id = (*iter)->geomDetId().rawId();
00146
00147
00148 if ( id == rawid ){
00149
00150
00151 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00152 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00153
00154
00155 (*iter)->move( gvector );
00156
00157
00158 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00159 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00160 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00161
00162 }
00163 }
00164 }
00165
00166
00167 void TrackerAlignment::moveAlignableInnerHalfBarrels( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
00168
00169
00170 const align::Alignables& theInnerHalfBarrelsAlignables = theAlignableTracker->innerBarrelGeomDets();
00171 for ( align::Alignables::const_iterator iter = theInnerHalfBarrelsAlignables.begin();
00172 iter != theInnerHalfBarrelsAlignables.end(); ++iter ){
00173
00174
00175 int id = (*iter)->geomDetId().rawId();
00176
00177
00178 if ( id == rawid ){
00179
00180
00181 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00182 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00183
00184
00185 (*iter)->move( gvector );
00186
00187
00188 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00189 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00190 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00191
00192 }
00193 }
00194 }
00195
00196
00197 void TrackerAlignment::moveAlignableTIDs( int rawid , const align::Scalars& local_displacements, const align::Scalars& local_rotations ){
00198
00199
00200 const align::Alignables& theTIDsAlignables = theAlignableTracker->TIDGeomDets();
00201 for ( align::Alignables::const_iterator iter = theTIDsAlignables.begin();
00202 iter != theTIDsAlignables.end(); ++iter ){
00203
00204
00205 int id = (*iter)->geomDetId().rawId();
00206
00207
00208 if ( id == rawid ){
00209
00210
00211 align::LocalVector lvector( local_displacements.at(0), local_displacements.at(1), local_displacements.at(2));
00212 align::GlobalVector gvector = ((*iter)->surface()).toGlobal( lvector );
00213
00214
00215 (*iter)->move( gvector );
00216
00217
00218 (*iter)->rotateAroundLocalX( local_rotations.at(0) );
00219 (*iter)->rotateAroundLocalY( local_rotations.at(1) );
00220 (*iter)->rotateAroundLocalZ( local_rotations.at(2) );
00221
00222 }
00223 }
00224 }
00225
00226
00227
00228 void TrackerAlignment::moveAlignableTIBTIDs( int rawId, const align::Scalars& globalDisplacements, const align::RotationType& backwardRotation, const align::RotationType& forwardRotation, bool toAndFro ){
00229
00230
00231 const align::Alignables& theTIBTIDAlignables = theAlignableTracker->TIBTIDGeomDets();
00232 for ( align::Alignables::const_iterator iter = theTIBTIDAlignables.begin();
00233 iter != theTIBTIDAlignables.end(); ++iter )
00234 {
00235
00236
00237 int id = (*iter)->geomDetId().rawId();
00238
00239
00240 if ( id == rawId ){
00241
00242
00243 align::GlobalVector gvector (globalDisplacements.at(0), globalDisplacements.at(1), globalDisplacements.at(2));
00244 (*iter)->move( gvector );
00245
00246
00247 if (toAndFro) {
00248 align::RotationType theResultRotation = backwardRotation*forwardRotation.transposed();
00249 (*iter)->rotateInGlobalFrame( theResultRotation );
00250 } else {
00251 (*iter)->rotateInGlobalFrame( backwardRotation );
00252 }
00253 }
00254 }
00255 }
00256
00257
00258
00259
00260 void TrackerAlignment::saveToDB(void){
00261
00262
00263 edm::Service<cond::service::PoolDBOutputService> poolDbService;
00264 if( !poolDbService.isAvailable() )
00265 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
00266
00267
00268 Alignments* alignments = theAlignableTracker->alignments();
00269 AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors();
00270
00271
00272
00273
00274
00275
00276
00277 poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(),
00278 theAlignRecordName);
00279
00280
00281
00282
00283
00284
00285
00286
00287 poolDbService->writeOne<AlignmentErrors>(alignmentErrors, poolDbService->currentTime(),
00288 theErrorRecordName);
00289 }
00290