CMS 3D CMS Logo

TrackerSystematicMisalignments.cc
Go to the documentation of this file.
7 
10 
17 
21 
26 #include "CLHEP/Random/RandGauss.h"
27 
29 
30 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" // for enums TID/TIB/etc.
31 
32 // Database
35 
36 // -----------------------------------------------------------------
37 // 2010-05-20 Frank Meier
38 // Changed sign of z-correction, i.e. z-expansion is now an expansion
39 // made some variables constant, removed obviously dead code and comments
40 
42  : geomDetToken_(esConsumes()),
43  ptpToken_(esConsumes()),
44  topoToken_(esConsumes()),
45  aliToken_(esConsumes()),
46  aliErrorToken_(esConsumes()),
47  gprToken_(esConsumes()),
48  theAlignableTracker(nullptr) {
49  // use existing geometry
50  m_fromDBGeom = cfg.getUntrackedParameter<bool>("fromDBGeom");
51 
52  // constants
53  m_radialEpsilon = cfg.getUntrackedParameter<double>("radialEpsilon");
54  m_telescopeEpsilon = cfg.getUntrackedParameter<double>("telescopeEpsilon");
55  m_layerRotEpsilon = cfg.getUntrackedParameter<double>("layerRotEpsilon");
56  m_bowingEpsilon = cfg.getUntrackedParameter<double>("bowingEpsilon");
57  m_zExpEpsilon = cfg.getUntrackedParameter<double>("zExpEpsilon");
58  m_twistEpsilon = cfg.getUntrackedParameter<double>("twistEpsilon");
59  m_ellipticalEpsilon = cfg.getUntrackedParameter<double>("ellipticalEpsilon");
60  m_skewEpsilon = cfg.getUntrackedParameter<double>("skewEpsilon");
61  m_sagittaEpsilon = cfg.getUntrackedParameter<double>("sagittaEpsilon");
62 
63  m_ellipticalDelta = cfg.getUntrackedParameter<double>("ellipticalDelta");
64  m_skewDelta = cfg.getUntrackedParameter<double>("skewDelta");
65  m_sagittaDelta = cfg.getUntrackedParameter<double>("sagittaDelta");
66 
67  if (m_radialEpsilon > -990.0) {
68  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
69  }
70  if (m_telescopeEpsilon > -990.0) {
71  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
72  }
73  if (m_layerRotEpsilon > -990.0) {
74  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
75  }
76  if (m_bowingEpsilon > -990.0) {
77  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
78  }
79  if (m_zExpEpsilon > -990.0) {
80  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
81  }
82  if (m_twistEpsilon > -990.0) {
83  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
84  }
85  if (m_ellipticalEpsilon > -990.0) {
86  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
87  }
88  if (m_skewEpsilon > -990.0) {
89  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
90  }
91  if (m_sagittaEpsilon > -990.0) {
92  edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
93  }
94 
95  // get flag for suppression of blind movements
96  suppressBlindMvmts = cfg.getUntrackedParameter<bool>("suppressBlindMvmts");
97  if (suppressBlindMvmts) {
98  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
99  }
100 
101  // compatibility with old (weird) z convention
102  oldMinusZconvention = cfg.getUntrackedParameter<bool>("oldMinusZconvention");
103  if (oldMinusZconvention) {
104  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
105  } else {
106  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
107  }
108 }
109 
111 
113  //Retrieve tracker topology from geometry
114  const GeometricDet* geom = &setup.getData(geomDetToken_);
115  const PTrackerParameters& ptp = setup.getData(ptpToken_);
116  const TrackerTopology* tTopo = &setup.getData(topoToken_);
117 
119 
120  //take geometry from DB or randomly generate geometry
121  if (m_fromDBGeom) {
122  //build the tracker
123  const Alignments* alignments = &setup.getData(aliToken_);
124  const AlignmentErrorsExtended* alignmentErrors = &setup.getData(aliErrorToken_);
125  const Alignments* globalPositionRcd = &setup.getData(gprToken_);
126 
127  //apply the latest alignments
128  GeometryAligner aligner;
129  aligner.applyAlignments<TrackerGeometry>(&(*tracker),
130  &(*alignments),
131  &(*alignmentErrors),
132  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
133  }
134 
135  theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
136 
138 
139  // -------------- writing out to alignment record --------------
140  Alignments* myAlignments = theAlignableTracker->alignments();
141  AlignmentErrorsExtended* myAlignmentErrorsExtended = theAlignableTracker->alignmentErrors();
142 
143  // Store alignment[Error]s to DB
145  std::string theAlignRecordName = "TrackerAlignmentRcd";
146  std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
147 
148  // Call service
149  if (!poolDbService.isAvailable()) // Die if not available
150  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
151 
152  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
153  poolDbService->writeOne<AlignmentErrorsExtended>(
154  &(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName);
155 }
156 
158  const align::Alignables& comp = ali->components();
159  unsigned int nComp = comp.size();
160  //move then do for lower level object
161  //for issue of det vs detunit
162  bool usecomps = true;
163  if ((ali->alignableObjectId() == 2) && (nComp >= 1))
164  usecomps = false;
165  for (unsigned int i = 0; i < nComp; ++i) {
166  if (usecomps)
168  }
169 
170  // if suppression of blind mvmts: check if subdet is blind to a certain mode
171  bool blindToZ(false), blindToR(false);
172  if (suppressBlindMvmts) {
173  const int subdetid = ali->geomDetId().subdetId();
174  switch (subdetid) {
175  // TIB/TON blind to z
176  case SiStripDetId::TIB:
177  case SiStripDetId::TOB:
178  blindToZ = true;
179  break;
180  // TID/TEC blind to R
181  case SiStripDetId::TID:
182  case SiStripDetId::TEC:
183  blindToR = true;
184  break;
185  default:
186  break;
187  }
188  }
189 
190  const int level = ali->alignableObjectId();
191  if ((level == 1) || (level == 2)) {
192  const align::PositionType gP = ali->globalPosition();
193  const align::GlobalVector gVec = findSystematicMis(gP, blindToZ, blindToR);
194  ali->move(gVec);
195  }
196 }
197 
199  const bool blindToZ,
200  const bool blindToR) {
201  //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
202  // calculates shift for the current alignable
203  // all corrections are calculated w.r.t. the original geometry
204  double deltaX = 0.0;
205  double deltaY = 0.0;
206  double deltaZ = 0.0;
207  const double oldX = globalPos.x();
208  const double oldY = globalPos.y();
209  const double oldZ = globalPos.z();
210  const double oldPhi = globalPos.phi();
211  const double oldR = sqrt(globalPos.x() * globalPos.x() + globalPos.y() * globalPos.y());
212 
213  if (m_radialEpsilon > -990.0 && !blindToR) {
214  deltaX += m_radialEpsilon * oldX;
215  deltaY += m_radialEpsilon * oldY;
216  }
217  if (m_telescopeEpsilon > -990.0 && !blindToZ) {
218  deltaZ += m_telescopeEpsilon * oldR;
219  }
220  if (m_layerRotEpsilon > -990.0) {
221  // The following number was chosen such that the Layer Rotation systematic
222  // misalignment would not cause an overall rotation of the tracker.
223  const double Roffset = 57.0;
224  const double xP = oldR * cos(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
225  const double yP = oldR * sin(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
226  deltaX += (xP - oldX);
227  deltaY += (yP - oldY);
228  }
229  if (m_bowingEpsilon > -990.0 && !blindToR) {
230  const double trackeredgePlusZ = 271.846;
231  const double bowfactor = m_bowingEpsilon * (trackeredgePlusZ * trackeredgePlusZ - oldZ * oldZ);
232  deltaX += oldX * bowfactor;
233  deltaY += oldY * bowfactor;
234  }
235  if (m_zExpEpsilon > -990.0 && !blindToZ) {
236  deltaZ += oldZ * m_zExpEpsilon;
237  }
238  if (m_twistEpsilon > -990.0) {
239  const double xP = oldR * cos(oldPhi + m_twistEpsilon * oldZ);
240  const double yP = oldR * sin(oldPhi + m_twistEpsilon * oldZ);
241  deltaX += (xP - oldX);
242  deltaY += (yP - oldY);
243  }
244  if (m_ellipticalEpsilon > -990.0 && !blindToR) {
245  deltaX += oldX * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
246  deltaY += oldY * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
247  }
248  if (m_skewEpsilon > -990.0 && !blindToZ) {
249  deltaZ += m_skewEpsilon * cos(oldPhi + m_skewDelta);
250  }
251  if (m_sagittaEpsilon > -990.0) {
252  // deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
253  deltaX += oldR * m_sagittaEpsilon * sin(m_sagittaDelta);
254  deltaY += oldR * m_sagittaEpsilon * cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
255  }
256 
257  // Compatibility with old version <= 1.5
259  deltaZ = -deltaZ;
260 
261  align::GlobalVector gV(deltaX, deltaY, deltaZ);
262  return gV;
263 }
264 
265 // Plug in to framework
266 
268 
Vector3DBase< Scalar, GlobalTag >
personalPlayback.level
level
Definition: personalPlayback.py:22
AlignmentErrorsExtended.h
TrackerSystematicMisalignments::findSystematicMis
align::GlobalVector findSystematicMis(const align::PositionType &, const bool blindToZ, const bool blindToR)
Definition: TrackerSystematicMisalignments.cc:198
GlobalPositionRcd.h
mps_fire.i
i
Definition: mps_fire.py:428
TrackerSystematicMisalignments::m_telescopeEpsilon
double m_telescopeEpsilon
Definition: TrackerSystematicMisalignments.h:52
MessageLogger.h
TrackerGeometry.h
TrackerSystematicMisalignments.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
PTrackerParameters
Definition: PTrackerParameters.h:6
ESHandle.h
TrackerSystematicMisalignments::m_ellipticalEpsilon
double m_ellipticalEpsilon
Definition: TrackerSystematicMisalignments.h:57
TrackerSystematicMisalignments::m_zExpEpsilon
double m_zExpEpsilon
Definition: TrackerSystematicMisalignments.h:55
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrackerSystematicMisalignments::oldMinusZconvention
bool oldMinusZconvention
Definition: TrackerSystematicMisalignments.h:70
TrackerTopology
Definition: TrackerTopology.h:16
Alignable
Definition: Alignable.h:27
TrackerSystematicMisalignments::m_skewDelta
double m_skewDelta
Definition: TrackerSystematicMisalignments.h:63
TrackerSystematicMisalignments::m_sagittaDelta
double m_sagittaDelta
Definition: TrackerSystematicMisalignments.h:64
Alignments.h
TrackerSystematicMisalignments::m_fromDBGeom
bool m_fromDBGeom
Definition: TrackerSystematicMisalignments.h:49
DetectorGlobalPosition.h
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
SiStripDetId.h
PTrackerParameters.h
TrackerSystematicMisalignments::beginJob
void beginJob() override
Read ideal tracker geometry from DB.
Definition: TrackerSystematicMisalignments.cc:110
TrackerSystematicMisalignments::m_radialEpsilon
double m_radialEpsilon
Definition: TrackerSystematicMisalignments.h:51
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TrackerAlignmentErrorExtendedRcd.h
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
TrackerSystematicMisalignments::suppressBlindMvmts
bool suppressBlindMvmts
Definition: TrackerSystematicMisalignments.h:67
MakerMacros.h
PoolDBOutputService.h
TrackerSystematicMisalignments::ptpToken_
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Definition: TrackerSystematicMisalignments.h:41
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerTopologyRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignableTracker::alignmentErrors
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
Definition: AlignableTracker.cc:59
TrackerSystematicMisalignments::geomDetToken_
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
Definition: TrackerSystematicMisalignments.h:40
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
TrackerSystematicMisalignments::gprToken_
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
Definition: TrackerSystematicMisalignments.h:45
Service.h
TrackerSystematicMisalignments::m_skewEpsilon
double m_skewEpsilon
Definition: TrackerSystematicMisalignments.h:58
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlignableTracker
Definition: AlignableTracker.h:17
TrackerSystematicMisalignments::m_sagittaEpsilon
double m_sagittaEpsilon
Definition: TrackerSystematicMisalignments.h:59
GeometricDet
Definition: GeometricDet.h:31
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< Scalar, GlobalTag >
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
TrackerSystematicMisalignments::m_bowingEpsilon
double m_bowingEpsilon
Definition: TrackerSystematicMisalignments.h:54
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
DetId::Tracker
Definition: DetId.h:25
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
PTrackerParametersRcd.h
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
edm::Service< cond::service::PoolDBOutputService >
TrackerSystematicMisalignments::applySystematicMisalignment
void applySystematicMisalignment(Alignable *)
Definition: TrackerSystematicMisalignments.cc:157
Alignable::geomDetId
const DetId & geomDetId() const
Definition: Alignable.h:177
TrackerSystematicMisalignments::aliToken_
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > aliToken_
Definition: TrackerSystematicMisalignments.h:43
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
IdealGeometryRecord.h
TrackerAlignmentRcd.h
edm::EventSetup
Definition: EventSetup.h:58
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
TrackerSystematicMisalignments::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: TrackerSystematicMisalignments.h:42
Alignable::move
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
looper.cfg
cfg
Definition: looper.py:297
TrackerSystematicMisalignments
Definition: TrackerSystematicMisalignments.h:26
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
TrackerSystematicMisalignments::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TrackerSystematicMisalignments.cc:112
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
TrackerSystematicMisalignments::m_ellipticalDelta
double m_ellipticalDelta
Definition: TrackerSystematicMisalignments.h:62
TrackerSystematicMisalignments::theAlignableTracker
AlignableTracker * theAlignableTracker
Definition: TrackerSystematicMisalignments.h:46
AlignableTracker::alignments
Alignments * alignments() const override
Return alignments, sorted by DetId.
Definition: AlignableTracker.cc:42
GeometryAligner.h
DetId.h
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
EventSetup.h
TrackerSystematicMisalignments::aliErrorToken_
const edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > aliErrorToken_
Definition: TrackerSystematicMisalignments.h:44
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:17
AlignableTracker.h
cms::Exception
Definition: Exception.h:70
ParameterSet.h
SurveyDet.h
Alignable::globalPosition
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
Alignable::components
virtual const Alignables & components() const =0
Return vector of all direct components.
TrackerSystematicMisalignments::m_twistEpsilon
double m_twistEpsilon
Definition: TrackerSystematicMisalignments.h:56
TrackerSystematicMisalignments::m_layerRotEpsilon
double m_layerRotEpsilon
Definition: TrackerSystematicMisalignments.h:53
Alignments
Definition: Alignments.h:10
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
TrackerSystematicMisalignments::TrackerSystematicMisalignments
TrackerSystematicMisalignments(const edm::ParameterSet &)
Definition: TrackerSystematicMisalignments.cc:41
TrackerGeometry
Definition: TrackerGeometry.h:14