Go to the documentation of this file.00001 #include "FWCore/Framework/interface/ESHandle.h"
00002 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00004
00005 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00006 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00007
00008 #include "CondFormats/Alignment/interface/Alignments.h"
00009 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
00010 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00011 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h"
00012
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016
00017 #include "DataFormats/DetId/interface/DetId.h"
00018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00019 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00020 #include "CLHEP/Random/RandGauss.h"
00021
00022 #include "Alignment/TrackerAlignment/plugins/TrackerSystematicMisalignments.h"
00023
00024 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00025
00026
00027 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00028 #include "FWCore/ServiceRegistry/interface/Service.h"
00029
00030
00031
00032
00033
00034
00035 TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::ParameterSet& cfg)
00036 : theAlignableTracker(0)
00037 {
00038
00039 m_fromDBGeom = cfg.getUntrackedParameter< bool > ("fromDBGeom");
00040
00041
00042 m_radialEpsilon = cfg.getUntrackedParameter< double > ("radialEpsilon");
00043 m_telescopeEpsilon = cfg.getUntrackedParameter< double > ("telescopeEpsilon");
00044 m_layerRotEpsilon = cfg.getUntrackedParameter< double > ("layerRotEpsilon");
00045 m_bowingEpsilon = cfg.getUntrackedParameter< double > ("bowingEpsilon");
00046 m_zExpEpsilon = cfg.getUntrackedParameter< double > ("zExpEpsilon");
00047 m_twistEpsilon = cfg.getUntrackedParameter< double > ("twistEpsilon");
00048 m_ellipticalEpsilon = cfg.getUntrackedParameter< double > ("ellipticalEpsilon");
00049 m_skewEpsilon = cfg.getUntrackedParameter< double > ("skewEpsilon");
00050 m_saggitaEpsilon = cfg.getUntrackedParameter< double > ("saggitaEpsilon");
00051
00052 if (m_radialEpsilon > -990.0){
00053 edm::LogWarning("MisalignedTracker") << "Applying radial ...";
00054 }
00055 if (m_telescopeEpsilon > -990.0){
00056 edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
00057 }
00058 if (m_layerRotEpsilon > -990.0){
00059 edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
00060 }
00061 if (m_bowingEpsilon > -990.0){
00062 edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
00063 }
00064 if (m_zExpEpsilon > -990.0){
00065 edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
00066 }
00067 if (m_twistEpsilon > -990.0){
00068 edm::LogWarning("MisalignedTracker") << "Applying twist ...";
00069 }
00070 if (m_ellipticalEpsilon > -990.0){
00071 edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
00072 }
00073 if (m_skewEpsilon > -990.0){
00074 edm::LogWarning("MisalignedTracker") << "Applying skew ...";
00075 }
00076 if (m_saggitaEpsilon > -990.0){
00077 edm::LogWarning("MisalignedTracker") << "Applying saggita ...";
00078 }
00079
00080
00081 suppressBlindMvmts = cfg.getUntrackedParameter< bool > ("suppressBlindMvmts");
00082 if (suppressBlindMvmts)
00083 {
00084 edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
00085 }
00086
00087
00088 oldMinusZconvention = cfg.getUntrackedParameter< bool > ("oldMinusZconvention");
00089 if (oldMinusZconvention)
00090 {
00091 edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
00092 }
00093 else
00094 {
00095 edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
00096 }
00097
00098 }
00099
00100 void TrackerSystematicMisalignments::beginJob()
00101 {
00102
00103 }
00104
00105
00106 void TrackerSystematicMisalignments::analyze(const edm::Event& event, const edm::EventSetup& setup){
00107
00108
00109 edm::ESHandle<GeometricDet> geom;
00110 setup.get<IdealGeometryRecord>().get(geom);
00111 TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom);
00112
00113
00114 if (m_fromDBGeom){
00115
00116 edm::ESHandle<Alignments> alignments;
00117 edm::ESHandle<AlignmentErrors> alignmentErrors;
00118
00119 setup.get<TrackerAlignmentRcd>().get(alignments);
00120 setup.get<TrackerAlignmentErrorRcd>().get(alignmentErrors);
00121
00122
00123 GeometryAligner aligner;
00124 aligner.applyAlignments<TrackerGeometry>( &(*tracker), &(*alignments), &(*alignmentErrors), AlignTransform() );
00125
00126 }
00127
00128 theAlignableTracker = new AlignableTracker(&(*tracker));
00129
00130 applySystematicMisalignment( &(*theAlignableTracker) );
00131
00132
00133 Alignments* myAlignments = theAlignableTracker->alignments() ;
00134 AlignmentErrors* myAlignmentErrors = theAlignableTracker->alignmentErrors() ;
00135
00136
00137 edm::Service<cond::service::PoolDBOutputService> poolDbService;
00138 std::string theAlignRecordName = "TrackerAlignmentRcd";
00139 std::string theErrorRecordName = "TrackerAlignmentErrorRcd";
00140
00141
00142 if( !poolDbService.isAvailable() )
00143 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
00144
00145 poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
00146 poolDbService->writeOne<AlignmentErrors>(&(*myAlignmentErrors), poolDbService->beginOfTime(), theErrorRecordName);
00147 }
00148
00149 void TrackerSystematicMisalignments::applySystematicMisalignment(Alignable* ali)
00150 {
00151
00152 const align::Alignables& comp = ali->components();
00153 unsigned int nComp = comp.size();
00154
00155
00156 bool usecomps = true;
00157 if ((ali->alignableObjectId()==2)&&(nComp>=1)) usecomps = false;
00158 for (unsigned int i = 0; i < nComp; ++i){
00159 if (usecomps) applySystematicMisalignment(comp[i]);
00160 }
00161
00162
00163 bool blindToZ(false), blindToR(false);
00164 if (suppressBlindMvmts)
00165 {
00166 const int subdetid = ali->geomDetId().subdetId();
00167 switch(subdetid)
00168 {
00169
00170 case SiStripDetId::TIB:
00171 case SiStripDetId::TOB:
00172 blindToZ = true;
00173 break;
00174
00175 case SiStripDetId::TID:
00176 case SiStripDetId::TEC:
00177 blindToR = true;
00178 break;
00179 default:
00180 break;
00181 }
00182 }
00183
00184 const int level = ali->alignableObjectId();
00185 if ((level == 1)||(level == 2)){
00186 const align::PositionType gP = ali->globalPosition();
00187 const align::GlobalVector gVec = findSystematicMis( gP, blindToZ, blindToR);
00188 ali->move( gVec );
00189 }
00190 }
00191
00192 align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos, const bool blindToZ, const bool blindToR ){
00193
00194
00195
00196 double deltaX = 0.0;
00197 double deltaY = 0.0;
00198 double deltaZ = 0.0;
00199 const double oldX = globalPos.x();
00200 const double oldY = globalPos.y();
00201 const double oldZ = globalPos.z();
00202 const double oldPhi = globalPos.phi();
00203 const double oldR = sqrt(globalPos.x()*globalPos.x() + globalPos.y()*globalPos.y());
00204
00205 if (m_radialEpsilon > -990.0 && !blindToR){
00206 deltaX += m_radialEpsilon*oldX;
00207 deltaY += m_radialEpsilon*oldY;
00208 }
00209 if (m_telescopeEpsilon > -990.0 && !blindToZ){
00210 deltaZ += m_telescopeEpsilon*oldR;
00211 }
00212 if (m_layerRotEpsilon > -990.0){
00213
00214
00215 const double Roffset = 57.0;
00216 const double xP = oldR*cos(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
00217 const double yP = oldR*sin(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
00218 deltaX += (xP - oldX);
00219 deltaY += (yP - oldY);
00220 }
00221 if (m_bowingEpsilon > -990.0 && !blindToR){
00222 const double trackeredgePlusZ=271.846;
00223 const double bowfactor=m_bowingEpsilon*(trackeredgePlusZ*trackeredgePlusZ-oldZ*oldZ);
00224 deltaX += oldX*bowfactor;
00225 deltaY += oldY*bowfactor;
00226 }
00227 if (m_zExpEpsilon > -990.0 && !blindToZ){
00228 deltaZ += oldZ*m_zExpEpsilon;
00229 }
00230 if (m_twistEpsilon > -990.0){
00231 const double xP = oldR*cos(oldPhi+m_twistEpsilon*oldZ);
00232 const double yP = oldR*sin(oldPhi+m_twistEpsilon*oldZ);
00233 deltaX += (xP - oldX);
00234 deltaY += (yP - oldY);
00235 }
00236 if (m_ellipticalEpsilon > -990.0 && !blindToR){
00237 deltaX += oldX*m_ellipticalEpsilon*cos(2.0*oldPhi);
00238 deltaY += oldY*m_ellipticalEpsilon*cos(2.0*oldPhi);
00239 }
00240 if (m_skewEpsilon > -990.0 && !blindToZ){
00241 deltaZ += m_skewEpsilon*cos(oldPhi);
00242 }
00243 if (m_saggitaEpsilon > -990.0){
00244
00245 deltaY += oldR*m_saggitaEpsilon;
00246 }
00247
00248
00249 if (oldMinusZconvention) deltaZ = -deltaZ;
00250
00251 align::GlobalVector gV( deltaX, deltaY, deltaZ );
00252 return gV;
00253 }
00254
00255
00256
00257 #include "FWCore/Framework/interface/MakerMacros.h"
00258
00259 DEFINE_FWK_MODULE(TrackerSystematicMisalignments);