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 
68 
69  // configurables needed for the systematic misalignment
71 
76  double m_zExpEpsilon;
79  double m_skewEpsilon;
81 
82  //misalignment phases
84  double m_skewDelta;
86 
87  // flag to steer suppression of blind movements
89 
90  // flag for old z behaviour, version <= 1.5
92 };
93 
94 // -----------------------------------------------------------------
95 // 2010-05-20 Frank Meier
96 // Changed sign of z-correction, i.e. z-expansion is now an expansion
97 // made some variables constant, removed obviously dead code and comments
98 
100  : geomDetToken_(esConsumes()),
101  ptpToken_(esConsumes()),
102  topoToken_(esConsumes()),
103  aliToken_(esConsumes()),
104  aliErrorToken_(esConsumes()),
105  gprToken_(esConsumes()),
106  theAlignableTracker(nullptr) {
107  // use existing geometry
108  m_fromDBGeom = cfg.getUntrackedParameter<bool>("fromDBGeom");
109 
110  // constants
111  m_radialEpsilon = cfg.getUntrackedParameter<double>("radialEpsilon");
112  m_telescopeEpsilon = cfg.getUntrackedParameter<double>("telescopeEpsilon");
113  m_layerRotEpsilon = cfg.getUntrackedParameter<double>("layerRotEpsilon");
114  m_bowingEpsilon = cfg.getUntrackedParameter<double>("bowingEpsilon");
115  m_zExpEpsilon = cfg.getUntrackedParameter<double>("zExpEpsilon");
116  m_twistEpsilon = cfg.getUntrackedParameter<double>("twistEpsilon");
117  m_ellipticalEpsilon = cfg.getUntrackedParameter<double>("ellipticalEpsilon");
118  m_skewEpsilon = cfg.getUntrackedParameter<double>("skewEpsilon");
119  m_sagittaEpsilon = cfg.getUntrackedParameter<double>("sagittaEpsilon");
120 
121  m_ellipticalDelta = cfg.getUntrackedParameter<double>("ellipticalDelta");
122  m_skewDelta = cfg.getUntrackedParameter<double>("skewDelta");
123  m_sagittaDelta = cfg.getUntrackedParameter<double>("sagittaDelta");
124 
125  if (m_radialEpsilon > -990.0) {
126  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
127  }
128  if (m_telescopeEpsilon > -990.0) {
129  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
130  }
131  if (m_layerRotEpsilon > -990.0) {
132  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
133  }
134  if (m_bowingEpsilon > -990.0) {
135  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
136  }
137  if (m_zExpEpsilon > -990.0) {
138  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
139  }
140  if (m_twistEpsilon > -990.0) {
141  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
142  }
143  if (m_ellipticalEpsilon > -990.0) {
144  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
145  }
146  if (m_skewEpsilon > -990.0) {
147  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
148  }
149  if (m_sagittaEpsilon > -990.0) {
150  edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
151  }
152 
153  // get flag for suppression of blind movements
154  suppressBlindMvmts = cfg.getUntrackedParameter<bool>("suppressBlindMvmts");
155  if (suppressBlindMvmts) {
156  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
157  }
158 
159  // compatibility with old (weird) z convention
160  oldMinusZconvention = cfg.getUntrackedParameter<bool>("oldMinusZconvention");
161  if (oldMinusZconvention) {
162  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
163  } else {
164  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
165  }
166 }
167 
169 
171  //Retrieve tracker topology from geometry
172  const GeometricDet* geom = &setup.getData(geomDetToken_);
173  const PTrackerParameters& ptp = setup.getData(ptpToken_);
174  const TrackerTopology* tTopo = &setup.getData(topoToken_);
175 
177 
178  //take geometry from DB or randomly generate geometry
179  if (m_fromDBGeom) {
180  //build the tracker
181  const Alignments* alignments = &setup.getData(aliToken_);
182  const AlignmentErrorsExtended* alignmentErrors = &setup.getData(aliErrorToken_);
183  const Alignments* globalPositionRcd = &setup.getData(gprToken_);
184 
185  //apply the latest alignments
186  GeometryAligner aligner;
187  aligner.applyAlignments<TrackerGeometry>(&(*tracker),
188  &(*alignments),
189  &(*alignmentErrors),
190  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
191  }
192 
193  theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
194 
196 
197  // -------------- writing out to alignment record --------------
198  Alignments myAlignments = *(theAlignableTracker->alignments());
199  AlignmentErrorsExtended myAlignmentErrorsExtended = *(theAlignableTracker->alignmentErrors());
200 
201  // Store alignment[Error]s to DB
203  std::string theAlignRecordName = "TrackerAlignmentRcd";
204  std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
205 
206  // Call service
207  if (!poolDbService.isAvailable()) // Die if not available
208  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
209 
210  poolDbService->writeOneIOV<Alignments>(myAlignments, poolDbService->beginOfTime(), theAlignRecordName);
211  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
212  myAlignmentErrorsExtended, poolDbService->beginOfTime(), theErrorRecordName);
213 }
214 
216  const align::Alignables& comp = ali->components();
217  unsigned int nComp = comp.size();
218  //move then do for lower level object
219  //for issue of det vs detunit
220  bool usecomps = true;
221  if ((ali->alignableObjectId() == 2) && (nComp >= 1))
222  usecomps = false;
223  for (unsigned int i = 0; i < nComp; ++i) {
224  if (usecomps)
226  }
227 
228  // if suppression of blind mvmts: check if subdet is blind to a certain mode
229  bool blindToZ(false), blindToR(false);
230  if (suppressBlindMvmts) {
231  const int subdetid = ali->geomDetId().subdetId();
232  switch (subdetid) {
233  // TIB/TON blind to z
234  case SiStripDetId::TIB:
235  case SiStripDetId::TOB:
236  blindToZ = true;
237  break;
238  // TID/TEC blind to R
239  case SiStripDetId::TID:
240  case SiStripDetId::TEC:
241  blindToR = true;
242  break;
243  default:
244  break;
245  }
246  }
247 
248  const int level = ali->alignableObjectId();
249  if ((level == 1) || (level == 2)) {
250  const align::PositionType gP = ali->globalPosition();
251  const align::GlobalVector gVec = findSystematicMis(gP, blindToZ, blindToR);
252  ali->move(gVec);
253  }
254 }
255 
257  const bool blindToZ,
258  const bool blindToR) {
259  //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
260  // calculates shift for the current alignable
261  // all corrections are calculated w.r.t. the original geometry
262  double deltaX = 0.0;
263  double deltaY = 0.0;
264  double deltaZ = 0.0;
265  const double oldX = globalPos.x();
266  const double oldY = globalPos.y();
267  const double oldZ = globalPos.z();
268  const double oldPhi = globalPos.phi();
269  const double oldR = sqrt(globalPos.x() * globalPos.x() + globalPos.y() * globalPos.y());
270 
271  if (m_radialEpsilon > -990.0 && !blindToR) {
272  deltaX += m_radialEpsilon * oldX;
273  deltaY += m_radialEpsilon * oldY;
274  }
275  if (m_telescopeEpsilon > -990.0 && !blindToZ) {
276  deltaZ += m_telescopeEpsilon * oldR;
277  }
278  if (m_layerRotEpsilon > -990.0) {
279  // The following number was chosen such that the Layer Rotation systematic
280  // misalignment would not cause an overall rotation of the tracker.
281  const double Roffset = 57.0;
282  const double xP = oldR * cos(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
283  const double yP = oldR * sin(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
284  deltaX += (xP - oldX);
285  deltaY += (yP - oldY);
286  }
287  if (m_bowingEpsilon > -990.0 && !blindToR) {
288  const double trackeredgePlusZ = 271.846;
289  const double bowfactor = m_bowingEpsilon * (trackeredgePlusZ * trackeredgePlusZ - oldZ * oldZ);
290  deltaX += oldX * bowfactor;
291  deltaY += oldY * bowfactor;
292  }
293  if (m_zExpEpsilon > -990.0 && !blindToZ) {
294  deltaZ += oldZ * m_zExpEpsilon;
295  }
296  if (m_twistEpsilon > -990.0) {
297  const double xP = oldR * cos(oldPhi + m_twistEpsilon * oldZ);
298  const double yP = oldR * sin(oldPhi + m_twistEpsilon * oldZ);
299  deltaX += (xP - oldX);
300  deltaY += (yP - oldY);
301  }
302  if (m_ellipticalEpsilon > -990.0 && !blindToR) {
303  deltaX += oldX * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
304  deltaY += oldY * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
305  }
306  if (m_skewEpsilon > -990.0 && !blindToZ) {
307  deltaZ += m_skewEpsilon * cos(oldPhi + m_skewDelta);
308  }
309  if (m_sagittaEpsilon > -990.0) {
310  // deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
311  deltaX += oldR * m_sagittaEpsilon * sin(m_sagittaDelta);
312  deltaY += oldR * m_sagittaEpsilon * cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
313  }
314 
315  // Compatibility with old version <= 1.5
317  deltaZ = -deltaZ;
318 
319  align::GlobalVector gV(deltaX, deltaY, deltaZ);
320  return gV;
321 }
322 
323 // Plug in to framework
324 
326 
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
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.
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
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