17 #include "Identifier/Identifier.h" 
   57     return StatusCode::SUCCESS;
 
   95     std::vector<std::vector<FlowElementLink_t>> muonChargedFEVec(muonReadHandle->
size());
 
   96     std::vector<std::vector<FlowElementLink_t>> muonNeutralFEVec(muonReadHandle->
size());
 
   99     std::vector<std::vector<double>> muonNeutralFE_frac_cluster_energy_matched_Vec(muonReadHandle->
size());
 
  110         size_t FETrackIndex = FE->chargedObjects().at(0)->index();
 
  112         std::vector<MuonLink_t> FEMuonLinks;
 
  115         std::vector<double> FEMatchedClusterCellEnergies;
 
  116         for (
unsigned int counter = 0; 
counter < FE->otherObjects().
size(); ++
counter) FEMatchedClusterCellEnergies.push_back(0.0);
 
  120             const xAOD::TrackParticle* muon_trk = 
muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
 
  122             if (!muon_trk) 
continue;
 
  124             int MuonType = 
muon->muonType();
 
  125             int MuonAuthor = 
muon->author();
 
  126             if (MuonType == xAOD::Muon::SiliconAssociatedForwardMuon) {  
 
  130                 ATH_MSG_DEBUG(
"Muon is identified as a forward muon, skipping");
 
  137             size_t MuonTrkIndex = muon_trk->
index();
 
  138             if (MuonTrkIndex == FETrackIndex) {
 
  141                 FEMuonLinks.emplace_back(*muonReadHandle, 
muon->index());
 
  144                 muonChargedFEVec.at(
muon->index()).emplace_back(*ChargedFEReadHandle, FE->index());
 
  153                 if (!muonCluster) 
continue;                
 
  155                 for (
auto thisCluster : FE->otherObjects()){
 
  157                     bool isCellMatched = 
false;
 
  158                     std::pair <double,double> FEAndMuonMatchedCellEnergy = this->
doMuonCellMatching(isCellMatched, *thisCaloCluster,*muonCluster);
 
  159                     FEMatchedClusterCellEnergies[
counter] += FEAndMuonMatchedCellEnergy.first;
 
  165         chargedFE_energy_match_muonWriteHandle(*FE) = FEMatchedClusterCellEnergies;
 
  168         ChargedFEmuonWriteDecorHandle(*FE) = FEMuonLinks;
 
  184         ATH_MSG_VERBOSE(
"Experimental: Cluster Linkers between neutral FEs and Muons are used");
 
  189             ATH_MSG_DEBUG(
"FE with e, eta and phi" << FE->e() << 
", " << FE->eta() << 
" and " << FE->phi());
 
  194                 ATH_MSG_DEBUG(
"No linked cluster for Neutral FE with E, eta and phi" << FE->e() << 
", " << FE->eta() << 
" and " << FE->phi());
 
  197             size_t FEclusterindex = otherObject->
index();
 
  207             double cluster_E = FE_cluster->
p4().E();
 
  208             bool neg_E_cluster = (cluster_E < 0.0);
 
  211             std::vector<MuonLink_t> FEMuonLinks;
 
  212             std::vector<double> FE_efrac_clustermatch;
 
  213             std::vector<double> Muon_efrac_clustermatch;
 
  225                     const std::vector<ElementLink<xAOD::CaloClusterContainer>>& linksToTopoClusters = acc_constClusterLinks(*cluster);
 
  229                         if (!TopoClusterLink.isValid()) {
 
  230                             ATH_MSG_DEBUG(
"Muon Calo cluster's TopoCluster link not found, skip");
 
  234                         size_t MuonTopoCluster_index = MuonTopoCluster->
index();
 
  235                         if (MuonTopoCluster_index == FEclusterindex) {
 
  238                             FEMuonLinks.emplace_back(*muonReadHandle, 
muon->index());
 
  240                             muonNeutralFEVec.at(
muon->index()).emplace_back(*NeutralFEReadHandle, FE->index());            
 
  243                             if (neg_E_cluster) 
ATH_MSG_ERROR(
"Muon cluster matched to negative E topocluster from FE");
 
  252                     bool isCellMatched = 
false;
 
  253                     std::pair<double,double> FEAndMuonMatchedCellEnergy = this->
doMuonCellMatching(isCellMatched, *FE_cluster,*cluster);
 
  255                     double FE_sum_matched_cellEnergy = FEAndMuonMatchedCellEnergy.first;
 
  256                     double Muon_sum_matched_cellEnergy = FEAndMuonMatchedCellEnergy.second;
 
  258                     double frac_FE_cluster_energy_matched = 0;
 
  260                     double tot_FE_cluster_energy = FE_cluster->
e();
 
  261                     if (tot_FE_cluster_energy != 0) {  
 
  262                         frac_FE_cluster_energy_matched = FE_sum_matched_cellEnergy / tot_FE_cluster_energy;
 
  264                     double tot_muon_cluster_energy = cluster->
e();
 
  265                     double frac_muon_cluster_energy_matched = 0;
 
  266                     if (tot_muon_cluster_energy != 0) {
 
  267                         frac_muon_cluster_energy_matched = Muon_sum_matched_cellEnergy / tot_muon_cluster_energy;
 
  269                     if (frac_FE_cluster_energy_matched > 0) {
 
  270                         ATH_MSG_VERBOSE(
"Fraction of FE cluster energy used in match: " << frac_FE_cluster_energy_matched << 
", ismatched? " 
  271                                                                                         << isCellMatched << 
"");
 
  272                         ATH_MSG_VERBOSE(
"Numerator and denominator are " << FE_sum_matched_cellEnergy << 
" and " << tot_FE_cluster_energy);
 
  273                         ATH_MSG_VERBOSE(
"Fraction of Muon cluster energy used in match: " << frac_muon_cluster_energy_matched << 
"");
 
  279                         FEMuonLinks.emplace_back(*muonReadHandle, 
muon->index());
 
  281                         muonNeutralFEVec.at(
muon->index()).emplace_back(*NeutralFEReadHandle, FE->index());
 
  283                         FE_efrac_clustermatch.push_back(frac_FE_cluster_energy_matched);  
 
  284                         muonNeutralFE_frac_cluster_energy_matched_Vec.at(
muon->index())
 
  285                             .push_back(frac_muon_cluster_energy_matched);  
 
  287                         if (neg_E_cluster) { 
ATH_MSG_ERROR(
"Muon cluster matched to negative E topocluster from FE"); }
 
  293             NeutralFEmuon_nMatches_WriteDecorHandle(*FE) = nMatchedFE;
 
  294             NeutralFEmuonWriteDecorHandle(*FE) = FEMuonLinks;
 
  295             NeutralFE_efrac_match_muonWriteDecorHandle(*FE) = FE_efrac_clustermatch;
 
  304         muonChargedFEWriteDecorHandle(*
muon) = muonChargedFEVec.at(
muon->index());
 
  308             if (!muonNeutralFEVec.empty()) {
 
  309                 muonNeutralFEWriteDecorHandle(*
muon) = muonNeutralFEVec.at(
muon->index());
 
  310                 muonNeutralFE_muon_efrac_WriteDecorHandle(*
muon) = muonNeutralFE_frac_cluster_energy_matched_Vec.at(
muon->index());
 
  322     return StatusCode::SUCCESS;
 
  330         ATH_MSG_WARNING(
"Flow Element CaloCluster CaloClusterCellLink is nullptr");
 
  331         return std::make_pair(0.0,0.0);
 
  335     if (!muonCellLinks) {
 
  336         ATH_MSG_WARNING(
"This Muon calo cluster does not have any cells associated to it");
 
  337         return std::make_pair(0.0,0.0);
 
  341     double FE_matchedCellEnergy = 0;
 
  343     double muon_matchedCellEnergy = 0;
 
  345     for (
auto thisFECell : *FECellLinks){
 
  347         for (
auto thisMuonCell : *muonCellLinks){
 
  349             if (muonCellID == FECellID){
 
  350                 isCellMatched = 
true;
 
  351                 FE_matchedCellEnergy += thisFECell->e();
 
  352                 muon_matchedCellEnergy += thisMuonCell->e();
 
  357     return std::make_pair(FE_matchedCellEnergy,muon_matchedCellEnergy);