25 for(
const std::string& collection : collections)
34 if (!
save)
return StatusCode::FAILURE;
36 return StatusCode::SUCCESS;
66 return StatusCode::SUCCESS;
84 TLorentzVector& top_afterFSR_SC_p4) {
87 std::vector<const xAOD::TruthParticle*> v_status3_top;
89 std::vector<const xAOD::TruthParticle*> v_status155_top;
91 std::vector<const xAOD::TruthParticle*> v_status11_top;
93 std::vector<const xAOD::TruthParticle*> v_statusOther_top;
101 }
else if (
particle->status() == 155) {
102 v_status155_top.push_back(
particle);
103 }
else if (
particle->status() == 11) {
104 if (!
particle->hasDecayVtx())
continue;
106 if (
vertex ==
nullptr)
continue;
107 if (
vertex->nOutgoingParticles() == 2) v_status11_top.push_back(
particle);
109 v_statusOther_top.push_back(
particle);
115 if (v_status3_top.size() > 1) {
116 v_status3_top = std::vector<const xAOD::TruthParticle*>(v_status3_top.end() - 1, v_status3_top.end());
119 if (v_status11_top.size() > 1) {
120 v_status11_top = std::vector<const xAOD::TruthParticle*>(v_status11_top.end() - 1, v_status11_top.end());
124 if (v_statusOther_top.size() > 1) {
125 v_statusOther_top = std::vector<const xAOD::TruthParticle*>(v_statusOther_top.end() - 1, v_statusOther_top.end());
131 if (v_status3_top.size() == 1 && v_status155_top.size() == 0) {
132 top = v_status3_top[0];
135 if (v_status155_top.size() == 1 && v_status3_top.size() == 0) {
136 top = v_status155_top[0];
139 if (v_statusOther_top.size() == 1 && v_status155_top.size() == 0 && v_status3_top.size() == 0) {
140 top = v_statusOther_top[0];
143 if (v_status11_top.size() == 1 && v_status3_top.size() == 0) {
144 top = v_status11_top[0];
148 if (
top !=
nullptr) {
149 top_afterFSR_SC_p4 =
top->p4();
157 TLorentzVector& b_beforeFSR, TLorentzVector& b_afterFSR) {
159 if (abs(
particle->pdgId()) != 5)
continue;
162 for (
size_t i = 0;
i <
particle->nParents();
i++) {
170 if (skipit)
continue;
183 int start, TLorentzVector& t_beforeFSR_p4, TLorentzVector& t_afterFSR_p4,
184 TLorentzVector& W_p4,
185 TLorentzVector& b_p4, TLorentzVector& Wdecay1_p4,
186 int& Wdecay1_pdgId, TLorentzVector& Wdecay2_p4,
int& Wdecay2_pdgId) {
190 bool hasWdecayProd1 =
false;
191 bool hasWdecayProd2 =
false;
205 for (
size_t k = 0;
k <
particle->nChildren();
k++) {
208 if (abs(topChildren->
pdgId()) == 24) {
209 W_p4 = topChildren->
p4();
221 if (abs(WChildren->
pdgId()) < 17) {
222 if (WChildren->
pdgId() > 0) {
223 Wdecay1_p4 = WChildren->
p4();
224 Wdecay1_pdgId = WChildren->
pdgId();
225 hasWdecayProd1 =
true;
227 Wdecay2_p4 = WChildren->
p4();
228 Wdecay2_pdgId = WChildren->
pdgId();
229 hasWdecayProd2 =
true;
233 }
else if (abs(topChildren->
pdgId()) == 5) {
234 b_p4 = topChildren->
p4();
239 if (hasT && hasW && hasB && hasWdecayProd1 && hasWdecayProd2)
return true;
247 int start, TLorentzVector& t_beforeFSR_p4, TLorentzVector& t_afterFSR_p4,
248 TLorentzVector& W_p4,
249 TLorentzVector& q_p4,
int& q_pdgId, TLorentzVector& Wdecay1_p4,
250 int& Wdecay1_pdgId, TLorentzVector& Wdecay2_p4,
int& Wdecay2_pdgId) {
254 bool hasWdecayProd1 =
false;
255 bool hasWdecayProd2 =
false;
269 for (
size_t k = 0;
k <
particle->nChildren();
k++) {
272 if (abs(topChildren->
pdgId()) == 24) {
273 W_p4 = topChildren->
p4();
281 if (abs(WChildren->
pdgId()) < 17) {
282 if (WChildren->
pdgId() > 0) {
283 Wdecay1_p4 = WChildren->
p4();
284 Wdecay1_pdgId = WChildren->
pdgId();
285 hasWdecayProd1 =
true;
287 Wdecay2_p4 = WChildren->
p4();
288 Wdecay2_pdgId = WChildren->
pdgId();
289 hasWdecayProd2 =
true;
293 }
else if (abs(topChildren->
pdgId()) == 5 || abs(topChildren->
pdgId()) == 3 || abs(topChildren->
pdgId()) == 1) {
294 q_p4 = topChildren->
p4();
295 q_pdgId = topChildren->
pdgId();
299 if (hasT && hasW && hasQ && hasWdecayProd1 && hasWdecayProd2)
return true;
306 TLorentzVector& W_p4,
307 TLorentzVector& Wdecay1_p4,
int& Wdecay1_pdgId,
308 TLorentzVector& Wdecay2_p4,
int& Wdecay2_pdgId) {
310 bool hasWdecayProd1 =
false;
311 bool hasWdecayProd2 =
false;
314 if (abs(
particle->pdgId()) != 24)
continue;
322 for (
size_t k = 0;
k <
particle->nChildren();
k++) {
324 if (abs(WChildren->
pdgId()) < 17) {
325 if (WChildren->
pdgId() % 2 == 1) {
326 Wdecay1_p4 = WChildren->
p4();
327 Wdecay1_pdgId = WChildren->
pdgId();
328 hasWdecayProd1 =
true;
330 Wdecay2_p4 = WChildren->
p4();
331 Wdecay2_pdgId = WChildren->
pdgId();
332 hasWdecayProd2 =
true;
337 if (hasW && hasWdecayProd1 && hasWdecayProd2)
return true;
346 TLorentzVector& W_p4,
int& W_pdgId, TLorentzVector& Wdecay1_p4,
347 int& Wdecay1_pdgId, TLorentzVector& Wdecay2_p4,
int& Wdecay2_pdgId) {
349 bool hasWdecayProd1 =
false;
350 bool hasWdecayProd2 =
false;
354 if (abs(
particle->pdgId()) != 24)
continue;
361 bool isFromTop =
false;
363 for (
size_t iparent = 0; iparent <
particle->nParents(); ++iparent) {
364 if (
particle->parent(iparent) ==
nullptr)
continue;
365 if (abs(
particle->parent(iparent)->pdgId()) == 6) {
371 if (isFromTop)
continue;
380 for (
size_t q = 0;
q <
particle->nChildren(); ++
q) {
382 if (WChildren ==
nullptr)
continue;
383 if (abs(WChildren->
pdgId()) < 17) {
384 if (WChildren->
pdgId() > 0) {
385 Wdecay1_p4 = WChildren->
p4();
386 Wdecay1_pdgId = WChildren->
pdgId();
387 hasWdecayProd1 =
true;
389 Wdecay2_p4 = WChildren->
p4();
390 Wdecay2_pdgId = WChildren->
pdgId();
391 hasWdecayProd2 =
true;
396 if (hasW && hasWdecayProd1 && hasWdecayProd2)
return true;
404 TLorentzVector& b_beforeFSR, TLorentzVector& b_afterFSR,
414 if (abs(
particle->pdgId()) != 5)
continue;
416 for (
size_t iparent = 0; iparent <
particle->nParents(); ++iparent) {
417 if (
particle->parent(iparent) ==
nullptr)
continue;
420 if (abs(
particle->parent(iparent)->pdgId()) == 5)
continue;
423 if (abs(
particle->parent(iparent)->pdgId()) == 6)
continue;
426 if (abs(
particle->parent(iparent)->pdgId()) == 24)
continue;
429 if (abs(
particle->parent(iparent)->pdgId()) == 2212)
continue;
442 if (hasB)
return true;
449 TLorentzVector& t_beforeFSR_p4, TLorentzVector& t_afterFSR_p4,
450 TLorentzVector& Ph_p4, TLorentzVector& W_p4, TLorentzVector& b_p4,
451 TLorentzVector& Wdecay1_p4,
int& Wdecay1_pdgId, TLorentzVector& Wdecay2_p4,
452 int& Wdecay2_pdgId,
bool& has_ph,
int& BranchType,
int& IniPartonType,
456 bool hasAbsentW =
false;
464 bool hasWdecayProd1 =
false;
465 bool hasWdecayProd2 =
false;
469 if (
particle->pdgId() != topId)
continue;
476 for (
size_t iparent = 0; iparent <
particle->nParents(); iparent++) {
477 if (abs(
particle->parent(iparent)->pdgId()) == 21) {
480 else if (abs(
particle->parent(iparent)->pdgId()) < 6) {
484 for (
size_t ichild = 0; ichild <
particle->parent(iparent)->nChildren(); ichild++) {
485 if (
particle->parent(iparent)->child(ichild)->pdgId() == 22) {
492 (abs(
particle->parent(iparent)->child(ichild)->pdgId()) == 5 ||
493 abs(
particle->parent(iparent)->child(ichild)->pdgId()) == 24)) {
505 for (
size_t k = 0;
k <
particle->nChildren();
k++) {
508 if (abs(topChildren->
pdgId()) == 24) {
509 W_p4 = topChildren->
p4();
517 if (abs(WChildren->
pdgId()) > 0 && abs(WChildren->
pdgId()) < 17) {
518 if (abs(WChildren->
pdgId()) < 7) {
521 else if (abs(WChildren->
pdgId()) > 10 && abs(WChildren->
pdgId()) < 17) {
524 if (WChildren->
pdgId() > 0) {
526 Wdecay1_p4 = WChildren->
p4();
527 Wdecay1_pdgId = WChildren->
pdgId();
528 hasWdecayProd1 =
true;
531 Wdecay2_p4 = WChildren->
p4();
532 Wdecay2_pdgId = WChildren->
pdgId();
533 hasWdecayProd2 =
true;
535 }
else if (abs(WChildren->
pdgId()) == 22) {
541 if (WChildren->
p4().Pt() > Ph_p4.Pt()) {
547 Ph_p4 = WChildren->
p4();
553 Ph_p4 = WChildren->
p4();
557 }
else if (abs(topChildren->
pdgId()) == 5) {
560 b_p4 = topChildren->
p4();
567 if (bChildren->
p4().Pt() > Ph_p4.Pt()) {
573 Ph_p4 = bChildren->
p4();
579 Ph_p4 = bChildren->
p4();
586 if (topChildren->
p4().Pt() > Ph_p4.Pt()) {
588 Ph_p4 = topChildren->
p4();
593 Ph_p4 = topChildren->
p4();
602 else if (abs(topChildren->
pdgId()) <= 4 || (abs(topChildren->
pdgId()) > 10 && abs(topChildren->
pdgId()) < 17)) {
605 if (abs(topChildren->
pdgId()) < 7) {
608 else if (abs(topChildren->
pdgId()) > 10 && abs(topChildren->
pdgId()) < 17) {
611 if (topChildren->
pdgId() > 0) {
613 Wdecay1_p4 = topChildren->
p4();
614 Wdecay1_pdgId = topChildren->
pdgId();
615 hasWdecayProd1 =
true;
618 Wdecay2_p4 = topChildren->
p4();
619 Wdecay2_pdgId = topChildren->
pdgId();
620 hasWdecayProd2 =
true;
622 W_p4 = W_p4 + topChildren->
p4();
627 if (hasAbsentW && (ph_Top || ph_W)) {
631 if (has_ph && ph_Top) {
632 BranchType = BranchType + 2;
634 if (has_ph && ph_W) {
635 BranchType = BranchType + 4;
637 if (has_ph && ph_ISR) {
638 BranchType = BranchType + 5;
640 if (has_ph && ph_b) {
641 BranchType = BranchType + 8;
644 if (hasT && hasW && hasB && hasWdecayProd1 && hasWdecayProd2 && BranchType != -1)
return true;
654 if(
m_config->getDerivationStream() ==
"PHYS")
657 std::vector<std::string> collections = {
"TruthTop"};
674 partonCont->setStore(partonAuxCont);
680 std::string outputSGKey =
m_config->sgKeyTopPartonHistory();
681 std::string outputSGKeyAux = outputSGKey +
"Aux.";
685 if (!
save || !saveAux) {
686 return StatusCode::FAILURE;
689 return StatusCode::SUCCESS;
693 TLorentzVector& tlv) {
694 if (tlv.CosTheta() == 1.) partonHistory->
auxdecor<
float >(branchName) = 1000.;
695 else if (tlv.CosTheta() == -1.) partonHistory->
auxdecor<
float >(branchName) = 1000.;
696 else partonHistory->
auxdecor<
float >(branchName) = tlv.Eta();