CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonResidualsFromTrack.cc
Go to the documentation of this file.
2 
5  m_tracker_chi2 = 0.;
6  m_contains_TIDTEC = false;
7  m_chamberIds.clear();
8  m_dt13.clear();
9  m_dt2.clear();
10  m_csc.clear();
11 
12  std::vector<TrajectoryMeasurement> measurements = traj->measurements();
13  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
14  TrajectoryMeasurement meas = *im;
15  const TransientTrackingRecHit *hit = &(*meas.recHit());
16  DetId id = hit->geographicalId();
17 
18  if (hit->isValid()) {
20  if (tsos.isValid() && fabs(tsos.localPosition().x() - hit->localPosition().x()) < maxResidual) {
21 
22  if (id.det() == DetId::Tracker) {
23  double xresid = tsos.localPosition().x() - hit->localPosition().x();
24  double xresiderr2 = tsos.localError().positionError().xx() + hit->localPositionError().xx();
25 
27  m_tracker_chi2 += xresid * xresid / xresiderr2;
28 
29  if (id.subdetId() == StripSubdetector::TID || id.subdetId() == StripSubdetector::TEC) m_contains_TIDTEC = true;
30  }
31 
32  else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
33  const DTChamberId chamberId(id.rawId());
34  const DTSuperLayerId superLayerId(id.rawId());
35 
36  // have we seen this chamber before?
37  if (m_dt13.find(chamberId) == m_dt13.end() && m_dt2.find(chamberId) == m_dt2.end()) {
38  m_chamberIds.push_back(chamberId);
39  }
40 
41  if (superLayerId.superlayer() == 2) {
42  if (m_dt2.find(chamberId) == m_dt2.end()) {
43  AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
44  m_dt2[chamberId] = new MuonDT2ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
45  }
46 
47  m_dt2[chamberId]->addResidual(&tsos, hit);
48  }
49 
50  else {
51  if (m_dt13.find(chamberId) == m_dt13.end()) {
52  AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
53  m_dt13[chamberId] = new MuonDT13ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
54  }
55 
56  m_dt13[chamberId]->addResidual(&tsos, hit);
57  }
58  }
59 
60  else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
61  const CSCDetId cscDetId(id.rawId());
62  const CSCDetId chamberId(cscDetId.endcap(), cscDetId.station(), cscDetId.ring(), cscDetId.chamber());
63 
64  // not sure why we sometimes get layer == 0
65  if (cscDetId.layer() != 0) {
66 
67  // have we seen this chamber before?
68  if (m_csc.find(chamberId) == m_csc.end()) {
69  m_chamberIds.push_back(chamberId);
70 
71  AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
72  m_csc[chamberId] = new MuonCSCChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
73  }
74 
75  m_csc[chamberId]->addResidual(&tsos, hit);
76 
77  } // end if cscDetId.layer() != 0
78  }
79 
80  } // end if track propagation is valid
81  } // end if hit is valid
82  } // end loop over measurments
83 }
84 
86  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt13.begin(); residual != m_dt13.end(); ++residual) {
87  delete residual->second;
88  }
89  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt2.begin(); residual != m_dt2.end(); ++residual) {
90  delete residual->second;
91  }
92  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_csc.begin(); residual != m_csc.end(); ++residual) {
93  delete residual->second;
94  }
95 }
int chamber() const
Definition: CSCDetId.h:70
float xx() const
Definition: LocalError.h:19
std::vector< DetId > m_chamberIds
TrajectoryStateOnSurface forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
MuonResidualsFromTrack(edm::ESHandle< GlobalTrackingGeometry > globalGeometry, const Trajectory *traj, AlignableNavigator *navigator, double maxResidual)
std::map< DetId, MuonChamberResidual * > m_dt2
std::map< DetId, MuonChamberResidual * > m_csc
ConstRecHitPointer recHit() const
int layer() const
Definition: CSCDetId.h:63
LocalError positionError() const
int endcap() const
Definition: CSCDetId.h:95
DataContainer const & measurements() const
Definition: Trajectory.h:169
static const int CSC
Definition: MuonSubdetId.h:15
const LocalTrajectoryError & localError() const
int superlayer() const
Return the superlayer number (deprecated method name)
int ring() const
Definition: CSCDetId.h:77
Definition: DetId.h:20
virtual LocalError localPositionError() const =0
bool isValid() const
int station() const
Definition: CSCDetId.h:88
static const int DT
Definition: MuonSubdetId.h:14
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:56
virtual LocalPoint localPosition() const =0
std::map< DetId, MuonChamberResidual * > m_dt13
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
TrajectoryStateOnSurface backwardPredictedState() const
Access to backward predicted state (from smoother)
TrajectoryStateCombiner m_tsoscomb