ATLAS Offline Software
MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 
7 #include <GeoModelHelpers/TransformToStringConverter.h>
10 #include <GaudiKernel/SystemOfUnits.h>
11 
12 #include <optional>
13 
14 
15 #ifndef SIMULATIONBASE
17 # include "Acts/Surfaces/TrapezoidBounds.hpp"
18 # include "Acts/Surfaces/LineBounds.hpp"
19 # include "Acts/Surfaces/Surface.hpp"
20 #endif
21 
22 using namespace ActsTrk;
23 
24 namespace MuonGMR4 {
25 std::ostream& operator<<(std::ostream& ostr, const MuonGMR4::MdtReadoutElement::parameterBook& pars) {
26  ostr << std::endl;
27  ostr << " // Chamber half- length (min/max): "<<pars.shortHalfX<<"/"<<pars.longHalfX
28  <<", half-width "<<pars.halfY<<", height: "<<pars.halfHeight;
29  ostr << " // Number of tube layers " << pars.tubeLayers.size()<< std::endl;
30  ostr << " // Tube pitch: " << pars.tubePitch
31  << " wall thickness: " << pars.tubeWall
32  << " inner radius: " << pars.tubeInnerRad
33  << " endplug: "<<pars.endPlugLength
34  << " deadlength: "<<pars.deadLength<< std::endl;
35  for (const MdtTubeLayerPtr& layer : pars.tubeLayers) {
36  ostr << " // **** "<< Amg::toString(layer->tubeTransform(0).translation(), 2)<<std::endl;
37  }
38  return ostr;
39 }
40 MdtReadoutElement::~MdtReadoutElement() = default;
41 MdtReadoutElement::MdtReadoutElement(defineArgs&& args)
43  m_pars{std::move(args)} {
44 }
46 Identifier MdtReadoutElement::measurementId(const IdentifierHash& measHash) const {
48  layerNumber(measHash) + 1,
49  tubeNumber(measHash) + 1);
50 }
54  if (!numLayers() || !numTubesInLay()) {
55  ATH_MSG_FATAL("The readout element "<< idHelperSvc()->toStringDetEl(identify())<<" has no tubes. Please check "<<std::endl<<m_pars);
56  return StatusCode::FAILURE;
57  }
58  if (m_pars.tubePitch<=tubeRadius()) {
59  ATH_MSG_FATAL("The tubes of "<<idHelperSvc()->toStringDetEl(identify())<<" will fall together on a single point. Please check "<<std::endl<<m_pars);
60  return StatusCode::FAILURE;
61  }
62 #ifndef SIMULATIONBASE
63  ATH_CHECK(planeSurfaceFactory(geoTransformHash(), m_pars.boundFactory->makeBounds<Acts::TrapezoidBounds>(m_pars.shortHalfX,
66  m_pars.halfY)));
67 #endif
68 
71  std::optional<Amg::Vector3D> prevLayPos{std::nullopt};
72 
73  for (unsigned int lay =1 ; lay <= numLayers() ; ++lay) {
75  const IdentifierHash layHash = measurementHash(lay,0);
76  ATH_CHECK(insertTransform<MdtReadoutElement>(layHash));
77 #ifdef SIMULATIONBASE_REMOVEPLANESURFACE
78  ATH_CHECK(planeSurfaceFactory(layHash, m_pars.boundFactory->makeBounds<Acts::TrapezoidBounds>(m_pars.shortHalfX,
80  m_pars.halfY)));
81 #endif
82  std::optional<Amg::Vector3D> prevTubePos{std::nullopt};
85 
86  for (unsigned int tube = 1; tube <= numTubesInLay(); ++ tube) {
87  const IdentifierHash idHash = measurementHash(lay,tube);
88  if (m_pars.removedTubes.count(idHash)) {
89  prevTubePos = std::nullopt;
90  continue;
91  }
92  ATH_CHECK(insertTransform<MdtReadoutElement>(idHash));
93 #ifndef SIMULATIONBASE
94  ATH_CHECK(strawSurfaceFactory(idHash, m_pars.boundFactory->makeBounds<Acts::LineBounds>(innerTubeRadius(), 0.5*tubeLength(idHash))));
95 #endif
96  GeoTrf::Transform3D tubeFrame = layer.tubeTransform(tubeNumber(idHash));
98  const AmgSymMatrix(3) tubeRot = tubeFrame.linear();
99  if (std::abs(tubeRot.determinant()- 1.) > std::numeric_limits<float>::epsilon()){
100  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Transformation matrix is not a pure rotation for "<<
101  idHelperSvc()->toStringDetEl(identify())<<" in layer: "<<lay<<", tube: "<<tube
102  <<Amg::toString(tubeFrame));
103  return StatusCode::FAILURE;
104  }
106  const Amg::Vector3D tubePos = tubeFrame.translation();
107 
108  constexpr double pitchTolerance = 20. * Gaudi::Units::micrometer;
109  if (prevTubePos) {
110  const double dR = std::abs((tubePos - (*prevTubePos)).z());
111  if (std::abs(dR - tubePitch()) > pitchTolerance) {
112  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Detected irregular tube in "<<
113  idHelperSvc()->toStringDetEl(identify())<<" in layer: "<<lay<<", tube: "<<tube
114  <<". Expected tube pitch: "<<tubePitch()<<" measured tube pitch: "
115  <<dR<<" tube position: "<<Amg::toString(tubePos,2)
116  <<" previous: "<<Amg::toString((*prevTubePos), 2));
117  return StatusCode::FAILURE;
118  }
119  }
120  if (prevLayPos && tube == 1) {
121  const double dR = (tubePos - (*prevLayPos)).mag();
122  if (std::abs(dR - tubePitch()) > pitchTolerance) {
123  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Detected irregular layer pitch in "<<
124  idHelperSvc()->toStringDetEl(identify())<<" for layer "<<lay
125  <<". Expected tube pitch: "<<tubePitch()<<" measured tube pitch: "
126  <<dR<<" tube position: "<<Amg::toString(tubePos,2)
127  <<" previous:"<<Amg::toString((*prevLayPos), 2));
128  }
129  }
130  if (tube == 1) {
131  prevLayPos = std::make_optional<Amg::Vector3D>(tubePos);
132  }
133  prevTubePos = std::make_optional<Amg::Vector3D>(tubePos);
134  }
135  }
136 #ifndef SIMULATIONBASE
137  m_pars.boundFactory.reset();
138 #endif
139  return StatusCode::SUCCESS;
140 }
141 
143  const IdentifierHash& hash) const {
144  return localToGlobalTrans(ctx, hash).translation();
145 }
146 
147 Amg::Vector3D MdtReadoutElement::localTubePos(const IdentifierHash& hash) const {
148  return toTubeFrame(hash).translation();
149 }
151  const IdentifierHash& hash) const {
152  return localToGlobalTrans(ctx, hash) *
153  (0.5*activeTubeLength(hash) * m_pars.readoutSide * Amg::Vector3D::UnitZ());
154 }
156  const IdentifierHash& hash) const {
157  return localToGlobalTrans(ctx, hash) *
158  (-0.5*activeTubeLength(hash) * m_pars.readoutSide * Amg::Vector3D::UnitZ());
159 }
161  const unsigned int layer = layerNumber(hash);
162  const MdtTubeLayer& zeroT{*m_pars.tubeLayers[layer]};
163  return zeroT.layerTransform();
164 }
166  const unsigned int layer = layerNumber(hash);
167  const unsigned int tube = tubeNumber(hash);
168  const MdtTubeLayer& zeroT{*m_pars.tubeLayers[layer]};
169  return zeroT.tubeTransform(tube);
170 }
171 double MdtReadoutElement::activeTubeLength(const IdentifierHash& hash) const {
172  const unsigned int layer = layerNumber(hash);
173  const unsigned int tube = tubeNumber(hash);
174  const MdtTubeLayer& zeroT{*m_pars.tubeLayers[layer]};
175  return 2. * zeroT.tubeHalfLength(tube);
176 }
177 double MdtReadoutElement::uncutTubeLength(const IdentifierHash& tubeHash) const {
178  const unsigned int layer = layerNumber(tubeHash);
179  const unsigned int tube = tubeNumber(tubeHash);
180  const MdtTubeLayer& zeroT{*m_pars.tubeLayers[layer]};
181  return 2.*zeroT.uncutHalfLength(tube);
182 }
183 double MdtReadoutElement::tubeLength(const IdentifierHash& hash) const {
184  return activeTubeLength(hash) + 2.*m_pars.deadLength;
185 }
186 double MdtReadoutElement::wireLength(const IdentifierHash& hash) const {
187  return tubeLength(hash) - 2.*m_pars.endPlugLength;
188 }
190  const IdentifierHash& measHash,
191  const Amg::Vector3D& globPoint) const {
192  return distanceToReadout(measHash, globalToLocalTrans(ctx, measHash) * globPoint);
193 
194 }
195 double MdtReadoutElement::distanceToReadout(const IdentifierHash& measHash,
196  const Amg::Vector3D& localPoint) const {
198  const unsigned int layer = layerNumber(measHash);
199  const unsigned int tube = tubeNumber(measHash);
200  const MdtTubeLayer& zeroT{*m_pars.tubeLayers[layer]};
201  const double readOutPos = m_pars.readoutSide * zeroT.tubeHalfLength(tube);
202  return std::abs(readOutPos - localPoint.z());
203 }
204 
206  m_reOtherMl = other;
207 }
208 
210  return alignableTransform()->getDefTransform().inverse()*
211  getMaterialGeom()->getParent()->getX() *
212  getMaterialGeom()->getX();
213 }
214 
216  /* The fix point is the point that's closest to the interaction point.
217  / Recall that the readout element origin is expressed in the geometric centre &
218  the x-axis points upwards. The point is then transformed into the Muon station frame */
219  const MdtReadoutElement* refEle{multilayer() == 1 ? this : m_reOtherMl};
220  return refEle->asBuiltRefFrame()*(-0.5*( refEle->moduleThickness() *Amg::Vector3D::UnitX() +
221  (stationEta() >0 || !isBarrel() ? 1. : -1.)*refEle->moduleHeight() * Amg::Vector3D::UnitZ()));
222 }
223 #ifndef SIMULATIONBASE
225  const IdentifierHash& tubeHash,
226  const Amg::Vector3D& wireEnd,
227  const tubeSide_t side) const {
228 
229 
230  ATH_MSG_VERBOSE( "Applying as-built parameters for chamber " << idHelperSvc()->toString(measurementId(tubeHash)));
231 
232 
234  using multilayer_t = MdtAsBuiltPar::multilayer_t;
235  const multilayer_t ml = (multilayer() == 1) ? multilayer_t::ML1 : multilayer_t::ML2;
236 
237  const IdentifierHash refLayer{measurementHash((ml == multilayer_t::ML1) ? numLayers() : 1, 1)};
238  const Amg::Vector3D refTube{localTubePos(refLayer)};
239 
240 
241  const double sideSign = 0.5*(1.- 2.*(side ==tubeSide_t::NEG));
242  // Compute the reference for the as-built parameters
243  const Amg::Vector3D reference_point = asBuiltRefFrame() *
244  Amg::Vector3D {refTube.x() + (1. - 2.*(ml == multilayer_t::ML2)) * tubeRadius(),
245  sideSign*uncutTubeLength(refLayer),
246  -0.5*moduleHeight()};
247  ATH_MSG_VERBOSE("AMDB transform "<<" "<<idHelperSvc()->toStringDetEl(identify())<<
248  " "<<GeoTrf::toString(asBuiltRefFrame(), true)<<", reference point: "<<Amg::toString(reference_point));
249 
250 
251  const int tubeLayer = layerNumber(tubeHash);
252  const int tube = tubeNumber(tubeHash);
253  const int layer_delta = ml == multilayer_t::ML1 ? numLayers() - tubeLayer : tubeLayer +1;
254 
255 
256  // Get the As-Built parameters for this ML and side of the chamber
257  const double zpitch = params.zpitch(ml, side);
258  const double ypitch = params.ypitch(ml, side);
259  const double stagg = params.stagg(ml, side);
260  const double alpha = params.alpha(ml, side);
261  const double y0 = params.y0(ml, side);
262  const double z0 = params.z0(ml, side);
263 
264  const Amg::Transform3D planeRot{Amg::getRotateX3D(-alpha)};
265  ATH_MSG_VERBOSE("Rotation angle "<<(alpha/Gaudi::Units::deg));
266 
267  // Find the vector from the reference_point to the endplug
268  // 0 for layer 1 and 3, 1 for layer 2 and 4
269  const double offset_stagg = 0.5 * zpitch * stagg * ( (layer_delta-1) % 2);
270  const Amg::Vector3D endPlug = planeRot * Amg::Vector3D{0.,
271  tube* zpitch + offset_stagg,
272  (layer_delta-1) * ypitch};
273 
274  // Calculate x position, which varies for endcap chambers
275  const double xshift = sideSign*(uncutTubeLength(tubeHash) - uncutTubeLength(refLayer));
276  ATH_MSG_VERBOSE("Off set staggering "<<offset_stagg<<", layer_delta: "<<layer_delta<<", zpitch: "<<zpitch<<", ypitch: "<<ypitch
277  <<", xshift: "<<xshift);
278 
279  Amg::Vector3D ret(reference_point.x() + xshift,
280  reference_point.y() + z0 + endPlug.y(),
281  reference_point.z() + y0 + endPlug.z());
282 
283 
284  if ((ret - wireEnd).mag() > 3. * Gaudi::Units::mm) {
285  ATH_MSG_WARNING("Large as-built correction for chamber " << idHelperSvc()->toString(measurementId(tubeHash))
286  << ", side "<< (side == tubeSide_t::POS ? "positive" : "negative")
287  << ", endpoint "<<Amg::toString(wireEnd)<<", return: "<<Amg::toString(ret));
288  }
289  ATH_MSG_VERBOSE((side == tubeSide_t::POS ? "positive" : "negative")<<" wire end has moved from "
290  <<Amg::toString(wireEnd)<<" to "<<Amg::toString(ret)<<" End plug: "<<Amg::toString(endPlug));
291  return ret;
292 }
293 
295  const Amg::Vector3D& localTubeEndPoint,
296  const Amg::Vector3D& fixedPoint,
297  const double chamberThickness) const {
298 
299  using Parameter = BLinePar::Parameter;
300  Amg::Vector3D deformedPos{localTubeEndPoint};
301  // MDT deformations like tube bow: bz,bp,bn bend the tube while the wire endpoints are not affected
302  // => the wire keeps it's nominal straight line trajectory but it is not concentric to the tube
303  // ==> in this function bz, bp and bn are ignored or set to 0
304  // MDT deformations that extend/contract the wire longitudinally (while keeping it straight):
305  // delta_s from eg and tr are irrelevant for the tube geometry
306  // and for the wire trajectory => set to 0 here
307  // (should be applied as a correction to the
308  // tube lenght => tube surface bounds
309  // =++>>>> effect in tracking just through the gravitational sagging TOTALLY NEGLIGIBLE=> ignore)
310  // pg is irrelevant for tracking purposes and (at least for the endcaps) is applies to the internal bars only, not to the tubes !!!
311  // =++>>>> IGNORE IT
312  // ep,en: bend the tube by moving (differently) the endplugs ===> the wire straight trajectory is moved w.r.t. the nominal one
313  // in addition the tubes keep their nominal position at the center => the wire is not concentric to
314  // the tube delta_s from ep,en must also be considered for the implementation of the realistic tube
315  // trajectory induced by ep,en
316  // tw,sp,sn,pg (for deltaT and deltaZ) are geometrical effects, that impact on tracking and keep the wire straight.
317  const double chamberHeight = std::max(moduleHeight(), m_reOtherMl->moduleHeight());
318 
319 
320  // NOTE s0,z0,t0 are the coord. in the amdb frame of this point: the origin of the frame can be different than the fixed point for
321  // deformations s0mdt,z0mdt,t0mdt
322  // (always equal to the point at lowest t,z and s=0 of the MDT stack)
323  ATH_MSG_VERBOSE( "** In "<<__func__<<" - moduleWidthS " << moduleWidthS()<<", moduleWidthL: "
324  <<moduleWidthL() <<", height: "<<chamberHeight<<", thickness: " <<chamberThickness << "." );
325  ATH_MSG_VERBOSE( "** In "<<__func__<<" - going to correct for B-line the position of Point at " << Amg::toString(localTubeEndPoint));
326 
327  double s0mdt = localTubeEndPoint.x(); // always I think !
328  if (std::abs(fixedPoint.x()) > 0.01) {
329  s0mdt = localTubeEndPoint.x() - fixedPoint.x();
330  }
331  double z0mdt = localTubeEndPoint.y();
332  // unless in the D section of this station there's a dy diff. from 0 for the innermost MDT multilayer (sometimes
333  // in the barrel)
334  // unless in the D section of this station there's a dz diff. from 0 for the innermost MDT multilayer (often in barrel)
335  if (std::abs(fixedPoint.y()) > 0.01) {
336  z0mdt = localTubeEndPoint.y() - fixedPoint.y();
337  }
338  double t0mdt = localTubeEndPoint.z();
339  if (std::abs(fixedPoint.z()) > 0.01) {
340  t0mdt = localTubeEndPoint.z() - fixedPoint.z();
341  }
342  if (z0mdt < 0 || t0mdt < 0) {
343  ATH_MSG_WARNING(""<<__func__<<": correcting the local position of a point outside the mdt station (2 multilayers) volume -- RE "
344  << idHelperSvc()->toStringDetEl(identify()) << " local point: szt=" <<Amg::toString(localTubeEndPoint)
345  << " fixedPoint " <<Amg::toString(fixedPoint)<<", z0mdt: "<<z0mdt<<", t0mdt"<<t0mdt);
346  }
347  ATH_MSG_VERBOSE( "** In "<<__func__<<" - correct for offset of B-line fixed point " << s0mdt << " " << z0mdt << " " << t0mdt);
348 
349  constexpr double amdbMargin = 1.*Gaudi::Units::cm;
350  const double width_actual = moduleWidthS() - amdbMargin + (moduleWidthL() - moduleWidthS()) * (z0mdt / chamberHeight);
351  const double s_rel = s0mdt / (width_actual / 2.);
352  const double z_rel = (z0mdt - chamberHeight / 2.) / (chamberHeight / 2.);
353  const double t_rel = (t0mdt - chamberThickness / 2.) / (chamberThickness / 2.);
354 
355  ATH_MSG_VERBOSE( "** In "<<__func__<<" - width_actual: "<<width_actual<<", s_rel: "<<s_rel<<", z_rel: "<<z_rel
356  <<", t_rel:" << t_rel );
357  double ds{0.},dz{0.},dt{0.};
358 
359  // sp, sn - cross plate sag out of plane
360  if ( bline.getParameter(Parameter::sp) || bline.getParameter(Parameter::sn)) {
361  double ztmp = z_rel * z_rel - 1;
362  dt += 0.5 * (bline.getParameter(Parameter::sp) + bline.getParameter(Parameter::sn)) * ztmp
363  + 0.5 * (bline.getParameter(Parameter::sp) - bline.getParameter(Parameter::sn)) * ztmp * s_rel;
364  }
365 
366  // tw - twist
367  if (bline.getParameter(Parameter::tw)) {
368  dt -= bline.getParameter(Parameter::tw) * s_rel * z_rel;
369  dz += bline.getParameter(Parameter::tw) * s_rel * t_rel * chamberThickness / chamberHeight;
370  ATH_MSG_VERBOSE( "** In "<<__func__<<": tw=" << bline.getParameter(Parameter::tw) << " dt: "<<dt<<", dz: "<< dz );
371  }
372 
373  constexpr double expansionScale = BLinePar::expansionScale;
374  // eg - global expansion
375  if (bline.getParameter(Parameter::eg)) {
376  double egppm = bline.getParameter(Parameter::eg) * expansionScale;
377  ds += 0.;
378  dz += z0mdt * egppm;
379  dt += t0mdt * egppm;
380  }
381 
382  // ep, en - local expansion
383  //
384  // Imporant note: the chamber height and length, as they denoted in Christoph's talk,
385  // correspond to thickness and height parameters of this function;
386  //
387 
388  if (bline.getParameter(Parameter::ep) || bline.getParameter(Parameter::en)) {
389  const double ep = bline.getParameter(Parameter::ep) * expansionScale;
390  const double en = bline.getParameter(Parameter::en) * expansionScale;
391  const double phi = 0.5 * (ep + en) * s_rel * s_rel + 0.5 * (ep - en) * s_rel;
392  const double localDt = phi * (t0mdt - chamberThickness / 2.);
393  const double localDz = phi * (z0mdt - chamberHeight / 2.);
394  dt += localDt;
395  dz += localDz;
396  }
397 
398  ATH_MSG_VERBOSE( "posOnDefChamStraighWire: ds="<<ds<<",z="<<dz<<",t="<<dt);
399  deformedPos[0] = localTubeEndPoint[0] + ds;
400  deformedPos[1] = localTubeEndPoint[1] + dz;
401  deformedPos[2] = localTubeEndPoint[2] + dt;
402  return deformedPos;
403 }
404 #endif
406  const ActsTrk::DetectorAlignStore* store) const {
407 #ifdef SIMULATIONBASE
408  ATH_MSG_VERBOSE("No deformed transformation available "<<idHelperSvc()->toString(measurementId(tubeHash))
409  <<"store address to make the compiler happy: "<<store);
410  return Amg::Transform3D::Identity();
411 #else
412  if (!store || !store->internalAlignment) {
414  ATH_MSG_VERBOSE("No deformed transformation available "<<idHelperSvc()->toString(measurementId(tubeHash)));
415  return Amg::Transform3D::Identity();
416  }
417  using ChamberDistortions = MdtAlignmentStore::chamberDistortions;
418 
420  const ChamberDistortions distortPars = static_cast<const MdtAlignmentStore&>(*store->internalAlignment).getDistortion(identify());
421  if (!distortPars) {
422  ATH_MSG_VERBOSE("No set of deformation parameters is in the DB for "<<idHelperSvc()->toString(measurementId(tubeHash)));
423  return Amg::Transform3D::Identity();
424  }
425 
426  const Amg::Vector3D fixedPoint{bLineReferencePoint()};
427 
428 
429  const double height = std::max(moduleHeight(), m_reOtherMl->moduleHeight()) -
430  (tubePitch() - 2. * tubeRadius());
431 
432  const Amg::Transform3D toAMDB{asBuiltRefFrame()};
435  const double relSign = (multilayer() == 1 ? -1. : 1.);
436 
437  const double modHalfThick{0.5*relSign*moduleThickness()},
438  modHalTHickO{-0.5*relSign*m_reOtherMl->moduleThickness()};
439 
440  const double thickness = relSign*( (toAMDB* (modHalfThick*Amg::Vector3D::UnitX())) -
441  (m_reOtherMl->asBuiltRefFrame()*(modHalTHickO* Amg::Vector3D::UnitX()))).z();
442 
443 
444  Amg::Vector3D idealTube = localTubePos(tubeHash);
446  idealTube[Amg::y] = 0.;
447 
448  Amg::Vector3D positiveEnd = toAMDB * (idealTube + 0.5 * uncutTubeLength(tubeHash) * Amg::Vector3D::UnitY());
449  Amg::Vector3D negativeEnd = toAMDB * (idealTube - 0.5 * uncutTubeLength(tubeHash) * Amg::Vector3D::UnitY());
451  if (distortPars.asBuilt) {
452  positiveEnd = wireEndpointAsBuilt(*distortPars.asBuilt, tubeHash, positiveEnd, tubeSide_t::POS);
453  negativeEnd = wireEndpointAsBuilt(*distortPars.asBuilt, tubeHash, negativeEnd, tubeSide_t::NEG);
454  }
455  Amg::Vector3D positiveEndBline{positiveEnd};
456  Amg::Vector3D negativeEndBline{negativeEnd};
457  if (distortPars.bLine) {
458  positiveEndBline = applyBlineCorrections(*distortPars.bLine, positiveEndBline, fixedPoint, thickness);
459  negativeEndBline = applyBlineCorrections(*distortPars.bLine, negativeEndBline, fixedPoint, thickness);
460  }
461 
462  ATH_MSG_VERBOSE("Calculate the deformation parameters of "<<idHelperSvc()->toString(measurementId(tubeHash))
463  <<", ideal tube "<<Amg::toString(idealTube)
464  <<", fixed point "<<Amg::toString(fixedPoint)
465  <<"/ "<<Amg::toString(alignableTransform()->getDefTransform() * fixedPoint)
466  <<", thickness: "<<thickness<<", height: "<<height);
467 
468  const Amg::Transform3D fromAMDB{toAMDB.inverse()};
470  positiveEnd = fromAMDB * positiveEnd;
471  negativeEnd = fromAMDB * negativeEnd;
472  positiveEndBline = fromAMDB * positiveEndBline;
473  negativeEndBline = fromAMDB * negativeEndBline;
474 
475  // Calculate deformation. Make sure that the wire length stays the same.
476  // Code in positionOnDeformedChamber does not provide this by default.
477  // Break transformation into translation of the wire center and the rotation of the wire
478  // Move to the coordinate system originated at the wire center, then rotate the wire, then
479  // move wire center to the new position
480  const Amg::Transform3D to_center{Amg::getTranslate3D(-idealTube)};
481  const Amg::Transform3D from_center{Amg::getTranslate3D( 0.5 * (positiveEndBline + negativeEndBline))};
482  const Amg::Vector3D old_direction = (positiveEnd - negativeEnd).unit();
483  const Amg::Vector3D new_direction = (positiveEndBline - negativeEndBline).unit();
484  const Amg::Vector3D rotation_vector = old_direction.cross(new_direction);
485 
486  Amg::Transform3D deformedTransform{Amg::Transform3D::Identity()};
487  if (rotation_vector.mag() > 10. * std::numeric_limits<double>::epsilon()) {
488  const Amg::AngleAxis3D wire_rotation(std::asin(rotation_vector.mag()), rotation_vector.unit());
489  deformedTransform = from_center * wire_rotation * to_center;
490  } else {
491  deformedTransform = from_center * to_center;
492  }
493  ATH_MSG_VERBOSE("To center "<<GeoTrf::toString(to_center)<<" from: "<<GeoTrf::toString(from_center)<<
494  " -- direction: "<<GeoTrf::toString(old_direction)<<" vs. "<<GeoTrf::toString(new_direction)
495  <<" --> rot: "<<GeoTrf::toString(rotation_vector)<<" ==> "<<GeoTrf::toString(deformedTransform,true));
496  return deformedTransform;
497 #endif
498 }
499 
500 
501 } // namespace MuonGMR4
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
SGTest::store
TestStore store
Definition: TestStore.cxx:23
MuonGMR4::MdtReadoutElement::parameterBook::boundFactory
std::shared_ptr< Acts::SurfaceBoundFactory > boundFactory
Sets of surface bounds which is shared amongst all readout elements used to assign the same bound obj...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:64
GeoModel::TransientConstSharedPtr
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
Definition: TransientConstSharedPtr.h:13
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:260
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonGMR4::MdtReadoutElement::asBuiltRefFrame
Amg::Transform3D asBuiltRefFrame() const
Returns the transformation to go into the reference frame of the as-buit & b-line model starting from...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:209
MuonGMR4::MdtReadoutElement::localTubePos
Amg::Vector3D localTubePos(const IdentifierHash &hash) const
Returns the tube position in the chamber coordinate frame (Not applying the B-line corrections)
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:147
add-xsec-uncert-quadrature-N.alpha
alpha
Definition: add-xsec-uncert-quadrature-N.py:110
MuonGMR4::MdtReadoutElement::parameterBook::removedTubes
std::set< IdentifierHash > removedTubes
List of tube places without tubes.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:30
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
MuonGMR4::MdtReadoutElement::numTubesInLay
unsigned int numTubesInLay() const
Returns the number of tubes per layer.
AthCheckMacros.h
ParticleTest.eg
eg
Definition: ParticleTest.py:29
MuonGMR4::MdtReadoutElement::m_reOtherMl
const MdtReadoutElement * m_reOtherMl
Complementary readout element.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:238
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:47
MuonGMR4::MdtReadoutElement::parameterBook::tubeLayers
std::vector< MdtTubeLayerPtr > tubeLayers
Vector defining the position of all tubes in each tube layer.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:27
ActsTrk::DetectorAlignStore
Definition: DetectorAlignStore.h:20
MuonGMR4::MdtReadoutElement::tubeLength
double tubeLength(const IdentifierHash &hash) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:183
MuonGMR4::MdtReadoutElement::isBarrel
bool isBarrel() const
States whether the chamber is built into the barrel or not.
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
MuonGMR4::MdtReadoutElement::moduleThickness
double moduleThickness() const
Returns the thickness of the chamber.
MuonGMR4::MdtReadoutElement::measurementHash
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
MuonGMR4::MdtReadoutElement::toChamberLayer
Amg::Transform3D toChamberLayer(const IdentifierHash &hash) const
Returns the transformation into the rest frame of the tube x-axis: Pointing towards the next layer y-...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:160
Amg::y
@ y
Definition: GeoPrimitives.h:35
MuonGMR4::MuonReadoutElement
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:38
MuonGMR4::MdtReadoutElement::activeTubeLength
double activeTubeLength(const IdentifierHash &hash) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:171
MuonGMR4::MdtReadoutElement::readOutPos
Amg::Vector3D readOutPos(const ActsGeometryContext &ctx, const Identifier &measId) const
Returns the global position of the readout card.
deg
#define deg
Definition: SbPolyhedron.cxx:17
MdtAsBuiltPar::multilayer_t
multilayer_t
MDT multi-layer index.
Definition: MdtAsBuiltPar.h:28
MuonGMR4::MuonReadoutElement::createGeoTransform
StatusCode createGeoTransform()
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:36
MuonGMR4::MdtTubeLayer
Helper struct to retrieve the tube lengths and the tube centers directly from the GeoModel tree.
Definition: MdtTubeLayer.h:28
MuonGMR4::MuonReadoutElement::globalToLocalTrans
Amg::Transform3D globalToLocalTrans(const ActsGeometryContext &ctx) const
Transformations to translate between local <-> global coordinates.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:78
BLinePar::getParameter
float getParameter(const Parameter p) const
Returns a given parameter.
Definition: BLinePar.h:40
MuonGMR4::MdtReadoutElement::initElement
StatusCode initElement() override final
Element initialization.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:51
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
MuonGMR4::MdtReadoutElement::tubeRadius
double tubeRadius() const
Adds the thickness of the tube wall onto the radius.
MuonGMR4::MdtReadoutElement::parameterBook::readoutSide
double readoutSide
Is the readout chip at positive or negative Z?
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:60
TRT::Hit::side
@ side
Definition: HitInfo.h:83
MuonGMR4::MdtReadoutElement::measurementId
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:46
MuonGMR4::MdtReadoutElement::multilayer
unsigned int multilayer() const
Returns the multi layer of the MdtReadoutElement.
MdtAlignmentStore
Helper struct to cache simulatenously the As-built and the BLine corrections of the Mdts for fast acc...
Definition: MdtAlignmentStore.h:19
MuonGMR4::MdtReadoutElement::wireLength
double wireLength(const IdentifierHash &hash) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:186
MuonGMR4::MdtReadoutElement::layerNumber
static unsigned int layerNumber(const IdentifierHash &hash)
Transforms the identifier hash into a layer number ranging from (0-numLayers()-1)
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
MuonGMR4::MdtReadoutElement::parameterBook::halfY
double halfY
Length ~ number of tubes.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:56
Amg::getRotateX3D
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
Definition: GeoPrimitivesHelpers.h:252
MuonGMR4::MdtReadoutElement::uncutTubeLength
double uncutTubeLength(const IdentifierHash &tubeHash) const
Returns the uncut tube length.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:177
MdtAlignmentStore::chamberDistortions
Helper struct to store the pointer to the Mdt distrotion parameters, namely the As-built and the BLin...
Definition: MdtAlignmentStore.h:25
BLinePar::expansionScale
static constexpr double expansionScale
Definition: BLinePar.h:35
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonGMR4
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Definition: MdtCalibInput.h:19
MuonGMR4::MdtReadoutElement::m_pars
parameterBook m_pars
defining parameter set
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:230
MuonGMR4::MdtReadoutElement::moduleWidthS
double moduleWidthS() const
Returns the length of the bottom edge of the chamber (short width)
z
#define z
MuonGMR4::MdtReadoutElement::parameterBook
Set of parameters to describe a MDT chamber.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:22
python.SystemOfUnits.micrometer
float micrometer
Definition: SystemOfUnits.py:80
MuonGMR4::MuonReadoutElement::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the pointer to the muonIdHelperSvc.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MdtAlignmentStore.h
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:56
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonGMR4::MdtReadoutElement::numLayers
unsigned int numLayers() const
Returns the number of tube layer.
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MdtAsBuiltPar::tubeSide_t::NEG
@ NEG
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::operator<<
MsgStream & operator<<(MsgStream &out, const ActsUtils::Stat &stat)
Definition: TrackToTruthAssociationAlg.cxx:25
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
BLinePar
Definition: BLinePar.h:14
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonGMR4::MdtReadoutElement::innerTubeRadius
double innerTubeRadius() const
Returns the inner tube radius.
MuonGMR4::MdtReadoutElement::moduleHeight
double moduleHeight() const
Returns the height of the chamber (Distance bottom - topWidth)
MdtAsBuiltPar::tubeSide_t
tubeSide_t
MDT tube side.
Definition: MdtAsBuiltPar.h:33
MuonGMR4::MdtReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:18
MdtIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Definition: MdtIdHelper.cxx:659
MuonGMR4::MdtReadoutElement::distanceToReadout
double distanceToReadout(const ActsGeometryContext &ctx, const Identifier &measId, const Amg::Vector3D &globPoint) const
Returns the distance along the wire from the readout card The distance is given as the delta z of the...
MuonGMR4::MuonReadoutElement::geoTransformHash
static IdentifierHash geoTransformHash()
Returns the hash that is associated with the surface cache holding the transformation that is placing...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:44
MuonGMR4::MuonReadoutElement::alignableTransform
const GeoAlignableTransform * alignableTransform() const
Returnsthe alignable transform of the readout element.
PlotCalibFromCool.en
en
Definition: PlotCalibFromCool.py:399
MuonGMR4::MuonReadoutElement::strawSurfaceFactory
StatusCode strawSurfaceFactory(const IdentifierHash &hash, std::shared_ptr< Acts::LineBounds > lBounds)
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:102
MuonGMR4::MuonReadoutElement::identify
Identifier identify() const override final
Return the athena identifier.
MuonGMR4::MdtReadoutElement::tubePitch
double tubePitch() const
Returns the pitch between 2 tubes in a layer.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGMR4::MdtReadoutElement::parameterBook::tubePitch
double tubePitch
Distance between 2 tubes in the layer.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:37
MuonGMR4::MdtReadoutElement::thickness
double thickness() const override final
Overload from the Acts::DetectorElement (2 * halfheight)
MuonGMR4::MdtReadoutElement::tubeNumber
static unsigned int tubeNumber(const IdentifierHash &hash)
Transforms the idenfier hash into a tube number ranging from (0- numTubesInLay()-1)
MuonGMR4::MdtReadoutElement::bLineReferencePoint
Amg::Vector3D bLineReferencePoint() const
Returns the fixed point of the B-line & as-bult defromation model expressed in the as-built frame.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:215
MuonGMR4::MdtReadoutElement::parameterBook::endPlugLength
double endPlugLength
Depth of the endplug into the active tube volume.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:41
BLinePar::Parameter
Parameter
Definition: BLinePar.h:21
MuonGMR4::MdtReadoutElement::m_idHelper
const MdtIdHelper & m_idHelper
Detector identifier helper to quickly extract the ID fields.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:232
MuonGMR4::MdtReadoutElement::parameterBook::shortHalfX
double shortHalfX
The chambers have either a rectangular or a trapezoidal shape to first approximation.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:53
MdtAsBuiltPar
Container classifier the MDT as-built parameters See parameter description in http://atlas-muon-align...
Definition: MdtAsBuiltPar.h:18
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
MuonGMR4::MuonReadoutElement::planeSurfaceFactory
StatusCode planeSurfaceFactory(const IdentifierHash &hash, std::shared_ptr< Acts::PlanarBounds > pBounds)
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:125
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonGMR4::MdtReadoutElement::fromIdealToDeformed
Amg::Transform3D fromIdealToDeformed(const IdentifierHash &tubeHash, const ActsTrk::DetectorAlignStore *store) const
Applies the B & as-built parameters.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:405
MdtReadoutElement.h
MuonGMR4::MdtReadoutElement::setComplementaryReadoutEle
void setComplementaryReadoutEle(const MdtReadoutElement *other)
Set the link to the second readout element inside the muon station.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:205
GeoPrimitivesHelpers.h
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
GeoPrimitivesToStringConverter.h
MuonGMR4::MdtReadoutElement::parameterBook::deadLength
double deadLength
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:43
MuonGMR4::MdtReadoutElement::parameterBook::longHalfX
double longHalfX
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:54
MuonGMR4::MuonReadoutElement::localToGlobalTrans
const Amg::Transform3D & localToGlobalTrans(const ActsGeometryContext &ctx) const
Returns the local to global transformation into the ATLAS coordinate system.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:81
MuonGMR4::MdtReadoutElement::globalTubePos
Amg::Vector3D globalTubePos(const ActsGeometryContext &ctx, const Identifier &measId) const
Returns the global position of the tube center.
MdtAsBuiltPar::tubeSide_t::POS
@ POS
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
MuonGMR4::MuonReadoutElement::stationEta
int stationEta() const
Returns the stationEta (positive A site, negative O site)
MuonGMR4::MdtReadoutElement::getParameters
const parameterBook & getParameters() const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:45
MuonGMR4::MdtReadoutElement::toTubeFrame
Amg::Transform3D toTubeFrame(const IdentifierHash &hash) const
Returns the transformation into the rest frame of the tube x-axis: Pointing towards the next layer y-...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:165
MuonGMR4::MdtReadoutElement::highVoltPos
Amg::Vector3D highVoltPos(const ActsGeometryContext &ctx, const Identifier &measId) const
Returns the global position of the High Voltage connectors.
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
MuonGMR4::MdtReadoutElement::moduleWidthL
double moduleWidthL() const
Returns the length of the top edge of the chamber (top width)
MuonGMR4::MdtReadoutElement::applyBlineCorrections
Amg::Vector3D applyBlineCorrections(const BLinePar &bline, const Amg::Vector3D &localTubeEndPoint, const Amg::Vector3D &fixedPoint, const double thickness) const
Apply the B-line model correction to a tube endpoint.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:294
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
MuonGMR4::MdtReadoutElement::wireEndpointAsBuilt
Amg::Vector3D wireEndpointAsBuilt(const MdtAsBuiltPar &asBuilt, const IdentifierHash &tubeHash, const Amg::Vector3D &nominalEnd, const tubeSide_t side) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:224
calibdata.tube
tube
Definition: calibdata.py:30
Amg::getTranslate3D
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Definition: GeoPrimitivesHelpers.h:289
MuonGMR4::MdtReadoutElement::defineArgs
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:70
Identifier
Definition: IdentifierFieldParser.cxx:14