CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/MuonAnalysis/MomentumScaleCalibration/plugins/TestResolution.h

Go to the documentation of this file.
00001 #ifndef TESTRESOLUTION_HH
00002 #define TESTRESOLUTION_HH
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:    TestResolution
00007 // Class:      TestResolution
00008 // 
00016 //
00017 // Original Author:  Marco De Mattia
00018 //         Created:  Thu Sep 11 12:16:00 CEST 2008
00019 // $Id: TestResolution.h,v 1.6 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 resolution
00045 #include "MuonAnalysis/MomentumScaleCalibration/interface/ResolutionFunction.h"
00046 
00047 #include "TFile.h"
00048 #include "TProfile.h"
00049 
00050 //
00051 // class decleration
00052 //
00053 
00054 class TestResolution : public edm::EDAnalyzer {
00055 public:
00056   explicit TestResolution(const edm::ParameterSet&);
00057   ~TestResolution();
00058 
00059 private:
00060   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00061   virtual void endJob() {};
00062   template<typename T>
00063   std::vector<reco::LeafCandidate> fillMuonCollection (const std::vector<T>& tracks) {
00064     std::vector<reco::LeafCandidate> muons;
00065     typename std::vector<T>::const_iterator track;
00066     for (track = tracks.begin(); track != tracks.end(); ++track){
00067       // Where 0.011163612 is the squared muon mass.
00068       reco::Particle::LorentzVector mu(track->px(),track->py(),track->pz(),
00069                                        sqrt(track->p()*track->p() + 0.011163612));
00070       reco::LeafCandidate muon(track->charge(),mu);
00071       // Store muon
00072       // ----------
00073       muons.push_back (muon);
00074     }
00075     return muons;
00076   } 
00077 
00078   // ----------member data ---------------------------
00079 
00080   // Collections labels
00081   // ------------------
00082   edm::InputTag theMuonLabel_;
00083 
00084   int theMuonType_;
00085   std::string theRootFileName_;
00086   TFile * outputFile_;
00087 
00088   TProfile * sigmaPt_;
00089 
00090   int eventCounter_;
00091 
00092   std::auto_ptr<ResolutionFunction> resolutionFunction_;
00093 };
00094 
00095 #endif // TESTRESOLUTION_HH