CMS 3D CMS Logo

ParticleDecayProducer.cc
Go to the documentation of this file.
1 
7 // user include files
13 #include <vector>
14 
16 public:
18  ~ParticleDecayProducer() override;
19 
20 private:
21  void produce(edm::Event&, const edm::EventSetup&) override;
24  std::vector<int> daughtersPdgId_;
26  std::vector<std::string> valias;
27 };
28 
29 // Candidate handling
34 #include <sstream>
35 using namespace edm;
36 using namespace std;
37 using namespace reco;
38 
39 // constructors
41  : genCandidatesToken_(consumes<CandidateCollection>(iConfig.getParameter<InputTag>("src"))),
42  motherPdgId_(iConfig.getParameter<int>("motherPdgId")),
43  daughtersPdgId_(iConfig.getParameter<vector<int> >("daughtersPdgId")),
44  decayChain_(iConfig.getParameter<std::string>("decayChain")) {
45  string alias;
46  produces<CandidateCollection>(alias = decayChain_ + "Mother").setBranchAlias(alias);
47  for (unsigned int j = 0; j < daughtersPdgId_.size(); ++j) {
48  ostringstream index, collection;
49  index << j;
50  collection << decayChain_ << "Lepton" << index.str();
51  valias.push_back(collection.str());
52  produces<CandidateCollection>(valias.at(j)).setBranchAlias(valias.at(j));
53  }
54 }
55 
56 // destructor
58 
60  // get gen particle candidates
61  edm::Handle<CandidateCollection> genCandidatesCollection;
62  iEvent.getByToken(genCandidatesToken_, genCandidatesCollection);
63 
64  unique_ptr<CandidateCollection> mothercands(new CandidateCollection);
65  unique_ptr<CandidateCollection> daughterscands(new CandidateCollection);
66  size_t daughtersize = daughtersPdgId_.size();
67  for (CandidateCollection::const_iterator p = genCandidatesCollection->begin(); p != genCandidatesCollection->end();
68  ++p) {
69  if (p->pdgId() == motherPdgId_ && p->status() == 3) {
70  mothercands->push_back(p->clone());
71  size_t ndau = p->numberOfDaughters();
72  for (size_t i = 0; i < ndau; ++i) {
73  for (size_t j = 0; j < daughtersize; ++j) {
74  if (p->daughter(i)->pdgId() == daughtersPdgId_[j] && p->daughter(i)->status() == 3) {
75  daughterscands->push_back(p->daughter(i)->clone());
76  }
77  }
78  }
79  }
80  }
81 
82  iEvent.put(std::move(mothercands), decayChain_ + "Mother");
83  daughterscands->sort(GreaterByPt<reco::Candidate>());
84 
85  for (unsigned int row = 0; row < daughtersize; ++row) {
86  unique_ptr<CandidateCollection> leptonscands_(new CandidateCollection);
87  leptonscands_->push_back((daughterscands->begin() + row)->clone());
88  iEvent.put(std::move(leptonscands_), valias.at(row));
89  }
90 }
91 
93 
mps_fire.i
i
Definition: mps_fire.py:428
GreaterByPt
Definition: PtComparator.h:24
EDProducer.h
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ParticleDecayProducer::~ParticleDecayProducer
~ParticleDecayProducer() override
Definition: ParticleDecayProducer.cc:57
PtComparator.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ParticleDecayProducer
Definition: ParticleDecayProducer.cc:15
edm::Handle
Definition: AssociativeIterator.h:50
CandMatchMap.h
MakerMacros.h
ParticleDecayProducer::decayChain_
std::string decayChain_
Definition: ParticleDecayProducer.cc:25
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
ParticleDecayProducer::daughtersPdgId_
std::vector< int > daughtersPdgId_
Definition: ParticleDecayProducer.cc:24
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ParticleDecayProducer::ParticleDecayProducer
ParticleDecayProducer(const edm::ParameterSet &)
Definition: ParticleDecayProducer.cc:40
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
ParticleDecayProducer::valias
std::vector< std::string > valias
Definition: ParticleDecayProducer.cc:26
ParticleDecayProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ParticleDecayProducer.cc:59
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
ParticleDecayProducer::genCandidatesToken_
edm::EDGetTokenT< reco::CandidateCollection > genCandidatesToken_
Definition: ParticleDecayProducer.cc:22
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:128
edm::EDProducer
Definition: EDProducer.h:35
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
AssociationVector.h
Candidate.h
ParameterSet.h
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
ParticleDecayProducer::motherPdgId_
int motherPdgId_
Definition: ParticleDecayProducer.cc:23
edm::InputTag
Definition: InputTag.h:15
edm::OwnVector
Definition: OwnVector.h:24