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 Member Functions | Private Attributes
ParticleDecayProducer Class Reference
Inheritance diagram for ParticleDecayProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ParticleDecayProducer (const edm::ParameterSet &)
 
 ~ParticleDecayProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::vector< int > daughtersPdgId_
 
std::string decayChain_
 
edm::InputTag genCandidates_
 
int motherPdgId_
 
std::vector< std::string > valias
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Original Author: Nicola De Filippis

Definition at line 14 of file ParticleDecayProducer.cc.

Constructor & Destructor Documentation

ParticleDecayProducer::ParticleDecayProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 40 of file ParticleDecayProducer.cc.

References ExpressReco_HICollisions_FallBack::alias, runEdmFileComparison::collection, daughtersPdgId_, decayChain_, getHLTprescales::index, j, and valias.

40  :
41  genCandidates_(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 }
T getParameter(std::string const &) const
std::vector< std::string > valias
int j
Definition: DBlmapReader.cc:9
std::vector< int > daughtersPdgId_
ParticleDecayProducer::~ParticleDecayProducer ( )

Definition at line 57 of file ParticleDecayProducer.cc.

57  {
58 }

Member Function Documentation

void ParticleDecayProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 60 of file ParticleDecayProducer.cc.

References clone(), daughtersPdgId_, decayChain_, genCandidates_, edm::Event::getByLabel(), i, j, motherPdgId_, L1TEmulatorMonitor_cff::p, edm::Event::put(), and valias.

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

60  {
61  // get gen particle candidates
62  edm::Handle<CandidateCollection> genCandidatesCollection;
63  iEvent.getByLabel(genCandidates_, genCandidatesCollection);
64 
65  auto_ptr<CandidateCollection> mothercands(new CandidateCollection);
66  auto_ptr<CandidateCollection> daughterscands(new CandidateCollection);
67  size_t daughtersize = daughtersPdgId_.size();
68  for( CandidateCollection::const_iterator p = genCandidatesCollection->begin();p != genCandidatesCollection->end(); ++ 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(mothercands, decayChain_ + "Mother");
83  daughterscands->sort(GreaterByPt<reco::Candidate>());
84 
85  for (unsigned int row = 0; row < daughtersize; ++ row ){
86  auto_ptr<CandidateCollection> leptonscands_(new CandidateCollection);
87  leptonscands_->push_back((daughterscands->begin()+row)->clone());
88  iEvent.put(leptonscands_, valias.at(row));
89  }
90 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > valias
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
std::vector< int > daughtersPdgId_
T * clone(const T *tp)
Definition: Ptr.h:42

Member Data Documentation

std::vector<int> ParticleDecayProducer::daughtersPdgId_
private

Definition at line 23 of file ParticleDecayProducer.cc.

Referenced by ParticleDecayProducer(), and produce().

std::string ParticleDecayProducer::decayChain_
private

Definition at line 24 of file ParticleDecayProducer.cc.

Referenced by ParticleDecayProducer(), and produce().

edm::InputTag ParticleDecayProducer::genCandidates_
private

Definition at line 21 of file ParticleDecayProducer.cc.

Referenced by produce().

int ParticleDecayProducer::motherPdgId_
private

Definition at line 22 of file ParticleDecayProducer.cc.

Referenced by produce().

std::vector<std::string> ParticleDecayProducer::valias
private

Definition at line 25 of file ParticleDecayProducer.cc.

Referenced by ParticleDecayProducer(), and produce().