ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCluster_OnTrackBuilder Class Reference

#include <CaloCluster_OnTrackBuilder.h>

Inheritance diagram for CaloCluster_OnTrackBuilder:
Collaboration diagram for CaloCluster_OnTrackBuilder:

Public Member Functions

 CaloCluster_OnTrackBuilder (const std::string &, const std::string &, const IInterface *)
 Constructor with AlgTool parameters.
 CaloCluster_OnTrackBuilder ()
 ~CaloCluster_OnTrackBuilder ()=default
virtual StatusCode initialize () override final
virtual StatusCode finalize () override final
virtual std::unique_ptr< Trk::CaloCluster_OnTrackbuildClusterOnTrack (const EventContext &ctx, const xAOD::CaloCluster *cl, int charge=0) const override final
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::unique_ptr< Trk::SurfacegetCaloSurface (const xAOD::CaloCluster *cluster, const CaloDetDescrManager *caloDDMgr) const
Trk::LocalParameters getClusterLocalParameters (const xAOD::CaloCluster *cluster, const Trk::Surface *surf, int charge) const
Amg::MatrixX getClusterErrorMatrix (const xAOD::CaloCluster *cluster, const Trk::Surface &surf, int charge) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< ICaloSurfaceBuilderm_calosurf
 Tool to build calorimeter layer surfaces.
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey
Gaudi::Property< bool > m_useClusterEnergy { this, "UseClusterEnergy", true }
 Which cluster measurements to use in order to add constraints by default we are interested in the ones that affect the bending plane Energy and phi.
Gaudi::Property< bool > m_useClusterPhi { this, "UseClusterPhi", true }
Gaudi::Property< bool > m_useClusterEta { this, "UseClusterEta", false }
std::unique_ptr< eg_resolutionm_eg_resol {}
 helper for returning energy resolution
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 31 of file CaloCluster_OnTrackBuilder.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CaloCluster_OnTrackBuilder() [1/2]

CaloCluster_OnTrackBuilder::CaloCluster_OnTrackBuilder ( const std::string & t,
const std::string & n,
const IInterface * p )

Constructor with AlgTool parameters.

Definition at line 67 of file CaloCluster_OnTrackBuilder.cxx.

70 : AthAlgTool(t, n, p)
71{
72 declareInterface<ICaloCluster_OnTrackBuilder>(this);
73}
AthAlgTool()
Default constructor:

◆ CaloCluster_OnTrackBuilder() [2/2]

CaloCluster_OnTrackBuilder::CaloCluster_OnTrackBuilder ( )

◆ ~CaloCluster_OnTrackBuilder()

CaloCluster_OnTrackBuilder::~CaloCluster_OnTrackBuilder ( )
default

Member Function Documentation

◆ buildClusterOnTrack()

std::unique_ptr< Trk::CaloCluster_OnTrack > CaloCluster_OnTrackBuilder::buildClusterOnTrack ( const EventContext & ctx,
const xAOD::CaloCluster * cl,
int charge = 0 ) const
finaloverridevirtual

Implements ICaloCluster_OnTrackBuilder.

Definition at line 91 of file CaloCluster_OnTrackBuilder.cxx.

95{
96
97 ATH_MSG_DEBUG("Building Trk::CaloCluster_OnTrack");
98
100 ATH_MSG_WARNING("CaloCluster_OnTrackBuilder is configured incorrectly");
101 return nullptr;
102 }
103
104 if (!cluster) {
105 return nullptr;
106 }
107
108 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{ m_caloMgrKey, ctx };
109 const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
110 std::unique_ptr<Trk::Surface> surface = getCaloSurface(cluster, caloDDMgr);
111
112 if (!surface) {
113 return nullptr;
114 }
115
116 Trk::LocalParameters lp =
117 getClusterLocalParameters(cluster, surface.get(), charge);
118
119 Amg::MatrixX em = getClusterErrorMatrix(cluster, *surface, charge);
120
121 return std::make_unique<Trk::CaloCluster_OnTrack>(std::move(lp), std::move(em), *surface);
122
123}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
Trk::LocalParameters getClusterLocalParameters(const xAOD::CaloCluster *cluster, const Trk::Surface *surf, int charge) const
Gaudi::Property< bool > m_useClusterEta
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::unique_ptr< Trk::Surface > getCaloSurface(const xAOD::CaloCluster *cluster, const CaloDetDescrManager *caloDDMgr) const
Amg::MatrixX getClusterErrorMatrix(const xAOD::CaloCluster *cluster, const Trk::Surface &surf, int charge) const
Gaudi::Property< bool > m_useClusterEnergy
Which cluster measurements to use in order to add constraints by default we are interested in the one...
Gaudi::Property< bool > m_useClusterPhi
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode CaloCluster_OnTrackBuilder::finalize ( )
finaloverridevirtual

Definition at line 85 of file CaloCluster_OnTrackBuilder.cxx.

86{
87 return StatusCode::SUCCESS;
88}

◆ getCaloSurface()

std::unique_ptr< Trk::Surface > CaloCluster_OnTrackBuilder::getCaloSurface ( const xAOD::CaloCluster * cluster,
const CaloDetDescrManager * caloDDMgr ) const
private

Definition at line 126 of file CaloCluster_OnTrackBuilder.cxx.

129{
130
131 std::unique_ptr<Trk::Surface> destinationSurface = nullptr;
132
133 // Determine if we want to extrapolate to the barrel or endcap. If in the
134 // crack choose the detector with largest amount of energy in the second
135 // sampling layer
136 if (xAOD::EgammaHelpers::isBarrel(cluster)) {
137 destinationSurface.reset(m_calosurf->CreateUserSurface(
138 CaloCell_ID::EMB2, 0., cluster->eta(), caloDDMgr));
139 } else {
140 destinationSurface.reset(m_calosurf->CreateUserSurface(
141 CaloCell_ID::EME2, 0., cluster->eta(), caloDDMgr));
142 }
143 return destinationSurface;
144}
ToolHandle< ICaloSurfaceBuilder > m_calosurf
Tool to build calorimeter layer surfaces.
virtual double eta() const
The pseudorapidity ( ) of the particle.
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel

◆ getClusterErrorMatrix()

Amg::MatrixX CaloCluster_OnTrackBuilder::getClusterErrorMatrix ( const xAOD::CaloCluster * cluster,
const Trk::Surface & surf,
int charge ) const
private

Definition at line 206 of file CaloCluster_OnTrackBuilder.cxx.

210{
211 int matrixSize = static_cast<int>(m_useClusterEta) +
212 static_cast<int>(m_useClusterPhi) +
213 static_cast<int>(m_useClusterEnergy);
214 Amg::MatrixX covMatrix(matrixSize, matrixSize);
215 covMatrix.setZero();
216
217 const double clusterE = cluster->e();
218 const double clusterEta = cluster->eta();
219
220 // variance in phi from calorimeter phi resolution
221 double phivariance = phiVariance(clusterE, std::abs(clusterEta));
222 if (phivariance < 1e-5) {
223 // Avoid going too small for very high E
224 phivariance = 1e-5;
225 }
226
227 // q over p variance from sigmaE/E (calo energy resolution)
228 const double sigmaP_over_P = m_eg_resol->getResolution(0, // electron
229 clusterE,
230 clusterEta,
231 2 // 90% quantile
232 );
233 const double qOverP = 1. / clusterE;
234 const double qOverP_variance =
235 (qOverP * qOverP) * (sigmaP_over_P * sigmaP_over_P);
236
237 // Variance in Z
238 // sigma ~ 20 mm large error
239 // As currently we do not want to rely
240 // on the eta side of the cluster.
241 constexpr double zvariance = 400;
242
243 if (xAOD::EgammaHelpers::isBarrel(cluster)) {
244 // The two coordinates for a cyclinder are
245 // Trk::locRPhi = 0 (ie phi)
246 // Trk::locZ = 1(ie z)
247 const Amg::Vector3D& surfRefPoint = surf.globalReferencePoint();
248 double r = surfRefPoint.perp();
249 double r2 = r * r;
250 int indexCount(0);
251 if (m_useClusterPhi) {
252 covMatrix(indexCount, indexCount) = phivariance * r2;
253 ++indexCount;
254 }
255 if (m_useClusterEta) {
256 covMatrix(indexCount, indexCount) = zvariance;
257 ++indexCount;
258 }
259 if (m_useClusterEnergy) {
260 covMatrix(indexCount, indexCount) = qOverP_variance;
261 ++indexCount;
262 }
263 } else {
264 // Local paramters of a disk are
265 // Trk::locR = 0
266 // Trk::locPhi = 1
267 int indexCount(0);
268
269 if (m_useClusterEta) {
270 covMatrix(indexCount, indexCount) = zvariance;
271 ++indexCount;
272 }
273 if (m_useClusterPhi) {
274 covMatrix(indexCount, indexCount) = phivariance;
275 ++indexCount;
276 }
277 if (m_useClusterEnergy) {
278 covMatrix(indexCount, indexCount) = qOverP_variance;
279 ++indexCount;
280 }
281 }
282
283 return covMatrix;
284}
std::unique_ptr< eg_resolution > m_eg_resol
helper for returning energy resolution
virtual const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
virtual double e() const
The total energy of the particle.
int r
Definition globals.cxx:22
Eigen::Matrix< double, 3, 1 > Vector3D
@ qOverP
perigee

◆ getClusterLocalParameters()

Trk::LocalParameters CaloCluster_OnTrackBuilder::getClusterLocalParameters ( const xAOD::CaloCluster * cluster,
const Trk::Surface * surf,
int charge ) const
private

Definition at line 147 of file CaloCluster_OnTrackBuilder.cxx.

151{
152
153 Amg::Vector3D surfRefPoint = surf->globalReferencePoint();
154 double eta = cluster->eta();
155 double phi = cluster->phi();
156 double clusterQoverE = cluster->e() != 0 ? (double)charge / cluster->e() : 0;
157
158 if (xAOD::EgammaHelpers::isBarrel(cluster)) {
159 // Two corindate in a cyclinder are
160 // Trk::locRPhi = 0 (ie phi)
161 // Trk::locZ = 1(ie z)
162 double r = surfRefPoint.perp();
163 std::vector<Trk::DefinedParameter> defPar;
164 if (m_useClusterPhi) {
166 defPar.push_back(locRPhi);
167 }
168 if (m_useClusterEta) {
169 double theta = 2 * atan(exp(-eta)); // -log(tan(theta/2));
170 double tantheta = tan(theta);
171 double z = tantheta == 0 ? 0. : r / tantheta;
173 defPar.push_back(locZ);
174 }
175 if (m_useClusterEnergy) {
177 defPar.push_back(qOverP);
178 }
179 return {defPar};
180 }
181 // Local paramters of a disk are
182 // Trk::locR = 0
183 // Trk::locPhi = 1
184 double z = surfRefPoint.z();
185 std::vector<Trk::DefinedParameter> defPar;
186 if (m_useClusterEta) {
187 double theta = 2 * atan(exp(-eta)); // -log(tan(theta/2));
188 double tantheta = tan(theta);
189 double r = z * tantheta;
191 defPar.push_back(locR);
192 }
193 if (m_useClusterPhi) {
195 defPar.push_back(locPhi);
196 }
197 if (m_useClusterEnergy) {
199 defPar.push_back(qOverP);
200 }
201
202 return {defPar};
203}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define z
virtual double phi() const
The azimuthal angle ( ) of the particle.
@ locR
Definition ParamDefs.h:44
@ locRPhi
Definition ParamDefs.h:40
@ qOverP
perigee
Definition ParamDefs.h:67
@ locZ
local cylindrical
Definition ParamDefs.h:42
@ locPhi
local polar
Definition ParamDefs.h:45
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...

◆ initialize()

StatusCode CaloCluster_OnTrackBuilder::initialize ( )
finaloverridevirtual

Definition at line 76 of file CaloCluster_OnTrackBuilder.cxx.

77{
78 m_eg_resol = std::make_unique<eg_resolution>("run2_R21_v1");
79 ATH_CHECK(m_calosurf.retrieve());
80 ATH_CHECK(m_caloMgrKey.initialize());
81 return StatusCode::SUCCESS;
82}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ICaloCluster_OnTrackBuilder::interfaceID ( )
inlinestaticinherited

Definition at line 22 of file ICaloCluster_OnTrackBuilder.h.

23 {
25 };
static const InterfaceID IID_caloCluster_OnTrackBuilder("ICaloCluster_OnTrackBuilder", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> CaloCluster_OnTrackBuilder::m_caloMgrKey
private
Initial value:
{
this,
"CaloDetDescrManager",
"CaloDetDescrManager"
}

Definition at line 75 of file CaloCluster_OnTrackBuilder.h.

75 {
76 this,
77 "CaloDetDescrManager",
78 "CaloDetDescrManager"
79 };

◆ m_calosurf

ToolHandle<ICaloSurfaceBuilder> CaloCluster_OnTrackBuilder::m_calosurf
private
Initial value:
{
this,
"CaloSurfaceBuilder",
"CaloSurfaceBuilder",
"Tool to build calorimeter layer surfaces"
}

Tool to build calorimeter layer surfaces.

Definition at line 69 of file CaloCluster_OnTrackBuilder.h.

69 {
70 this,
71 "CaloSurfaceBuilder",
72 "CaloSurfaceBuilder",
73 "Tool to build calorimeter layer surfaces"
74 };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eg_resol

std::unique_ptr<eg_resolution> CaloCluster_OnTrackBuilder::m_eg_resol {}
private

helper for returning energy resolution

Definition at line 89 of file CaloCluster_OnTrackBuilder.h.

89{};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_useClusterEnergy

Gaudi::Property<bool> CaloCluster_OnTrackBuilder::m_useClusterEnergy { this, "UseClusterEnergy", true }
private

Which cluster measurements to use in order to add constraints by default we are interested in the ones that affect the bending plane Energy and phi.

Definition at line 84 of file CaloCluster_OnTrackBuilder.h.

84{ this, "UseClusterEnergy", true };

◆ m_useClusterEta

Gaudi::Property<bool> CaloCluster_OnTrackBuilder::m_useClusterEta { this, "UseClusterEta", false }
private

Definition at line 86 of file CaloCluster_OnTrackBuilder.h.

86{ this, "UseClusterEta", false };

◆ m_useClusterPhi

Gaudi::Property<bool> CaloCluster_OnTrackBuilder::m_useClusterPhi { this, "UseClusterPhi", true }
private

Definition at line 85 of file CaloCluster_OnTrackBuilder.h.

85{ this, "UseClusterPhi", true };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: