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::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPackedGenParticleProducer (const edm::ParameterSet &)
 
virtual void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const
 
 ~PATPackedGenParticleProducer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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  maxRapidity_(iConfig.getParameter<double>("maxRapidity"))
64 {
65  produces< std::vector<pat::PackedGenParticle> > ();
66  produces< edm::Association< std::vector<pat::PackedGenParticle> > >();
67 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< reco::GenParticleCollection > Cands_
const edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > Asso_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
const edm::EDGetTokenT< reco::GenParticleCollection > GenOrigs_
const edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > AssoOriginal_
pat::PATPackedGenParticleProducer::~PATPackedGenParticleProducer ( )

Definition at line 69 of file PATPackedGenParticleProducer.cc.

69 {}

Member Function Documentation

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

Implements edm::global::EDProducerBase.

Definition at line 71 of file PATPackedGenParticleProducer.cc.

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

71  {
72 
73 
75  iEvent.getByToken( Cands_, cands );
76  std::vector<reco::Candidate>::const_iterator cand;
77 
79  iEvent.getByToken( Asso_, asso );
80 
82  iEvent.getByToken( AssoOriginal_, assoOriginal);
83 
85  iEvent.getByToken( GenOrigs_, genOrigs);
86  std::vector<int> mapping(genOrigs->size(), -1);
87 
88 
90  iEvent.getByToken( PVs_, PVs );
91  reco::VertexRef PV(PVs.id());
92  math::XYZPoint PVpos;
93  if (!PVs->empty()) {
94  PV = reco::VertexRef(PVs, 0);
95  PVpos = PV->position();
96  }
97 
98  //invert the value map from Orig2New to New2Orig
99  std::map< edm::Ref<reco::GenParticleCollection> , edm::Ref<reco::GenParticleCollection> > reverseMap;
100  for(unsigned int ic=0, nc = genOrigs->size(); ic < nc; ++ic)
101  {
103  edm::Ref<reco::GenParticleCollection> newRef = (*assoOriginal)[originalRef];
104  reverseMap.insert(std::pair<edm::Ref<reco::GenParticleCollection>,edm::Ref<reco::GenParticleCollection>>(newRef,originalRef));
105  }
106 
107  std::auto_ptr< std::vector<pat::PackedGenParticle> > outPtrP( new std::vector<pat::PackedGenParticle> );
108 
109  unsigned int packed=0;
110  for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
111  const reco::GenParticle &cand=(*cands)[ic];
112  if(cand.status() ==1 && std::abs(cand.y()) < maxRapidity_)
113  {
114  // Obtain original gen particle collection reference from input reference and map
116  edm::Ref<reco::GenParticleCollection> originalRef=reverseMap[inputRef];
117  mapping[originalRef.key()]=packed;
118  packed++;
119  if(cand.numberOfMothers() > 0) {
120  edm::Ref<reco::GenParticleCollection> newRef=(*asso)[cand.motherRef(0)];
121  outPtrP->push_back( pat::PackedGenParticle(cand,newRef));
122  } else {
124 
125  }
126 
127  }
128  }
129 
130 
132 
133  std::auto_ptr<edm::Association< std::vector<pat::PackedGenParticle> > > gp2pgp(new edm::Association< std::vector<pat::PackedGenParticle> > (oh ));
134  edm::Association< std::vector<pat::PackedGenParticle> >::Filler gp2pgpFiller(*gp2pgp);
135  gp2pgpFiller.insert(genOrigs, mapping.begin(), mapping.end());
136  gp2pgpFiller.fill();
137  iEvent.put(gp2pgp);
138 
139 
140 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
virtual int status() const
status word
virtual double y() const
rapidity
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const edm::EDGetTokenT< reco::GenParticleCollection > Cands_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
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
const edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > Asso_
daughters::value_type motherRef(size_type i=0) const
reference to mother at given position
const edm::EDGetTokenT< reco::VertexCollection > PVs_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const edm::EDGetTokenT< reco::GenParticleCollection > GenOrigs_
const edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > AssoOriginal_

Member Data Documentation

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

Definition at line 50 of file PATPackedGenParticleProducer.cc.

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

Definition at line 51 of file PATPackedGenParticleProducer.cc.

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

Definition at line 48 of file PATPackedGenParticleProducer.cc.

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

Definition at line 49 of file PATPackedGenParticleProducer.cc.

const double pat::PATPackedGenParticleProducer::maxRapidity_
private

Definition at line 53 of file PATPackedGenParticleProducer.cc.

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

Definition at line 52 of file PATPackedGenParticleProducer.cc.