CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

AlignmentMuonHIPTrajectorySelector Class Reference

#include <Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc>

Inheritance diagram for AlignmentMuonHIPTrajectorySelector:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 AlignmentMuonHIPTrajectorySelector (const edm::ParameterSet &)
 ~AlignmentMuonHIPTrajectorySelector ()

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

bool m_hists
edm::InputTag m_input
double m_maxMuonResidual
double m_maxTrackerForwardRedChi2
double m_minPt
int m_minTrackerDOF
TH1F * m_pt
TH1F * m_resid_after
TH1F * m_resid_before
TH1F * m_tracker_dof
TH1F * m_tracker_forwardredchi2

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 55 of file AlignmentMuonHIPTrajectorySelector.cc.


Constructor & Destructor Documentation

AlignmentMuonHIPTrajectorySelector::AlignmentMuonHIPTrajectorySelector ( const edm::ParameterSet iConfig) [explicit]

Definition at line 87 of file AlignmentMuonHIPTrajectorySelector.cc.

References m_hists, m_pt, m_resid_after, m_resid_before, m_tracker_dof, and m_tracker_forwardredchi2.

   : m_input(iConfig.getParameter<edm::InputTag>("input"))
   , m_minPt(iConfig.getParameter<double>("minPt"))
   , m_maxTrackerForwardRedChi2(iConfig.getParameter<double>("maxTrackerForwardRedChi2"))
   , m_minTrackerDOF(iConfig.getParameter<int>("minTrackerDOF"))
   , m_maxMuonResidual(iConfig.getParameter<double>("maxMuonResidual"))
   , m_hists(iConfig.getParameter<bool>("hists"))
   , m_pt(NULL), m_tracker_forwardredchi2(NULL), m_tracker_dof(NULL)
{
   produces<TrajTrackAssociationCollection>();

   if (m_hists) {
      edm::Service<TFileService> fs;
      m_pt = fs->make<TH1F>("pt", "Transverse momentum (GeV)", 100, 0., 100.);
      m_tracker_forwardredchi2 = fs->make<TH1F>("trackerForwardRedChi2", "forward-biased reduced chi2 in tracker", 100, 0., 5.);
      m_tracker_dof = fs->make<TH1F>("trackerDOF", "DOF in tracker", 61, -0.5, 60.5);
      m_resid_before = fs->make<TH1F>("residBefore", "muon residuals before cut (cm)", 100, -20, 20);
      m_resid_after = fs->make<TH1F>("residAfter", "muon residuals after cut (cm)", 100, -20, 20);
   }
}
AlignmentMuonHIPTrajectorySelector::~AlignmentMuonHIPTrajectorySelector ( )

Definition at line 109 of file AlignmentMuonHIPTrajectorySelector.cc.

{}

Member Function Documentation

void AlignmentMuonHIPTrajectorySelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 118 of file AlignmentMuonHIPTrajectorySelector.cc.

References TrajectoryMeasurement::backwardPredictedState(), TrajectoryStateCombiner::combine(), CSC(), TrackingRecHit::dimension(), MuonSubdetId::DT, TrajectoryMeasurement::forwardPredictedState(), TrackingRecHit::geographicalId(), edm::Event::getByLabel(), TrackingRecHit::isValid(), TrajectoryStateOnSurface::localError(), TrackingRecHit::localPosition(), TrajectoryStateOnSurface::localPosition(), TrackingRecHit::localPositionError(), m_hists, m_input, m_maxMuonResidual, m_minPt, m_minTrackerDOF, m_pt, m_resid_after, m_resid_before, m_tracker_dof, m_tracker_forwardredchi2, DetId::Muon, LocalTrajectoryError::positionError(), edm::Event::put(), TrajectoryMeasurement::recHit(), align::Tracker, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), LocalError::xy(), PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

{
   // input
   edm::Handle<TrajTrackAssociationCollection> originalTrajTrackMap;
   iEvent.getByLabel(m_input, originalTrajTrackMap);

   // output
   std::auto_ptr<TrajTrackAssociationCollection> newTrajTrackMap(new TrajTrackAssociationCollection());

   TrajectoryStateCombiner tsoscomb;

   for (TrajTrackAssociationCollection::const_iterator iPair = originalTrajTrackMap->begin();  iPair != originalTrajTrackMap->end();  ++iPair) {
      if (m_hists) {
         m_pt->Fill((*(*iPair).val).pt());
      }

      if ((*(*iPair).val).pt() > m_minPt) {

         std::vector<TrajectoryMeasurement> measurements = (*(*iPair).key).measurements();

         bool has_bad_residual = false;

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

            if (hit->isValid()  &&  id.det() == DetId::Tracker) {
               if (hit->dimension() == 1) {
                  double residual = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
                  double error2 = meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();

                  tracker_forwardchi2 += residual * residual / error2;
                  tracker_dof += 1.;
               }
               else if (hit->dimension() == 2) {
                  double residualx = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
                  double residualy = meas.forwardPredictedState().localPosition().y() - hit->localPosition().y();
                  double errorxx2 = meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();
                  double errorxy2 = meas.forwardPredictedState().localError().positionError().xy() + hit->localPositionError().xy();
                  double erroryy2 = meas.forwardPredictedState().localError().positionError().yy() + hit->localPositionError().yy();

                  tracker_forwardchi2 += (residualx * residualx + residualy * residualy) / (errorxx2 + 2.*errorxy2 + erroryy2);
                  tracker_dof += 2.;
               }
            } // end if a tracker hit

            if (hit->isValid()  &&  id.det() == DetId::Muon  &&  (id.subdetId() == MuonSubdetId::DT  ||  id.subdetId() == MuonSubdetId::CSC)) {
               TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
               double residual = tsosc.localPosition().x() - hit->localPosition().x();
               m_resid_before->Fill(residual);
               if (fabs(residual) > m_maxMuonResidual) {
                  has_bad_residual = true;
               }
            } // end if a muon hit

         }
         tracker_dof -= 5.;
         double tracker_forwardredchi2 = tracker_forwardchi2 / tracker_dof;

         if (m_hists) {
            m_tracker_forwardredchi2->Fill(tracker_forwardredchi2);
            m_tracker_dof->Fill(tracker_dof);

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

               if (!has_bad_residual) {
                  if (hit->isValid()  &&  id.det() == DetId::Muon  &&  (id.subdetId() == MuonSubdetId::DT  ||  id.subdetId() == MuonSubdetId::CSC)) {
                     TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
                     double residual = tsosc.localPosition().x() - hit->localPosition().x();
                     m_resid_after->Fill(residual);
                  }
               } // end if residuals pass cut
            } // end second loop over hits
         } // end if filling histograms

         if (tracker_forwardredchi2 < m_maxTrackerForwardRedChi2  &&  tracker_dof >= m_minTrackerDOF  &&  !has_bad_residual) {
            newTrajTrackMap->insert((*iPair).key, (*iPair).val);
         } // end if passes tracker cuts
      } // end if passes pT cut
   } // end loop over original trajTrackMap

   // put it in the Event
   iEvent.put(newTrajTrackMap);
}

Member Data Documentation

Definition at line 64 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

Definition at line 68 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

Definition at line 66 of file AlignmentMuonHIPTrajectorySelector.cc.

Definition at line 65 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

Definition at line 67 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().