Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/Utilities/interface/InputTag.h"
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033
00034 #include "DataFormats/MuonReco/interface/Muon.h"
00035 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00036 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00037
00038 #include "DataFormats/TrackReco/interface/Track.h"
00039 #include "DataFormats/PatCandidates/interface/Muon.h"
00040 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
00041
00042 #include "MuonAnalysis/MomentumScaleCalibration/interface/Functions.h"
00043
00044 class MuScleFitMuonProducer : public edm::EDProducer {
00045 public:
00046 explicit MuScleFitMuonProducer(const edm::ParameterSet&);
00047 ~MuScleFitMuonProducer();
00048
00049 private:
00050 virtual void beginJob() ;
00051 virtual void produce(edm::Event&, const edm::EventSetup&);
00052 virtual void endJob() ;
00053
00054 edm::InputTag theMuonLabel_;
00055
00056
00057 };
00058
00059 MuScleFitMuonProducer::MuScleFitMuonProducer(const edm::ParameterSet& iConfig) :
00060 theMuonLabel_( iConfig.getParameter<edm::InputTag>( "MuonLabel" ) )
00061 {
00062 produces<reco::MuonCollection>();
00063 }
00064
00065
00066 MuScleFitMuonProducer::~MuScleFitMuonProducer()
00067 {
00068 }
00069
00070
00071 void MuScleFitMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00072 {
00073 edm::Handle<reco::MuonCollection> allMuons;
00074 iEvent.getByLabel (theMuonLabel_, allMuons);
00075
00076 std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
00077
00078
00079 for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
00080
00081 double pt = muon->pt();
00082
00083
00084 double a_0 = 1.0039;
00085
00086
00087
00088
00089
00090 pt = a_0*pt;
00091
00092
00093
00094
00095
00096 TF1 G("G", "[0]*exp(-0.5*pow(x,2)/[1])", -5., 5.);
00097 double sigma = 0.00014;
00098 double norm = 1/(sqrt(2*TMath::Pi()));
00099 G.SetParameter(0,norm);
00100 G.SetParameter(1,1);
00101
00102 pt = 1/(1/pt + sigma*G.GetRandom());
00103
00104
00105 double eta = muon->eta();
00106 double phi = muon->phi();
00107
00108
00109
00110 reco::Muon * newMuon = muon->clone();
00111 newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
00112
00113 pOut->push_back(*newMuon);
00114 }
00115
00116
00117
00118 iEvent.put(pOut);
00119 }
00120
00121
00122 void
00123 MuScleFitMuonProducer::beginJob()
00124 {
00125 }
00126
00127
00128 void
00129 MuScleFitMuonProducer::endJob()
00130 {
00131 }
00132
00133
00134 DEFINE_FWK_MODULE(MuScleFitMuonProducer);