test
CMS 3D CMS Logo

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