ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Fabozzi/plugins/muonValidHitSelector.cc
Revision: 1.1
Committed: Thu Apr 15 14:51:37 2010 UTC (15 years ago) by fabozzi
Content type: text/plain
Branch: MAIN
CVS Tags: ff150610, ff080610, HEAD
Error occurred while calculating annotation data.
Log Message:
*** empty log message ***

File Contents

# Content
1 #include "FWCore/Framework/interface/EDFilter.h"
2 #include "FWCore/ParameterSet/interface/InputTag.h"
3 #include "FWCore/Framework/interface/Event.h"
4 #include "DataFormats/Common/interface/Handle.h"
5 #include "FWCore/Framework/interface/ESHandle.h"
6 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
7 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
8 #include "DataFormats/TrackReco/interface/TrackFwd.h"
9 #include "DataFormats/TrackReco/interface/Track.h"
10 #include "DataFormats/Candidate/interface/Candidate.h"
11 #include "DataFormats/MuonReco/interface/Muon.h"
12 #include <iterator>
13
14 using namespace edm;
15 using namespace std;
16 using namespace reco;
17
18
19 class MuonValidHitsSelector : public edm::EDFilter {
20 public:
21 MuonValidHitsSelector(const edm::ParameterSet& pset);
22 virtual bool filter( edm::Event& event, const edm::EventSetup& setup );
23 private:
24 InputTag muons_;
25
26 };
27
28 MuonValidHitsSelector::MuonValidHitsSelector(const edm::ParameterSet& pset) :
29 muons_(pset.getParameter<InputTag>("src") )
30 {
31 }
32
33 bool MuonValidHitsSelector::filter(edm::Event& event, const edm::EventSetup& setup) {
34 bool hasValidHits = false;
35 Handle<CandidateView> muonCands;
36 event.getByLabel(muons_, muonCands);
37
38 ESHandle<MagneticField> theMGField;
39 setup.get<IdealMagneticFieldRecord>().get(theMGField);
40
41 for( unsigned int i = 0; i < muonCands->size(); i++ ) {
42 const Candidate & goodMuon = (*muonCands)[i];
43 const Muon * muCand = dynamic_cast<const Muon*>(&goodMuon);
44 TrackRef staTrack = muCand->outerTrack();
45 reco::TransientTrack muTrack(staTrack,&*theMGField);
46 for (trackingRecHit_iterator it = muTrack.recHitsBegin(); it != muTrack.recHitsEnd(); it++) {
47 if ((*it)->isValid ()) {
48 hasValidHits = true;
49 return hasValidHits;
50 }
51 }
52 }
53 return hasValidHits;
54 }
55
56 #include "FWCore/Framework/interface/MakerMacros.h"
57
58 DEFINE_FWK_MODULE( MuonValidHitsSelector );
59