Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IsolationCloseByCorrectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3  */
4 
12 #include <xAODBase/ObjectType.h>
17 
18 #include "xAODEgamma/Egamma.h"
20 
21 namespace CP {
22  using namespace xAOD::Iso;
25  return {"IsoCloseByCorr_assocClustEta", "IsoCloseByCorr_assocClustPhi", "IsoCloseByCorr_assocClustEnergy",
26  "IsoCloseByCorr_assocClustDecor"};
27  }
29  return {"IsoCloseByCorr_assocPflowEta", "IsoCloseByCorr_assocPflowPhi", "IsoCloseByCorr_assocPflowEnergy",
30  "IsoCloseByCorr_assocPflowDecor"};
31  }
32  constexpr float MinClusterEnergy = 100.;
33  constexpr float MeVtoGeV = 1.e-3;
34 
35  IsolationCloseByCorrectionTool::IsolationCloseByCorrectionTool(const std::string& toolName) : asg::AsgTool(toolName) {}
36 
39  ATH_CHECK(m_selectorTool.retrieve());
43 
47  if (!m_isoDecSuffix.empty()) ATH_MSG_INFO("IsoDecSuffix set to " << m_isoDecSuffix);
48  if (!m_quality_name.empty()) ATH_MSG_INFO("SelectionDecorator set to " << m_quality_name);
49 
50 
51 #ifndef XAOD_ANALYSIS
56  ATH_CHECK(m_isoVarKeys.initialize());
57  ATH_CHECK(m_isoWriteDecVarKeys.initialize());
58  if (!m_caloExtTool.empty()) ATH_CHECK(m_caloExtTool.retrieve());
59  else {
60  ATH_MSG_WARNING("The ParticleCaloExtensionTool was not configured. Pleease include it!!!");
61  }
62 #endif
63 
64  ATH_CHECK(m_VtxKey.initialize());
65  ATH_CHECK(m_CaloClusterKey.initialize(m_caloModel == TopoConeCorrectionModel::SubtractObjectsDirectly));
66  ATH_CHECK(m_PflowKey.initialize(m_caloModel == TopoConeCorrectionModel::SubtractObjectsDirectly));
67 
68  // set default properties of track selection tool, if the user hasn't configured it
69  if (m_trkselTool.empty()) {
70  asg::AsgToolConfig config{"InDet::InDetTrackSelectionTool/TrackParticleSelectionTool"};
71  ATH_MSG_INFO("No TrackSelectionTool provided, so I will create and configure my own, called: " << config.name());
72  // The z0 cut is checked in any case either by the
73  // track to vertex association tool or by the tracking tool
74  ATH_CHECK(config.setProperty("maxZ0SinTheta", 3.));
75  // The minimum Pt requirement is lowered to 500 MeV because
76  // the Loose ttva cone variables accept very low-pt tracks
77  // https://gitlab.cern.ch/atlas/athena/blob/21.2/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoUpdatedTrackCones.py#L21
78  ATH_CHECK(config.setProperty("minPt", 500.));
79  ATH_CHECK(config.setProperty("CutLevel", "Loose"));
80  ATH_CHECK(config.makePrivateTool(m_trkselTool));
81  }
83  if (m_ttvaTool.empty()) {
84  asg::AsgToolConfig config{"CP::TrackVertexAssociationTool/ttva_selection_tool"};
85  ATH_CHECK(config.setProperty("WorkingPoint", "Nonprompt_All_MaxWeight"));
86  ATH_CHECK(config.makePrivateTool(m_ttvaTool));
87  }
88  ATH_CHECK(m_trkselTool.retrieve());
89  ATH_CHECK(m_ttvaTool.retrieve());
90 
91  if (!m_quality_name.empty()) m_acc_quality = std::make_unique<CharAccessor>(m_quality_name);
92  if (!m_passOR_name.empty()) m_acc_passOR = std::make_unique<CharAccessor>(m_passOR_name);
93  if (!m_isoSelection_name.empty()) m_dec_isoselection = std::make_unique<CharDecorator>(m_isoSelection_name);
94  m_isInitialised = true;
95  return StatusCode::SUCCESS;
96  }
97  void IsolationCloseByCorrectionTool::isoTypesFromWP(const std::vector<std::unique_ptr<IsolationWP>>& WPs, IsoVector& types) {
98  types.clear();
99  for (const std::unique_ptr<IsolationWP>& W : WPs) {
100  for (const std::unique_ptr<IsolationCondition>& C : W->conditions()) {
101  for (unsigned int t = 0; t < C->num_types(); ++t) {
102  const IsoType iso_type = C->type(t);
103  if (std::find(types.begin(), types.end(), iso_type) == types.end()) types.emplace_back(iso_type);
104  if (m_isohelpers.find(iso_type) == m_isohelpers.end()) {
105  m_isohelpers.insert(std::make_pair(iso_type, std::make_unique<IsoVariableHelper>(iso_type, m_backup_prefix, m_isoDecSuffix)));
106  }
107  }
108  }
109  }
110  m_has_nonTTVA |= std::find_if(types.begin(), types.end(),
111  [](const IsolationType& t) { return isTrackIso(t) && !isTrackIsoTTVA(t); }) != types.end();
112  m_hasPflowIso |= std::find_if(types.begin(), types.end(),
113  [](const IsolationType& t) { return isPFlowIso(t); }) != types.end();
114  m_hasEtConeIso |= std::find_if(types.begin(), types.end(),
115  [](const IsolationType& t) { return isTopoEtIso(t); }) != types.end();
116  }
117 #ifndef XAOD_ANALYSIS
118  void IsolationCloseByCorrectionTool::declareDependency(const std::vector<std::string>& containers, const IsoVector& types) {
119  for (const std::string& cont : containers) {
120  for (const IsoType iso : types) {
121  // define read accessor iso variable keys
122  m_isoVarKeys.emplace_back(cont + "." + std::string(toString(iso)));
123  // define write decorator iso variable keys - needed for MT, but we do not use handles for writing the decorators in isoHelpers
124  m_isoWriteDecVarKeys.emplace_back(cont + "." + std::string(toString(iso) + (m_isoDecSuffix.empty() ? "" : "_") + m_isoDecSuffix));
125  }
126  if (!m_declareCaloDecors && m_caloModel == TopoConeCorrectionModel::SubtractObjectsDirectly) continue;
128  for (const std::string& decor : pflowDecors()) m_isoVarKeys.emplace_back(cont + "." + decor);
129  }
131  for (const std::string& decor : caloDecors()) m_isoVarKeys.emplace_back(cont + "." + decor);
132  }
133  }
134  }
135 #endif
137  if (!container) return;
138  for (const xAOD::IParticle* particle : *container) {
139  if (m_dec_isoselection) (*m_dec_isoselection)(*particle) = true && m_selectorTool->accept(*particle);
140  const IsoVector& iso_types = getIsolationTypes(particle);
141  if (iso_types.empty()) { ATH_MSG_DEBUG("No isolation types have been defined for particle type " << particleName(particle)); }
142  for (const IsoType type : iso_types) {
143  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
144  IsoHelperMap::const_iterator Itr = m_isohelpers.find(type);
145  if (Itr == m_isohelpers.end() || Itr->second->backupIsolation(particle) == CorrectionCode::Error) {
146  ATH_MSG_WARNING("Failed to properly access the vanilla isolation variable "
147  << toString(type) << "for particle " << particleName(particle) << " with pT: "
148  << particle->pt() * MeVtoGeV << " GeV, eta: " << particle->eta() << ", phi: " << particle->phi());
149  }
150  }
151  // Save all particles to be sure to output the new iso decorated values
152  // They either pass or not the selection.
153  // The selected ones participate in the CloseBy and may have their isolation corrected.
154  if (!passSelectionQuality(particle)) {
155  cache.not_sel_parts.insert(particle);
156  }
157  else {
158  cache.prim_parts.insert(particle);
159  }
160  }
161  }
162  void IsolationCloseByCorrectionTool::loadAssociatedObjects(const EventContext& ctx, ObjectCache& cache) const {
163 
164  // Use isLRT decoration for LLP particles to avoid looking for tracks from the primary vertex
165  static const CharAccessor isLRT("isLRT");
166 
168  for (const xAOD::IParticle* prim : cache.prim_parts) {
169  // skip LRT leptons
170  if (!isLRT.isAvailable(*prim) || !isLRT(*prim) ) {
171  const TrackSet tracks = getAssociatedTracks(prim, cache.prim_vtx);
172  cache.tracks.insert(tracks.begin(), tracks.end());
173  }
174  const ClusterSet clusters = getAssociatedClusters(ctx, prim, cache);
175  cache.clusters.insert(clusters.begin(), clusters.end());
176  }
177  getAssocFlowElements(ctx, cache);
178  }
179  PflowSet IsolationCloseByCorrectionTool::getAssocFlowElements(const EventContext& ctx, const xAOD::IParticle* particle) const {
180  ObjectCache cache{};
181  cache.prim_parts = {particle};
182  loadAssociatedObjects(ctx, cache);
183  return cache.flows;
184  }
185 
186  void IsolationCloseByCorrectionTool::getAssocFlowElements(const EventContext& ctx, ObjectCache& cache) const {
187  if (m_PflowKey.empty()) return;
189  if (!readHandle.isValid()) return;
190  std::set<const xAOD::IParticle*> tombola{};
191  for (const xAOD::IParticle* p : cache.prim_parts) tombola.insert(p);
192  for (const TrackPtr& p : cache.tracks) tombola.insert(p);
193  for (const CaloClusterPtr& p : cache.clusters) tombola.insert(p);
194 
195  for (const xAOD::FlowElement* flow : *readHandle) {
196  if (!flow) continue;
197  for (size_t ch = 0; ch < flow->nChargedObjects(); ++ch) {
198  const xAOD::IParticle* obj = flow->chargedObject(ch);
199  if (tombola.count(obj)) {
200  const std::vector<float>& weights = flow->chargedObjectWeights();
201  cache.flows.emplace(flow, ch < weights.size() ? weights[ch] : 1.f);
202  }
203  }
204  for (size_t ne = 0; ne < flow->nOtherObjects(); ++ne) {
205  const xAOD::IParticle* obj = flow->otherObject(ne);
206  if (tombola.count(obj)) {
207  const std::vector<float>& weights = flow->otherObjectWeights();
208  cache.flows.emplace(flow, ne < weights.size() ? weights[ne] : 1.f);
209  ATH_MSG_VERBOSE("getAssocFlowElements: neflow " << ne << ", " << obj->type() << ", " << obj->pt() << ", " << obj->eta() << ", " << obj->phi() << ", " << flow->pt() << ", " << flow->eta() << ", " << flow->phi());
210  }
211  }
212  }
213  }
214 
215  #ifndef XAOD_ANALYSIS
216  bool IsolationCloseByCorrectionTool::getExtrapEtaPhi(const EventContext& ctx, const xAOD::TrackParticle* tp, float& eta, float& phi) const {
218  ATH_MSG_DEBUG("Geting calo extension caloExtension tool.");
219  // If we have an extension cache then it owns the extension, otherwise we own it
220  // Therefore we have to prepare both an owning and a non-owning pointer
221  std::unique_ptr<Trk::CaloExtension> caloExtension;
222  caloExtension = m_caloExtTool->caloExtension(ctx, *tp);
223  if(!caloExtension){
224  ATH_MSG_WARNING("Can not get caloExtension.");
225  return false;
226  };
227 
228  const std::vector<Trk::CurvilinearParameters>& intersections = caloExtension->caloLayerIntersections();
229  if(!intersections.empty()){
230  Amg::Vector3D avePoint(0,0,0);
231  for (unsigned int i = 0; i < intersections.size(); ++i){
232  const Amg::Vector3D& point = intersections[i].position();
233  avePoint += point;
234  }
235  avePoint = (1./intersections.size())*avePoint;
236  eta = avePoint.eta();
237  phi = avePoint.phi();
238  return true;
239  } else {
240  ATH_MSG_WARNING("Muon Calo extension got no intersection!!!");
241  }
243  ATH_MSG_WARNING("Calo extension can not be obtained!!!");
244  return false;
245  }
246  #endif // xAOD
247 
249  const EventContext& ctx,
251  const xAOD::MuonContainer* muons,
252  const xAOD::PhotonContainer* photons) const {
253  if (!m_isInitialised) {
254  ATH_MSG_ERROR("The IsolationCloseByCorrectionTool was not initialised!!!");
255  return CorrectionCode::Error;
256  }
257  ObjectCache cache{};
260  loadPrimaryParticles(muons, cache);
261  loadPrimaryParticles(photons, cache);
262 
263  loadAssociatedObjects(ctx, cache);
264  CorrectionCode ret = performCloseByCorrection(ctx, cache);
266  lockDecorations(muons);
267  lockDecorations(photons);
268  return ret;
269  }
271  if (cache.prim_vtx) {
272  // require a primary vertex for isolation correction - expect that if there is not primary vertex, then we only need to assure that the cache.not_sel_parts are treated correctly below
273  for (const xAOD::IParticle* particle : cache.prim_parts) {
274  ATH_MSG_DEBUG("Correct the isolation of particle "<<particleName(particle)<< " with pt: " << particle->pt() * MeVtoGeV << " GeV"
275  << " eta: " << particle->eta()
276  << " phi: " << particle->phi());
277 
278  if (subtractCloseByContribution(ctx, particle, cache) == CorrectionCode::Error) {
279  ATH_MSG_ERROR("Failed to correct the isolation of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
280  << " eta: " << particle->eta()
281  << " phi: " << particle->phi());
282  return CorrectionCode::Error;
283  }
284  if (m_dec_isoselection) (*m_dec_isoselection)(*particle) = bool(m_selectorTool->accept(*particle));
285  ATH_MSG_DEBUG("Corrected the isolation of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
286  << " eta: " << particle->eta()
287  << " phi: " << particle->phi());
288 
289  }
290  }
291  else {
292  // Missing primary vertex - need to copy the uncorrected iso values
293  for (const xAOD::IParticle* particle : cache.prim_parts) {
294  ATH_MSG_DEBUG("Copy isolation values of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
295  << " eta: " << particle->eta()
296  << " phi: " << particle->phi());
298  ATH_MSG_ERROR("Failed to copy the isolation of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
299  << " eta: " << particle->eta()
300  << " phi: " << particle->phi());
301  return CorrectionCode::Error;
302  }
303  }
304  }
305  // Only need to copy the uncorrected iso values
306  for (const xAOD::IParticle* particle : cache.not_sel_parts) {
307  ATH_MSG_DEBUG("Copy isolation values of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
308  << " eta: " << particle->eta()
309  << " phi: " << particle->phi());
311  ATH_MSG_ERROR("Failed to copy the isolation of particle with pt: " << particle->pt() * MeVtoGeV << " GeV"
312  << " eta: " << particle->eta()
313  << " phi: " << particle->phi());
314  return CorrectionCode::Error;
315  }
316  }
317  return CorrectionCode::Ok;
318  }
320  if (!parts) return;
321  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
322  for (const auto& p : m_isohelpers) {
323  if (parts->ownPolicy() == SG::VIEW_ELEMENTS) {
324  for (const xAOD::IParticle* part : *parts) {
325  p.second->lockDecorations(*part->container());
326  }
327  }
328  else {
329  p.second->lockDecorations(*parts);
330  }
331  }
332  }
334  static const IsoVector dummy{};
335  if (!particle) return dummy;
336  if (particle->type() == xAOD::Type::ObjectType::Electron)
337  return m_electron_isoTypes;
338  else if (particle->type() == xAOD::Type::ObjectType::Muon)
339  return m_muon_isoTypes;
340  else if (particle->type() == xAOD::Type::ObjectType::Photon)
341  return m_photon_isoTypes;
342  return dummy;
343  }
344 
346  const xAOD::IParticle* par,
347  ObjectCache& cache) const {
348  const IsoVector& types = getIsolationTypes(par);
349  if (types.empty()) {
350  ATH_MSG_WARNING("No isolation types are defiend for " << particleName(par));
352  }
353  for (const IsolationType iso_type : types) {
354  float iso_variable{0.f};
355  if (isTrackIso(iso_type)) {
356  if (getCloseByCorrectionTrackIso(par, iso_type, cache, iso_variable) == CorrectionCode::Error) {
357  ATH_MSG_ERROR("Failed to apply track correction");
358  return CorrectionCode::Error;
359  }
360  } else if (isTopoEtIso(iso_type)) {
361  if (getCloseByCorrectionTopoIso(ctx, par, iso_type, cache, iso_variable) == CorrectionCode::Error) {
362  ATH_MSG_ERROR("Failed to apply topo cluster correction");
363  return CorrectionCode::Error;
364  }
365  } else if (isPFlowIso(iso_type)) {
366  if (getCloseByCorrectionPflowIso(ctx, par, iso_type, cache, iso_variable) == CorrectionCode::Error) {
367  ATH_MSG_ERROR("Failed to apply pflow correction");
368  return CorrectionCode::Error;
369  }
370  }
371  ATH_MSG_DEBUG("subtractCloseByContribution: Set pt, eta, phi " << par->pt() << ", " << par->eta() << ", " << par->phi() << " for " << toString(iso_type) << " to " << iso_variable);
372  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
373  if (m_isohelpers.at(iso_type)->setIsolation(par, iso_variable) == CorrectionCode::Error) {
374  ATH_MSG_ERROR("Cannot set " << toString(iso_type) << " to " << iso_variable);
375  return CorrectionCode::Error;
376  }
377  }
378  return CorrectionCode::Ok;
379  }
380 
382  const IsoVector& types = getIsolationTypes(part);
383 
384  ATH_MSG_DEBUG("copyIsoValuesForPartsNotSelected " << part->type() << " " << part->pt() * MeVtoGeV << " GeV" << " eta: " << part->eta() << " phi: " << part->phi());
385 
386  if (types.empty()) {
387  ATH_MSG_WARNING("No isolation types are defiend for " << particleName(part));
389  }
390  for (const IsolationType iso_type : types) {
391  float iso_variable{0.f};
392  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
393  if (m_isohelpers.at(iso_type)->getIsolation(part, iso_variable) == CorrectionCode::Error) {
394  ATH_MSG_ERROR("Cannot get value for " << toString(iso_type));
395  return CorrectionCode::Error;
396  }
397  ATH_MSG_DEBUG("copyIsoValuesForPartsNotSelected: Set pt, eta " << part->pt() << ", " << part->eta() << ", " << part->phi() << " for " << toString(iso_type) << " to " << iso_variable);
398  if (m_isohelpers.at(iso_type)->setIsolation(part, iso_variable) == CorrectionCode::Error) {
399  ATH_MSG_ERROR("Cannot set " << toString(iso_type) << " to " << iso_variable);
400  return CorrectionCode::Error;
401  }
402  }
403  return CorrectionCode::Ok;
404  }
405 
406 
408  const std::vector<IsolationType>& types,
409  const xAOD::IParticleContainer& closePar) const {
410 
411  if (!m_isInitialised) {
412  ATH_MSG_ERROR("The IsolationCloseByCorrectionTool was not initialised!!!");
413  return CorrectionCode::Error;
414  }
416  {
417  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
418  for (const IsolationType& t : types) {
419  IsoHelperMap::const_iterator Itr = m_isohelpers.find(t);
420  if (Itr != m_isohelpers.end()) { continue; }
421  Itr = m_isohelpers.insert(std::make_pair(t, std::make_unique<IsoVariableHelper>(t, m_backup_prefix, m_isoDecSuffix))).first;
422  }
423  }
424  corrections.assign(types.size(), 0);
425  ObjectCache cache{};
426  loadPrimaryParticles(&closePar, cache);
427  const EventContext& ctx = Gaudi::Hive::currentContext();
428  loadAssociatedObjects(ctx, cache);
429  std::vector<float>::iterator Cone = corrections.begin();
430  for (const IsolationType& iso_type : types) {
431  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
432  IsoHelperMap::const_iterator Itr = m_isohelpers.find(iso_type);
433  if (Itr->second->backupIsolation(&par) == CP::CorrectionCode::Error) {
434  ATH_MSG_ERROR("Failed to backup isolation");
435  return CorrectionCode::Error;
436  }
437  if (isTrackIso(iso_type)) {
438  if (getCloseByCorrectionTrackIso(&par, iso_type, cache, (*Cone)) == CorrectionCode::Error) {
439  ATH_MSG_ERROR("Failed to apply track correction");
440  return CorrectionCode::Error;
441 
442  }
443  }
444  else if (isTopoEtIso(iso_type)) {
445  if (getCloseByCorrectionTopoIso(ctx, &par, iso_type, cache, (*Cone)) == CorrectionCode::Error) {
446  ATH_MSG_ERROR("Failed to apply topo cluster correction");
447  return CorrectionCode::Error;
448  }
449  }
450  else if (isPFlowIso(iso_type)) {
451  if (getCloseByCorrectionPflowIso(ctx, &par, iso_type, cache, (*Cone)) == CorrectionCode::Error) {
452  ATH_MSG_ERROR("Failed to apply pflow correction");
453  return CorrectionCode::Error;
454  }
455  }
456  ++Cone;
457  }
458  return CorrectionCode::Ok;
459  }
460  // check for non-zero primary vtx - single particle samples don't have one
462  return trk && vtx && m_trkselTool->accept(*trk, vtx) && (!m_has_nonTTVA || m_ttvaTool->isCompatible(*trk, *vtx));
463  }
465  TrackSet to_return{};
466  if (P->type() == xAOD::Type::Muon) {
467  const xAOD::Muon* mu = static_cast<const xAOD::Muon*>(P);
468  if (mu->muonType() != xAOD::Muon::SiliconAssociatedForwardMuon)
469  to_return.emplace(mu->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle));
470  } else if (P->type() == xAOD::Type::TrackParticle) {
471  const xAOD::TrackParticle* trk = static_cast<const xAOD::TrackParticle*>(P);
472  to_return.emplace(trk);
473  } else if (isEgamma(P)) {
474  const xAOD::Egamma* EG = static_cast<const xAOD::Egamma*>(P);
475  std::set<const xAOD::TrackParticle*> trk_vec = xAOD::EgammaHelpers::getTrackParticles(EG, true, true);
476  for (const xAOD::TrackParticle* trk : trk_vec) {
477  ATH_MSG_VERBOSE("Adding egamma track with "
478  << trk->pt() * MeVtoGeV << " GeV, eta: " << trk->eta() << ", phi: " << trk->phi());
479  to_return.emplace(trk);
480  }
481  }
482  return to_return;
483  }
485  const TrackSet assoc_tracks = getAssociatedTracks(P);
486  TrackSet to_ret{};
487  for (const TrackPtr trk : assoc_tracks) {
488  if (passFirstStage(trk, vtx)) to_ret.insert(trk);
489  }
490  return to_ret;
491  }
492  TrackSet IsolationCloseByCorrectionTool::getTrackCandidates(const EventContext& ctx, const xAOD::IParticle* particle) const {
493  return getAssociatedTracks(particle, retrieveIDBestPrimaryVertex(ctx));
494  }
496  return P && (P->type() == xAOD::Type::ObjectType::Electron || P->type() == xAOD::Type::ObjectType::Photon);
497  }
498 
499  // Collect topoclusters for electron, photon and muons
500  // - for electrons and photons, collect the associated clusters
501  // - for muons, use associated cluster, if it exists, to get topocluster, otherwise, extrapolate the InDet trackParticle to calo
502  // and look for topoclusters matching in dR the core muon cone
504  ObjectCache& cache) const {
505  // Remember topoclusters which are associated to an egamma object, electron or photon
506  // This will be used to avoid associating the same object to a muon
508  if (isEgamma(P)) {
509  const xAOD::Egamma* egamm = static_cast<const xAOD::Egamma*>(P);
510  for (size_t calo = 0; calo < egamm->nCaloClusters(); ++calo) {
511  const xAOD::CaloCluster* clust = egamm->caloCluster(calo);
512  if (!clust) continue;
513  std::vector<const xAOD::CaloCluster*> constituents = xAOD::EgammaHelpers::getAssociatedTopoClusters(clust);
514  for (const xAOD::CaloCluster* cluster : constituents) {
515  if (cluster && std::abs(cluster->eta()) < 7. && cluster->e() > MinClusterEnergy) {
516  clusters.emplace(cluster);
517  cache.eg_associated_clusters.insert(cluster); // set flag that this cluster is associated to an electron or photon
518  ATH_MSG_VERBOSE("getAssociatedClusters: " << P->type() << " has topo cluster with pt: " << cluster->pt() * MeVtoGeV << " GeV, eta: "
519  << cluster->eta() << ", phi: " << cluster->phi());
520  }
521  }
522  }
523  if (clusters.size()) return clusters;
524  }
525  if (m_CaloClusterKey.empty()) return clusters;
527  if (!topoClusters.isValid()) return clusters;
528 
529  if (P->type() == xAOD::Type::ObjectType::Muon) {
530  const xAOD::Muon* mu = static_cast<const xAOD::Muon*>(P);
531  const xAOD::CaloCluster* cl = mu->cluster();
532  bool foundMuonTopo = false;
533  if (cl) {
534  ATH_MSG_VERBOSE("getAssociatedClusters: muon has cluster with pt: " << cl->pt() * MeVtoGeV << " GeV, eta: "
535  << cl->eta() << ", phi: " << cl->phi());
536  std::vector<const xAOD::CaloCluster*> constituents = xAOD::EgammaHelpers::getAssociatedTopoClusters(cl);
537  for (const xAOD::CaloCluster* cluster : constituents) {
538  if (cluster && std::abs(cluster->eta()) < 7. && cluster->e() > MinClusterEnergy) {
539  // skip association if this cluster is already associated with an electron or photon - priority is given to egamma reco
540  if (!cache.eg_associated_clusters.contains(cluster)) {
541  clusters.emplace(cluster);
542  foundMuonTopo = true;
543  ATH_MSG_VERBOSE("getAssociatedClusters: muon has topo cluster with pt: " << cluster->pt() * MeVtoGeV << " GeV, eta: "
544  << cluster->eta() << ", phi: " << cluster->phi());
545  }
546  else {
547  ATH_MSG_VERBOSE("getAssociatedClusters: muon topo cluster already associated with an EG objet - cluster with pt: "
548  << cluster->pt() * MeVtoGeV << " GeV, eta: " << cluster->eta() << ", phi: " << cluster->phi());
549  }
550  }
551  }
552  }
553  if (!foundMuonTopo) {
554 #ifndef XAOD_ANALYSIS
555  // extraploate muon to calo and look for matching topo cluster
556  const xAOD::TrackParticle* tp = mu->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
557  if (tp) {
558  ATH_MSG_VERBOSE("getAssociatedClusters: found mu tp " << " with pt: " << tp->pt() * MeVtoGeV << " GeV, eta: " << tp->eta() << ", phi: " << tp->phi());
559  float tpEtaAtCalo;
560  float tpPhiAtCalo;
561  if (getExtrapEtaPhi(ctx, tp, tpEtaAtCalo, tpPhiAtCalo)) {
562  ATH_MSG_VERBOSE("getAssociatedClusters: tp extrapolated - tpEtaAtCalo " << tpEtaAtCalo << ", tpPhiAtCalo " << tpPhiAtCalo);
563  for (const xAOD::CaloCluster* cluster : *topoClusters) {
564  if (cluster && std::abs(cluster->eta()) < 7. && cluster->e() > MinClusterEnergy &&
565  xAOD::P4Helpers::deltaR(tpEtaAtCalo, tpPhiAtCalo, cluster->eta(), cluster->phi()) < m_coreConeMu) {
566  clusters.emplace(cluster);
567  ATH_MSG_VERBOSE("getAssociatedClusters: for mu trkPart save clus " << " with pt: " << cluster->pt() * MeVtoGeV << " GeV, eta: " << cluster->eta() << ", phi: " << cluster->phi() << ", tpEtaAtCalo " << tpEtaAtCalo << ", tpPhiAtCalo " << tpPhiAtCalo);
568  }
569  }
570  }
571  }
572 #endif
573  }
574  }
575 
576  return clusters;
577  }
579  if (!P) return false;
580  if (m_acc_quality && (!m_acc_quality->isAvailable(*P) || !(*m_acc_quality)(*P))) return false;
581  if (m_acc_passOR && (!m_acc_passOR->isAvailable(*P) || !(*m_acc_passOR)(*P))) return false;
582  return true;
583  }
585  const ObjectCache& cache, float& isoValue) const {
586  if (!isTrackIso(type)) {
587  ATH_MSG_ERROR("Invalid isolation type " << toString(type));
588  return CorrectionCode::Error;
589  }
590  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
591  IsoHelperMap::const_iterator Itr = m_isohelpers.find(type);
592  if (Itr == m_isohelpers.end() || Itr->second->getOriginalIsolation(par, isoValue) == CorrectionCode::Error) {
593  ATH_MSG_WARNING(__func__<<"() -- "<<__LINE__<<" Could not retrieve the isolation variable " << toString(type));
594  return CorrectionCode::Error;
595  } else if (cache.tracks.empty())
596  return CorrectionCode::Ok;
597 
598  float MaxDR = coneSize(par, type);
599  const TrackSet ToExclude = getAssociatedTracks(par);
600 
601  const xAOD::IParticle* Ref = isoRefParticle(par);
602  ATH_MSG_VERBOSE(toString(type) << " of " << particleName(par) << " with pt: " << par->pt() * MeVtoGeV << " GeV, eta: " << par->eta()
603  << ", phi: " << par->phi() << " before correction: " << isoValue * MeVtoGeV << " GeV. "
604  << ToExclude.size() << " tracks will be excluded.");
605 
606  for (const TrackPtr& poluting_trk : cache.tracks) {
607  // Checks for the Pile-up robust isolation WP's
608  if (poluting_trk->pt() < trackPtCut(type)) continue;
610  if (isTrackIsoTTVA(type) && m_has_nonTTVA && !m_ttvaTool->isCompatible(*poluting_trk, *cache.prim_vtx)) continue;
611 
612  if (overlap(Ref, poluting_trk, MaxDR) && !ToExclude.count(poluting_trk)) {
613  ATH_MSG_VERBOSE("Subtract track with "
614  << poluting_trk->pt() * MeVtoGeV << " GeV, eta: " << poluting_trk->eta() << ", phi: " << poluting_trk->phi()
615  << " with dR: " << std::sqrt(deltaR2(Ref, poluting_trk)) << " from the isolation cone " << toString(type)
616  << " " << (isoValue * MeVtoGeV) << " GeV.");
617  isoValue -= poluting_trk->pt();
618  }
619  }
620  isoValue = std::max(0.f, isoValue);
621  ATH_MSG_VERBOSE(toString(type) << " of " << particleName(par) << " with pt: " << par->pt() * MeVtoGeV << " GeV, eta: " << par->eta()
622  << ", phi: " << par->phi() << " after correction: " << isoValue * MeVtoGeV << " GeV");
623  return CorrectionCode::Ok;
624  }
626  const IsoType type, const ObjectCache& cache,
627  float& isoValue) const {
628  if (!isPFlowIso(type)) {
629  ATH_MSG_ERROR("getCloseByCorrectionPflowIso() -- The isolation type is not a Pflow variable " << toString(type));
630  return CorrectionCode::Error;
631  }
632  if (m_isohelpers.at(type)->getOriginalIsolation(primary, isoValue) == CorrectionCode::Error) {
633  ATH_MSG_ERROR("getCloseByCorrectionPflowIso() -- Could not retrieve the isolation variable.");
634  return CorrectionCode::Error;
635  }
637  if (isoValue <= 0.) {
638  ATH_MSG_DEBUG("Pflow varible is already sufficiently isolated ");
639  return CorrectionCode::Ok;
640  }
641  const float coneDR = coneSize(primary, type);
642  float ref_eta{0.f}, ref_phi{0.f};
643  getExtrapEtaPhi(primary, ref_eta, ref_phi);
644  if (m_caloModel == TopoConeCorrectionModel::SubtractObjectsDirectly) {
646  ATH_MSG_VERBOSE("getCloseByCorrectionPflowIso: " << toString(type) << " of " << particleName(primary) << " with pt: "
647  << primary->pt() * MeVtoGeV << " GeV, eta: " << primary->eta()
648  << ", phi: " << primary->phi() << " before correction: " << isoValue * MeVtoGeV << " GeV. ");
649  PflowSet assoc_coll = getAssocFlowElements(ctx, primary);
650  for (const FlowElementPtr& flow : cache.flows) {
651  ATH_MSG_VERBOSE("Loop over pflow element: " << flow->pt() << " GeV, eta: " << flow->eta() << " phi: " << flow->phi());
652 
653  const float dR = xAOD::P4Helpers::deltaR(ref_eta,ref_phi, flow->eta(),flow->phi());
655  ATH_MSG_VERBOSE("Flow element is in core cone");
656  continue;
657  }
658  if (assoc_coll.count(flow)) {
659  ATH_MSG_VERBOSE("Flow element is directly associated with the object");
660  continue;
661  }
662  if (dR < coneDR) {
663  ATH_MSG_VERBOSE("Found overlapping pflow element: " << flow->pt() << " GeV, eta: " << flow->eta()
664  << " phi: " << flow->phi() << " dR: " << dR);
665  isoValue -= flow->pt() * flow.weight;
666  }
667  }
668  ATH_MSG_VERBOSE("getCloseByCorrectionPflowIso: " << toString(type) << " of " << particleName(primary) << " with pt: "
669  << primary->pt() * MeVtoGeV << " GeV, eta: " << primary->eta()
670  << ", phi: " << primary->phi() << " after correction: " << isoValue * MeVtoGeV << " GeV. ");
671  } else if (m_caloModel == TopoConeCorrectionModel::UseAveragedDecorators) {
672  static const FloatAccessor acc_eta{pflowDecors()[0]};
673  static const FloatAccessor acc_phi{pflowDecors()[1]};
674  static const FloatAccessor acc_ene{pflowDecors()[2]};
675  static const CharAccessor acc_isDecor{pflowDecors()[3]};
676  for (const xAOD::IParticle* others : cache.prim_parts) {
677  if (others == primary) continue;
678  if (!acc_isDecor.isAvailable(*others) || !acc_isDecor(*others)) {
679  ATH_MSG_ERROR("The variable energy averaged pflow decorations are not available for "<<particleName(others)<<". Please check");
680  return CorrectionCode::Error;
681  }
682  const float other_eta = acc_eta(*others);
683  const float other_phi = acc_phi(*others);
684  const float dR = xAOD::P4Helpers::deltaR(ref_eta,ref_phi,other_eta,other_phi);
685  if (dR > coneDR) continue;
686  if (dR< (primary->type() == xAOD::Type::ObjectType::Muon ? m_coreConeMu : m_coreConeEl)) continue;
687  isoValue -= acc_ene(*others);
688  }
689  } else {
690  ATH_MSG_ERROR("Unknown calo correction model "<<m_caloModel);
691  return CorrectionCode::Error;
692  }
693  isoValue = std::max(0.f, isoValue);
694  return CorrectionCode::Ok;
695  }
696 
698  const IsoType type, ObjectCache& cache,
699  float& isoValue) const {
700  // check if the isolation can be loaded
701  if (!isTopoEtIso(type)) {
702  ATH_MSG_ERROR("getCloseByCorrectionTopoIso() -- The isolation type is not an et cone variable " << toString(type));
703  return CorrectionCode::Error;
704  }
705  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
706  if (m_isohelpers.at(type)->getOriginalIsolation(primary, isoValue) == CorrectionCode::Error) {
707  ATH_MSG_WARNING("Could not retrieve the isolation variable.");
708  return CorrectionCode::Error;
709  }
711  if (isoValue <= 0.) {
712  ATH_MSG_DEBUG("Topo et cone variable is already sufficiently isolated");
713  return CorrectionCode::Ok;
714  }
715  float ref_eta{0.f}, ref_phi{0.f};
716  getExtrapEtaPhi(primary, ref_eta, ref_phi);
717  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: " << toString(type) << " of " << particleName(primary) << " with ref eta: " << ref_eta << ", ref phi " << ref_phi);
718 
719  float MaxDR = coneSize(primary, type) * (primary->type() != xAOD::Type::ObjectType::Muon ? 1. : m_ConeSizeVariation.value());
720  if (m_caloModel == TopoConeCorrectionModel::SubtractObjectsDirectly) {
721  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: " << toString(type) << " of " << particleName(primary) << " with pt: "
722  << primary->pt() * MeVtoGeV << " GeV, eta: " << primary->eta()
723  << ", phi: " << primary->phi() << " before correction: " << isoValue * MeVtoGeV << " GeV. ");
724  ClusterSet assoc = getAssociatedClusters(ctx, primary, cache);
725  for (const CaloClusterPtr& calo : cache.clusters) {
726  const float dR = xAOD::P4Helpers::deltaR(ref_eta, ref_phi, calo->eta(), calo->phi());
727  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: Loop over cluster: " << calo->pt() * MeVtoGeV << " GeV, eta: " << calo->eta() << " phi: " << calo->phi() << " dR: " << dR);
728  if (dR > MaxDR) continue;
729  // REMOVED CORE CUT SINCE TOPOCLUSTERS SHOULD BE ASSOCIATED TO THE ELECTRONS AND MUONS AND WILL BE CUT BY ASSOC CUT BELOW
730  if (assoc.count(calo)) {
731  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: skip due to assoc " << assoc.count(calo));
732  continue;
733  }
734  float Polution = clusterEtMinusTile(calo) / (isoValue != 0 ? isoValue : 1.);
735  if (Polution < 0. || Polution > m_maxTopoPolution) {
736  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: skip due to polution " << Polution << ", clus noTile " << clusterEtMinusTile(calo) * MeVtoGeV << " GeV");
737  continue;
738  }
739  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: Found overlapping topocluster: " << calo->pt() * MeVtoGeV << " GeV, lessTile " << clusterEtMinusTile(calo) * MeVtoGeV << " GeV, eta: " << calo->eta()
740  << " phi: " << calo->phi() << " dR: " << dR);
741  isoValue -= clusterEtMinusTile(calo);
742  }
743  ATH_MSG_VERBOSE("getCloseByCorrectionTopoIso: " << toString(type) << " of " << particleName(primary) << " with pt: "
744  << primary->pt() * MeVtoGeV << " GeV, eta: " << primary->eta()
745  << ", phi: " << primary->phi() << " after correction: " << isoValue * MeVtoGeV << " GeV. ");
746  } else if (m_caloModel == TopoConeCorrectionModel::UseAveragedDecorators) {
747  static const FloatAccessor acc_eta{caloDecors()[0]};
748  static const FloatAccessor acc_phi{caloDecors()[1]};
749  static const FloatAccessor acc_ene{caloDecors()[2]};
750  static const CharAccessor acc_isDecor{caloDecors()[3]};
751  for (const xAOD::IParticle* others : cache.prim_parts) {
752  if (others == primary) continue;
753  if (!acc_isDecor.isAvailable(*others) || !acc_isDecor(*others)) {
754  ATH_MSG_ERROR("The averaged calo cluster decorations are not available for "<<particleName(others)<<". Please check");
755  return CorrectionCode::Error;
756  }
757  const float other_eta = acc_eta(*others);
758  const float other_phi = acc_phi(*others);
759  const float dR = xAOD::P4Helpers::deltaR(ref_eta,ref_phi,other_eta,other_phi);
760  if (dR > MaxDR) continue;
761  if (dR< (primary->type() == xAOD::Type::ObjectType::Muon ? m_coreConeMu : m_coreConeEl)) continue;
762  isoValue -= acc_ene(*others);
763  }
764  }
765  isoValue = std::max(0.f, isoValue);
766  return CorrectionCode::Ok;
767  }
768  void IsolationCloseByCorrectionTool::getExtrapEtaPhi(const xAOD::IParticle* par, float& eta, float& phi) const {
769  static const FloatAccessor acc_assocEta{IsolationCloseByCorrectionTool::caloDecors()[0]};
770  static const FloatAccessor acc_assocPhi{IsolationCloseByCorrectionTool::caloDecors()[1]};
771  static const CharAccessor acc_isDecor{caloDecors()[3]};
772  if (par->type() != xAOD::Type::ObjectType::Muon) {
773  const xAOD::Egamma* egam = dynamic_cast<const xAOD::Egamma*>(par);
774  if( egam ) {
775  eta = egam->caloCluster()->eta();
776  phi = egam->caloCluster()->phi();
777  }
778  else {
779  eta = par->eta();
780  phi = par->phi();
781  }
782  } else if (acc_isDecor.isAvailable(*par) && acc_isDecor(*par)) {
783  eta = acc_assocEta(*par);
784  phi = acc_assocPhi(*par);
785  } else {
786  float assoc_ene{0.f};
787  static const FloatDecorator dec_assocEta{IsolationCloseByCorrectionTool::caloDecors()[0]};
788  static const FloatDecorator dec_assocPhi{IsolationCloseByCorrectionTool::caloDecors()[1]};
789  static const CharDecorator dec_isDecor{caloDecors()[3]};
790  associateCluster(par,eta, phi, assoc_ene);
791  dec_assocEta(*par) = eta;
792  dec_assocPhi(*par) = phi;
793  dec_isDecor(*par) = true;
794  }
795  }
796  void IsolationCloseByCorrectionTool::associateFlowElement(const EventContext& ctx, const xAOD::IParticle* particle, float& eta,
797  float& phi, float& energy) const {
798  phi = eta = energy = 0.;
799  PflowSet flowCollection = getAssocFlowElements(ctx, particle);
800  if (flowCollection.empty()) {
801  phi = particle->phi();
802  eta = particle->eta();
803  return;
804  }
805  for (const FlowElementPtr& ele : flowCollection) {
806  const float flow_energy = ele->e() * ele.weight;
807  if (flow_energy < MinClusterEnergy) continue;
808  phi += ele->phi() * flow_energy;
809  eta += ele->eta() * flow_energy;
810  energy += flow_energy;
811  }
812  if (energy < MinClusterEnergy) {
813  phi = particle->phi();
814  eta = particle->eta();
815  return;
816  }
818  eta /= energy;
819  }
820  void IsolationCloseByCorrectionTool::associateCluster(const xAOD::IParticle* particle, float& eta, float& phi, float& energy) const {
821  phi = particle->phi();
822  eta = particle->eta();
823  energy = -1.;
824  if (particle->type() == xAOD::Type::ObjectType::Muon) {
825  const xAOD::Muon* mu = static_cast<const xAOD::Muon*>(particle);
826  const xAOD::CaloCluster* cluster = mu->cluster();
827  if (!cluster) return;
828  energy = cluster->e();
829  // At the moment no cluster associated with muons is in the derivations
830  int nSample{0};
831  float etaT{0.f}, phiT{0.f}, dphiT{0.f};
832 
833  for (unsigned int i = 0; i < CaloSampling::Unknown; ++i) {
835  if (cluster->hasSampling(s)) {
836  ATH_MSG_VERBOSE("Sampling: " << i << "eta-phi (" << cluster->etaSample(s) << ", " << cluster->phiSample(s) << ")");
837  etaT += cluster->etaSample(s);
838  if (!nSample)
839  phiT = cluster->phiSample(s);
840  else
841  dphiT += xAOD::P4Helpers::deltaPhi(cluster->phiSample(s), phiT);
842  ++nSample;
843  }
844  }
845  if (!nSample) return;
846  ATH_MSG_DEBUG("Eta, phi before sampling: " << eta << ", " << phi << " and after sampling: " << etaT / nSample << ", "
847  << phiT / nSample);
848  phi = xAOD::P4Helpers::deltaPhi(phiT + dphiT / nSample, 0);
849  eta = etaT / nSample;
850  ATH_MSG_VERBOSE("associateCluster: mu with pt: " << mu->pt() * MeVtoGeV << " GeV, eta: "
851  << mu->eta() << ", phi: " << mu->phi() << " energy, eta, phi " << energy << ", " << eta << ", " << phi
852  << ", et " << energy * mu->pt() / mu->e());
853  }
854  if (!isEgamma(particle)) return;
855  const xAOD::Egamma* egamm = static_cast<const xAOD::Egamma*>(particle);
856  eta = phi = energy = 0.;
857  for (unsigned int cl = 0; cl < egamm->nCaloClusters(); ++cl) {
858  const xAOD::CaloCluster* prim_cluster = egamm->caloCluster(cl);
859  if (!prim_cluster) {
860  ATH_MSG_DEBUG("Cluster " << cl << " is not defined " << egamm);
861  continue;
862  }
863  std::vector<const xAOD::CaloCluster*> constituents = xAOD::EgammaHelpers::getAssociatedTopoClusters(prim_cluster);
864  for (const xAOD::CaloCluster* cluster : constituents) {
865  if (!cluster) continue;
866  const float clus_e = clusterEtMinusTile(cluster);
868  if (clus_e < MinClusterEnergy) continue;
869  eta += cluster->eta() * clus_e;
870  phi += cluster->phi() * clus_e;
871  energy += clus_e;
872  ATH_MSG_VERBOSE("associateCluster: eg add in clus with e: " << clus_e * MeVtoGeV << " clus et " << cluster->pt() * MeVtoGeV << " GeV, eta: "
873  << cluster->eta() << ", phi: " << cluster->phi());
874  }
875  }
876  if (energy >= MinClusterEnergy) {
878  eta /= energy;
879  ATH_MSG_VERBOSE("associateCluster: eg with pt: " << egamm->pt() * MeVtoGeV << " GeV, eta: "
880  << egamm->eta() << ", phi: " << egamm->phi() << " energy, eta, phi " << energy << ", " << eta << ", " << phi );
881  } else {
882  ATH_MSG_DEBUG("Average energy from the clusters is too low " << energy << " copy particle properties");
883  eta = egamm->eta();
884  phi = egamm->phi();
885  energy = egamm->e();
886  }
887  }
889  const xAOD::IParticleContainer& closePar) const {
890  if (!m_isInitialised) { ATH_MSG_WARNING("The IsolationCloseByCorrectionTool was not initialised!!!"); }
891  assert(!m_selectorTool.empty());
892  const IsoVector& iso_types = getIsolationTypes(&x);
893  if (iso_types.empty()) {
894  // TODO: figure out if this is actually a valid situation
895  // or if we should just fail at this point.
896  ATH_MSG_WARNING("Could not cast particle for acceptCorrected. Will return false.");
897  static const asg::AcceptInfo dummyAcceptInfo = []() {
899  info.addCut("castCut", "whether we managed to cast to a known type");
900  return info;
901  }();
902  if (m_dec_isoselection) (*m_dec_isoselection)(x) = false;
903  return asg::AcceptData(&dummyAcceptInfo);
904  }
905 
906  if (closePar.empty()) return m_selectorTool->accept(x);
907  strObj strPar;
908  strPar.isolationValues.resize(numIsolationTypes);
909  strPar.pt = x.pt();
910  strPar.eta = x.eta();
911  strPar.type = x.type();
912  std::vector<float> corrections;
913  if (getCloseByCorrection(corrections, x, iso_types, closePar) == CorrectionCode::Error) {
914  ATH_MSG_WARNING("Could not calculate the corrections. acceptCorrected(x) is done without the corrections.");
915  if (m_dec_isoselection) (*m_dec_isoselection)(x) = bool(m_selectorTool->accept(x));
916  return m_selectorTool->accept(x);
917  }
918  for (unsigned int i = 0; i < iso_types.size(); ++i) {
919  strPar.isolationValues[iso_types[i]] = corrections[i];
921  float old = (*acc)(x);
922  ATH_MSG_DEBUG("Correcting " << toString(iso_types.at(i)) << " from " << old << " to " << corrections[i]);
923  }
924  auto accept = m_selectorTool->accept(strPar);
925  if (m_dec_isoselection) (*m_dec_isoselection)(x) = bool(accept);
926  return accept;
927  }
930  if (!Verticies.isValid() || !Verticies->size()) {
931  ATH_MSG_WARNING("Failed to load vertex collection " << m_VtxKey.key());
932  return nullptr;
933  }
934  for (const xAOD::Vertex* V : *Verticies) {
935  if (V->vertexType() == xAOD::VxType::VertexType::PriVtx) {
936  ATH_MSG_VERBOSE("retrieveIDBestPrimaryVertex: vertex found ");
937  return V;
938  }
939  }
940  ATH_MSG_VERBOSE("retrieveIDBestPrimaryVertex: no vertex found ");
941  return nullptr;
942  }
943 
945  using xAOD::Iso::coneSize;
946  float ConeDR = coneSize(Cone);
948  const xAOD::IParticle* Reference = isoRefParticle(P);
949  float MiniIso = m_ptvarconeRadius / unCalibPt(Reference);
950  if (MiniIso < ConeDR) return MiniIso;
951  }
952  return ConeDR;
953  }
955  if (!P) {
956  ATH_MSG_WARNING("No partcile given. Return stupidly big number. ");
957  return 1.e25;
958  }
960  if (!OR) {
961  ATH_MSG_VERBOSE("No reference from the shallow copy container of " << particleName(P) << " could be found");
962  return P->pt();
963  }
964  return OR->pt();
965  }
966 
968  if (!P) {
969  ATH_MSG_ERROR("Nullptr given");
970  return nullptr;
971  }
972  // Use for muons the associated ID track. Else the particle itself
973  if (P->type() == xAOD::Type::ObjectType::Muon) {
974  const xAOD::Muon* muon = static_cast<const xAOD::Muon*>(P);
975  const xAOD::TrackParticle* idTrk = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
976  return idTrk ? idTrk : muon->primaryTrackParticle();
977  }
978  return P;
979  }
981  if (!P || !P1) {
982  ATH_MSG_WARNING("Nullptr were given");
983  return true;
984  }
985  return (P == P1);
986  }
987 
988  float IsolationCloseByCorrectionTool::deltaR2(const xAOD::IParticle* P, const xAOD::IParticle* P1, bool AvgCalo) const {
989  if (isSame(P, P1)) return 0.;
990  // Check if one of the objects is a CaloCluster or the Averaging over the clusters is requested.
991  if (AvgCalo || (P->type() != P1->type() &&
993  float phi1{0.f}, eta1{0.f}, eta2{0.f}, phi2{0.f};
994  getExtrapEtaPhi(P, eta1, phi1);
995  getExtrapEtaPhi(P1, eta2, phi2);
996  return xAOD::P4Helpers::deltaR2(eta1, phi1, eta2, phi2);
997  }
998  float dPhi = xAOD::P4Helpers::deltaPhi(P, P1);
999  float dEta = P->eta() - P1->eta();
1000  return dEta * dEta + dPhi * dPhi;
1001  }
1003  return (!isSame(P, P1) && deltaR2(P, P1) < (dR * dR));
1004  }
1006  std::lock_guard<std::mutex> guard{m_isoHelpersMutex};
1007  IsoHelperMap::const_iterator itr = m_isohelpers.find(isoVariable);
1008  float isovalue = 0;
1009  if (itr == m_isohelpers.end() || itr->second->getOriginalIsolation(particle, isovalue) == CorrectionCode::Error) {
1010  ATH_MSG_ERROR("Failed to retrive the original isolation cone ");
1011  isovalue = FLT_MAX;
1012  }
1013  return isovalue;
1014  }
1016  return getOriginalIsolation(&particle, type);
1017  }
1019  float Et{0.f};
1020  if (cluster) {
1021  try {
1022  Et = cluster->p4(xAOD::CaloCluster::State::UNCALIBRATED).Et();
1023  Et = Et - cluster->eSample(xAOD::CaloCluster::CaloSample::TileGap3) /
1024  std::cosh(cluster->p4(xAOD::CaloCluster::State::UNCALIBRATED).Eta());
1025  } catch (...) { Et = cluster->p4().Et(); }
1026  }
1027  return std::max(Et, 0.f);
1028  }
1031  if (T == xAOD::Type::ObjectType::Electron) return "Electron";
1032  if (T == xAOD::Type::ObjectType::Photon) return "Photon";
1033  if (T == xAOD::Type::ObjectType::Muon) return "Muon";
1034  if (T == xAOD::Type::ObjectType::TrackParticle) return "Track";
1035  if (T == xAOD::Type::ObjectType::CaloCluster) return "Cluster";
1036  return "Unknown";
1037  }
1042  }
1046  static const std::set<IsolationFlavour> ttvaFlavours{IsolationFlavour::ptcone_Nonprompt_All_MaxWeightTTVA_pt500,
1050  return ttvaFlavours.count(flavour);
1051  }
1054  static const std::set<IsolationFlavour> ttvaFlavours{IsolationFlavour::ptvarcone_Nonprompt_All_MaxWeightTTVA_pt500,
1058  return ttvaFlavours.count(flavour);
1059  }
1062  ATH_MSG_INFO("The following isolation cones are considered for " << particleName(T));
1063  for (const IsoType& cone : types) { ATH_MSG_INFO(" --- " << toString(cone)); }
1064  }
1066  if (!isTrackIso(type)) return -1;
1068  static const std::set<IsolationFlavour> Pt1000_Flavours{IsolationFlavour::ptcone_Nonprompt_All_MaxWeightTTVA_pt1000,
1072  if (Pt1000_Flavours.count(flavour)) return 1000;
1073  return 500;
1074  }
1076 } // namespace CP
grepfile.info
info
Definition: grepfile.py:38
CP::IsolationCloseByCorrectionTool::copyIsoValuesForPartsNotSelected
CorrectionCode copyIsoValuesForPartsNotSelected(const xAOD::IParticle *part) const
Definition: IsolationCloseByCorrectionTool.cxx:381
CP::IsolationCloseByCorrectionTool::m_hasEtConeIso
bool m_hasEtConeIso
Switch whether a topoetcone isolation working point is defined.
Definition: IsolationCloseByCorrectionTool.h:294
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
CP::IsolationCloseByCorrectionTool::m_backup_prefix
Gaudi::Property< std::string > m_backup_prefix
Definition: IsolationCloseByCorrectionTool.h:219
CP::caloDecorNames
IsolationCloseByCorrectionTool::caloDecorNames caloDecorNames
Definition: IsolationCloseByCorrectionTool.cxx:23
xAOD::Iso::topoetcone
@ topoetcone
Topo-cluster ET-sum.
Definition: IsolationFlavour.h:25
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
CP::IsolationCloseByCorrectionTool::m_maxTopoPolution
Gaudi::Property< float > m_maxTopoPolution
Definition: IsolationCloseByCorrectionTool.h:245
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
CP::IsolationCloseByCorrectionTool::getAssociatedClusters
ClusterSet getAssociatedClusters(const EventContext &ctx, const xAOD::IParticle *particle, ObjectCache &cache) const
Loads the topo clusters associated with the primary IParticle.
Definition: IsolationCloseByCorrectionTool.cxx:503
CP::IsolationCloseByCorrectionTool::lockDecorations
void lockDecorations(const xAOD::IParticleContainer *parts) const
Definition: IsolationCloseByCorrectionTool.cxx:319
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
CP::IsolationCloseByCorrectionTool::m_ttvaTool
ToolHandle< CP::ITrackVertexAssociationTool > m_ttvaTool
Definition: IsolationCloseByCorrectionTool.h:205
CP::IsolationCloseByCorrectionTool::ObjectCache::not_sel_parts
PrimaryCollection not_sel_parts
Definition: IsolationCloseByCorrectionTool.h:89
xAOD::EgammaHelpers::getAssociatedTopoClusters
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters(const xAOD::CaloCluster *cluster)
Return a vector of all the topo clusters associated with the egamma cluster.
Definition: EgammaxAODHelpers.cxx:65
CP::IsolationCloseByCorrectionTool::m_isoWriteDecVarKeys
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainer > m_isoWriteDecVarKeys
Definition: IsolationCloseByCorrectionTool.h:267
CP::IsolationCloseByCorrectionTool::isTrackIsoTTVA
static bool isTrackIsoTTVA(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1060
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
CP::IsolationCloseByCorrectionTool::isVarTrackIsoTTVA
static bool isVarTrackIsoTTVA(xAOD::Iso::IsolationType Iso)
Definition: IsolationCloseByCorrectionTool.cxx:1052
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CP::IsolationCloseByCorrectionTool::isFixedTrackIso
static bool isFixedTrackIso(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1038
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CP::IsolationCloseByCorrectionTool::m_acc_quality
SelectionAccessor m_acc_quality
Definition: IsolationCloseByCorrectionTool.h:299
ObjectType
ObjectType
Definition: BaseObject.h:11
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
CP::IsolationCloseByCorrectionTool::m_declareCaloDecors
Gaudi::Property< bool > m_declareCaloDecors
Definition: IsolationCloseByCorrectionTool.h:254
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
CP::IsolationCloseByCorrectionTool::m_passOR_name
Gaudi::Property< std::string > m_passOR_name
Definition: IsolationCloseByCorrectionTool.h:215
CurrentContext.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAODP4Helpers.h
JetTiledMap::W
@ W
Definition: TiledEtaPhiMap.h:44
xAOD::Iso::IsolationFlavour
IsolationFlavour
Enumeration for different ways of calculating isolation in xAOD files.
Definition: IsolationFlavour.h:17
CP::IsolationCloseByCorrectionTool::m_PflowKey
SG::ReadHandleKey< xAOD::FlowElementContainer > m_PflowKey
Definition: IsolationCloseByCorrectionTool.h:281
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
xAOD::Egamma_v1::e
virtual double e() const override final
The total energy of the particle.
Definition: Egamma_v1.cxx:90
DMTest::P
P_v1 P
Definition: P.h:23
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
CP::PflowSet
std::set< FlowElementPtr > PflowSet
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:75
CP::IsolationCloseByCorrectionTool::passSelectionQuality
bool passSelectionQuality(const xAOD::IParticle *particle) const
Definition: IsolationCloseByCorrectionTool.cxx:578
CP::IsolationCloseByCorrectionTool::IsolationCloseByCorrectionTool
IsolationCloseByCorrectionTool(const std::string &name)
Definition: IsolationCloseByCorrectionTool.cxx:35
CP::IsolationCloseByCorrectionTool::ObjectCache::clusters
ClusterSet clusters
Definition: IsolationCloseByCorrectionTool.h:91
asg
Definition: DataHandleTestTool.h:28
CP::IsolationCloseByCorrectionTool::m_muonKeys
Gaudi::Property< std::vector< std::string > > m_muonKeys
Definition: IsolationCloseByCorrectionTool.h:261
CP::MeVtoGeV
constexpr float MeVtoGeV
Definition: IsolationCloseByCorrectionTool.cxx:33
CP::IsolationCloseByCorrectionTool::isTopoEtIso
static bool isTopoEtIso(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1043
CP::IsolationCloseByCorrectionTool::clusterEtMinusTile
static float clusterEtMinusTile(const xAOD::CaloCluster *C)
Definition: IsolationCloseByCorrectionTool.cxx:1018
CP::IsolationCloseByCorrectionTool::m_electron_isoTypes
IsoVector m_electron_isoTypes
Isolation variables used by the electron working point.
Definition: IsolationCloseByCorrectionTool.h:286
CP::TrackSet
std::set< TrackPtr > TrackSet
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:73
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::IParticle::type
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
CP::IsolationCloseByCorrectionTool::m_elecKeys
Gaudi::Property< std::vector< std::string > > m_elecKeys
Declare the data dependencies of the Input containers.
Definition: IsolationCloseByCorrectionTool.h:259
CP::IsolationCloseByCorrectionTool::pflowDecors
static caloDecorNames pflowDecors()
Definition: IsolationCloseByCorrectionTool.cxx:28
CP::strObj::isolationValues
std::vector< float > isolationValues
Definition: IsolationCondition.h:26
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: xAODP4Helpers.h:69
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
CP::IsolationCloseByCorrectionTool::associateCluster
void associateCluster(const xAOD::IParticle *particle, float &eta, float &phi, float &energy) const override
Retrieve the associated clusters from the Particle and calculate the average eta/phi/energy.
Definition: IsolationCloseByCorrectionTool.cxx:820
CP::IsolationCloseByCorrectionTool::ObjectCache::prim_vtx
const xAOD::Vertex * prim_vtx
Definition: IsolationCloseByCorrectionTool.h:87
xAOD::EgammaHelpers::getTrackParticles
std::set< const xAOD::TrackParticle * > getTrackParticles(const xAOD::Egamma *eg, bool useBremAssoc=true, bool allParticles=true)
Return a list of all or only the best TrackParticle associated to the object.
Definition: EgammaxAODHelpers.cxx:120
CP::SortedObjPtr
Small helper struct to have sets of particle pointers sorted by pt.
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:41
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP::IsolationCloseByCorrectionTool::loadAssociatedObjects
void loadAssociatedObjects(const EventContext &ctx, ObjectCache &cache) const
Load all associated tracks / clusters / flow elements into the cache.
Definition: IsolationCloseByCorrectionTool.cxx:162
xAOD::Iso::neflowisol
@ neflowisol
neutral eflow
Definition: IsolationFlavour.h:31
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
CP::IsolationCloseByCorrectionTool::m_caloModel
Gaudi::Property< int > m_caloModel
EXPERT PROPERTIES.
Definition: IsolationCloseByCorrectionTool.h:226
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
CP::IsolationCloseByCorrectionTool::isSame
bool isSame(const xAOD::IParticle *particle, const xAOD::IParticle *particle1) const
Definition: IsolationCloseByCorrectionTool.cxx:980
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
x
#define x
CP::IsolationCloseByCorrectionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: IsolationCloseByCorrectionTool.cxx:37
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
CP::IsolationCloseByCorrectionTool::performCloseByCorrection
CorrectionCode performCloseByCorrection(const EventContext &ctx, ObjectCache &cache) const
Definition: IsolationCloseByCorrectionTool.cxx:270
xAOD::Egamma_v1::nCaloClusters
size_t nCaloClusters() const
Return the number of xAOD::CaloClusters that define the electron candidate.
Definition: Egamma_v1.cxx:377
CaloCell_ID_FCS::TileGap3
@ TileGap3
Definition: FastCaloSim_CaloCell_ID.h:36
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
CP::IsolationCloseByCorrectionTool::m_coreConeMu
Gaudi::Property< float > m_coreConeMu
Definition: IsolationCloseByCorrectionTool.h:234
CP::strObj
Definition: IsolationCondition.h:23
CP::IsolationCloseByCorrectionTool::m_isoSelection_name
Gaudi::Property< std::string > m_isoSelection_name
Definition: IsolationCloseByCorrectionTool.h:217
getIsolationCorrectionAccessor.h
CP::IsolationCloseByCorrectionTool::m_photon_isoTypes
IsoVector m_photon_isoTypes
Isolation variables used by the photon working point.
Definition: IsolationCloseByCorrectionTool.h:288
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Iso
Namespace holding the IsolationType enumeration.
Definition: IsolationConeSize.h:13
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
CP::IsolationCloseByCorrectionTool::m_has_nonTTVA
bool m_has_nonTTVA
Switch whether a pile-up non robust TTVA working point is defined.
Definition: IsolationCloseByCorrectionTool.h:290
CP::IsolationCloseByCorrectionTool::retrieveIDBestPrimaryVertex
const xAOD::Vertex * retrieveIDBestPrimaryVertex(const EventContext &ctx) const
Definition: IsolationCloseByCorrectionTool.cxx:928
xAOD::Cone
@ Cone
Definition: TrackingPrimitives.h:553
Egamma.h
CP::IsolationCloseByCorrectionTool::m_ConeSizeVariation
Gaudi::Property< float > m_ConeSizeVariation
Definition: IsolationCloseByCorrectionTool.h:249
CP::IsolationCloseByCorrectionTool::getAssocFlowElements
void getAssocFlowElements(const EventContext &ctx, ObjectCache &cache) const
Retrieve all Flow elements associated with the particles in the cache.
Definition: IsolationCloseByCorrectionTool.cxx:186
CP::IsolationCloseByCorrectionTool::m_muon_isoTypes
IsoVector m_muon_isoTypes
Isolation variables used by the muon working point.
Definition: IsolationCloseByCorrectionTool.h:284
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::IsolationCloseByCorrectionTool::m_CaloClusterKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_CaloClusterKey
Definition: IsolationCloseByCorrectionTool.h:279
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::Iso::ptvarcone
@ ptvarcone
mini isolation
Definition: IsolationFlavour.h:28
CP::IsolationCloseByCorrectionTool::isEgamma
static bool isEgamma(const xAOD::IParticle *particle)
Definition: IsolationCloseByCorrectionTool.cxx:495
EgammaxAODHelpers.h
CP::IsolationCloseByCorrectionTool::loadPrimaryParticles
void loadPrimaryParticles(const xAOD::IParticleContainer *container, ObjectCache &cache) const
Filter all electrons/muons/photons from the collection which pass the selection decoration.
Definition: IsolationCloseByCorrectionTool.cxx:136
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ObjectType.h
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
StateLessPT_NewConfig.primary
primary
Definition: StateLessPT_NewConfig.py:228
xAOD::Iso::ptvarcone_Nonprompt_All_MaxWeightTTVALooseCone_pt1000
@ ptvarcone_Nonprompt_All_MaxWeightTTVALooseCone_pt1000
Definition: IsolationFlavour.h:42
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::IsolationCloseByCorrectionTool::deltaR2
float deltaR2(const xAOD::IParticle *particle, const xAOD::IParticle *particle1, bool AvgCalo=false) const
Definition: IsolationCloseByCorrectionTool.cxx:988
asg::AsgToolConfig
an object that can create a AsgTool
Definition: AsgToolConfig.h:22
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
asg::AcceptInfo
Definition: AcceptInfo.h:28
IsolationSelectionTool.h
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
CP::IsolationCloseByCorrectionTool::m_coreConeEl
Gaudi::Property< float > m_coreConeEl
Definition: IsolationCloseByCorrectionTool.h:229
CP::IsolationCloseByCorrectionTool::coneSize
float coneSize(const xAOD::IParticle *particle, IsoType Cone) const
Definition: IsolationCloseByCorrectionTool.cxx:944
HepMC::flow
int flow(const T &a, int i)
Definition: Flow.h:51
IsoCloseByCorrectionTest.containers
containers
Associate the close-by pflow objects and the calorimeter clusters.
Definition: IsoCloseByCorrectionTest.py:82
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
CP::IsolationCloseByCorrectionTool::particleName
static std::string particleName(const xAOD::IParticle *C)
Definition: IsolationCloseByCorrectionTool.cxx:1029
CP::IsolationCloseByCorrectionTool::ObjectCache::flows
PflowSet flows
Definition: IsolationCloseByCorrectionTool.h:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::IsolationCloseByCorrectionTool::getCloseByCorrectionPflowIso
CorrectionCode getCloseByCorrectionPflowIso(const EventContext &ctx, const xAOD::IParticle *primary, const IsoType type, const ObjectCache &cache, float &isoValue) const
Definition: IsolationCloseByCorrectionTool.cxx:625
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::IsolationCloseByCorrectionTool::passFirstStage
bool passFirstStage(const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx) const
The Track particle has to pass the Track selection tool and the TTVA selection.
Definition: IsolationCloseByCorrectionTool.cxx:461
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
CP::IsolationCloseByCorrectionTool::printIsolationCones
void printIsolationCones(const IsoVector &types, xAOD::Type::ObjectType T) const
Definition: IsolationCloseByCorrectionTool.cxx:1061
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:548
xAOD::Iso::ptcone_Nonprompt_All_MaxWeightTTVALooseCone_pt500
@ ptcone_Nonprompt_All_MaxWeightTTVALooseCone_pt500
ptcone for high mu
Definition: IsolationFlavour.h:45
AsgToolConfig.h
CP::IsolationCloseByCorrectionTool::isFixedTrackIsoTTVA
static bool isFixedTrackIsoTTVA(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1044
xAOD::Egamma_v1::caloCluster
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Definition: Egamma_v1.cxx:388
xAOD::Iso::ptcone_Nonprompt_All_MaxWeightTTVA_pt500
@ ptcone_Nonprompt_All_MaxWeightTTVA_pt500
ptcone for high mu
Definition: IsolationFlavour.h:38
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
CP::IsolationCloseByCorrectionTool::isPFlowIso
static bool isPFlowIso(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1075
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
CP::IsolationCloseByCorrectionTool::m_photKeys
Gaudi::Property< std::vector< std::string > > m_photKeys
Definition: IsolationCloseByCorrectionTool.h:263
python.xAODType.dummy
dummy
Definition: xAODType.py:4
CP::IsolationCloseByCorrectionTool::m_caloExtTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtTool
calo extension tool for muon track particle extrapolation to calo
Definition: IsolationCloseByCorrectionTool.h:271
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:141
xAOD::Iso::ptvarcone_Nonprompt_All_MaxWeightTTVALooseCone_pt500
@ ptvarcone_Nonprompt_All_MaxWeightTTVALooseCone_pt500
Definition: IsolationFlavour.h:41
xAOD::Iso::ptcone
@ ptcone
Track isolation.
Definition: IsolationFlavour.h:22
xAOD::Egamma_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition: Egamma_v1.cxx:75
CP::IsolationCloseByCorrectionTool::unCalibPt
float unCalibPt(const xAOD::IParticle *particle) const
Definition: IsolationCloseByCorrectionTool.cxx:954
CP::IsolationCloseByCorrectionTool::getTrackCandidates
TrackSet getTrackCandidates(const EventContext &ctx, const xAOD::IParticle *particle) const override
Load all TrackParticles associated with the particles in the Container. The particles have to pass th...
Definition: IsolationCloseByCorrectionTool.cxx:492
CP::IsolationCloseByCorrectionTool::getAssociatedTracks
TrackSet getAssociatedTracks(const xAOD::IParticle *P) const
Retrieve all Inner detector tracks associated with the primary particle.
Definition: IsolationCloseByCorrectionTool.cxx:464
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::getIsolationAccessor
const SG::AuxElement::Accessor< float > * getIsolationAccessor(Iso::IsolationType type)
Get the Accessor object for a given isolation type.
Definition: getIsolationAccessor.cxx:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::IsolationCloseByCorrectionTool::ObjectCache::eg_associated_clusters
UnorderedClusterSet eg_associated_clusters
Definition: IsolationCloseByCorrectionTool.h:93
CP::IsolationCloseByCorrectionTool::m_hasPflowIso
bool m_hasPflowIso
Switch whether a pflow isolation working point is defined.
Definition: IsolationCloseByCorrectionTool.h:292
CP::IsolationCloseByCorrectionTool::m_selectorTool
ToolHandle< CP::IIsolationSelectionTool > m_selectorTool
Definition: IsolationCloseByCorrectionTool.h:207
CP::IsolationCloseByCorrectionTool::ObjectCache::prim_parts
PrimaryCollection prim_parts
Definition: IsolationCloseByCorrectionTool.h:88
CP::IsolationCloseByCorrectionTool::m_isInitialised
bool m_isInitialised
Definition: IsolationCloseByCorrectionTool.h:297
xAOD::Iso::isolationFlavour
IsolationFlavour isolationFlavour(IsolationType type)
convert Isolation Type into Isolation Flavour
Definition: IsolationHelpers.h:47
CP::IsolationCloseByCorrectionTool::m_acc_passOR
SelectionAccessor m_acc_passOR
Definition: IsolationCloseByCorrectionTool.h:300
CP::IsolationCloseByCorrectionTool::getExtrapEtaPhi
bool getExtrapEtaPhi(const EventContext &ctx, const xAOD::TrackParticle *tp, float &eta, float &phi) const
helper to get eta,phi of muon extrap
Definition: IsolationCloseByCorrectionTool.cxx:216
CP::IsolationCloseByCorrectionTool::getIsolationTypes
const IsoVector & getIsolationTypes(const xAOD::IParticle *particle) const
Definition: IsolationCloseByCorrectionTool.cxx:333
xAOD::Iso::ptvarcone_Nonprompt_All_MaxWeightTTVA_pt1000
@ ptvarcone_Nonprompt_All_MaxWeightTTVA_pt1000
Definition: IsolationFlavour.h:35
CP::IsolationCloseByCorrectionTool::m_isoDecSuffix
Gaudi::Property< std::string > m_isoDecSuffix
Definition: IsolationCloseByCorrectionTool.h:222
CP::IsolationCloseByCorrectionTool::m_trkselTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trkselTool
Definition: IsolationCloseByCorrectionTool.h:203
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
ReadHandle.h
Handle class for reading from StoreGate.
CP::IsolationCloseByCorrectionTool::caloDecors
static caloDecorNames caloDecors()
Returns an array with the calo cluster decoration ames [0]-> eta, [1]->phi, [2]->energy....
Definition: IsolationCloseByCorrectionTool.cxx:24
weights
Definition: herwig7_interface.h:38
CP::FlowElementPtr
For the flow elements we need a special derivate which also contains the weights.
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:60
CP::IsolationCloseByCorrectionTool::getCloseByIsoCorrection
virtual CorrectionCode getCloseByIsoCorrection(const EventContext &ctx, const xAOD::ElectronContainer *Electrons, const xAOD::MuonContainer *Muons, const xAOD::PhotonContainer *Photons) const override
Definition: IsolationCloseByCorrectionTool.cxx:248
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CP::IsolationCloseByCorrectionTool::getCloseByCorrectionTrackIso
CorrectionCode getCloseByCorrectionTrackIso(const xAOD::IParticle *primary, const IsoType type, const ObjectCache &cache, float &isoValue) const
Definition: IsolationCloseByCorrectionTool.cxx:584
CP::IsolationCloseByCorrectionTool::ObjectCache
Definition: IsolationCloseByCorrectionTool.h:85
xAOD::Iso::ptcone_Nonprompt_All_MaxWeightTTVALooseCone_pt1000
@ ptcone_Nonprompt_All_MaxWeightTTVALooseCone_pt1000
Definition: IsolationFlavour.h:46
CP::IsolationCloseByCorrectionTool::associateFlowElement
void associateFlowElement(const EventContext &ctx, const xAOD::IParticle *particle, float &eta, float &phi, float &energy) const override
Definition: IsolationCloseByCorrectionTool.cxx:796
CP::IsolationCloseByCorrectionTool::m_ptvarconeRadius
Gaudi::Property< float > m_ptvarconeRadius
Definition: IsolationCloseByCorrectionTool.h:238
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
CP::ClusterSet
std::set< CaloClusterPtr > ClusterSet
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:74
Muon
struct TBPatternUnitContext Muon
CP::IsolationCloseByCorrectionTool::ObjectCache::tracks
TrackSet tracks
Definition: IsolationCloseByCorrectionTool.h:90
CP::IsolationCloseByCorrectionTool::subtractCloseByContribution
CorrectionCode subtractCloseByContribution(const EventContext &ctx, const xAOD::IParticle *P, ObjectCache &cache) const
Definition: IsolationCloseByCorrectionTool.cxx:345
IsolationCloseByCorrectionTool.h
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
getIsolationAccessor.h
CP::IsolationCloseByCorrectionTool::getCloseByCorrectionTopoIso
CorrectionCode getCloseByCorrectionTopoIso(const EventContext &ctx, const xAOD::IParticle *primary, const IsoType type, ObjectCache &cache, float &isoValue) const
Definition: IsolationCloseByCorrectionTool.cxx:697
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
python.HLT.Muon.MuonRecoSequences.isLRT
def isLRT(name)
Definition: MuonRecoSequences.py:65
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
CP::IsolationCloseByCorrectionTool::m_VtxKey
SG::ReadHandleKey< xAOD::VertexContainer > m_VtxKey
Definition: IsolationCloseByCorrectionTool.h:277
CheckAppliedSFs.WPs
WPs
Definition: CheckAppliedSFs.py:206
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::IParticle::eta
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
IsolationHelpers.h
CP::IsolationCloseByCorrectionTool::getOriginalIsolation
virtual float getOriginalIsolation(const xAOD::IParticle &P, IsoType type) const override
Definition: IsolationCloseByCorrectionTool.cxx:1015
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
Root::OR
@ OR
Definition: TGRLCollection.h:32
CP::IsolationCloseByCorrectionTool::m_quality_name
Gaudi::Property< std::string > m_quality_name
Definition: IsolationCloseByCorrectionTool.h:212
CP::IsolationCloseByCorrectionTool::isTrackIso
static bool isTrackIso(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1040
xAOD::Egamma_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: Egamma_v1.cxx:65
CP::IsolationCloseByCorrectionTool::caloDecorNames
std::array< std::string, 4 > caloDecorNames
Definition: IsolationCloseByCorrectionTool.h:45
xAOD::Iso::numIsolationTypes
@ numIsolationTypes
Definition: IsolationType.h:118
CP::IsolationCloseByCorrectionTool::acceptCorrected
virtual asg::AcceptData acceptCorrected(const xAOD::IParticle &x, const xAOD::IParticleContainer &closePar) const override
Definition: IsolationCloseByCorrectionTool.cxx:888
doL1CaloHVCorrections.parts
parts
Definition: doL1CaloHVCorrections.py:334
CorrectionCode.h
xAOD::Egamma_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: Egamma_v1.cxx:70
CP::IsolationCloseByCorrectionTool::overlap
bool overlap(const xAOD::IParticle *particle, const xAOD::IParticle *particle1, float dR) const
Definition: IsolationCloseByCorrectionTool.cxx:1002
CP::MinClusterEnergy
constexpr float MinClusterEnergy
Definition: IsolationCloseByCorrectionTool.cxx:32
IParticleHelpers.h
CP::IsolationCloseByCorrectionTool::m_dec_isoselection
SelectionDecorator m_dec_isoselection
Definition: IsolationCloseByCorrectionTool.h:301
CP::strObj::pt
float pt
Definition: IsolationCondition.h:24
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::getOriginalObject
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Definition: IParticleHelpers.cxx:140
Trk::CaloExtension::caloLayerIntersections
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Definition: CaloExtension.h:76
asg::AcceptData
Definition: AcceptData.h:30
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:537
python.PyAthena.obj
obj
Definition: PyAthena.py:132
CP::IsolationCloseByCorrectionTool::isoRefParticle
const xAOD::IParticle * isoRefParticle(const xAOD::IParticle *particle) const override
Retrieve the reference particle to define the cone axis in which the track particles contributing to ...
Definition: IsolationCloseByCorrectionTool.cxx:967
CP::IsolationCloseByCorrectionTool::getCloseByCorrection
virtual CorrectionCode getCloseByCorrection(std::vector< float > &corrections, const xAOD::IParticle &par, const std::vector< xAOD::Iso::IsolationType > &types, const xAOD::IParticleContainer &closePar) const override
Definition: IsolationCloseByCorrectionTool.cxx:407
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
xAOD::Iso::coneSize
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
Definition: IsolationHelpers.h:27
CP::IsolationCloseByCorrectionTool::isVarTrackIso
static bool isVarTrackIso(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1039
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
CP::IsolationCloseByCorrectionTool::declareDependency
void declareDependency(const std::vector< std::string > &containers, const IsoVector &types)
Helper function to declare the data dependencies.
Definition: IsolationCloseByCorrectionTool.cxx:118
xAOD::Iso::ptcone_Nonprompt_All_MaxWeightTTVA_pt1000
@ ptcone_Nonprompt_All_MaxWeightTTVA_pt1000
Definition: IsolationFlavour.h:39
CP::IsolationCloseByCorrectionTool::isoTypesFromWP
void isoTypesFromWP(const std::vector< std::unique_ptr< IsolationWP >> &WP, IsoVector &types)
Helper function to load all Isolation types from the iso working points.
Definition: IsolationCloseByCorrectionTool.cxx:97
CP::IsolationCloseByCorrectionTool::trackPtCut
static float trackPtCut(xAOD::Iso::IsolationType type)
Definition: IsolationCloseByCorrectionTool.cxx:1065
xAOD::Iso::ptvarcone_Nonprompt_All_MaxWeightTTVA_pt500
@ ptvarcone_Nonprompt_All_MaxWeightTTVA_pt500
ptvarcone for high mu
Definition: IsolationFlavour.h:34
CP::IsoVector
std::vector< IsoType > IsoVector
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:38
CP::IsolationCloseByCorrectionTool::m_isoVarKeys
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_isoVarKeys
Definition: IsolationCloseByCorrectionTool.h:265
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
CP::strObj::eta
float eta
Definition: IsolationCondition.h:25
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25
CP::strObj::type
xAOD::Type::ObjectType type
Definition: IsolationCondition.h:27