CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonCSCChamberResidual.cc
Go to the documentation of this file.
1 /*
2  * $Id: $
3  */
4 
7 
8 
10  DetId chamberId, const AlignableDetOrUnitPtr& chamberAlignable)
11  : MuonHitsChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable)
12 {
14  align::GlobalVector zDirection(0., 0., 1.);
15  m_sign = m_globalGeometry->idToDet(m_chamberId)->toLocal(zDirection).z() > 0. ? 1. : -1.;
16 }
17 
18 
20 {
21  DetId id = hit->geographicalId();
22  const CSCGeometry *cscGeometry = dynamic_cast<const CSCGeometry*>(m_globalGeometry->slaveGeometry(id));
23  assert(cscGeometry);
24 
25  align::LocalPoint hitChamberPos = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(hit->localPosition()));
26  align::LocalPoint tsosChamberPos = m_chamberAlignable->surface().toLocal(m_globalGeometry->idToDet(id)->toGlobal(tsos->localPosition()));
27 
28  int strip = cscGeometry->layer(id)->geometry()->nearestStrip(hit->localPosition());
29  double angle = cscGeometry->layer(id)->geometry()->stripAngle(strip) - M_PI/2.;
30  double sinAngle = sin(angle);
31  double cosAngle = cos(angle);
32 
33  double residual = cosAngle * (tsosChamberPos.x() - hitChamberPos.x()) + sinAngle * (tsosChamberPos.y() - hitChamberPos.y()); // yes, that's +sin()
34 
35  double xx = hit->localPositionError().xx();
36  double xy = hit->localPositionError().xy();
37  double yy = hit->localPositionError().yy();
38  double weight = 1. / (xx*cosAngle*cosAngle + 2.*xy*sinAngle*cosAngle + yy*sinAngle*sinAngle);
39 
40  double layerPosition = tsosChamberPos.z(); // the layer's position in the chamber's coordinate system
41  double layerHitPos = hitChamberPos.z();
42 
43  m_numHits++;
44 
45  // "x" is the layerPosition, "y" is the residual (this is a linear fit to residual versus layerPosition)
47  m_residual_x += weight * layerPosition;
48  m_residual_y += weight * residual;
49  m_residual_xx += weight * layerPosition * layerPosition;
50  m_residual_xy += weight * layerPosition * residual;
51 
52  // "x" is the layerPosition, "y" is chamberx (this is a linear fit to chamberx versus layerPosition)
53  m_trackx_1 += weight;
54  m_trackx_x += weight * layerPosition;
55  m_trackx_y += weight * tsosChamberPos.x();
56  m_trackx_xx += weight * layerPosition * layerPosition;
57  m_trackx_xy += weight * layerPosition * tsosChamberPos.x();
58 
59  // "x" is the layerPosition, "y" is chambery (this is a linear fit to chambery versus layerPosition)
60  m_tracky_1 += weight;
61  m_tracky_x += weight * layerPosition;
62  m_tracky_y += weight * tsosChamberPos.y();
63  m_tracky_xx += weight * layerPosition * layerPosition;
64  m_tracky_xy += weight * layerPosition * tsosChamberPos.y();
65 
66  m_hitx_1 += weight;
67  m_hitx_x += weight * layerHitPos;
68  m_hitx_y += weight * hitChamberPos.x();
69  m_hitx_xx += weight * layerHitPos * layerHitPos;
70  m_hitx_xy += weight * layerHitPos * hitChamberPos.x();
71 
72  m_hity_1 += weight;
73  m_hity_x += weight * layerHitPos;
74  m_hity_y += weight * hitChamberPos.y();
75  m_hity_xx += weight * layerHitPos * layerHitPos;
76  m_hity_xy += weight * layerHitPos * hitChamberPos.y();
77 
78  m_localIDs.push_back(id);
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
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:63
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
AlignableDetOrUnitPtr m_chamberAlignable
#define M_PI
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
int nearestStrip(const LocalPoint &lp) const
Definition: DetId.h:18
virtual LocalError localPositionError() const =0
virtual void addResidual(const TrajectoryStateOnSurface *tsos, const TransientTrackingRecHit *hit)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:124
edm::ESHandle< GlobalTrackingGeometry > m_globalGeometry
MuonCSCChamberResidual(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, AlignableNavigator *navigator, DetId chamberId, const AlignableDetOrUnitPtr &chamberAlignable)
DetId geographicalId() const
int weight
Definition: histoStyle.py:50
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
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