CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::PATPackedGenParticleProducer Class Reference
Inheritance diagram for pat::PATPackedGenParticleProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPackedGenParticleProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PATPackedGenParticleProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT
< edm::Association
< reco::GenParticleCollection > > 
Asso_
 
edm::EDGetTokenT
< edm::Association
< reco::GenParticleCollection > > 
AssoOriginal_
 
edm::EDGetTokenT
< reco::GenParticleCollection
Cands_
 
edm::EDGetTokenT
< reco::GenParticleCollection
GenOrigs_
 
double maxEta_
 
edm::EDGetTokenT
< reco::VertexCollection
PVs_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 40 of file PATPackedGenParticleProducer.cc.

Constructor & Destructor Documentation

pat::PATPackedGenParticleProducer::PATPackedGenParticleProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 57 of file PATPackedGenParticleProducer.cc.

57  :
58  Cands_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("inputCollection"))),
59  GenOrigs_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("inputOriginal"))),
62  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("inputVertices"))),
63  maxEta_(iConfig.getParameter<double>("maxEta"))
64 {
65  produces< std::vector<pat::PackedGenParticle> > ();
66  produces< edm::Association< std::vector<pat::PackedGenParticle> > >();
67 
68 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > PVs_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::GenParticleCollection > GenOrigs_
edm::EDGetTokenT< reco::GenParticleCollection > Cands_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > Asso_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > AssoOriginal_
pat::PATPackedGenParticleProducer::~PATPackedGenParticleProducer ( )

Definition at line 70 of file PATPackedGenParticleProducer.cc.

70 {}

Member Function Documentation

void pat::PATPackedGenParticleProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 72 of file PATPackedGenParticleProducer.cc.

References funct::abs(), reco::LeafCandidate::eta(), edm::Event::getByToken(), edm::Ref< C, T, F >::key(), reco::CompositeRefCandidateT< D >::motherRef(), reco::CompositeRefCandidateT< D >::numberOfMothers(), edm::Event::put(), and reco::LeafCandidate::status().

72  {
73 
74 
76  iEvent.getByToken( Cands_, cands );
77  std::vector<reco::Candidate>::const_iterator cand;
78 
80  iEvent.getByToken( Asso_, asso );
81 
83  iEvent.getByToken( AssoOriginal_, assoOriginal);
84 
86  iEvent.getByToken( GenOrigs_, genOrigs);
87  std::vector<int> mapping(genOrigs->size(), -1);
88 
89 
91  iEvent.getByToken( PVs_, PVs );
92  reco::VertexRef PV(PVs.id());
93  math::XYZPoint PVpos;
94  if (!PVs->empty()) {
95  PV = reco::VertexRef(PVs, 0);
96  PVpos = PV->position();
97  }
98 
99  //invert the value map from Orig2New to New2Orig
100  std::map< edm::Ref<reco::GenParticleCollection> , edm::Ref<reco::GenParticleCollection> > reverseMap;
101  for(unsigned int ic=0, nc = genOrigs->size(); ic < nc; ++ic)
102  {
104  edm::Ref<reco::GenParticleCollection> newRef = (*assoOriginal)[originalRef];
105  reverseMap.insert(std::pair<edm::Ref<reco::GenParticleCollection>,edm::Ref<reco::GenParticleCollection>>(newRef,originalRef));
106  }
107 
108  std::auto_ptr< std::vector<pat::PackedGenParticle> > outPtrP( new std::vector<pat::PackedGenParticle> );
109 
110  unsigned int packed=0;
111  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
112  const reco::GenParticle &cand=(*cands)[ic];
113  if(cand.status() ==1 && std::abs(cand.eta()) < maxEta_)
114  {
115  // Obtain original gen particle collection reference from input reference and map
117  edm::Ref<reco::GenParticleCollection> originalRef=reverseMap[inputRef];
118  mapping[originalRef.key()]=packed;
119  packed++;
120  if(cand.numberOfMothers() > 0) {
121  edm::Ref<reco::GenParticleCollection> newRef=(*asso)[cand.motherRef(0)];
122  outPtrP->push_back( pat::PackedGenParticle(cand,newRef));
123  } else {
125 
126  }
127 
128  }
129  }
130 
131 
133 
134  std::auto_ptr<edm::Association< std::vector<pat::PackedGenParticle> > > gp2pgp(new edm::Association< std::vector<pat::PackedGenParticle> > (oh ));
135  edm::Association< std::vector<pat::PackedGenParticle> >::Filler gp2pgpFiller(*gp2pgp);
136  gp2pgpFiller.insert(genOrigs, mapping.begin(), mapping.end());
137  gp2pgpFiller.fill();
138  iEvent.put(gp2pgp);
139 
140 
141 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< reco::VertexCollection > PVs_
edm::EDGetTokenT< reco::GenParticleCollection > GenOrigs_
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
key_type key() const
Accessor for product key.
Definition: Ref.h:266
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > AssoOriginal_

Member Data Documentation

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > pat::PATPackedGenParticleProducer::Asso_
private

Definition at line 50 of file PATPackedGenParticleProducer.cc.

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > pat::PATPackedGenParticleProducer::AssoOriginal_
private

Definition at line 51 of file PATPackedGenParticleProducer.cc.

edm::EDGetTokenT<reco::GenParticleCollection> pat::PATPackedGenParticleProducer::Cands_
private

Definition at line 48 of file PATPackedGenParticleProducer.cc.

edm::EDGetTokenT<reco::GenParticleCollection> pat::PATPackedGenParticleProducer::GenOrigs_
private

Definition at line 49 of file PATPackedGenParticleProducer.cc.

double pat::PATPackedGenParticleProducer::maxEta_
private

Definition at line 53 of file PATPackedGenParticleProducer.cc.

edm::EDGetTokenT<reco::VertexCollection> pat::PATPackedGenParticleProducer::PVs_
private

Definition at line 52 of file PATPackedGenParticleProducer.cc.