Go to the documentation of this file.00001 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonResidualsFromTrack.h"
00002
00003 MuonResidualsFromTrack::MuonResidualsFromTrack(edm::ESHandle<GlobalTrackingGeometry> globalGeometry, const Trajectory *traj, AlignableNavigator *navigator, double maxResidual) {
00004 m_tracker_numHits = 0;
00005 m_tracker_chi2 = 0.;
00006 m_contains_TIDTEC = false;
00007 m_chamberIds.clear();
00008 m_dt13.clear();
00009 m_dt2.clear();
00010 m_csc.clear();
00011
00012 std::vector<TrajectoryMeasurement> measurements = traj->measurements();
00013 for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
00014 TrajectoryMeasurement meas = *im;
00015 const TransientTrackingRecHit *hit = &(*meas.recHit());
00016 DetId id = hit->geographicalId();
00017
00018 if (hit->isValid()) {
00019 TrajectoryStateOnSurface tsos = m_tsoscomb(meas.forwardPredictedState(), meas.backwardPredictedState());
00020 if (tsos.isValid() && fabs(tsos.localPosition().x() - hit->localPosition().x()) < maxResidual) {
00021
00022 if (id.det() == DetId::Tracker) {
00023 double xresid = tsos.localPosition().x() - hit->localPosition().x();
00024 double xresiderr2 = tsos.localError().positionError().xx() + hit->localPositionError().xx();
00025
00026 m_tracker_numHits++;
00027 m_tracker_chi2 += xresid * xresid / xresiderr2;
00028
00029 if (id.subdetId() == StripSubdetector::TID || id.subdetId() == StripSubdetector::TEC) m_contains_TIDTEC = true;
00030 }
00031
00032 else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
00033 const DTChamberId chamberId(id.rawId());
00034 const DTSuperLayerId superLayerId(id.rawId());
00035
00036
00037 if (m_dt13.find(chamberId) == m_dt13.end() && m_dt2.find(chamberId) == m_dt2.end()) {
00038 m_chamberIds.push_back(chamberId);
00039 }
00040
00041 if (superLayerId.superlayer() == 2) {
00042 if (m_dt2.find(chamberId) == m_dt2.end()) {
00043 AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
00044 m_dt2[chamberId] = new MuonDT2ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
00045 }
00046
00047 m_dt2[chamberId]->addResidual(&tsos, hit);
00048 }
00049
00050 else {
00051 if (m_dt13.find(chamberId) == m_dt13.end()) {
00052 AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
00053 m_dt13[chamberId] = new MuonDT13ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
00054 }
00055
00056 m_dt13[chamberId]->addResidual(&tsos, hit);
00057 }
00058 }
00059
00060 else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
00061 const CSCDetId cscDetId(id.rawId());
00062 const CSCDetId chamberId(cscDetId.endcap(), cscDetId.station(), cscDetId.ring(), cscDetId.chamber());
00063
00064
00065 if (cscDetId.layer() != 0) {
00066
00067
00068 if (m_csc.find(chamberId) == m_csc.end()) {
00069 m_chamberIds.push_back(chamberId);
00070
00071 AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
00072 m_csc[chamberId] = new MuonCSCChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
00073 }
00074
00075 m_csc[chamberId]->addResidual(&tsos, hit);
00076
00077 }
00078 }
00079
00080 }
00081 }
00082 }
00083 }
00084
00085 MuonResidualsFromTrack::~MuonResidualsFromTrack() {
00086 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt13.begin(); residual != m_dt13.end(); ++residual) {
00087 delete residual->second;
00088 }
00089 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt2.begin(); residual != m_dt2.end(); ++residual) {
00090 delete residual->second;
00091 }
00092 for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_csc.begin(); residual != m_csc.end(); ++residual) {
00093 delete residual->second;
00094 }
00095 }