Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:19

0001 #ifndef RecoMuon_TrackingTools_MuonErrorMatrixAnalyzer_H
0002 #define RecoMuon_TrackingTools_MuonErrorMatrixAnalyzer_H
0003 
0004 /** \class MuonErrorMatrixAnalyzer
0005  * 
0006  * EDAalyzer which compare reconstructed tracks to simulated tracks parameter in bins of pt, eta, (phi)
0007  * to give an empirical parametrization of the track parameters errors.
0008  *
0009  *
0010  * \author Jean-Roch Vlimant  UCSB
0011  * \author Finn Rebassoo      UCSB
0012 */
0013 
0014 #include <memory>
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0017 
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 
0023 #include "RecoMuon/TrackingTools/interface/MuonErrorMatrix.h"
0024 
0025 #include "FWCore/Framework/interface/ESHandle.h"
0026 
0027 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0028 #include "DataFormats/GeometrySurface/interface/Plane.h"
0029 
0030 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0031 
0032 class MagneticField;
0033 class IdealMagneticFieldRecord;
0034 class TrackingComponentsRecord;
0035 class TH1;
0036 class TH2;
0037 class Propagator;
0038 //
0039 // class decleration
0040 //
0041 
0042 class MuonErrorMatrixAnalyzer : public edm::one::EDAnalyzer<> {
0043 public:
0044   /// constructor
0045   explicit MuonErrorMatrixAnalyzer(const edm::ParameterSet&);
0046 
0047   ///destructor
0048   ~MuonErrorMatrixAnalyzer();
0049 
0050 private:
0051   /// framework methods
0052   virtual void beginJob();
0053   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0054   virtual void endJob();
0055 
0056   /// produce error parametrization from reported errors
0057   void analyze_from_errormatrix(const edm::Event&, const edm::EventSetup&);
0058   /// produces error parametrization from the pull of track parameters
0059   void analyze_from_pull(const edm::Event&, const edm::EventSetup&);
0060 
0061   // ----------member data ---------------------------
0062   /// log category: "MuonErrorMatrixAnalyzer"
0063   std::string theCategory;
0064 
0065   /// input tags for reco::Track and TrackingParticle
0066   edm::InputTag theTrackLabel;
0067   edm::InputTag trackingParticleLabel;
0068 
0069   /// The associator used for reco/gen association (configurable)
0070   std::string theAssocLabel;
0071 
0072   /// hold on the magnetic field
0073   edm::ESHandle<MagneticField> theField;
0074   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0075 
0076   /// class holder for the reported error parametrization
0077   MuonErrorMatrix* theErrorMatrixStore_Reported;
0078   edm::ParameterSet theErrorMatrixStore_Reported_pset;
0079 
0080   /// class holder for the empirical error parametrization from residual
0081   MuonErrorMatrix* theErrorMatrixStore_Residual;
0082   edm::ParameterSet theErrorMatrixStore_Residual_pset;
0083 
0084   /// class holder for the empirical error scale factor parametrization from pull
0085   MuonErrorMatrix* theErrorMatrixStore_Pull;
0086   edm::ParameterSet theErrorMatrixStore_Pull_pset;
0087 
0088   /// the range of the pull fit is [-theGaussianPullFitRange, theGaussianPullFitRange] [-2,2] by default
0089   double theGaussianPullFitRange;
0090 
0091   /// radius at which the comparison is made: =0 is using TSCPBuilderNoMaterial, !=0 is using the propagator
0092   double theRadius;
0093 
0094   /// reference to the cylinder of radius theRadius
0095   Cylinder::CylinderPointer refRSurface;
0096 
0097   /// z at which the comparison is made: =0 is using TSCPBuilderNoMaterial, !=0 is using the propagator
0098   double theZ;
0099 
0100   ///reference to a plane at -z [0] and +z [1]:  [(z>0)]
0101   Plane::PlanePointer refZSurface[2];
0102 
0103   /// propagator used to go to the cylinder surface, ALONG momentum
0104   std::string thePropagatorName;
0105   edm::ESHandle<Propagator> thePropagator;
0106   edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
0107 
0108   /// put the free trajectory state to the TSCPBuilderNoMaterial or the cylinder surface
0109   FreeTrajectoryState refLocusState(const FreeTrajectoryState& fts);
0110 
0111   /// control plot root file (auxiliary, configurable)
0112   TFile* thePlotFile;
0113   TFileDirectory* thePlotDir;
0114   TList* theBookKeeping;
0115   std::string thePlotFileName;
0116 
0117   /// arrays of plots for the empirical error parametrization
0118   typedef TH1* TH1ptr;
0119   TH1ptr* theHist_array_residual[15];
0120   TH1ptr* theHist_array_pull[15];
0121 
0122   /// index whithin the array of plots
0123   inline unsigned int index(TProfile3D* pf, unsigned int i, unsigned int j, unsigned int k) {
0124     return (((i * pf->GetNbinsY()) + j) * pf->GetNbinsZ()) + k;
0125   }
0126   unsigned int maxIndex(TProfile3D* pf) { return pf->GetNbinsX() * pf->GetNbinsY() * pf->GetNbinsZ(); }
0127 
0128   struct extractRes {
0129     double corr;
0130     double x;
0131     double y;
0132   };
0133   /// fit procedure to extract sigma_x sigma_y and correlation factor from 2D residual histogram
0134   extractRes extract(TH2* h2);
0135 };
0136 #endif