8#ifndef DECORATORHELPERS_H
9#define DECORATORHELPERS_H
11#include <Math/Vector4D.h>
28template <
typename T,
typename U,
typename V>
45template <
typename T,
typename U,
typename V>
47 const U& value,
const V*
object) {
48 dec(*object).push_back(value);
64template <
typename T,
typename U>
69 const ROOT::Math::PtEtaPhiMVector& particle, U*
object) {
83template <
typename T,
typename U>
88 const ROOT::Math::PtEtaPhiMVector& particle,
103template <
typename T,
typename U>
109 const ROOT::Math::PtEtaPhiMVector& particle,
int pdgId,
122template <
typename T,
typename U>
128 const ROOT::Math::PtEtaPhiMVector& particle,
129 int pdgId, U*
object) {
141template <
typename T,
typename U>
159template <
typename T,
typename U>
165 dec_pt(*
object) = {};
166 dec_eta(*
object) = {};
167 dec_phi(*
object) = {};
178template <
typename T,
typename U>
195template <
typename T,
typename U>
201 const SG::Decorator<std::vector<int>>& dec_pdgId, U*
object) {
202 dec_pdgId(*
object) = {};
223 std::map<std::string, std::unique_ptr<SG::Decorator<std::vector<float>>>>
226 std::map<std::string, std::unique_ptr<SG::Decorator<std::vector<int>>>>
255 const std::string key =
fullName(name);
261 const std::string key =
fullName(name);
263 std::make_unique<SG::Decorator<std::vector<float>>>(key);
268 for (
const auto& name : names)
297 const std::string key =
fullName(name);
298 intDecorators[key] = std::make_unique<SG::Decorator<int>>(key);
303 const std::string key =
fullName(name);
305 std::make_unique<SG::Decorator<std::vector<int>>>(key);
310 for (
const auto& name : names)
321 const std::string key =
fullName(name);
324 return it->second.get();
325 throw std::runtime_error(
"Decorator with name " + key +
" not found.");
333 const std::string& name)
const {
334 const std::string key =
fullName(name);
337 return it->second.get();
338 throw std::runtime_error(
"Decorator with name " + key +
" not found.");
346 const std::string key =
fullName(name);
349 return it->second.get();
350 throw std::runtime_error(
"Decorator with name " + key +
" not found.");
358 const std::string& name)
const {
359 const std::string key =
fullName(name);
362 return it->second.get();
363 throw std::runtime_error(
"Decorator with name " + key +
" not found.");
418 const ROOT::Math::PtEtaPhiMVector& p) {
433 const ROOT::Math::PtEtaPhiMVector& p,
int pdgId) {
449 const std::string& prefix,
450 const std::vector<ROOT::Math::PtEtaPhiMVector>& vec_p,
451 const std::vector<int>& vec_pdgId) {
452 for (
size_t i = 0; i < vec_p.size(); i++) {
470 std::string
fullName(
const std::string& name)
const {
void FillDefaultParticleInfo(const SG::Decorator< T > &dec_pt, const SG::Decorator< T > &dec_eta, const SG::Decorator< T > &dec_phi, const SG::Decorator< T > &dec_m, U *object)
Template function to fill default (placeholder) particle kinematics into an object.
void FillParticleInfo(const SG::Decorator< T > &dec, const U &value, const V *object)
Template function to fill particle information into a given object.
void FillDefaultVectorParticleInfo(const SG::Decorator< std::vector< T > > &dec_pt, const SG::Decorator< std::vector< T > > &dec_eta, const SG::Decorator< std::vector< T > > &dec_phi, const SG::Decorator< std::vector< T > > &dec_m, U *object)
Template function to fill default (placeholder) vector particle kinematics into an object.
void FillVectorParticleInfo(const SG::Decorator< std::vector< T > > &dec, const U &value, const V *object)
Template function to fill vector particle information into a given object.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
EventInfo_v1 EventInfo
Definition of the latest event info version.
Struct to manage and apply decorators to the EventInfo object.
void setPrefix(const std::string &prefix)
Set the prefix prepended to all decorator names.
void decorateVectorParticle(const std::string &prefix, const std::vector< ROOT::Math::PtEtaPhiMVector > &vec_p, const std::vector< int > &vec_pdgId)
Decorate with a vector of particle kinematics and PDG IDs (bare prefix).
void decorateDefault(const std::string &prefix)
Decorate with default particle kinematics (bare prefix).
void decorateVectorDefault(const std::string &prefix)
Decorate with default vector particle kinematics (bare prefix).
SG::Decorator< float > * getFloatDecorator(const std::string &name) const
Retrieve a pointer to a float decorator by bare name.
const xAOD::EventInfo * m_eventInfo
Target object; set once per event via setEventInfo().
void initializeVectorPtEtaPhiMDecorator(const std::string &prefix)
Initialize vector pt, eta, phi, m float decorators for a bare prefix.
SG::Decorator< std::vector< int > > * getVectorIntDecorator(const std::string &name) const
Retrieve a pointer to a vector-of-int decorator by bare name.
std::map< std::string, std::unique_ptr< SG::Decorator< float > > > floatDecorators
void initializeVectorFloatDecorator(const std::string &name)
Initialize a vector-of-float decorator by bare name.
void initializeFloatDecorator(const std::string &name)
Initialize a float decorator by bare name.
SG::Decorator< std::vector< float > > * getVectorFloatDecorator(const std::string &name) const
Retrieve a pointer to a vector-of-float decorator by bare name.
void decorateDefaultNoPdgId(const std::string &prefix)
Decorate with default particle kinematics, no PDG ID (bare prefix).
void initializeFloatDecorator(const std::vector< std::string > &names)
Initialize multiple float decorators by a list of bare names.
void decorateCustom(const std::string &name, int value)
Decorate with a custom integer value (bare name).
void setEventInfo(const xAOD::EventInfo *eventInfo)
Set the EventInfo object to decorate for the current event.
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< float > > > > vectorfloatDecorators
void decorateCustom(const std::string &name, float value)
Decorate with a custom float value (bare name).
void initializeIntDecorator(const std::string &name)
Initialize an integer decorator by bare name.
void initializeVectorIntDecorator(const std::string &name)
Initialize a vector-of-int decorator by bare name.
std::string m_prefix
Prefix prepended to all decorator names.
void initializeIntDecorator(const std::vector< std::string > &names)
Initialize multiple integer decorators by a list of bare names.
std::string fullName(const std::string &name) const
Returns the full (prefixed) decorator key for internal use.
void initializePtEtaPhiMDecorator(const std::string &prefix)
Initialize pt, eta, phi, m float decorators for a bare prefix.
void decorateParticle(const std::string &prefix, const ROOT::Math::PtEtaPhiMVector &p, int pdgId)
Decorate with particle kinematics and PDG ID (bare prefix).
std::map< std::string, std::unique_ptr< SG::Decorator< int > > > intDecorators
void decorateParticle(const std::string &prefix, const ROOT::Math::PtEtaPhiMVector &p)
Decorate with particle kinematics, no PDG ID (bare prefix).
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< int > > > > vectorintDecorators
SG::Decorator< int > * getIntDecorator(const std::string &name) const
Retrieve a pointer to an integer decorator by bare name.