-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12249 from vmariani/Dstargen_filter
Adding Dstar filter for enriched MC production request
- Loading branch information
Showing
6 changed files
with
573 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Dstar_D0_K3pi.dec | ||
# | ||
# This is the decay file for the decay D*+ -> D0(K-pi+pi+pi-) pi+ | ||
# | ||
Alias MyD0 D0 | ||
Alias Myanti-D0 anti-D0 | ||
ChargeConj Myanti-D0 MyD0 | ||
Alias MyD*+ D*+ | ||
Alias MyD*- D*- | ||
ChargeConj MyD*- MyD*+ | ||
# | ||
Decay MyD*+ | ||
1.000 MyD0 pi+ VSS; | ||
Enddecay | ||
CDecay MyD*- | ||
# | ||
Decay MyD0 | ||
1.000 K- pi+ pi+ pi- PHSP; | ||
Enddecay | ||
CDecay Myanti-D0 | ||
# | ||
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Dstar_D0_Kpi.dec | ||
# | ||
# This is the decay file for the decay D*+ -> D0(K-pi+) pi+ | ||
# | ||
Alias MyD0 D0 | ||
Alias Myanti-D0 anti-D0 | ||
ChargeConj Myanti-D0 MyD0 | ||
Alias MyD*+ D*+ | ||
Alias MyD*- D*- | ||
ChargeConj MyD*- MyD*+ | ||
# | ||
Decay MyD*+ | ||
1.000 MyD0 pi+ VSS; | ||
Enddecay | ||
CDecay MyD*- | ||
# | ||
Decay MyD0 | ||
1.000 K- pi+ PHSP; | ||
Enddecay | ||
CDecay Myanti-D0 | ||
# | ||
End |
74 changes: 74 additions & 0 deletions
74
GeneratorInterface/GenFilters/interface/PythiaMomDauFilter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#ifndef PYTHIAMOMDAUFILTER_h | ||
#define PYTHIAMOMDAUFILTER_h | ||
// -*- C++ -*- | ||
// | ||
// Package: PythiaMomDauFilter | ||
// Class: PythiaMomDauFilter | ||
// | ||
/**\class PythiaMomDauFilter PythiaMomDauFilter.cc | ||
Description: Filter events using MotherId and ChildrenIds infos | ||
Implementation: | ||
<Notes on implementation> | ||
*/ | ||
// | ||
// Original Author: Daniele Pedrini | ||
// Created: Oct 27 2015 | ||
// $Id: PythiaMomDauFilter.h,v 1.1 2015/10/27 pedrini Exp $ | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDFilter.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
|
||
// | ||
// class decleration | ||
// | ||
|
||
class PythiaMomDauFilter : public edm::EDFilter { | ||
public: | ||
explicit PythiaMomDauFilter(const edm::ParameterSet&); | ||
~PythiaMomDauFilter(); | ||
|
||
|
||
virtual bool filter(edm::Event&, const edm::EventSetup&); | ||
private: | ||
// ----------memeber function---------------------- | ||
|
||
// ----------member data --------------------------- | ||
|
||
std::string label_; | ||
std::vector<int> dauIDs; | ||
std::vector<int> desIDs; | ||
int particleID; | ||
int daughterID; | ||
bool chargeconju; | ||
int ndaughters; | ||
int ndescendants; | ||
double minptcut; | ||
double maxptcut; | ||
double minetacut; | ||
double maxetacut; | ||
double mom_minptcut; | ||
double mom_maxptcut; | ||
double mom_minetacut; | ||
double mom_maxetacut; | ||
}; | ||
#define PYCOMP pycomp_ | ||
extern "C" { | ||
int PYCOMP(int& ip); | ||
} | ||
#endif | ||
DEFINE_FWK_MODULE(PythiaMomDauFilter); |
161 changes: 161 additions & 0 deletions
161
GeneratorInterface/GenFilters/src/PythiaMomDauFilter.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
|
||
#include "GeneratorInterface/GenFilters/interface/PythiaMomDauFilter.h" | ||
|
||
|
||
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" | ||
#include "HepMC/PythiaWrapper6_4.h" | ||
#include <iostream> | ||
|
||
using namespace edm; | ||
using namespace std; | ||
|
||
|
||
PythiaMomDauFilter::PythiaMomDauFilter(const edm::ParameterSet& iConfig) : | ||
label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))), | ||
particleID(iConfig.getUntrackedParameter("ParticleID", 0)), | ||
daughterID(iConfig.getUntrackedParameter("DaughterID", 0)), | ||
chargeconju(iConfig.getUntrackedParameter("ChargeConjugation", true)), | ||
ndaughters(iConfig.getUntrackedParameter("NumberDaughters", 0)), | ||
ndescendants(iConfig.getUntrackedParameter("NumberDescendants", 0)), | ||
minptcut(iConfig.getUntrackedParameter("MinPt", 0.)), | ||
maxptcut(iConfig.getUntrackedParameter("MaxPt", 14000.)), | ||
minetacut(iConfig.getUntrackedParameter("MinEta", -10.)), | ||
maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.)), | ||
mom_minptcut(iConfig.getUntrackedParameter("MomMinPt", 0.)), | ||
mom_maxptcut(iConfig.getUntrackedParameter("MomMaxPt", 14000.)), | ||
mom_minetacut(iConfig.getUntrackedParameter("MomMinEta", -10.)), | ||
mom_maxetacut(iConfig.getUntrackedParameter("MomMaxEta", 10.)) | ||
{ | ||
//now do what ever initialization is needed | ||
vector<int> defdauID; | ||
defdauID.push_back(0); | ||
vector<int> defdesID; | ||
defdesID.push_back(0); | ||
dauIDs = iConfig.getUntrackedParameter< vector<int> >("DaughterIDs", defdauID); | ||
desIDs = iConfig.getUntrackedParameter< vector<int> >("DescendantsIDs", defdesID); | ||
} | ||
|
||
|
||
PythiaMomDauFilter::~PythiaMomDauFilter() | ||
{ | ||
|
||
// do anything here that needs to be done at desctruction time | ||
// (e.g. close files, deallocate resources etc.) | ||
|
||
} | ||
|
||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
bool PythiaMomDauFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
bool accepted = false; | ||
bool mom_accepted = false; | ||
Handle<HepMCProduct> evt; | ||
iEvent.getByLabel(label_, evt); | ||
|
||
const HepMC::GenEvent * myGenEvent = evt->GetEvent(); | ||
int ndauac = 0; | ||
int ndau = 0; | ||
int ndesac = 0; | ||
int ndes = 0; | ||
|
||
for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) { | ||
|
||
if( (*p)->pdg_id() != particleID ) continue ; | ||
if( (*p)->momentum().perp() > mom_minptcut && (*p)->momentum().perp() < mom_maxptcut && (*p)->momentum().eta() > mom_minetacut && (*p)->momentum().eta() < mom_maxetacut ){ | ||
mom_accepted = true; | ||
ndauac = 0; | ||
ndau = 0; | ||
ndesac = 0; | ||
ndes = 0; | ||
if ( (*p)->end_vertex() ) { | ||
for ( HepMC::GenVertex::particle_iterator dau =(*p)->end_vertex()->particles_begin(HepMC::children); dau != (*p)->end_vertex()->particles_end(HepMC::children); ++dau ) { | ||
++ndau; | ||
for( unsigned int i=0; i<dauIDs.size(); ++i) { | ||
if( (*dau)->pdg_id() != dauIDs[i] ) continue ; | ||
++ndauac; | ||
break; | ||
} | ||
if((*dau)->pdg_id() == daughterID){ | ||
for(HepMC::GenVertex::particle_iterator des = (*dau)->end_vertex()->particles_begin(HepMC::children); des != (*des)->end_vertex()->particles_end(HepMC::children); ++des ){ | ||
++ndes; | ||
for( unsigned int i=0; i<desIDs.size(); ++i) { | ||
if( (*des)->pdg_id() != desIDs[i] ) continue ; | ||
if( (*des)->momentum().perp() > minptcut && (*des)->momentum().perp() < maxptcut && (*des)->momentum().eta() > minetacut && (*des)->momentum().eta() < maxetacut ) { | ||
++ndesac; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if( ndau == ndaughters && ndauac == ndaughters && mom_accepted && ndes == ndescendants && ndesac == ndescendants ) { | ||
accepted = true; | ||
break; | ||
} | ||
|
||
} | ||
|
||
|
||
if( !accepted && chargeconju ) { | ||
|
||
mom_accepted = false; | ||
for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) { | ||
|
||
if( (*p)->pdg_id() != -particleID ) continue ; | ||
if( (*p)->momentum().perp() > mom_minptcut && (*p)->momentum().perp() < mom_maxptcut && (*p)->momentum().eta() > mom_minetacut && (*p)->momentum().eta() < mom_maxetacut ){ | ||
mom_accepted = true; | ||
ndauac = 0; | ||
ndau = 0; | ||
ndesac = 0; | ||
ndes = 0; | ||
if ( (*p)->end_vertex() ) { | ||
for ( HepMC::GenVertex::particle_iterator dau =(*p)->end_vertex()->particles_begin(HepMC::children); dau != (*p)->end_vertex()->particles_end(HepMC::children); ++dau ) { | ||
++ndau; | ||
for( unsigned int i=0; i<dauIDs.size(); ++i) { | ||
int IDanti = -dauIDs[i]; | ||
int pythiaCode = PYCOMP(dauIDs[i]); | ||
int has_antipart = pydat2.kchg[3-1][pythiaCode-1]; | ||
if( has_antipart == 0 ) IDanti = dauIDs[i]; | ||
if( (*dau)->pdg_id() != IDanti ) continue ; | ||
++ndauac; | ||
break; | ||
} | ||
if((*dau)->pdg_id() == -daughterID) { | ||
for( HepMC::GenVertex::particle_iterator des = (*dau)->end_vertex()->particles_begin(HepMC::children); des != (*des)->end_vertex()->particles_end(HepMC::children); ++des ){ | ||
++ndes; | ||
for( unsigned int i=0; i<desIDs.size(); ++i) { | ||
int IDanti = -desIDs[i]; | ||
int pythiaCode = PYCOMP(desIDs[i]); | ||
int has_antipart = pydat2.kchg[3-1][pythiaCode-1]; | ||
if( has_antipart == 0 ) IDanti = desIDs[i]; | ||
if( (*des)->pdg_id() != IDanti ) continue ; | ||
if( (*des)->momentum().perp() > minptcut && (*des)->momentum().perp() < maxptcut && (*des)->momentum().eta() > minetacut && (*des)->momentum().eta() < maxetacut ) { | ||
++ndesac; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if( ndau == ndaughters && ndauac == ndaughters && mom_accepted && ndes == ndescendants && ndesac == ndescendants ) { | ||
accepted = true; | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
if (accepted){ | ||
return true; } else {return false;} | ||
|
||
} |
Oops, something went wrong.