ATLAS Offline Software
Loading...
Searching...
No Matches
PartonAccessor Struct Reference

Struct to manage accessors to objects. More...

#include <AccessorHelpers.h>

Collaboration diagram for PartonAccessor:

Public Member Functions

void initializeFloatAccessor (const std::string &name)
 Initialize a float accessor by name.
void initializeFloatAccessor (const std::vector< std::string > &names)
 Initialize multiple float accessors by a list of names.
void initializeIntAccessor (const std::string &name)
 Initialize an integer accessor by name.
void initializeIntAccessor (const std::vector< std::string > &names)
 Initialize multiple integer accessors by a list of names.
void initializePtEtaPhiMAccessor (const std::string &prefix)
 Initialize a PtEtaPhiMVector using floats.
template<typename T>
float getFloat (const std::string &name, T *object)
 Template to get an Float via the name of an accessor.
template<typename T>
int getInt (const std::string &name, T *object)
 Template to get an Int via the name of an accessor.
template<typename T>
void getPtEtaPhiMVector (const std::string &prefix, ROOT::Math::PtEtaPhiMVector &p, T *object)
 Template to get a PtEtaPhiMVector via the name of an accessor.

Public Attributes

std::map< std::string, std::unique_ptr< SG::Accessor< float > > > floatAccessors
std::map< std::string, std::unique_ptr< SG::Accessor< int > > > intAccessors

Detailed Description

Struct to manage accessors to objects.

Author
Baptiste Ravina bapti.nosp@m.ste..nosp@m.ravin.nosp@m.a@ce.nosp@m.rn.ch
Steffen Korn steff.nosp@m.en.k.nosp@m.orn@c.nosp@m.ern..nosp@m.ch

PartonAccessor provides methods to initialize, retrieve, and apply accessors for various properties like mass, pt, eta, phi, and PDG ID. It manages both float and integer accessors.

Definition at line 23 of file AccessorHelpers.h.

Member Function Documentation

◆ getFloat()

template<typename T>
float PartonAccessor::getFloat ( const std::string & name,
T * object )
inline

Template to get an Float via the name of an accessor.

Parameters
nameThe name of the Float accessor.
objectThe object to access.

Definition at line 86 of file AccessorHelpers.h.

86 {
87 return (*floatAccessors.at(name))(*object);
88 }
std::map< std::string, std::unique_ptr< SG::Accessor< float > > > floatAccessors

◆ getInt()

template<typename T>
int PartonAccessor::getInt ( const std::string & name,
T * object )
inline

Template to get an Int via the name of an accessor.

Parameters
nameThe name of the Int accessor.
objectThe object to access.

Definition at line 97 of file AccessorHelpers.h.

97 {
98 return (*intAccessors.at(name))(*object);
99 }
std::map< std::string, std::unique_ptr< SG::Accessor< int > > > intAccessors

◆ getPtEtaPhiMVector()

template<typename T>
void PartonAccessor::getPtEtaPhiMVector ( const std::string & prefix,
ROOT::Math::PtEtaPhiMVector & p,
T * object )
inline

Template to get a PtEtaPhiMVector via the name of an accessor.

Parameters
prefixThe prefix of the accessor holding the different components.
pThe PtEtaPhiVector to fill with pT, eta, phi and m values.
objectThe object to access.

Definition at line 109 of file AccessorHelpers.h.

110 {
111 p.SetCoordinates(
112 getFloat(prefix + "_pt", object), getFloat(prefix + "_eta", object),
113 getFloat(prefix + "_phi", object), getFloat(prefix + "_m", object));
114 }
float getFloat(const std::string &name, T *object)
Template to get an Float via the name of an accessor.

◆ initializeFloatAccessor() [1/2]

void PartonAccessor::initializeFloatAccessor ( const std::string & name)
inline

Initialize a float accessor by name.

Parameters
nameThe name of the float accessor to initialize.

Definition at line 32 of file AccessorHelpers.h.

32 {
33 floatAccessors[name] = std::make_unique<SG::Accessor<float>>(name);
34 }

◆ initializeFloatAccessor() [2/2]

void PartonAccessor::initializeFloatAccessor ( const std::vector< std::string > & names)
inline

Initialize multiple float accessors by a list of names.

Parameters
namesA vector of accessor names.

Definition at line 41 of file AccessorHelpers.h.

41 {
42 for (const auto& name : names) {
44 }
45 }
void initializeFloatAccessor(const std::string &name)
Initialize a float accessor by name.

◆ initializeIntAccessor() [1/2]

void PartonAccessor::initializeIntAccessor ( const std::string & name)
inline

Initialize an integer accessor by name.

Parameters
nameThe name of the integer accessor to initialize.

Definition at line 52 of file AccessorHelpers.h.

52 {
53 intAccessors[name] = std::make_unique<SG::Accessor<int>>(name);
54 }

◆ initializeIntAccessor() [2/2]

void PartonAccessor::initializeIntAccessor ( const std::vector< std::string > & names)
inline

Initialize multiple integer accessors by a list of names.

Parameters
namesA vector of accessor names.

Definition at line 61 of file AccessorHelpers.h.

61 {
62 for (const auto& name : names) {
64 }
65 }
void initializeIntAccessor(const std::string &name)
Initialize an integer accessor by name.

◆ initializePtEtaPhiMAccessor()

void PartonAccessor::initializePtEtaPhiMAccessor ( const std::string & prefix)
inline

Initialize a PtEtaPhiMVector using floats.

Parameters
prefixA prefix for the name of the PtEtaPhiMvector.

Definition at line 72 of file AccessorHelpers.h.

72 {
73 initializeFloatAccessor(prefix + "_pt");
74 initializeFloatAccessor(prefix + "_eta");
75 initializeFloatAccessor(prefix + "_phi");
76 initializeFloatAccessor(prefix + "_m");
77 }

Member Data Documentation

◆ floatAccessors

std::map<std::string, std::unique_ptr<SG::Accessor<float> > > PartonAccessor::floatAccessors

Definition at line 24 of file AccessorHelpers.h.

◆ intAccessors

std::map<std::string, std::unique_ptr<SG::Accessor<int> > > PartonAccessor::intAccessors

Definition at line 25 of file AccessorHelpers.h.


The documentation for this struct was generated from the following file: