CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATLostTracks.cc
Go to the documentation of this file.
1 #include <string>
2 
3 
22 
23 
24 namespace pat {
25  class PATLostTracks : public edm::EDProducer {
26  public:
27  explicit PATLostTracks(const edm::ParameterSet&);
29 
30  virtual void produce(edm::Event&, const edm::EventSetup&);
31 
32  private:
35  double minPt_;
36  double minHits_;
37  double minPixelHits_;
38  };
39 }
40 
42  Cands_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("inputCandidates"))),
43  Tracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputTracks"))),
44  minPt_(iConfig.getParameter<double>("minPt")),
45  minHits_(iConfig.getParameter<uint32_t>("minHits")),
46  minPixelHits_(iConfig.getParameter<uint32_t>("minPixelHits"))
47 
48 {
49  produces< std::vector<reco::Track> > ();
50 }
51 
53 
55 
57  iEvent.getByToken( Cands_, cands );
58  std::vector<reco::Candidate>::const_iterator cand;
59 
61  iEvent.getByToken( Tracks_, Tracks );
62 
63  std::auto_ptr< std::vector<reco::Track> > outPtrP( new std::vector<reco::Track> );
64  std::vector<bool> used(Tracks->size());
65 
66 
67  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
68  const reco::PFCandidate &cand=(*cands)[ic];
69  if (cand.charge()) {
70  if(cand.trackRef().isNonnull() && cand.trackRef().id() == Tracks.id())
71  {
72  used[cand.trackRef().key()]=true;
73  }
74  }
75  }
76 
77  for(unsigned int i=0; i < used.size(); i++)
78  {
79  if(!used[i] && (*Tracks)[i].pt() > minPt_ &&
80  (*Tracks)[i].numberOfValidHits() >= minHits_ &&
81  (*Tracks)[i].hitPattern().numberOfValidPixelHits() >= minPixelHits_ ) outPtrP->push_back((*Tracks)[i]);
82  }
83 
84  iEvent.put(outPtrP);
85 
86 }
87 
88 
89 using pat::PATLostTracks;
int i
Definition: DBlmapReader.cc:9
ProductID id() const
Definition: HandleBase.cc:15
edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
PATLostTracks(const edm::ParameterSet &)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:429
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual int charge() const GCC11_FINAL
electric charge
key_type key() const
Accessor for product key.
Definition: Ref.h:266
edm::EDGetTokenT< reco::TrackCollection > Tracks_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
virtual void produce(edm::Event &, const edm::EventSetup &)