CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATSecondaryVertexSlimmer.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 
4 // user include files
8 
12 
16 
17 namespace pat {
19  public:
22 
23  virtual void produce(edm::Event&, const edm::EventSetup&);
24  private:
28  };
29 }
30 
32  src_(consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("src"))),
33  map_(consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
34  map2_(consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("lostTracksCandidates")))
35 {
36  produces< reco::VertexCompositePtrCandidateCollection >();
37 }
38 
40 
43  iEvent.getByToken(src_, vertices);
44  std::auto_ptr<reco::VertexCompositePtrCandidateCollection > outPtr(new reco::VertexCompositePtrCandidateCollection);
45 
47  iEvent.getByToken(map_,pf2pc);
49  iEvent.getByToken(map2_,pf2pc2);
50 
51 
52  outPtr->reserve(vertices->size());
53  for (unsigned int i = 0, n = vertices->size(); i < n; ++i) {
54  const reco::Vertex &v = (*vertices)[i];
55  outPtr->push_back(reco::VertexCompositePtrCandidate(0,v.p4(),v.position(), v.error(), v.chi2(), v.ndof()));
56 
57  for(reco::Vertex::trackRef_iterator it=v.tracks_begin(); it != v.tracks_end(); it++) {
58  if(v.trackWeight(*it)>0.5) {
59  if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0) {
60  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
61  }
62  else {
63  if((*pf2pc2)[*it].isNonnull()) {
64  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[*it]) ));
65  }
66  else { std::cout << "HELPME" << std::endl;}
67  }
68  }
69  }
70  }
71 
72  iEvent.put(outPtr);
73 }
74 
virtual void produce(edm::Event &, const edm::EventSetup &)
int i
Definition: DBlmapReader.cc:9
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< pat::PackedCandidate > PackedCandidateCollection
PATSecondaryVertexSlimmer(const edm::ParameterSet &)
const Point & position() const
position
Definition: Vertex.h:92
std::vector< VertexCompositePtrCandidate > VertexCompositePtrCandidateCollection
collection of Candidate objects
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
edm::EDGetTokenT< std::vector< reco::Vertex > > src_
double chi2() const
chi-squares
Definition: Vertex.h:81
double ndof() const
Definition: Vertex.h:88
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
Definition: Vertex.cc:112
Error error() const
return SMatrix
Definition: Vertex.h:115
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
tuple cout
Definition: gather_cfg.py:121
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39