11 m_mcName(
"TruthEvents"),
16 declareInterface<DerivationFramework::HadronOriginClassifier>(
this);
161 return StatusCode::SUCCESS;
173 std::map<const xAOD::TruthParticle*, int> mainHadronMap;
174 std::map<const xAOD::TruthParticle*, HF_id> partonsOrigin;
175 std::map<const xAOD::TruthParticle*, const xAOD::TruthParticle*> hadronsPartons;
176 std::map<const xAOD::TruthParticle*, HF_id> hadronsOrigin;
180 std::vector<const xAOD::TruthParticle*> matched_partons;
181 std::vector<const xAOD::TruthParticle*> matched_hadrons;
183 while (matched_partons.size()<partonsOrigin.size() && matched_hadrons.size()<mainHadronMap.size()){
192 if(
std::find(matched_partons.begin(), matched_partons.end(), (*itr).first) != matched_partons.end())
continue;
195 if ((*itr).first->pt()>0.)
196 v.SetPtEtaPhi((*itr).first->pt(),(*itr).first->eta(),(*itr).first->phi());
198 v.SetXYZ(0.,0.,(*itr).first->pz());
202 if(
std::find(matched_hadrons.begin(), matched_hadrons.end(), (*it).first) != matched_hadrons.end())
continue;
204 if((*it).second != abs((*itr).first->pdgId()) )
continue;
206 vtmp.SetPtEtaPhi((*it).first->pt(),(*it).first->eta(),(*it).first->phi());
209 if(vtmp.DeltaR(
v) < dR){
212 parton = (*itr).first;
217 matched_partons.push_back(parton);
218 matched_hadrons.push_back(
hadron);
219 hadronsPartons[
hadron ] = parton;
229 if(hadronsPartons.find(
hadron)!=hadronsPartons.end()){
230 hadronsOrigin[
hadron] = partonsOrigin[ hadronsPartons[
hadron] ];
235 return hadronsOrigin;
246 std::set<const xAOD::TruthParticle*> usedHadron;
247 for (
const auto* truthevent : *xTruthEventContainer ) {
249 for(
unsigned int i = 0;
i < truthevent->nTruthParticles();
i++){
256 bool isbquark =
false;
257 bool iscquark =
false;
258 bool isHFhadron =
false;
260 int pdgid = abs(
part->pdgId());
264 else if(pdgid == 4 ){
339 if(usedHadron.insert(
part).second) {
354 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
355 checked ->insert(
part);
357 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
360 if(checked->count(
parent))
continue;
377 usedHadron.insert(ihad);
380 int parent_flav,child_flav;
385 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
395 if(child_flav!=4 && child_flav!=5)
continue;
397 if(child_flav!=parent_flav)
continue;
403 if(isFinal && !decayed){
405 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
432 if(!
part || !
part->nParents())
return false;
434 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
438 if(looping)
continue;
440 if( abs(
parent->pdgId() ) == 6 )
return true;
458 if(!
part || !
part->nParents())
return false;
460 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
464 if(looping)
continue;
475 if(!
part->nParents())
return false;
476 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
479 if( looping )
continue;
491 if(!
part->nParents())
return false;
492 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
495 if(looping )
continue;
497 if(abs(
part->pdgId())==4){
511 if(!
part->nParents())
return false;
512 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
515 if( looping )
continue;
524 if(!
part->nParents())
return false;
525 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
528 if( looping )
continue;
529 if( abs(
parent->pdgId())<6 ) {
552 if(!
part->nParents())
return false;
554 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
560 if( looping )
continue;
574 if(!
part->nParents())
return false;
576 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
580 if(looping )
continue;
582 if( abs(
parent->pdgId())<6 ) {
605 if(!
part->nParents())
return false;
606 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
609 if( looping )
continue;
621 if(!
part->hasProdVtx())
return false;
635 if(!
part->nParents())
return false;
638 if (!init_part) init_part = std::make_shared<std::set<const xAOD::TruthParticle*>>();
639 init_part->insert(
part);
641 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
647 if( init_part->count(
parent))
return true;
659 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
661 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
665 if(checked->count(
parent) && looping)
continue;