CMS 3D CMS Logo

PackedGenParticleSignalProducer.cc
Go to the documentation of this file.
1 #include <memory>
9 
10 namespace pat {
11 
13  public:
15  : genParticleToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticles"))),
17  iConfig.getParameter<edm::InputTag>("packedGenParticles"))) {
18  produces<pat::PackedGenParticleRefVector>();
19  }
20  ~PackedGenParticleSignalProducer() override = default;
21 
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
25 
26  private:
29  };
30 
31 } // namespace pat
32 
35  const edm::EventSetup& iSetup) const {
36  const auto& genParticles = iEvent.getHandle(genParticleToken_);
37  const auto& orig2packed = iEvent.get(assoToken_);
38 
39  auto signalGenParticleRefs = std::make_unique<pat::PackedGenParticleRefVector>();
40 
41  for (auto it = genParticles->begin(); it != genParticles->end(); ++it) {
42  const auto& orig = reco::GenParticleRef(genParticles, it - genParticles->begin());
43  if (orig->collisionId() != 0)
44  continue;
45  const auto& packed = orig2packed[orig];
46  if (packed.isNonnull()) {
47  signalGenParticleRefs->push_back(packed);
48  }
49  }
50 
51  iEvent.put(std::move(signalGenParticleRefs));
52 }
53 
54 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
57  desc.add<edm::InputTag>("genParticles", edm::InputTag("genParticles"))->setComment("genParticles input collection");
58  desc.add<edm::InputTag>("packedGenParticles", edm::InputTag("packedGenParticles"))
59  ->setComment("packedGenParticles input collection");
60  descriptions.add("packedGenParticlesSignal", desc);
61 }
62 
64 using namespace pat;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
~PackedGenParticleSignalProducer() override=default
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
PackedGenParticleSignalProducer(const edm::ParameterSet &iConfig)
fixed size matrix
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > assoToken_
def move(src, dest)
Definition: eostools.py:511