CMS 3D CMS Logo

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