Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:32:24

0001 #ifndef Alignment_MuonAlignmentAlgorithms_MuonResidualsFromTrack_H
0002 #define Alignment_MuonAlignmentAlgorithms_MuonResidualsFromTrack_H
0003 
0004 /** \class MuonResidualsFromTrack
0005  *  $Id: $
0006  *  \author J. Pivarski - Texas A&M University <pivarski@physics.tamu.edu>
0007  */
0008 
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 #include "Alignment/CommonAlignment/interface/AlignableNavigator.h"
0012 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0013 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0014 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0017 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
0018 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0019 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0020 #include "DataFormats/MuonReco/interface/Muon.h"
0021 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0022 #include "DataFormats/TrackReco/interface/Track.h"
0023 #include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
0024 
0025 #include "FWCore/Framework/interface/EventSetup.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028 
0029 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0030 #include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"
0031 #include "TrackingTools/PatternTools/interface/TrajectorySmoother.h"
0032 
0033 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0034 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0035 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0036 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0037 //#include "TrackingTools/PatternTools/interface/Trajectory.h"
0038 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0039 
0040 #include "DataFormats/TrackReco/interface/Track.h"
0041 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0042 #include "DataFormats/DetId/interface/DetId.h"
0043 
0044 #include "TMatrixDSym.h"
0045 #include "TMatrixD.h"
0046 
0047 #include <vector>
0048 #include <map>
0049 
0050 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonChamberResidual.h"
0051 
0052 class MuonResidualsFromTrack {
0053 public:
0054   using BuilderToken = edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord>;
0055   static edm::ESInputTag builderESInputTag();
0056 
0057   // residuals from global muon trajectories
0058   MuonResidualsFromTrack(edm::ESHandle<TransientTrackingRecHitBuilder> builder,
0059                          edm::ESHandle<MagneticField> magneticField,
0060                          edm::ESHandle<GlobalTrackingGeometry> globalGeometry,
0061                          edm::ESHandle<DetIdAssociator> muonDetIdAssociator_,
0062                          edm::ESHandle<Propagator> prop,
0063                          const Trajectory *traj,
0064                          const reco::Track *recoTrack,
0065                          AlignableNavigator *navigator,
0066                          double maxResidual);
0067 
0068   // residuals from tracker muons
0069   MuonResidualsFromTrack(edm::ESHandle<GlobalTrackingGeometry> globalGeometry,
0070                          const reco::Muon *recoMuon,
0071                          AlignableNavigator *navigator,
0072                          double maxResidual);
0073 
0074   ~MuonResidualsFromTrack();
0075 
0076   void clear();
0077 
0078   const reco::Track *getTrack() { return m_recoTrack; }
0079   const reco::Muon *getMuon() { return m_recoMuon; }
0080 
0081   int trackerNumHits() const { return m_tracker_numHits; }
0082 
0083   double trackerChi2() const { return m_tracker_chi2; }
0084   double trackerRedChi2() const;
0085   double normalizedChi2() const;
0086 
0087   bool contains_TIDTEC() const { return m_contains_TIDTEC; }
0088 
0089   const std::vector<DetId> chamberIds() const { return m_chamberIds; }
0090 
0091   MuonChamberResidual *chamberResidual(DetId chamberId, int type);
0092 
0093   TMatrixDSym covMatrix(DetId chamberId);
0094   TMatrixDSym corrMatrix(DetId chamberId);
0095   TMatrixD choleskyCorrMatrix(DetId chamberId);
0096 
0097 private:
0098   TrajectoryStateCombiner m_tsoscomb;
0099 
0100   int m_tracker_numHits;
0101   double m_tracker_chi2;
0102   bool m_contains_TIDTEC;
0103 
0104   std::vector<DetId> m_chamberIds;
0105   std::map<DetId, MuonChamberResidual *> m_dt13, m_dt2, m_csc;
0106   std::map<DetId, TMatrixDSym> m_trkCovMatrix;
0107 
0108   void addTrkCovMatrix(DetId, TrajectoryStateOnSurface &);
0109 
0110   // pointer to its track
0111   const reco::Track *m_recoTrack;
0112 
0113   // track muon
0114   const reco::Muon *m_recoMuon;
0115 };
0116 
0117 #endif  // Alignment_MuonAlignmentAlgorithms_MuonResidualsFromTrack_H