CMS 3D CMS Logo

MuonCSCChamberResidual.cc
Go to the documentation of this file.
1 /*
2  * $Id: $
3  */
4 
7 
10 
12  DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
13 : MuonHitsChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable)
14 {
16  align::GlobalVector zDirection(0., 0., 1.);
17  m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(zDirection).z() > 0. ? 1. : -1.;
18 }
19 
20 
21 void MuonCSCChamberResidual::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  if (m_debug) std::cout << "MuonCSCChamberResidual::addResidual 1" << std::endl;
26  DetId id = hit->geographicalId();
27  if (m_debug) std::cout << "MuonCSCChamberResidual::addResidual 2" << std::endl;
28  const CSCGeometry *cscGeometry = dynamic_cast<const CSCGeometry*>(m_globalGeometry->slaveGeometry(id));
29  if (m_debug) std::cout << "MuonCSCChamberResidual::addResidual 3" << std::endl;
30  assert(cscGeometry);
31 
32  if (m_debug) {
33  std::cout << " MuonCSCChamberResidual hit->localPosition() x: " << hit->localPosition().x() << " tsos->localPosition() x: " << tsos->localPosition().x() << std::endl;
34  std::cout << " hit->localPosition() y: " << hit->localPosition().y() << " tsos->localPosition() y: " << tsos->localPosition().y() << std::endl;
35  std::cout << " hit->localPosition() z: " << hit->localPosition().z() << " tsos->localPosition() z: " << tsos->localPosition().z() << std::endl;
36  }
37 
38  // hit->localPosition() is coordinate in local system of LAYER. Transfer it to coordiante in local system of chamber
40  // TSOS->localPosition() is given in local system of CHAMBER (for segment-based reconstruction)
41  // align::LocalPoint tsosChamberPos = tsos->localPosition();
43 
44  int strip = cscGeometry->layer(id)->geometry()->nearestStrip(hit->localPosition());
45  double angle = cscGeometry->layer(id)->geometry()->stripAngle(strip) - M_PI/2.;
46  double sinAngle = sin(angle);
47  double cosAngle = cos(angle);
48 
49  double residual = cosAngle * (tsosChamberPos.x() - hitChamberPos.x()) + sinAngle * (tsosChamberPos.y() - hitChamberPos.y()); // yes, that's +sin()
50 
51  if (m_debug) std::cout << " MuonCSCChamberResidual residual: " << residual << std::endl;
52 
53  double xx = hit->localPositionError().xx();
54  double xy = hit->localPositionError().xy();
55  double yy = hit->localPositionError().yy();
56  double weight = 1. / (xx*cosAngle*cosAngle + 2.*xy*sinAngle*cosAngle + yy*sinAngle*sinAngle);
57 
58  double layerPosition = tsosChamberPos.z(); // the layer's position in the chamber's coordinate system
59  double layerHitPos = hitChamberPos.z();
60 
61  m_numHits++;
62 
63  // "x" is the layerPosition, "y" is the residual (this is a linear fit to residual versus layerPosition)
65  m_residual_x += weight * layerPosition;
66  m_residual_y += weight * residual;
67  m_residual_xx += weight * layerPosition * layerPosition;
68  m_residual_xy += weight * layerPosition * residual;
69 
70  // "x" is the layerPosition, "y" is chamberx (this is a linear fit to chamberx versus layerPosition)
71  m_trackx_1 += weight;
72  m_trackx_x += weight * layerPosition;
73  m_trackx_y += weight * tsosChamberPos.x();
74  m_trackx_xx += weight * layerPosition * layerPosition;
75  m_trackx_xy += weight * layerPosition * tsosChamberPos.x();
76 
77  // "x" is the layerPosition, "y" is chambery (this is a linear fit to chambery versus layerPosition)
78  m_tracky_1 += weight;
79  m_tracky_x += weight * layerPosition;
80  m_tracky_y += weight * tsosChamberPos.y();
81  m_tracky_xx += weight * layerPosition * layerPosition;
82  m_tracky_xy += weight * layerPosition * tsosChamberPos.y();
83 
84  m_hitx_1 += weight;
85  m_hitx_x += weight * layerHitPos;
86  m_hitx_y += weight * hitChamberPos.x();
87  m_hitx_xx += weight * layerHitPos * layerHitPos;
88  m_hitx_xy += weight * layerHitPos * hitChamberPos.x();
89 
90  m_hity_1 += weight;
91  m_hity_x += weight * layerHitPos;
92  m_hity_y += weight * hitChamberPos.y();
93  m_hity_xx += weight * layerHitPos * layerHitPos;
94  m_hity_xy += weight * layerHitPos * hitChamberPos.y();
95 
96  m_localIDs.push_back(id);
97  m_localResids.push_back(residual); // FIXME Check if this method is needed
98  m_individual_x.push_back(layerPosition);
99  m_individual_y.push_back(residual);
100  m_individual_weight.push_back(weight);
101 
102  if (m_numHits>1) segment_fit();
103 }
104 
float xx() const
Definition: LocalError.h:24
void addResidual(edm::ESHandle< Propagator > prop, const TrajectoryStateOnSurface *tsos, const TrackingRecHit *hit, double, double) override
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
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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
float xy() const
Definition: LocalError.h:25
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.
float yy() const
Definition: LocalError.h:26
std::vector< double > m_localResids
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
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
#define M_PI
int nearestStrip(const LocalPoint &lp) const
Definition: DetId.h:18
MuonCSCChamberResidual(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, AlignableNavigator *navigator, DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:139
edm::ESHandle< GlobalTrackingGeometry > m_globalGeometry
const GeomDet * idToDet(DetId) const override
DetId geographicalId() const
virtual LocalError localPositionError() const =0
T x() const
Definition: PV3DBase.h:62
std::vector< double > m_individual_weight
float stripAngle(int strip) const
double residual() const
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11