1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#include "GeneratorInterface/GenFilters/plugins/PythiaFilter.h"
#include "GeneratorInterface/GenFilters/plugins/MCFilterZboostHelper.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include <iostream>
using namespace edm;
using namespace std;
PythiaFilter::PythiaFilter(const edm::ParameterSet& iConfig)
: token_(consumes<edm::HepMCProduct>(
edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))),
particleID(iConfig.getUntrackedParameter("ParticleID", 0)),
minpcut(iConfig.getUntrackedParameter("MinP", 0.)),
maxpcut(iConfig.getUntrackedParameter("MaxP", 10000.)),
minptcut(iConfig.getUntrackedParameter("MinPt", 0.)),
maxptcut(iConfig.getUntrackedParameter("MaxPt", 10000.)),
minetacut(iConfig.getUntrackedParameter("MinEta", -10.)),
maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.)),
minrapcut(iConfig.getUntrackedParameter("MinRapidity", -20.)),
maxrapcut(iConfig.getUntrackedParameter("MaxRapidity", 20.)),
minphicut(iConfig.getUntrackedParameter("MinPhi", -3.5)),
maxphicut(iConfig.getUntrackedParameter("MaxPhi", 3.5)),
status(iConfig.getUntrackedParameter("Status", 0)),
motherID(iConfig.getUntrackedParameter("MotherID", 0)),
processID(iConfig.getUntrackedParameter("ProcessID", 0)),
betaBoost(iConfig.getUntrackedParameter("BetaBoost", 0.)) {
//now do what ever initialization is needed
}
PythiaFilter::~PythiaFilter() {
// 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 PythiaFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
using namespace edm;
bool accepted = false;
Handle<HepMCProduct> evt;
iEvent.getByToken(token_, evt);
const HepMC::GenEvent* myGenEvent = evt->GetEvent();
if (processID == 0 || processID == myGenEvent->signal_process_id()) {
for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
++p) {
HepMC::FourVector mom = MCFilterZboostHelper::zboost((*p)->momentum(), betaBoost);
double rapidity = 0.5 * log((mom.e() + mom.pz()) / (mom.e() - mom.pz()));
if (abs((*p)->pdg_id()) == particleID && mom.rho() > minpcut && mom.rho() < maxpcut &&
(*p)->momentum().perp() > minptcut && (*p)->momentum().perp() < maxptcut && mom.eta() > minetacut &&
mom.eta() < maxetacut && rapidity > minrapcut && rapidity < maxrapcut && (*p)->momentum().phi() > minphicut &&
(*p)->momentum().phi() < maxphicut) {
if (status == 0 && motherID == 0) {
accepted = true;
}
if (status != 0 && motherID == 0) {
if ((*p)->status() == status)
accepted = true;
}
HepMC::GenParticle* mother = (*((*p)->production_vertex()->particles_in_const_begin()));
if (status == 0 && motherID != 0) {
if (abs(mother->pdg_id()) == abs(motherID)) {
accepted = true;
}
}
if (status != 0 && motherID != 0) {
if ((*p)->status() == status && abs(mother->pdg_id()) == abs(motherID)) {
accepted = true;
}
}
/*
if (status == 0 && motherID != 0){
if (abs(((*p)->mother())->pdg_id()) == abs(motherID)) {
accepted = true;
}
}
if (status != 0 && motherID != 0){
if ((*p)->status() == status && abs(((*p)->mother())->pdg_id()) == abs(motherID)){
accepted = true;
}
}
*/
}
}
} else {
accepted = true;
}
if (accepted) {
return true;
} else {
return false;
}
}
|