CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TopInitSubset.cc
Go to the documentation of this file.
2 
4  : srcToken_(consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("src"))) {
5  produces<reco::GenParticleCollection>();
6 }
7 
9 
12  evt.getByToken(srcToken_, src);
13 
15  std::unique_ptr<reco::GenParticleCollection> sel(new reco::GenParticleCollection);
16 
17  //fill output collection
18  fillOutput(*src, *sel);
19 
20  evt.put(std::move(sel));
21 }
22 
24  for (reco::GenParticleCollection::const_iterator t = src.begin(); t != src.end(); ++t) {
25  if (std::abs(t->pdgId()) == TopInitID::tID) {
26  bool hasTopMother = false;
27  for (unsigned idx = 0; idx < t->numberOfMothers(); ++idx)
28  if (std::abs(t->mother(idx)->pdgId()) == TopInitID::tID)
29  hasTopMother = true;
30  if (hasTopMother)
31  continue;
32  for (unsigned idx = 0; idx < t->numberOfMothers(); ++idx) {
33  reco::GenParticle* cand = new reco::GenParticle(t->mother(idx)->threeCharge(),
34  t->mother(idx)->p4(),
35  t->mother(idx)->vertex(),
36  t->mother(idx)->pdgId(),
37  t->mother(idx)->status(),
38  false);
39  std::unique_ptr<reco::GenParticle> ptr(cand);
40  sel.push_back(*ptr);
41  }
42  break;
43  }
44  }
45 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple cfg
Definition: looper.py:296
TopInitSubset(const edm::ParameterSet &)
Definition: TopInitSubset.cc:3
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void fillOutput(const reco::GenParticleCollection &, reco::GenParticleCollection &)
~TopInitSubset() override
Definition: TopInitSubset.cc:8
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void produce(edm::Event &, const edm::EventSetup &) override
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
Definition: TopInitSubset.h:22
static const int tID
Definition: TopInitSubset.h:10