Skip to content

Commit a3ba379

Browse files
authored
Merge pull request #47075 from pianonick411/LHEMotherIndices_15_0_0pre1
Add Mother Indices to LHEPart
2 parents 98dcc38 + 44a3d33 commit a3ba379

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

PhysicsTools/NanoAOD/plugins/LHETablesProducer.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@ class LHETablesProducer : public edm::global::EDProducer<> {
6666
std::vector<int> vals_pid;
6767
std::vector<int> vals_status;
6868
std::vector<int> vals_spin;
69+
std::vector<int16_t> vals_firstMotherIdx;
70+
std::vector<int16_t> vals_lastMotherIdx;
6971
alphaS = hepeup.AQCDUP;
72+
73+
int nOutPart = 0;
74+
std::vector<int> newIdxs(pup.size());
75+
7076
for (unsigned int i = 0, n = pup.size(); i < n; ++i) {
7177
int status = hepeup.ISTUP[i];
7278
int idabs = std::abs(hepeup.IDUP[i]);
79+
7380
if (status == 1 || status == -1 || (status == 2 && (idabs >= 23 && idabs <= 25))) {
81+
newIdxs[i] = nOutPart;
82+
83+
nOutPart += 1;
7484
TLorentzVector p4(pup[i][0], pup[i][1], pup[i][2], pup[i][3]); // x,y,z,t
7585
vals_pid.push_back(hepeup.IDUP[i]);
7686
vals_spin.push_back(hepeup.SPINUP[i]);
@@ -81,13 +91,19 @@ class LHETablesProducer : public edm::global::EDProducer<> {
8191
vals_phi.push_back(0);
8292
vals_mass.push_back(0);
8393
vals_pz.push_back(p4.Pz());
94+
vals_firstMotherIdx.push_back(-1);
95+
vals_lastMotherIdx.push_back(-1);
8496
} else {
8597
vals_pt.push_back(p4.Pt());
8698
vals_eta.push_back(p4.Eta());
8799
vals_phi.push_back(p4.Phi());
88100
vals_mass.push_back(p4.M());
89101
vals_pz.push_back(0);
102+
vals_firstMotherIdx.push_back(newIdxs[std::max(hepeup.MOTHUP[i].first - 1, 0)]);
103+
vals_lastMotherIdx.push_back(newIdxs[std::max(hepeup.MOTHUP[i].second - 1, 0)]);
90104
}
105+
} else {
106+
newIdxs[i] = -1;
91107
}
92108
if ((status == 1) && ((idabs == 21) || (idabs > 0 && idabs < 7))) { //# gluons and quarks
93109
// object counters
@@ -118,6 +134,7 @@ class LHETablesProducer : public edm::global::EDProducer<> {
118134
(hepeup.IDUP[i] > 0 ? lep : lepBar) = i;
119135
}
120136
}
137+
121138
std::pair<int, int> v(0, 0);
122139
if (lep != -1 && lepBar != -1)
123140
v = std::make_pair(lep, lepBar);
@@ -153,6 +170,10 @@ class LHETablesProducer : public edm::global::EDProducer<> {
153170
outPart->addColumn<int>("pdgId", vals_pid, "PDG ID of LHE particles");
154171
outPart->addColumn<int>("status", vals_status, "LHE particle status; -1:incoming, 1:outgoing");
155172
outPart->addColumn<int>("spin", vals_spin, "Spin of LHE particles");
173+
outPart->addColumn<int16_t>(
174+
"firstMotherIdx", vals_firstMotherIdx, "Index of this particle's first mother in the LHEPart collection");
175+
outPart->addColumn<int16_t>(
176+
"lastMotherIdx", vals_lastMotherIdx, "Index of this particle's last mother in the LHEPart collection");
156177

157178
return outPart;
158179
}

PhysicsTools/NanoAOD/python/nanoDQM_cfi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@
521521
Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'),
522522
Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
523523
Plot1D('pt', 'pt', 20, 0, 200, 'pt'),
524+
NoPlot('firstMotherIdx'),
525+
NoPlot('lastMotherIdx'),
524526
)
525527
),
526528
LHEPdfWeight = cms.PSet(

0 commit comments

Comments
 (0)