@@ -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<Short_t> vals_firstMotherIdx;
70+ std::vector<Short_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 <Short_t>(
174+ " firstMotherIdx" , vals_firstMotherIdx, " Index of this particle's first mother in the LHEPart collection" );
175+ outPart->addColumn <Short_t>(
176+ " lastMotherIdx" , vals_lastMotherIdx, " Index of this particle's last mother in the LHEPart collection" );
156177
157178 return outPart;
158179 }
0 commit comments