Go to the documentation of this file.00001
00018
00019 #include "FWCore/Framework/interface/EDProducer.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/EventSetup.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 #include "DataFormats/Common/interface/Handle.h"
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025
00026 #include "RecoMuon/L3MuonProducer/src/L3MuonCandidateProducer.h"
00027
00028
00029 #include "DataFormats/TrackReco/interface/Track.h"
00030 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00031 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00032 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00033
00034 #include <string>
00035
00036 using namespace edm;
00037 using namespace std;
00038 using namespace reco;
00039
00041 L3MuonCandidateProducer::L3MuonCandidateProducer(const ParameterSet& parameterSet){
00042 LogTrace("Muon|RecoMuon|L3MuonCandidateProducer")<<" constructor called";
00043
00044
00045 theL3CollectionLabel = parameterSet.getParameter<InputTag>("InputObjects");
00046
00047 produces<RecoChargedCandidateCollection>();
00048 }
00049
00051 L3MuonCandidateProducer::~L3MuonCandidateProducer(){
00052 LogTrace("Muon|RecoMuon|L3MuonCandidateProducer")<<" L3MuonCandidateProducer destructor called";
00053 }
00054
00055
00057 void L3MuonCandidateProducer::produce(Event& event, const EventSetup& eventSetup){
00058 const string metname = "Muon|RecoMuon|L3MuonCandidateProducer";
00059
00060
00061 LogTrace(metname)<<" Taking the L3/GLB muons: "<<theL3CollectionLabel.label();
00062 Handle<TrackCollection> tracks;
00063 event.getByLabel(theL3CollectionLabel,tracks);
00064
00065
00066 LogTrace(metname)<<" Creating the RecoChargedCandidate collection";
00067 auto_ptr<RecoChargedCandidateCollection> candidates( new RecoChargedCandidateCollection());
00068
00069 for (unsigned int i=0; i<tracks->size(); i++) {
00070 TrackRef tkref(tracks,i);
00071 Particle::Charge q = tkref->charge();
00072 Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
00073 Particle::Point vtx(tkref->vx(),tkref->vy(), tkref->vz());
00074
00075 int pid = 13;
00076 if(abs(q)==1) pid = q < 0 ? 13 : -13;
00077 else LogWarning(metname) << "L3MuonCandidate has charge = "<<q;
00078 RecoChargedCandidate cand(q, p4, vtx, pid);
00079
00080 cand.setTrack(tkref);
00081 candidates->push_back(cand);
00082 }
00083
00084 event.put(candidates);
00085
00086 LogTrace(metname)<<" Event loaded"
00087 <<"================================";
00088 }