ATLAS Offline Software
EgammaDRScoringTool.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
7 #include "xAODBase/ObjectType.h"
9 #include "xAODEgamma/Egamma.h"
11 #include <sstream>
12 
13 // Anonymous namespace for helper functions
14 namespace {
15  float dr(const xAOD::CaloCluster &lhs, const xAOD::CaloCluster &rhs)
16  {
17  return xAOD::P4Helpers::deltaR(lhs.etaBE(2), lhs.phiBE(2), rhs.etaBE(2), rhs.phiBE(2));
18  }
19  float dr(const xAOD::IParticle &online, const xAOD::CaloCluster &offline, bool useDecor = true)
20  {
21  static const SG::ConstAccessor<float> cl_eta2Acc ("cl_eta2");
22  static const SG::ConstAccessor<float> cl_phi2Acc ("cl_phi2");
23  double lhs_eta = useDecor ? cl_eta2Acc(online) : online.eta();
24  double lhs_phi = useDecor ? cl_phi2Acc(online) : online.phi();
25  double rhs_eta = offline.etaBE(2);
26  double rhs_phi = offline.phiBE(2);
27 
28  return xAOD::P4Helpers::deltaR(lhs_eta, lhs_phi, rhs_eta, rhs_phi);
29  }
30 }
31 
32 namespace Trig {
34  asg::AsgTool(name)
35  {
36  declareProperty("UseClusterDecorator", m_useClusterDecorator = true,
37  "Use the decorated cluster values instead of the link to the cluster.");
38  }
39 
41  {
42  return StatusCode::SUCCESS;
43  }
44 
46  const xAOD::IParticle &online,
47  const xAOD::IParticle &offline) const
48  {
49  switch(online.type())
50  {
52  return dr(
53  dynamic_cast<const xAOD::CaloCluster &>(online),
54  dynamic_cast<const xAOD::CaloCluster &>(offline));
57  {
58  return dr(online,
59  *dynamic_cast<const xAOD::Egamma &>(offline).caloCluster(), true);
60  } else {
61  return dr(
62  *dynamic_cast<const xAOD::Egamma &>(online).caloCluster(),
63  *dynamic_cast<const xAOD::Egamma &>(offline).caloCluster());
64  }
65  case xAOD::Type::Photon:
66  return dr(
67  *dynamic_cast<const xAOD::Egamma &>(online).caloCluster(),
68  *dynamic_cast<const xAOD::Egamma &>(offline).caloCluster());
69  default:
70  {
71  std::ostringstream oss;
72  oss << "Not an egamma type: " << online.type();
73  throw std::runtime_error(oss.str());
74  }
75  }
76  return -1;
77  }
78 } //> end namespace Trig
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
Trig::EgammaDRScoringTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: EgammaDRScoringTool.cxx:40
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
EgammaDRScoringTool.h
Trig::EgammaDRScoringTool::EgammaDRScoringTool
EgammaDRScoringTool(const std::string &name)
Definition: EgammaDRScoringTool.cxx:33
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
asg
Definition: DataHandleTestTool.h:28
offline
xAOD::CaloCluster_v1::phiBE
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:680
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::ConstAccessor< float >
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloCluster_v1::etaBE
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:644
Egamma.h
TileSynchronizeBch.online
online
Definition: TileSynchronizeBch.py:88
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ObjectType.h
CaloCluster.h
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Trig::EgammaDRScoringTool::score
virtual float score(const xAOD::IParticle &online, const xAOD::IParticle &offline) const override
Calculate the matching score for a pair of particles.
Definition: EgammaDRScoringTool.cxx:45
Trig::EgammaDRScoringTool::m_useClusterDecorator
bool m_useClusterDecorator
Use decorated cluster information.
Definition: EgammaDRScoringTool.h:28