Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-16 22:19:00

0001 #ifndef RecoMuon_TrackingTools_MuonErrorMatrixAdjuster_H
0002 #define RecoMuon_TrackingTools_MuonErrorMatrixAdjuster_H
0003 
0004 /** \class MuonErrorMatrixAdjuster
0005  *
0006  * EDProducer which duplicatesa collection of track, adjusting their error matrix
0007  *
0008  * track collection is retrieve from the event, duplicated, while the error matrix is corrected
0009  * rechit are copied into a new collection
0010  * track extra is also copied and error matrix are corrected by the same scale factors
0011  *
0012  *
0013  * \author Jean-Roch Vlimant  UCSB
0014  * \author Finn Rebassoo      UCSB
0015  */
0016 
0017 #include <memory>
0018 #include "FWCore/Framework/interface/Frameworkfwd.h"
0019 #include "FWCore/Framework/interface/stream/EDProducer.h"
0020 
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 
0026 #include "DataFormats/TrackReco/interface/Track.h"
0027 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0028 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0029 
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031 
0032 class FreeTrajectoryState;
0033 class MuonErroMatrix;
0034 class MagneticField;
0035 class IdealMagneticFieldRecord;
0036 class MuonErrorMatrix;
0037 class TrackerTopologyRcd;
0038 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0039 
0040 #include "FWCore/Framework/interface/ESHandle.h"
0041 
0042 //
0043 // class decleration
0044 //
0045 
0046 class MuonErrorMatrixAdjuster : public edm::stream::EDProducer<> {
0047 public:
0048   /// constructor
0049   explicit MuonErrorMatrixAdjuster(const edm::ParameterSet&);
0050   /// destructor
0051   ~MuonErrorMatrixAdjuster() override;
0052 
0053 private:
0054   /// framework method
0055   void produce(edm::Event&, const edm::EventSetup&) override;
0056 
0057   /// return a corrected error matrix
0058   reco::TrackBase::CovarianceMatrix fix_cov_matrix(const reco::TrackBase::CovarianceMatrix& error_matrix,
0059                                                    const GlobalVector& momentum);
0060   /// mutliply revised_matrix (first argument)  by second matrix TERM by TERM
0061   void multiply(reco::TrackBase::CovarianceMatrix& revised_matrix,
0062                 const reco::TrackBase::CovarianceMatrix& scale_matrix);
0063   /// divide the num_matrix  (first argument) by second matrix, TERM by TERM
0064   bool divide(reco::TrackBase::CovarianceMatrix& num_matrix, const reco::TrackBase::CovarianceMatrix& denom_matrix);
0065 
0066   /// create a corrected reco::Track from itself and trajectory state (redundant information)
0067   reco::Track makeTrack(const reco::Track& recotrack_orig, const FreeTrajectoryState& PCAstate);
0068 
0069   /// make a selection on the reco:Track. (dummy for the moment)
0070   bool selectTrack(const reco::Track& recotrack_orig);
0071 
0072   /// create a track extra for the newly created recotrack, scaling the outer/inner measurment error matrix by the scale matrix recotrack/recotrack_orig
0073   reco::TrackExtra* makeTrackExtra(const reco::Track& recotrack_orig,
0074                                    reco::Track& recotrack,
0075                                    reco::TrackExtraCollection& TEcol);
0076 
0077   /// attached rechits to the newly created reco::Track and reco::TrackExtra
0078   bool attachRecHits(const reco::Track& recotrack_orig,
0079                      reco::Track& recotrack,
0080                      reco::TrackExtra& trackextra,
0081                      TrackingRecHitCollection& RHcol,
0082                      const TrackerTopology& ttopo);
0083 
0084   // ----------member data ---------------------------
0085   /// log category: MuonErrorMatrixAdjuster
0086   std::string theCategory;
0087 
0088   /// input tag of the reco::Track collection to be corrected
0089   edm::InputTag theTrackLabel;
0090 
0091   /// instrance name of the created track collecion. rechit and trackextra have no instance name
0092   std::string theInstanceName;
0093 
0094   /// select the rescaling or replacing method to correct the error matrix
0095   bool theRescale;
0096 
0097   /// holds the error matrix parametrization
0098   std::unique_ptr<MuonErrorMatrix> theMatrixProvider;
0099 
0100   /// hold on to the magnetic field
0101   edm::ESHandle<MagneticField> theField;
0102   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0103   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theHttopoToken;
0104 
0105   /// get reference before put track extra to the event, in order to create edm::Ref
0106   edm::RefProd<reco::TrackExtraCollection> theRefprodTE;
0107   edm::Ref<reco::TrackExtraCollection>::key_type theTEi;
0108 
0109   /// get reference before put rechit to the event, in order to create edm::Ref
0110   edm::RefProd<TrackingRecHitCollection> theRefprodRH;
0111   edm::Ref<TrackingRecHitCollection>::key_type theRHi;
0112 };
0113 
0114 #endif