CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATPackedGenParticleProducer.cc
Go to the documentation of this file.
1 #include <string>
2 
3 
22 
26 
33 #include "CLHEP/Vector/ThreeVector.h"
34 #include "CLHEP/Vector/LorentzVector.h"
35 #include "CLHEP/Matrix/Vector.h"
36 #include <string>
37 
38 
39 namespace pat {
41  public:
44 
45  virtual void produce(edm::Event&, const edm::EventSetup&);
46 
47  private:
51  double maxEta_;
52  };
53 }
54 
56  Cands_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("inputCollection"))),
57  Asso_(consumes<edm::Association<reco::GenParticleCollection> >(iConfig.getParameter<edm::InputTag>("map"))),
58  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("inputVertices"))),
59  maxEta_(iConfig.getParameter<double>("maxEta"))
60 {
61  produces< std::vector<pat::PackedGenParticle> > ();
62 }
63 
65 
67 
68 
70  iEvent.getByToken( Cands_, cands );
71  std::vector<reco::Candidate>::const_iterator cand;
72 
74  iEvent.getByToken( Asso_, asso );
75 
76 
78  iEvent.getByToken( PVs_, PVs );
79  reco::VertexRef PV(PVs.id());
80  math::XYZPoint PVpos;
81  if (!PVs->empty()) {
82  PV = reco::VertexRef(PVs, 0);
83  PVpos = PV->position();
84  }
85 
86  std::auto_ptr< std::vector<pat::PackedGenParticle> > outPtrP( new std::vector<pat::PackedGenParticle> );
87 
88 
89  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
90  const reco::GenParticle &cand=(*cands)[ic];
91  if(cand.status() ==1 && std::abs(cand.eta() < maxEta_))
92  {
93  if(cand.numberOfMothers() > 0) {
94  edm::Ref<reco::GenParticleCollection> newRef=(*asso)[cand.motherRef(0)];
95  outPtrP->push_back( pat::PackedGenParticle(cand,newRef));
96  } else {
98 
99  }
100 
101  }
102  }
103 
104 
105  iEvent.put( outPtrP );
106 
107 
108 }
109 
110 
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< reco::VertexCollection > PVs_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
PATPackedGenParticleProducer(const edm::ParameterSet &)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual int status() const GCC11_FINAL
status word
edm::EDGetTokenT< reco::GenParticleCollection > Cands_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual size_t numberOfMothers() const
number of mothers
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
daughters::value_type motherRef(size_type i=0) const
reference to mother at given position
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > Asso_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12