CMS 3D CMS Logo

MuonDT2ChamberResidual.cc
Go to the documentation of this file.
1 /*
2  * $Id: $
3  */
4 
6 
9  DetId chamberId,
10  AlignableDetOrUnitPtr chamberAlignable)
11  : MuonHitsChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable) {
13  align::GlobalVector zDirection(0., 0., 1.);
14  m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(zDirection).y() > 0. ? 1. : -1.;
15 }
16 
17 // void MuonDT2ChamberResidual::addResidual(const TrajectoryStateOnSurface *tsos, const TransientTrackingRecHit *hit)
18 
20  const TrajectoryStateOnSurface *tsos,
21  const TrackingRecHit *hit,
22  double chamber_width,
23  double chamber_length) {
24  bool m_debug = false;
25 
26  m_chamber_width = chamber_width;
27  m_chamber_length = chamber_length;
28 
29  DetId id = hit->geographicalId();
30 
31  align::LocalPoint hitChamberPos =
33  align::LocalPoint tsosChamberPos =
35 
36  if (m_debug) {
37  std::cout << " MuonDT2ChamberResidual hitChamberPos x: " << hitChamberPos.x()
38  << " tsosChamberPos x: " << tsosChamberPos.x() << std::endl;
39  std::cout << " hitChamberPos y: " << hitChamberPos.y()
40  << " tsosChamberPos y: " << tsosChamberPos.y() << std::endl;
41  std::cout << " hitChamberPos z: " << hitChamberPos.z()
42  << " tsosChamberPos z: " << tsosChamberPos.z() << std::endl;
43  }
44 
45  double residual = tsosChamberPos.y() - hitChamberPos.y(); // residual is track minus hit
46  double weight =
47  1. / hit->localPositionError().xx(); // weight linear fit by hit-only local error (yes, xx: layer x is chamber y)
48  double layerPosition = tsosChamberPos.z(); // the layer's position in the chamber's coordinate system
49  double layerHitPos = hitChamberPos.z();
50 
51  m_numHits++;
52 
53  // "x" is the layerPosition, "y" is the residual (this is a linear fit to residual versus layerPosition)
55  m_residual_x += weight * layerPosition;
57  m_residual_xx += weight * layerPosition * layerPosition;
58  m_residual_xy += weight * layerPosition * residual;
59 
60  // "x" is the layerPosition, "y" is chamberx (this is a linear fit to chamberx versus layerPosition)
61  m_trackx_1 += weight;
62  m_trackx_x += weight * layerPosition;
63  m_trackx_y += weight * tsosChamberPos.x();
64  m_trackx_xx += weight * layerPosition * layerPosition;
65  m_trackx_xy += weight * layerPosition * tsosChamberPos.x();
66 
67  // "x" is the layerPosition, "y" is chambery (this is a linear fit to chambery versus layerPosition)
68  m_tracky_1 += weight;
69  m_tracky_x += weight * layerPosition;
70  m_tracky_y += weight * tsosChamberPos.y();
71  m_tracky_xx += weight * layerPosition * layerPosition;
72  m_tracky_xy += weight * layerPosition * tsosChamberPos.y();
73 
74  m_hitx_1 += weight;
75  m_hitx_x += weight * layerHitPos;
76  m_hitx_y += weight * hitChamberPos.x();
77  m_hitx_xx += weight * layerHitPos * layerHitPos;
78  m_hitx_xy += weight * layerHitPos * hitChamberPos.x();
79 
80  m_hity_1 += weight;
81  m_hity_x += weight * layerHitPos;
82  m_hity_y += weight * hitChamberPos.y();
83  m_hity_xx += weight * layerHitPos * layerHitPos;
84  m_hity_xy += weight * layerHitPos * hitChamberPos.y();
85 
86  m_localIDs.push_back(id);
87  // m_localResids.push_back(tsos->localPosition().x() - hit->localPosition().x()); //FIXME looks like this line is not used anywhere, moreover it is wrong for segment-based reconstruction, I changed it to the follwoing line
88  m_localResids.push_back(residual);
89  m_individual_x.push_back(layerPosition);
90  m_individual_y.push_back(residual);
91  m_individual_weight.push_back(weight);
92 
93  if (m_numHits > 1)
94  segment_fit();
95 }
std::vector< double > m_individual_y
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
T z() const
Definition: PV3DBase.h:61
Definition: weight.py:1
const GeomDet * idToDet(DetId) const override
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
std::vector< double > m_individual_x
void addResidual(edm::ESHandle< Propagator > prop, const TrajectoryStateOnSurface *tsos, const TrackingRecHit *hit, double, double) override
std::vector< DetId > m_localIDs
std::vector< double > m_localResids
MuonDT2ChamberResidual(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, AlignableNavigator *navigator, DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
AlignableDetOrUnitPtr m_chamberAlignable
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Definition: DetId.h:17
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
edm::ESHandle< GlobalTrackingGeometry > m_globalGeometry
std::vector< double > m_individual_weight