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