CMS 3D CMS Logo

Public Member Functions | Private Attributes

MuonResidualsFromTrack Class Reference

#include <MuonResidualsFromTrack.h>

List of all members.

Public Member Functions

const std::vector< DetIdchamberIds () const
MuonChamberResidualchamberResidual (DetId chamberId, int type)
bool contains_TIDTEC () const
 MuonResidualsFromTrack (edm::ESHandle< GlobalTrackingGeometry > globalGeometry, const Trajectory *traj, AlignableNavigator *navigator, double maxResidual)
double trackerChi2 () const
int trackerNumHits () const
double trackerRedChi2 () const
 ~MuonResidualsFromTrack ()

Private Attributes

std::vector< DetIdm_chamberIds
bool m_contains_TIDTEC
std::map< DetId,
MuonChamberResidual * > 
m_csc
std::map< DetId,
MuonChamberResidual * > 
m_dt13
std::map< DetId,
MuonChamberResidual * > 
m_dt2
double m_tracker_chi2
int m_tracker_numHits
TrajectoryStateCombiner m_tsoscomb

Detailed Description

Date:
2009/04/23 05:06:01
Revision:
1.3
Author:
J. Pivarski - Texas A&M University <pivarski@physics.tamu.edu>

Definition at line 29 of file MuonResidualsFromTrack.h.


Constructor & Destructor Documentation

MuonResidualsFromTrack::MuonResidualsFromTrack ( edm::ESHandle< GlobalTrackingGeometry globalGeometry,
const Trajectory traj,
AlignableNavigator navigator,
double  maxResidual 
)

Definition at line 3 of file MuonResidualsFromTrack.cc.

References AlignableNavigator::alignableFromDetId(), TrajectoryMeasurement::backwardPredictedState(), CSCDetId::chamber(), MuonSubdetId::CSC, MuonSubdetId::DT, CSCDetId::endcap(), TrajectoryMeasurement::forwardPredictedState(), TrackingRecHit::geographicalId(), TrackingRecHit::isValid(), TrajectoryStateOnSurface::isValid(), CSCDetId::layer(), TrajectoryStateOnSurface::localError(), TrackingRecHit::localPosition(), TrajectoryStateOnSurface::localPosition(), TrackingRecHit::localPositionError(), m_chamberIds, m_contains_TIDTEC, m_csc, m_dt13, m_dt2, m_tracker_chi2, m_tracker_numHits, m_tsoscomb, Trajectory::measurements(), DetId::Muon, LocalTrajectoryError::positionError(), TrajectoryMeasurement::recHit(), CSCDetId::ring(), CSCDetId::station(), DTSuperLayerId::superlayer(), StripSubdetector::TEC, StripSubdetector::TID, align::Tracker, PV3DBase< T, PVType, FrameType >::x(), and LocalError::xx().

                                                                                                                                                                            {
  m_tracker_numHits = 0;
  m_tracker_chi2 = 0.;
  m_contains_TIDTEC = false;
  m_chamberIds.clear();
  m_dt13.clear();
  m_dt2.clear();
  m_csc.clear();

  std::vector<TrajectoryMeasurement> measurements = traj->measurements();
  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin();  im != measurements.end();  ++im) {
    TrajectoryMeasurement meas = *im;
    const TransientTrackingRecHit *hit = &(*meas.recHit());
    DetId id = hit->geographicalId();

    if (hit->isValid()) {
      TrajectoryStateOnSurface tsos = m_tsoscomb(meas.forwardPredictedState(), meas.backwardPredictedState());
      if (tsos.isValid()  &&  fabs(tsos.localPosition().x() - hit->localPosition().x()) < maxResidual) {

        if (id.det() == DetId::Tracker) {
          double xresid = tsos.localPosition().x() - hit->localPosition().x();
          double xresiderr2 = tsos.localError().positionError().xx() + hit->localPositionError().xx();

          m_tracker_numHits++;
          m_tracker_chi2 += xresid * xresid / xresiderr2;

          if (id.subdetId() == StripSubdetector::TID  ||  id.subdetId() == StripSubdetector::TEC) m_contains_TIDTEC = true;
        }

        else if (id.det() == DetId::Muon  &&  id.subdetId() == MuonSubdetId::DT) {
          const DTChamberId chamberId(id.rawId());
          const DTSuperLayerId superLayerId(id.rawId());

          // have we seen this chamber before?
          if (m_dt13.find(chamberId) == m_dt13.end()  &&  m_dt2.find(chamberId) == m_dt2.end()) {
            m_chamberIds.push_back(chamberId);
          }

          if (superLayerId.superlayer() == 2) {
            if (m_dt2.find(chamberId) == m_dt2.end()) {
              AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
              m_dt2[chamberId] = new MuonDT2ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
            }

            m_dt2[chamberId]->addResidual(&tsos, hit);
          }

          else {
            if (m_dt13.find(chamberId) == m_dt13.end()) {
              AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
              m_dt13[chamberId] = new MuonDT13ChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
            }

            m_dt13[chamberId]->addResidual(&tsos, hit);
          }
        }

        else if (id.det() == DetId::Muon  &&  id.subdetId() == MuonSubdetId::CSC) {
          const CSCDetId cscDetId(id.rawId());
          const CSCDetId chamberId(cscDetId.endcap(), cscDetId.station(), cscDetId.ring(), cscDetId.chamber());

          // not sure why we sometimes get layer == 0
          if (cscDetId.layer() != 0) {

             // have we seen this chamber before?
             if (m_csc.find(chamberId) == m_csc.end()) {
                m_chamberIds.push_back(chamberId);

                AlignableDetOrUnitPtr chamberAlignable = navigator->alignableFromDetId(chamberId);
                m_csc[chamberId] = new MuonCSCChamberResidual(globalGeometry, navigator, chamberId, chamberAlignable);
             }

             m_csc[chamberId]->addResidual(&tsos, hit);

          } // end if cscDetId.layer() != 0
        }

      } // end if track propagation is valid
    } // end if hit is valid
  } // end loop over measurments
}
MuonResidualsFromTrack::~MuonResidualsFromTrack ( )

Definition at line 85 of file MuonResidualsFromTrack.cc.

References m_csc, m_dt13, and m_dt2.

                                                {
  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt13.begin();  residual != m_dt13.end();  ++residual) {
    delete residual->second;
  }
  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_dt2.begin();  residual != m_dt2.end();  ++residual) {
    delete residual->second;
  }
  for (std::map<DetId,MuonChamberResidual*>::const_iterator residual = m_csc.begin();  residual != m_csc.end();  ++residual) {
    delete residual->second;
  }
}

Member Function Documentation

const std::vector<DetId> MuonResidualsFromTrack::chamberIds ( ) const [inline]
MuonChamberResidual* MuonResidualsFromTrack::chamberResidual ( DetId  chamberId,
int  type 
) [inline]

Definition at line 45 of file MuonResidualsFromTrack.h.

References MuonChamberResidual::kCSC, MuonChamberResidual::kDT13, MuonChamberResidual::kDT2, m_csc, m_dt13, m_dt2, and NULL.

Referenced by AlignmentMonitorSegmentDifferences::event(), AlignmentMonitorMuonVsCurvature::event(), AlignmentMonitorMuonSystemMap1D::event(), and MuonAlignmentFromReference::run().

                                                                  {
    if (type == MuonChamberResidual::kDT13) {
      if (m_dt13.find(chamberId) == m_dt13.end()) return NULL;
      return m_dt13[chamberId];
    }
    else if (type == MuonChamberResidual::kDT2) {
      if (m_dt2.find(chamberId) == m_dt2.end()) return NULL;
      return m_dt2[chamberId];
    }
    else if (type == MuonChamberResidual::kCSC) {
      if (m_csc.find(chamberId) == m_csc.end()) return NULL;
      return m_csc[chamberId];
    }
    else return NULL;
  };
bool MuonResidualsFromTrack::contains_TIDTEC ( ) const [inline]
double MuonResidualsFromTrack::trackerChi2 ( ) const [inline]

Definition at line 35 of file MuonResidualsFromTrack.h.

References m_tracker_chi2.

{ return m_tracker_chi2; };
int MuonResidualsFromTrack::trackerNumHits ( ) const [inline]
double MuonResidualsFromTrack::trackerRedChi2 ( ) const [inline]

Member Data Documentation

Definition at line 68 of file MuonResidualsFromTrack.h.

Referenced by chamberIds(), and MuonResidualsFromTrack().

Definition at line 66 of file MuonResidualsFromTrack.h.

Referenced by contains_TIDTEC(), and MuonResidualsFromTrack().

Definition at line 65 of file MuonResidualsFromTrack.h.

Referenced by MuonResidualsFromTrack(), trackerChi2(), and trackerRedChi2().

Definition at line 64 of file MuonResidualsFromTrack.h.

Referenced by MuonResidualsFromTrack(), trackerNumHits(), and trackerRedChi2().

Definition at line 59 of file MuonResidualsFromTrack.h.

Referenced by MuonResidualsFromTrack().