CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonTrackCSCChamberResidual.cc
Go to the documentation of this file.
1 /*
2  * $Id: MuonTrackCSCChamberResidual.cc,v 1.2 2011/11/02 07:38:30 mussgill Exp $
3  */
4 
6 //#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
7 
8 
10  DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
11  : MuonChamberResidual(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  CSCDetId id(trk->id.rawId());
22  CSCDetId chamber(id.chamberId());
23 
24  CSCSegmentRef segmentCSC = seg->cscSegmentRef;
25  if (segmentCSC.get() != 0)
26  {
27  const CSCSegment* segment = segmentCSC.get();
28  m_numHits = segment->nRecHits();
29  m_ndof = segment->degreesOfFreedom();
30  m_chi2 = segment->chi2();
31  //std::cout<<"csc seg position = "<<segment->localPosition()<<" numhits="<<m_numHits<<" id: "<<id<<std::endl;
32  }
33 
34  align::LocalPoint l_seg(seg->x, seg->y, 0.);
35  align::LocalPoint l_trk(trk->x, trk->y, 0.);
36 
37  /*
38  double dphi = g_trk.phi() - g_seg.phi();
39  while (dphi > M_PI) dphi -= 2.*M_PI;
40  while (dphi < -M_PI) dphi += 2.*M_PI;
41  m_residual = - m_sign * g_trk.perp() * dphi; // coming from global, need to adjust the sign
42  std::cout<<"cscres="<<m_residual<<" dx="<<trk->x-seg->x<<" diff="<<trk->x-seg->x - m_residual<<std::endl;
43  */
44  m_residual = trk->x-seg->x;
45  m_residual_error = sqrt( pow(trk->xErr, 2) + pow(seg->xErr, 2) );
46  m_resslope = trk->dXdZ - seg->dXdZ;
47  m_resslope_error = sqrt( pow(trk->dXdZErr, 2) + pow(seg->dXdZErr, 2) );
48 
49  m_trackx = trk->x;
50  m_tracky = trk->y;
51  m_trackdxdz = trk->dXdZ;
52  m_trackdydz = trk->dYdZ;
53 
54  m_segx = seg->x;
55  m_segy = seg->y;
56  m_segdxdz = seg->dXdZ;
57  m_segdydz = seg->dYdZ;
58 
59  //double yresidual_error = sqrt( pow(trk->yErr, 2) + pow(seg->yErr, 2) );
60  //double yresslope_error = sqrt( pow(trk->dYdZErr, 2) + pow(seg->dYdZErr, 2) );
61  //std::cout<<"csc res "<<m_residual<<"+-"<<m_residual_error<<" "<<m_resslope<<"+-"<<m_resslope_error<<" "<<trk->y-seg->y<<"+-"<<yresidual_error<<" "<<trk->dYdZ - seg->dYdZ<<"+-"<<yresslope_error<<std::endl;
62  //std::cout<<"csc trk "<<m_trackx<<" "<<m_tracky<<" "<<m_trackdxdz<<" "<<m_trackdydz<<std::endl;
63  //std::cout<<"csc seg "<<m_segx<<" "<<m_segy<<" "<<m_segdxdz<<" "<<m_segdydz<<std::endl;
64 }
virtual void setSegmentResidual(const reco::MuonChamberMatch *, const reco::MuonSegmentMatch *)
MuonTrackCSCChamberResidual(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, AlignableNavigator *navigator, DetId chamberId, AlignableDetOrUnitPtr chamberAlignable)
CSCSegmentRef cscSegmentRef
virtual int degreesOfFreedom() const
Degrees of freedom of the segment fit.
Definition: CSCSegment.h:62
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int nRecHits() const
Definition: CSCSegment.h:68
T sqrt(T t)
Definition: SSEVec.h:46
Definition: DetId.h:20
double chi2() const
Chi2 of the segment fit.
Definition: CSCSegment.h:58
edm::ESHandle< GlobalTrackingGeometry > m_globalGeometry
DetId chamberId() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40