00001 // -*- C++ -*- 00002 // Framework 00003 #include "FWCore/Framework/interface/EDProducer.h" 00004 #include "FWCore/Framework/interface/Event.h" 00005 #include "FWCore/Framework/interface/EventSetup.h" 00006 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00007 #include "DataFormats/Common/interface/Handle.h" 00008 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00009 #include "FWCore/PluginManager/interface/ModuleDef.h" 00010 #include "FWCore/Framework/interface/MakerMacros.h" 00011 #include "DataFormats/TrackReco/interface/Track.h" 00012 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00013 00014 class L3MuonCleaner : public edm::EDProducer { 00015 public: 00016 L3MuonCleaner(const edm::ParameterSet&); 00017 virtual ~L3MuonCleaner(){} 00018 virtual void produce(edm::Event&, const edm::EventSetup&); 00019 private: 00020 edm::InputTag m_input; 00021 int m_minTrkHits; 00022 int m_minMuonHits; 00023 double m_maxNormalizedChi2; 00024 }; 00025 00026 L3MuonCleaner::L3MuonCleaner(const edm::ParameterSet& parameterSet){ 00027 m_input = parameterSet.getParameter<edm::InputTag>("input"); 00028 m_minTrkHits = parameterSet.getParameter<int>("minTrkHits"); 00029 m_minMuonHits = parameterSet.getParameter<int>("minMuonHits"); 00030 m_maxNormalizedChi2 = parameterSet.getParameter<double>("maxNormalizedChi2"); 00031 produces<reco::TrackCollection>(); 00032 } 00033 00034 void L3MuonCleaner::produce(edm::Event& event, const edm::EventSetup&){ 00035 edm::Handle<reco::TrackCollection> tracks; 00036 event.getByLabel(m_input,tracks); 00037 std::auto_ptr<reco::TrackCollection> outTracks( new reco::TrackCollection() ); 00038 for ( reco::TrackCollection::const_iterator trk=tracks->begin(); trk!=tracks->end(); ++trk ){ 00039 if (trk->normalizedChi2()>m_maxNormalizedChi2) continue; 00040 if (trk->hitPattern().numberOfValidTrackerHits()<m_minTrkHits) continue; 00041 if (trk->hitPattern().numberOfValidMuonHits()<m_minMuonHits) continue; 00042 outTracks->push_back(*trk); 00043 } 00044 event.put(outTracks); 00045 } 00046 DEFINE_FWK_MODULE(L3MuonCleaner);