CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.h

Go to the documentation of this file.
00001 #ifndef TESTCORRECTION_HH
00002 #define TESTCORRECTION_HH
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:    TestCorrection
00007 // Class:      TestCorrection
00008 // 
00016 //
00017 // Original Author:  Marco De Mattia
00018 //         Created:  Thu Sep 11 12:16:00 CEST 2008
00019 // $Id: TestCorrection.h,v 1.9 2010/10/22 17:48:08 wmtan Exp $
00020 //
00021 //
00022 
00023 // system include files
00024 #include <memory>
00025 #include <string>
00026 #include <vector>
00027 
00028 // user include files
00029 #include "FWCore/Framework/interface/Frameworkfwd.h"
00030 #include "FWCore/Framework/interface/EDAnalyzer.h"
00031 #include "FWCore/Framework/interface/Event.h"
00032 #include "FWCore/Framework/interface/MakerMacros.h"
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034 
00035 #include "DataFormats/TrackReco/interface/Track.h"
00036 #include "DataFormats/MuonReco/interface/Muon.h"
00037 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00038 #include "DataFormats/Candidate/interface/Candidate.h"
00039 #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"
00040 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00041 
00042 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00043 
00044 // For the momentum scale correction
00045 #include "MuonAnalysis/MomentumScaleCalibration/interface/MomentumScaleCorrector.h"
00046 #include "MuonAnalysis/MomentumScaleCalibration/interface/ResolutionFunction.h"
00047 #include "MuonAnalysis/MomentumScaleCalibration/interface/BackgroundFunction.h"
00048 
00049 #include "TFile.h"
00050 #include "TProfile.h"
00051 #include "TH1F.h"
00052 
00053 #include "MuonAnalysis/MomentumScaleCalibration/interface/MuScleFitBase.h"
00054 
00055 //
00056 // class decleration
00057 //
00058 
00059 class TestCorrection : public edm::EDAnalyzer, MuScleFitBase {
00060 public:
00061   explicit TestCorrection(const edm::ParameterSet&);
00062   ~TestCorrection();
00063 
00064 private:
00065   virtual void initialize(const edm::EventSetup&);
00066   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00067   virtual void endJob() {};
00068   template<typename T>
00069   std::vector<reco::LeafCandidate> fillMuonCollection (const std::vector<T>& tracks) {
00070     std::vector<reco::LeafCandidate> muons;
00071     typename std::vector<T>::const_iterator track;
00072     for (track = tracks.begin(); track != tracks.end(); ++track){
00073       // Where 0.011163612 is the squared muon mass.
00074       reco::Particle::LorentzVector mu(track->px(),track->py(),track->pz(),
00075                                        sqrt(track->p()*track->p() + 0.011163612));
00076       reco::LeafCandidate muon(track->charge(),mu);
00077       // Store muon
00078       // ----------
00079       muons.push_back (muon);
00080     }
00081     return muons;
00082   }
00083   lorentzVector correctMuon( const lorentzVector& muon );
00084 
00085   // ----------member data ---------------------------
00086 
00087   // Collections labels
00088   // ------------------
00089   TH1F * uncorrectedPt_;
00090   TProfile * uncorrectedPtVsEta_;
00091   TH1F * correctedPt_;
00092   TProfile * correctedPtVsEta_;
00093 
00094   int eventCounter_;
00095 
00096   std::auto_ptr<MomentumScaleCorrector> corrector_;
00097   std::auto_ptr<ResolutionFunction> resolution_;
00098   std::auto_ptr<BackgroundFunction> background_;
00099 };
00100 
00101 #endif // TESTCORRECTION_HH