diff --git a/analyzers/dataframe/FCCAnalyses/Analysis_FCChh.h b/analyzers/dataframe/FCCAnalyses/Analysis_FCChh.h index f402158216..1ee51b0243 100644 --- a/analyzers/dataframe/FCCAnalyses/Analysis_FCChh.h +++ b/analyzers/dataframe/FCCAnalyses/Analysis_FCChh.h @@ -200,6 +200,7 @@ namespace AnalysisFCChh{ ROOT::VecOps::RVec find_reco_matches_exclusive(ROOT::VecOps::RVec truth_parts, ROOT::VecOps::RVec truth_parts_exc, ROOT::VecOps::RVec reco_particles, float dR_thres=0.1); ROOT::VecOps::RVec find_reco_match_indices(ROOT::VecOps::RVec truth_parts, ROOT::VecOps::RVec reco_particles, float dR_thres=0.1); ROOT::VecOps::RVec find_reco_matched_particle(edm4hep::MCParticleData truth_part_to_match, ROOT::VecOps::RVec check_reco_parts, float dR_thres=0.1); + ROOT::VecOps::RVec find_mc_matched_particle(edm4hep::ReconstructedParticleData reco_part_to_match, ROOT::VecOps::RVec check_mc_parts, float dR_thres=0.1); ROOT::VecOps::RVec find_reco_matched_index(edm4hep::MCParticleData truth_part_to_match, ROOT::VecOps::RVec check_reco_parts, float dR_thres=0.1); ROOT::VecOps::RVec find_true_signal_leps_reco_matches(ROOT::VecOps::RVec truth_leps_to_match, ROOT::VecOps::RVec reco_electrons, ROOT::VecOps::RVec reco_muons, float dR_thres=0.1); ROOT::VecOps::RVec find_truth_to_reco_matches_indices(ROOT::VecOps::RVec truth_leps_to_match, ROOT::VecOps::RVec reco_parts, int pdg_ID, float dR_thres=0.1); diff --git a/analyzers/dataframe/src/Analysis_FCChh.cc b/analyzers/dataframe/src/Analysis_FCChh.cc index ec0190abd5..ccfda9518d 100644 --- a/analyzers/dataframe/src/Analysis_FCChh.cc +++ b/analyzers/dataframe/src/Analysis_FCChh.cc @@ -610,6 +610,9 @@ ROOT::VecOps::RVec AnalysisFCChh::getBhadron(ROOT::VecO return b_had_list; } + + + //return the full jets rather than the list of tags ROOT::VecOps::RVec AnalysisFCChh::get_tagged_jets(ROOT::VecOps::RVec jets, ROOT::VecOps::RVec index, ROOT::VecOps::RVec pid, ROOT::VecOps::RVec tag_values, int algoIndex){ @@ -922,7 +925,6 @@ ROOT::VecOps::RVec AnalysisFCChh::SortPartic } } - //build all pairs from the input particles -> this returns the pair made of pT leading particles!!! ROOT::VecOps::RVec AnalysisFCChh::getPairs(ROOT::VecOps::RVec particles_in){ @@ -2002,7 +2004,6 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauHads(ROOT: return tau_list; } - //find leptons (including taus?) that came from a H->WW decay ROOT::VecOps::RVec AnalysisFCChh::getLepsFromW(ROOT::VecOps::RVec truth_particles, ROOT::VecOps::RVec parent_ids){ //test by simply counting first: @@ -2346,6 +2347,51 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthME // additonal code for validation of new delphes card: +//helper function to find dR matched mc particle for a single reco particle - returns vector of size 1 always, only the one that is closest in dR! (technically doesnt need to be vector at this stage ..) +ROOT::VecOps::RVec AnalysisFCChh::find_mc_matched_particle(edm4hep::ReconstructedParticleData reco_part_to_match, ROOT::VecOps::RVec check_mc_parts, float dR_thres){ + + ROOT::VecOps::RVec out_vector; + + TLorentzVector reco_part_tlv = getTLV_reco(reco_part_to_match); + + for (auto & check_mc_part: check_mc_parts){ + TLorentzVector check_mc_part_tlv = getTLV_MC(check_mc_part); + + float dR_val = reco_part_tlv.DeltaR(check_mc_part_tlv); + + if (dR_val <= dR_thres){ + + //check if already sth in the vector - always want only exactly one match! + + if (out_vector.size() > 0 ){ + // check which one is closer + float dR_val_old = reco_part_tlv.DeltaR(getTLV_MC(out_vector.at(0))); + + float pT_diff_old = abs(reco_part_tlv.Pt() - getTLV_MC(out_vector.at(0)).Pt()); + + + if (dR_val < dR_val_old){ + out_vector.at(0) = check_mc_part; + + if (pT_diff_old < abs(reco_part_tlv.Pt() - check_mc_part_tlv.Pt() )){ + std::cout << "Found case where closest in pT is not closest in dR" << std::endl; + } + } + } + + else { + out_vector.push_back(check_mc_part); + } + + } + + check_mc_part_tlv.Clear(); + } + + return out_vector; +} + + //helper function to find dR matched reco particle for a single truth particle - returns vector of size 1 always, only the one that is closest in dR! (technically doesnt need to be vector at this stage ..) ROOT::VecOps::RVec AnalysisFCChh::find_reco_matched_particle(edm4hep::MCParticleData truth_part_to_match, ROOT::VecOps::RVec check_reco_parts, float dR_thres){ @@ -2457,7 +2503,18 @@ ROOT::VecOps::RVec AnalysisFCChh::find_reco_ std::cout << "Warning in AnalysisFCChh::find_reco_matches() - Truth particle matched to more than one reco particle." << std::endl; } - out_vector.append(reco_match_vector.begin(), reco_match_vector.end()); + //check that the reco particle is not already in the out_vector + bool isAlready=false; + for (auto & out_i: out_vector){ + if ((getTLV_reco(reco_match_vector[0]).Pt() == getTLV_reco(out_i).Pt()) && + (getTLV_reco(reco_match_vector[0]).Eta() == getTLV_reco(out_i).Eta())){ + isAlready=true; + std::cout<<"Already in the array"< AnalysisFCChh::find_reco_ } + ROOT::VecOps::RVec AnalysisFCChh::find_truth_matches(ROOT::VecOps::RVec truth_parts, ROOT::VecOps::RVec reco_particles, float dR_thres){ ROOT::VecOps::RVec out_vector; @@ -2533,6 +2591,7 @@ ROOT::VecOps::RVec AnalysisFCChh::find_truth_matches(RO } + //same as above just with indices ROOT::VecOps::RVec AnalysisFCChh::find_reco_match_indices(ROOT::VecOps::RVec truth_parts, ROOT::VecOps::RVec reco_particles, float dR_thres){