CMS 3D CMS Logo

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