CMS 3D CMS Logo

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