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

Struct to manage accessors to objects. More...

#include <AccessorHelpers.h>

Collaboration diagram for CP::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.

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 29 of file AccessorHelpers.h.

Member Function Documentation

◆ getFloat()

template<typename T>
float CP::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 92 of file AccessorHelpers.h.

92 {
93 return (*floatAccessors.at(name))(*object);
94 }
std::map< std::string, std::unique_ptr< SG::Accessor< float > > > floatAccessors

◆ getInt()

template<typename T>
int CP::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 103 of file AccessorHelpers.h.

103 {
104 return (*intAccessors.at(name))(*object);
105 }
std::map< std::string, std::unique_ptr< SG::Accessor< int > > > intAccessors

◆ getPtEtaPhiMVector()

template<typename T>
void CP::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 115 of file AccessorHelpers.h.

116 {
117 p.SetCoordinates(
118 getFloat(prefix + "_pt", object), getFloat(prefix + "_eta", object),
119 getFloat(prefix + "_phi", object), getFloat(prefix + "_m", object));
120 }
float getFloat(const std::string &name, T *object)
Template to get an Float via the name of an accessor.

◆ initializeFloatAccessor() [1/2]

void CP::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 38 of file AccessorHelpers.h.

38 {
39 floatAccessors[name] = std::make_unique<SG::Accessor<float>>(name);
40 }

◆ initializeFloatAccessor() [2/2]

void CP::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 47 of file AccessorHelpers.h.

47 {
48 for (const auto& name : names) {
50 }
51 }
static const EventInfo_v1::Accessor< std::vector< std::string > > names("streamTagNames")
void initializeFloatAccessor(const std::string &name)
Initialize a float accessor by name.

◆ initializeIntAccessor() [1/2]

void CP::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 58 of file AccessorHelpers.h.

58 {
59 intAccessors[name] = std::make_unique<SG::Accessor<int>>(name);
60 }

◆ initializeIntAccessor() [2/2]

void CP::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 67 of file AccessorHelpers.h.

67 {
68 for (const auto& name : names) {
70 }
71 }
void initializeIntAccessor(const std::string &name)
Initialize an integer accessor by name.

◆ initializePtEtaPhiMAccessor()

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

Initialize a PtEtaPhiMVector using floats.

Parameters
prefixA prefix for the name of the PtEtaPhiMvector.

Definition at line 78 of file AccessorHelpers.h.

78 {
79 initializeFloatAccessor(prefix + "_pt");
80 initializeFloatAccessor(prefix + "_eta");
81 initializeFloatAccessor(prefix + "_phi");
82 initializeFloatAccessor(prefix + "_m");
83 }

Member Data Documentation

◆ floatAccessors

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

Definition at line 30 of file AccessorHelpers.h.

◆ intAccessors

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

Definition at line 31 of file AccessorHelpers.h.


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