11 m_mcName(
"TruthEvents"),
16 declareInterface<DerivationFramework::HadronOriginClassifier>(
this);
149 return StatusCode::SUCCESS;
161 std::map<const xAOD::TruthParticle*, int> mainHadronMap;
162 std::map<const xAOD::TruthParticle*, HF_id> partonsOrigin;
163 std::map<const xAOD::TruthParticle*, const xAOD::TruthParticle*> hadronsPartons;
164 std::map<const xAOD::TruthParticle*, HF_id> hadronsOrigin;
168 std::vector<const xAOD::TruthParticle*> matched_partons;
169 std::vector<const xAOD::TruthParticle*> matched_hadrons;
171 while (matched_partons.size()<partonsOrigin.size() && matched_hadrons.size()<mainHadronMap.size()){
180 if(
std::find(matched_partons.begin(), matched_partons.end(), (*itr).first) != matched_partons.end())
continue;
183 if ((*itr).first->pt()>0.)
184 v.SetPtEtaPhi((*itr).first->pt(),(*itr).first->eta(),(*itr).first->phi());
186 v.SetXYZ(0.,0.,(*itr).first->pz());
190 if(
std::find(matched_hadrons.begin(), matched_hadrons.end(), (*it).first) != matched_hadrons.end())
continue;
192 if((*it).second != abs((*itr).first->pdgId()) )
continue;
194 vtmp.SetPtEtaPhi((*it).first->pt(),(*it).first->eta(),(*it).first->phi());
197 if(vtmp.DeltaR(
v) < dR){
200 parton = (*itr).first;
205 matched_partons.push_back(parton);
206 matched_hadrons.push_back(
hadron);
207 hadronsPartons[
hadron ] = parton;
217 if(hadronsPartons.find(
hadron)!=hadronsPartons.end()){
218 hadronsOrigin[
hadron] = partonsOrigin[ hadronsPartons[
hadron] ];
223 return hadronsOrigin;
234 std::set<const xAOD::TruthParticle*> usedHadron;
235 for (
const auto* truthevent : *xTruthEventContainer ) {
237 for(
unsigned int i = 0;
i < truthevent->nTruthParticles();
i++){
244 bool isbquark =
false;
245 bool iscquark =
false;
246 bool isHFhadron =
false;
248 int pdgid = abs(
part->pdgId());
252 else if(pdgid == 4 ){
327 if(usedHadron.insert(
part).second) {
342 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
343 checked ->insert(
part);
345 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
348 if(checked->count(
parent))
continue;
365 usedHadron.insert(ihad);
368 int parent_flav,child_flav;
373 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
383 if(child_flav!=4 && child_flav!=5)
continue;
385 if(child_flav!=parent_flav)
continue;
391 if(isFinal && !decayed){
393 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
420 if(!
part || !
part->nParents())
return false;
422 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
426 if(looping)
continue;
428 if( abs(
parent->pdgId() ) == 6 )
return true;
446 if(!
part || !
part->nParents())
return false;
448 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
452 if(looping)
continue;
463 if(!
part->nParents())
return false;
464 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
467 if( looping )
continue;
479 if(!
part->nParents())
return false;
480 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
483 if(looping )
continue;
485 if(abs(
part->pdgId())==4){
499 if(!
part->nParents())
return false;
500 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
503 if( looping )
continue;
512 if(!
part->nParents())
return false;
513 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
516 if( looping )
continue;
517 if( abs(
parent->pdgId())<6 ) {
540 if(!
part->nParents())
return false;
542 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
548 if( looping )
continue;
562 if(!
part->nParents())
return false;
564 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
568 if(looping )
continue;
570 if( abs(
parent->pdgId())<6 ) {
593 if(!
part->nParents())
return false;
594 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
597 if( looping )
continue;
609 if(!
part->hasProdVtx())
return false;
623 if(!
part->nParents())
return false;
626 if (!init_part) init_part = std::make_shared<std::set<const xAOD::TruthParticle*>>();
627 init_part->insert(
part);
629 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
635 if( init_part->count(
parent))
return true;
647 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
649 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
653 if(checked->count(
parent) && looping)
continue;