12 fVerbose(iConfig.getUntrackedParameter(
"verbose",0)),
14 particleID(iConfig.getUntrackedParameter(
"ParticleID", 0)),
15 motherID(iConfig.getUntrackedParameter(
"MotherID", 0)),
16 chargeconju(iConfig.getUntrackedParameter(
"ChargeConjugation",
true)),
17 ndaughters(iConfig.getUntrackedParameter(
"NumberDaughters", 0)),
18 maxptcut(iConfig.getUntrackedParameter(
"MaxPt", 14000.))
22 defdauID.push_back(0);
24 vector<double> defminptcut;
25 defminptcut.push_back(0.);
27 vector<double> defminetacut;
28 defminetacut.push_back(-10.);
30 vector<double> defmaxetacut;
31 defmaxetacut.push_back(10.);
34 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"----------------------------------------------------------------------" << endl;
35 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"--- PythiaDauVFilterMatchID" << endl;
36 for (
unsigned int i=0;
i<
dauIDs.size(); ++
i) {
44 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"Creating pythia8 instance for particle properties" << endl;
70 vector<int> vparticles;
78 for (HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end(); ++
p) {
85 for (HepMC::GenVertex::particles_in_const_iterator des = (*p)->production_vertex()->particles_in_const_begin();
86 des != (*p)->production_vertex()->particles_in_const_end();
89 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"mother: " << (*des)->pdg_id() <<
" pT: " << (*des)->momentum().perp() <<
" eta: " << (*des)->momentum().eta() << endl;
97 if (0 == OK)
continue;
100 std::vector<decayTarget> targets;
101 for (
unsigned int i=0;
i<
dauIDs.size();
i++)
109 targets.push_back(target);
113 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"created target: ";
114 for (
unsigned int i=0;
i<targets.size();
i++) {
edm::LogInfo(
"PythiaDauVFilterMatchID") << targets[
i].pdgID <<
" ";}
121 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"found ID: " << (*p)->pdg_id() <<
" pT: " << (*p)->momentum().perp() <<
" eta: " << (*p)->momentum().eta() << endl;
123 vparticles.push_back((*p)->pdg_id());
124 if ((*p)->end_vertex()) {
125 for (HepMC::GenVertex::particle_iterator des=(*p)->end_vertex()->particles_begin(
HepMC::children);
128 if (
TMath::Abs((*des)->pdg_id()) == 22 ) {
continue;}
131 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"ID: " << (*des)->pdg_id() <<
" pT: " << (*des)->momentum().perp() <<
" eta: " << (*des)->momentum().eta() << endl;
135 for (
unsigned int i=0;
i<targets.size();
i++)
137 if ( (*des)->pdg_id() != targets[
i].pdgID ) {
continue;}
138 if (
fVerbose>5) {
edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"i = " <<
i <<
" pT = " << (*des)->momentum().perp() <<
" eta = " << (*des)->momentum().eta() << endl;}
140 if ((*des)->momentum().perp() > targets[
i].minPt &&
141 (*des)->momentum().perp() < targets[
i].maxPt &&
142 (*des)->momentum().eta() > targets[
i].minEta &&
143 (*des)->momentum().eta() < targets[
i].maxEta )
145 vparticles.push_back((*des)->pdg_id());
147 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
" accepted this particle " << (*des)->pdg_id()
148 <<
" pT = " << (*des)->momentum().perp() <<
" eta = " << (*des)->momentum().eta() << endl;
154 if (matchedIdx>-1) {targets.erase(targets.begin()+matchedIdx);}
157 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"remaining targets: ";
158 for (
unsigned int i=0;
i<targets.size();
i++) {
edm::LogInfo(
"PythiaDauVFilterMatchID") << targets[
i].pdgID <<
" ";}
165 if (ndau ==
ndaughters && targets.size() == 0 )
169 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
" accepted this decay: ";
170 for (
unsigned int iv = 0; iv < vparticles.size(); ++iv)
edm::LogInfo(
"PythiaDauVFilterMatchID") << vparticles[iv] <<
" ";
180 if ( !(
fLookupGen->particleData.isParticle( anti_particleID )) ) {
182 if (
fVerbose > 5)
edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"Particle " <<
particleID <<
" is its own anti-particle, skipping further testing " << endl;
187 for (HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
188 p != myGenEvent->particles_end(); ++
p) {
190 if ((*p)->pdg_id() != anti_particleID)
continue ;
195 for (HepMC::GenVertex::particles_in_const_iterator des = (*p)->production_vertex()->particles_in_const_begin();
196 des != (*p)->production_vertex()->particles_in_const_end();
199 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"mother: " << (*des)->pdg_id() <<
" pT: " << (*des)->momentum().perp() <<
" eta: " << (*des)->momentum().eta() << endl;
207 if (0 == OK)
continue;
210 std::vector<decayTarget> targets;
211 for (
unsigned int i=0;
i<
dauIDs.size();
i++)
216 target.
pdgID = IDanti;
221 targets.push_back(target);
225 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"created anti target: ";
226 for (
unsigned int i=0;
i<targets.size();
i++) {
edm::LogInfo(
"PythiaDauVFilterMatchID") << targets[
i].pdgID <<
" ";}
231 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"found ID: " << (*p)->pdg_id() <<
" pT: " << (*p)->momentum().perp() <<
" eta: " << (*p)->momentum().eta() << endl;
233 vparticles.push_back((*p)->pdg_id());
235 if ((*p)->end_vertex()) {
236 for (HepMC::GenVertex::particle_iterator des=(*p)->end_vertex()->particles_begin(
HepMC::children);
239 if (
TMath::Abs((*des)->pdg_id()) == 22 ) {
continue;}
242 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"ID: " << (*des)->pdg_id() <<
" pT: " << (*des)->momentum().perp() <<
" eta: " << (*des)->momentum().eta() << endl;
246 for (
unsigned int i=0;
i<targets.size();
i++)
248 if ( (*des)->pdg_id() != targets[
i].pdgID ) {
continue;}
249 if (
fVerbose>5) {
edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"i = " <<
i <<
" pT = " << (*des)->momentum().perp() <<
" eta = " << (*des)->momentum().eta() << endl;}
251 if ((*des)->momentum().perp() > targets[
i].minPt &&
252 (*des)->momentum().perp() < targets[
i].maxPt &&
253 (*des)->momentum().eta() > targets[
i].minEta &&
254 (*des)->momentum().eta() < targets[
i].maxEta )
256 vparticles.push_back((*des)->pdg_id());
258 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
" accepted this particle " << (*des)->pdg_id()
259 <<
" pT = " << (*des)->momentum().perp() <<
" eta = " << (*des)->momentum().eta() << endl;
265 if (matchedIdx>-1) {targets.erase(targets.begin()+matchedIdx);}
268 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
"remaining targets: ";
269 for (
unsigned int i=0;
i<targets.size();
i++) {
edm::LogInfo(
"PythiaDauVFilterMatchID") << targets[
i].pdgID <<
" ";}
275 if (ndau ==
ndaughters && targets.size() == 0 )
279 edm::LogInfo(
"PythiaDauVFilterMatchID") <<
" accepted this decay: ";
280 for (
unsigned int iv = 0; iv < vparticles.size(); ++iv)
edm::LogInfo(
"PythiaDauVFilterMatchID") << vparticles[iv] <<
" ";
std::unique_ptr< Pythia8::Pythia > fLookupGen
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > minetacut
std::vector< double > maxetacut
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< double > minptcut
~PythiaDauVFilterMatchID() override
std::vector< int > dauIDs
const edm::EDGetTokenT< edm::HepMCProduct > token_
PythiaDauVFilterMatchID(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
std::pair< int, edm::FunctionWithDict > OK
const HepMC::GenEvent * GetEvent() const
bool accepted(std::vector< std::string_view > const &, std::string_view)