CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ParticleDecayProducer Class Reference

Inheritance diagram for ParticleDecayProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ParticleDecayProducer (const edm::ParameterSet &)
 ~ParticleDecayProducer ()

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

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 runEdmFileComparison::collection, daughtersPdgId_, decayChain_, getHLTprescales::index, j, and valias.

                                                                           :
  genCandidates_(iConfig.getParameter<InputTag>("src")),
  motherPdgId_(iConfig.getParameter<int>("motherPdgId")),
  daughtersPdgId_(iConfig.getParameter<vector<int> >("daughtersPdgId")),
  decayChain_(iConfig.getParameter<std::string>("decayChain")) {
  string alias;
  produces<CandidateCollection >(alias = decayChain_+ "Mother").setBranchAlias(alias);
  for (unsigned int j = 0; j < daughtersPdgId_.size(); ++ j) {
    ostringstream index,collection;
    index << j;
    collection << decayChain_ << "Lepton" << index.str();
    valias.push_back(collection.str());
    produces<CandidateCollection >(valias.at(j)).setBranchAlias( valias.at(j) );
  }
}
ParticleDecayProducer::~ParticleDecayProducer ( )

Definition at line 57 of file ParticleDecayProducer.cc.

                                              {
}

Member Function Documentation

void ParticleDecayProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

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.

                                                                                 {
  // get gen particle candidates
  edm::Handle<CandidateCollection> genCandidatesCollection;
  iEvent.getByLabel(genCandidates_, genCandidatesCollection);

  auto_ptr<CandidateCollection> mothercands(new CandidateCollection);
  auto_ptr<CandidateCollection> daughterscands(new CandidateCollection);
  size_t daughtersize = daughtersPdgId_.size();
  for( CandidateCollection::const_iterator p = genCandidatesCollection->begin();p != genCandidatesCollection->end(); ++ p ) {
    if (p->pdgId() == motherPdgId_  && p->status() == 3){
      mothercands->push_back(p->clone());
      size_t ndau = p->numberOfDaughters();
      for(size_t i = 0; i < ndau; ++ i){
        for (size_t j = 0; j < daughtersize; ++j){
          if (p->daughter(i)->pdgId()==daughtersPdgId_[j] && p->daughter(i)->status()==3){
            daughterscands->push_back(p->daughter(i)->clone());
          }
        }
      }      
    }
  }

  iEvent.put(mothercands, decayChain_ + "Mother");
  daughterscands->sort(GreaterByPt<reco::Candidate>());
  
  for (unsigned int row = 0; row < daughtersize; ++ row ){
    auto_ptr<CandidateCollection> leptonscands_(new CandidateCollection);
    leptonscands_->push_back((daughterscands->begin()+row)->clone());
    iEvent.put(leptonscands_, valias.at(row));
  }
}

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().

Definition at line 21 of file ParticleDecayProducer.cc.

Referenced by produce().

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().