Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:04:12

0001 #include "GeneratorInterface/Core/interface/PartonShowerCsHepMCFilter.h"
0002 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0003 #include <iostream>
0004 #include "HepPDT/ParticleID.hh"
0005 
0006 using namespace edm;
0007 using namespace std;
0008 
0009 //constructor
0010 PartonShowerCsHepMCFilter::PartonShowerCsHepMCFilter(const edm::ParameterSet& iConfig) {}
0011 
0012 //destructor
0013 PartonShowerCsHepMCFilter::~PartonShowerCsHepMCFilter() {}
0014 
0015 //
0016 // member functions
0017 //
0018 
0019 // ------------ method called to produce the data  ------------
0020 bool PartonShowerCsHepMCFilter::filter(const HepMC::GenEvent* evt) {
0021   // loop over gen particles
0022   for (HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
0023     // check only status 2 particles
0024     if ((*p)->status() == 2) {
0025       // if one of the status 2 particles is a C-hadron, accept the event
0026       HepPDT::ParticleID pid((*p)->pdg_id());
0027       if (pid.hasCharm()) {
0028         return true;  // accept event
0029       }
0030     }
0031   }
0032 
0033   return false;  // skip event
0034 }