14 Sample(
int low,
int high, GEN_id
gen,
bool ttbb=
false) :
15 low(low), high(high),
gen(
gen), ttbb(ttbb) {}
18 Sample(
int id, GEN_id
gen,
bool ttbb=
false) :
33 declareInterface<DerivationFramework::HadronOriginClassifier>(
this);
42 static const std::vector<Sample> samples = {
93 {504330, 504332,
GEN_id::Pythia8}, {504334, 504336,
GEN_id::Pythia8}, {504338,
GEN_id::Pythia8}, {504342, 504344,
GEN_id::Pythia8}, {504346,
GEN_id::Pythia8},
131 for (
const auto&
s : samples) {
135 return StatusCode::SUCCESS;
152 return StatusCode::SUCCESS;
164 std::map<const xAOD::TruthParticle*, int> mainHadronMap;
165 std::map<const xAOD::TruthParticle*, HF_id> partonsOrigin;
166 std::map<const xAOD::TruthParticle*, const xAOD::TruthParticle*> hadronsPartons;
167 std::map<const xAOD::TruthParticle*, HF_id> hadronsOrigin;
171 std::vector<const xAOD::TruthParticle*> matched_partons;
172 std::vector<const xAOD::TruthParticle*> matched_hadrons;
174 while (matched_partons.size()<partonsOrigin.size() && matched_hadrons.size()<mainHadronMap.size()){
183 if(
std::find(matched_partons.begin(), matched_partons.end(), (*itr).first) != matched_partons.end())
continue;
186 if ((*itr).first->pt()>0.)
187 v.SetPtEtaPhi((*itr).first->pt(),(*itr).first->eta(),(*itr).first->phi());
189 v.SetXYZ(0.,0.,(*itr).first->pz());
193 if(
std::find(matched_hadrons.begin(), matched_hadrons.end(), (*it).first) != matched_hadrons.end())
continue;
195 if((*it).second != abs((*itr).first->pdgId()) )
continue;
197 vtmp.SetPtEtaPhi((*it).first->pt(),(*it).first->eta(),(*it).first->phi());
200 if(vtmp.DeltaR(
v) < dR){
203 parton = (*itr).first;
208 matched_partons.push_back(parton);
209 matched_hadrons.push_back(
hadron);
210 hadronsPartons[
hadron ] = parton;
220 if(hadronsPartons.find(
hadron)!=hadronsPartons.end()){
221 hadronsOrigin[
hadron] = partonsOrigin[ hadronsPartons[
hadron] ];
226 return hadronsOrigin;
237 std::set<const xAOD::TruthParticle*> usedHadron;
238 for (
const auto* truthevent : *xTruthEventContainer ) {
240 for(
unsigned int i = 0;
i < truthevent->nTruthParticles();
i++){
247 bool isbquark =
false;
248 bool iscquark =
false;
249 bool isHFhadron =
false;
251 int pdgid = abs(
part->pdgId());
330 if(usedHadron.insert(
part).second) {
345 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
346 checked ->insert(
part);
348 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
351 if(checked->count(
parent))
continue;
368 usedHadron.insert(ihad);
371 int parent_flav,child_flav;
376 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
386 if(child_flav!=4 && child_flav!=5)
continue;
388 if(child_flav!=parent_flav)
continue;
394 if(isFinal && !decayed){
396 for(
unsigned int j=0; j<ihad->
nChildren(); ++j){
423 if(!
part || !
part->nParents())
return false;
425 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
429 if(looping)
continue;
449 if(!
part || !
part->nParents())
return false;
451 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
455 if(looping)
continue;
466 if(!
part->nParents())
return false;
467 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
470 if( looping )
continue;
482 if(!
part->nParents())
return false;
483 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
486 if(looping )
continue;
502 if(!
part->nParents())
return false;
503 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
506 if( looping )
continue;
515 if(!
part->nParents())
return false;
516 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
519 if( looping )
continue;
520 if( abs(
parent->pdgId())<MC::TQUARK ) {
543 if(!
part->nParents())
return false;
545 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
551 if( looping )
continue;
565 if(!
part->nParents())
return false;
567 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
571 if(looping )
continue;
573 if( abs(
parent->pdgId())<MC::TQUARK ) {
596 if(!
part->nParents())
return false;
597 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
600 if( looping )
continue;
612 if(!
part->hasProdVtx())
return false;
626 if(!
part->nParents())
return false;
629 if (!init_part) init_part = std::make_shared<std::set<const xAOD::TruthParticle*>>();
630 init_part->insert(
part);
632 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
638 if( init_part->count(
parent))
return true;
650 if (!checked) checked = std::make_shared<std::set<const xAOD::TruthParticle*>>();
652 for(
unsigned int i=0;
i<
part->nParents(); ++
i){
656 if(checked->count(
parent) && looping)
continue;