27 <<
" Invalid Configuration Parameter 'before_or_afterFSR' = " << before_or_afterFSR_string <<
" !!\n";
32 produces<reco::GenParticleCollection>(
"");
43 int pdgIdMother,
int pdgIdDaughter, std::vector<const reco::GenParticle*>& genParticlesFromZs)
45 for ( reco::GenParticleCollection::const_iterator genParticle = genParticles.begin();
46 genParticle != genParticles.end(); ++genParticle ) {
47 if (
TMath::Abs(genParticle->pdgId()) == pdgIdMother ) {
48 unsigned numDaughters = genParticle->numberOfDaughters();
49 for (
unsigned iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
51 if (
TMath::Abs(daughter->
pdgId()) == pdgIdDaughter ) genParticlesFromZs.push_back(daughter);
58 int pdgIdDaughter,
int minDaughters,
bool requireSubsequentEntries, std::vector<const reco::GenParticle*>& genParticlesFromZs)
60 int indexDaughterPlus = -1;
61 int indexDaughterMinus = -1;
63 unsigned numGenParticles = genParticles.size();
64 for (
unsigned iGenParticle = 0; iGenParticle < numGenParticles; ++iGenParticle ) {
68 if ( genParticle.
charge() > 0 ) indexDaughterPlus = (
int)iGenParticle;
69 else if ( genParticle.
charge() < 0 ) indexDaughterMinus = (
int)iGenParticle;
71 if ( indexDaughterPlus != -1 && indexDaughterMinus != -1 ) {
72 if (
TMath::Abs(indexDaughterPlus - indexDaughterMinus) == 1 || (!requireSubsequentEntries) ) {
73 genParticlesFromZs.push_back(&genParticles[indexDaughterPlus]);
74 genParticlesFromZs.push_back(&genParticles[indexDaughterMinus]);
75 indexDaughterPlus = -1;
76 indexDaughterMinus = -1;
81 if ( (
int)genParticlesFromZs.size() >= minDaughters )
break;
85 void findDaughters(
const reco::GenParticle* mother, std::vector<const reco::GenParticle*>& daughters,
int status)
88 for (
unsigned iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
91 if ( status == -1 || daughter->
status() ==
status ) daughters.push_back(daughter);
93 findDaughters(daughter, daughters, status);
101 std::cout <<
"<GenParticlesFromZsSelectorForMCEmbedding::produce>:" << std::endl;
108 std::vector<const reco::GenParticle*> genParticlesFromZs_tmp;
120 findGenParticles(*genParticles, *pdgIdMother, *pdgIdDaughter, genParticlesFromZs_tmp);
129 if ( !((
int)genParticlesFromZs_tmp.size() >=
minDaughters_) ) {
132 findGenParticles(*genParticles, *pdgIdDaughter,
minDaughters_,
true, genParticlesFromZs_tmp);
135 if ( !((
int)genParticlesFromZs_tmp.size() >=
minDaughters_) ) {
138 findGenParticles(*genParticles, *pdgIdDaughter,
minDaughters_,
false, genParticlesFromZs_tmp);
145 for ( std::vector<const reco::GenParticle*>::const_iterator genParticleFromZ_beforeFSR = genParticlesFromZs_tmp.begin();
146 genParticleFromZ_beforeFSR != genParticlesFromZs_tmp.end(); ++genParticleFromZ_beforeFSR ) {
148 genParticlesFromZs->push_back(**genParticleFromZ_beforeFSR);
150 std::vector<const reco::GenParticle*> daughters;
151 findDaughters(*genParticleFromZ_beforeFSR, daughters, -1);
152 const reco::GenParticle* genParticleFromZ_afterFSR = (*genParticleFromZ_beforeFSR);
153 for ( std::vector<const reco::GenParticle*>::const_iterator daughter = daughters.
begin();
154 daughter != daughters.
end(); ++daughter ) {
155 if ( (*daughter)->pdgId() == (*genParticleFromZ_beforeFSR)->pdgId() &&
156 (*daughter)->energy() < genParticleFromZ_afterFSR->
energy() ) genParticleFromZ_afterFSR = (*daughter);
159 std::cout <<
"genParticleFromZ #" << idx <<
" (beforeFSR): Pt = " << (*genParticleFromZ_beforeFSR)->pt() <<
","
160 <<
" eta = " << (*genParticleFromZ_beforeFSR)->eta() <<
", phi = " << (*genParticleFromZ_beforeFSR)->phi() << std::endl;
161 std::cout <<
"genParticleFromZ #" << idx <<
" (afterFSR): Pt = " << genParticleFromZ_afterFSR->
pt() <<
","
162 <<
" eta = " << genParticleFromZ_afterFSR->
eta() <<
", phi = " << genParticleFromZ_afterFSR->
phi() << std::endl;
164 genParticlesFromZs->push_back(*genParticleFromZ_afterFSR);
169 evt.
put(genParticlesFromZs);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
~GenParticlesFromZsSelectorForMCEmbedding()
virtual double energy() const final
energy
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void produce(edm::Event &, const edm::EventSetup &)
virtual double phi() const final
momentum azimuthal angle
virtual int status() const final
status word
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
const_iterator end() const
last daughter const_iterator
virtual size_t numberOfDaughters() const
number of daughters
virtual int charge() const final
electric charge
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
GenParticlesFromZsSelectorForMCEmbedding(const edm::ParameterSet &)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
virtual int pdgId() const final
PDG identifier.
const_iterator begin() const
first daughter const_iterator
virtual double eta() const final
momentum pseudorapidity
virtual double pt() const final
transverse momentum