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);
119 for (
const xAOD::Muon* muon : *muonChargedFEWriteDecorHandle) {
120 const xAOD::TrackParticle* muon_trk = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
122 if (!muon_trk)
continue;
124 if (muon->muonType() == xAOD::Muon::MuonType::SiliconAssociatedForwardMuon) {
128 ATH_MSG_DEBUG(
"Muon is identified as a forward muon, skipping");
131 if (muon->author() == xAOD::Muon::Author::STACO) {
135 size_t MuonTrkIndex = muon_trk->index();
136 if (MuonTrkIndex == FETrackIndex) {
139 FEMuonLinks.emplace_back(*muonReadHandle, muon->index());
142 muonChargedFEVec.at(muon->index()).emplace_back(*ChargedFEReadHandle, FE->index());
151 if (!muonCluster)
continue;
152 unsigned int counter = 0;
153 for (
auto thisCluster : FE->otherObjects()){
155 bool isCellMatched =
false;
156 std::pair <double,double> FEAndMuonMatchedCellEnergy = this->
doMuonCellMatching(isCellMatched, *thisCaloCluster,*muonCluster);
157 FEMatchedClusterCellEnergies[counter] += FEAndMuonMatchedCellEnergy.first;
163 chargedFE_energy_match_muonWriteHandle(*FE) = FEMatchedClusterCellEnergies;
166 ChargedFEmuonWriteDecorHandle(*FE) = FEMuonLinks;
182 ATH_MSG_VERBOSE(
"Experimental: Cluster Linkers between neutral FEs and Muons are used");
187 ATH_MSG_DEBUG(
"FE with e, eta and phi" << FE->e() <<
", " << FE->eta() <<
" and " << FE->phi());
192 ATH_MSG_DEBUG(
"No linked cluster for Neutral FE with E, eta and phi" << FE->e() <<
", " << FE->eta() <<
" and " << FE->phi());
195 size_t FEclusterindex = otherObject->index();
205 double cluster_E = FE_cluster->
p4().E();
206 bool neg_E_cluster = (cluster_E < 0.0);
209 std::vector<MuonLink_t> FEMuonLinks;
210 std::vector<double> FE_efrac_clustermatch;
211 std::vector<double> Muon_efrac_clustermatch;
212 for (
const xAOD::Muon* muon : *muonNeutralFEWriteDecorHandle) {
223 const std::vector<ElementLink<xAOD::CaloClusterContainer>>& linksToTopoClusters = acc_constClusterLinks(*cluster);
227 if (!TopoClusterLink.isValid()) {
228 ATH_MSG_DEBUG(
"Muon Calo cluster's TopoCluster link not found, skip");
232 size_t MuonTopoCluster_index = MuonTopoCluster->index();
233 if (MuonTopoCluster_index == FEclusterindex) {
236 FEMuonLinks.emplace_back(*muonReadHandle, muon->index());
238 muonNeutralFEVec.at(muon->index()).emplace_back(*NeutralFEReadHandle, FE->index());
241 if (neg_E_cluster)
ATH_MSG_ERROR(
"Muon cluster matched to negative E topocluster from FE");
250 bool isCellMatched =
false;
251 std::pair<double,double> FEAndMuonMatchedCellEnergy = this->
doMuonCellMatching(isCellMatched, *FE_cluster,*cluster);
253 double FE_sum_matched_cellEnergy = FEAndMuonMatchedCellEnergy.first;
254 double Muon_sum_matched_cellEnergy = FEAndMuonMatchedCellEnergy.second;
256 double frac_FE_cluster_energy_matched = 0;
258 double tot_FE_cluster_energy = FE_cluster->
e();
259 if (tot_FE_cluster_energy != 0) {
260 frac_FE_cluster_energy_matched = FE_sum_matched_cellEnergy / tot_FE_cluster_energy;
262 double tot_muon_cluster_energy = cluster->
e();
263 double frac_muon_cluster_energy_matched = 0;
264 if (tot_muon_cluster_energy != 0) {
265 frac_muon_cluster_energy_matched = Muon_sum_matched_cellEnergy / tot_muon_cluster_energy;
267 if (frac_FE_cluster_energy_matched > 0) {
268 ATH_MSG_VERBOSE(
"Fraction of FE cluster energy used in match: " << frac_FE_cluster_energy_matched <<
", ismatched? "
269 << isCellMatched <<
"");
270 ATH_MSG_VERBOSE(
"Numerator and denominator are " << FE_sum_matched_cellEnergy <<
" and " << tot_FE_cluster_energy);
271 ATH_MSG_VERBOSE(
"Fraction of Muon cluster energy used in match: " << frac_muon_cluster_energy_matched <<
"");
277 FEMuonLinks.emplace_back(*muonReadHandle, muon->index());
279 muonNeutralFEVec.at(muon->index()).emplace_back(*NeutralFEReadHandle, FE->index());
281 FE_efrac_clustermatch.push_back(frac_FE_cluster_energy_matched);
282 muonNeutralFE_frac_cluster_energy_matched_Vec.at(muon->index())
283 .push_back(frac_muon_cluster_energy_matched);
285 if (neg_E_cluster) {
ATH_MSG_ERROR(
"Muon cluster matched to negative E topocluster from FE"); }
291 NeutralFEmuon_nMatches_WriteDecorHandle(*FE) = nMatchedFE;
292 NeutralFEmuonWriteDecorHandle(*FE) = FEMuonLinks;
293 NeutralFE_efrac_match_muonWriteDecorHandle(*FE) = FE_efrac_clustermatch;
301 for (
const xAOD::Muon* muon : *muonChargedFEWriteDecorHandle) {
302 muonChargedFEWriteDecorHandle(*muon) = muonChargedFEVec.at(muon->index());
305 for (
const xAOD::Muon* muon : *muonNeutralFEWriteDecorHandle) {
306 if (!muonNeutralFEVec.empty()) {
307 muonNeutralFEWriteDecorHandle(*muon) = muonNeutralFEVec.at(muon->index());
308 muonNeutralFE_muon_efrac_WriteDecorHandle(*muon) = muonNeutralFE_frac_cluster_energy_matched_Vec.at(muon->index());
320 return StatusCode::SUCCESS;