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;
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
reco::GenParticleRef
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
Definition: GenParticleFwd.h:17
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
pat::PackedGenParticleSignalProducer
Definition: PackedGenParticleSignalProducer.cc:12
pat::PackedGenParticleSignalProducer::assoToken_
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > assoToken_
Definition: PackedGenParticleSignalProducer.cc:28
edm::EDGetTokenT< reco::GenParticleCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::PackedGenParticleSignalProducer::genParticleToken_
const edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
Definition: PackedGenParticleSignalProducer.cc:27
PackedGenParticle.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::PackedGenParticleSignalProducer::~PackedGenParticleSignalProducer
~PackedGenParticleSignalProducer() override=default
pat::PackedGenParticleSignalProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PackedGenParticleSignalProducer.cc:33
GenParticle.h
MakerMacros.h
pat::PackedGenParticle
Definition: PackedGenParticle.h:19
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
pat::PackedGenParticleSignalProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: PackedGenParticleSignalProducer.cc:55
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
pat::PackedGenParticleSignalProducer::PackedGenParticleSignalProducer
PackedGenParticleSignalProducer(const edm::ParameterSet &iConfig)
Definition: PackedGenParticleSignalProducer.cc:14
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15