Skip to content

Commit 47ff64d

Browse files
authored
Merge pull request cms-sw#33806 from BParkHNLs/12_X_Modified_PythiaFilterMotherSister
Modification to PythiaFilterMotherSister
2 parents 9b64f44 + e7adc04 commit 47ff64d

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

GeneratorInterface/GenFilters/plugins/PythiaFilterMotherSister.cc

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ PythiaFilterMotherSister::PythiaFilterMotherSister(const edm::ParameterSet& iCon
2222
maxrapcut(iConfig.getUntrackedParameter("MaxRapidity", 20.)),
2323
minphicut(iConfig.getUntrackedParameter("MinPhi", -3.5)),
2424
maxphicut(iConfig.getUntrackedParameter("MaxPhi", 3.5)),
25+
betaBoost(iConfig.getUntrackedParameter("BetaBoost", 0.)),
2526
motherIDs(iConfig.getUntrackedParameter("MotherIDs", std::vector<int>{0})),
2627
sisterID(iConfig.getUntrackedParameter("SisterID", 0)),
27-
betaBoost(iConfig.getUntrackedParameter("BetaBoost", 0.)),
28-
maxSisDisplacement(iConfig.getUntrackedParameter("MaxSisterDisplacement", -1.)) {
29-
//now do what ever initialization is needed
28+
maxSisDisplacement(iConfig.getUntrackedParameter("MaxSisterDisplacement", -1.)),
29+
nephewIDs(iConfig.getUntrackedParameter("NephewIDs", std::vector<int>{0})),
30+
minNephewPts(iConfig.getUntrackedParameter("MinNephewPts", std::vector<double>{0.})) {
31+
if (nephewIDs.size() != minNephewPts.size()) {
32+
throw cms::Exception("BadConfig") << "PythiaFilterMotherSister: "
33+
<< "'nephewIDs' and 'minNephewPts' need same length.";
34+
}
3035
}
3136

3237
PythiaFilterMotherSister::~PythiaFilterMotherSister() {
@@ -66,17 +71,29 @@ bool PythiaFilterMotherSister::filter(edm::StreamID, edm::Event& iEvent, const e
6671
++dau) {
6772
// find the daugther you're interested in
6873
if (abs((*dau)->pdg_id()) == abs(sisterID)) {
74+
int failNephewPt = 0;
75+
// check pt of the nephews
76+
for (HepMC::GenVertex::particle_iterator nephew = (*dau)->end_vertex()->particles_begin(HepMC::children);
77+
nephew != (*dau)->end_vertex()->particles_end(HepMC::children);
78+
++nephew) {
79+
int nephew_pdgId = abs((*nephew)->pdg_id());
80+
for (unsigned int i = 0; i < nephewIDs.size(); i++) {
81+
if (nephew_pdgId == abs(nephewIDs.at(i)))
82+
failNephewPt += ((*nephew)->momentum().perp() < minNephewPts.at(i));
83+
}
84+
}
85+
if (failNephewPt > 0)
86+
return false;
6987
// calculate displacement of the sister particle, from production to decay
7088
HepMC::GenVertex* v1 = (*dau)->production_vertex();
7189
HepMC::GenVertex* v2 = (*dau)->end_vertex();
7290

7391
double lx12 = v1->position().x() - v2->position().x();
7492
double ly12 = v1->position().y() - v2->position().y();
75-
double lz12 = v1->position().z() - v2->position().z();
76-
double lxyz12 = sqrt(lx12 * lx12 + ly12 * ly12 + lz12 * lz12);
93+
double lxy12 = sqrt(lx12 * lx12 + ly12 * ly12);
7794

7895
if (maxSisDisplacement != -1) {
79-
if (lxyz12 < maxSisDisplacement) {
96+
if (lxy12 < maxSisDisplacement) {
8097
return true;
8198
}
8299
} else {

GeneratorInterface/GenFilters/plugins/PythiaFilterMotherSister.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ class PythiaFilterMotherSister : public edm::global::EDFilter<> {
6161
const double maxrapcut;
6262
const double minphicut;
6363
const double maxphicut;
64+
const double betaBoost;
6465

65-
//const int status;
6666
std::vector<int> motherIDs;
6767
const int sisterID;
68-
//const int processID;
69-
70-
const double betaBoost;
7168
const double maxSisDisplacement;
69+
std::vector<int> nephewIDs;
70+
std::vector<double> minNephewPts;
7271
};
7372
#endif

0 commit comments

Comments
 (0)