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

Struct to manage and apply decorators to the EventInfo object. More...

#include <DecoratorHelpers.h>

Collaboration diagram for PartonDecorator:

Public Member Functions

void setPrefix (const std::string &prefix)
 Set the prefix prepended to all decorator names.
void setEventInfo (const xAOD::EventInfo *eventInfo)
 Set the EventInfo object to decorate for the current event.
void initializeFloatDecorator (const std::string &name)
 Initialize a float decorator by bare name.
void initializeVectorFloatDecorator (const std::string &name)
 Initialize a vector-of-float decorator by bare name.
void initializeFloatDecorator (const std::vector< std::string > &names)
 Initialize multiple float decorators by a list of bare names.
void initializePtEtaPhiMDecorator (const std::string &prefix)
 Initialize pt, eta, phi, m float decorators for a bare prefix.
void initializeVectorPtEtaPhiMDecorator (const std::string &prefix)
 Initialize vector pt, eta, phi, m float decorators for a bare prefix.
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.
void initializeIntDecorator (const std::vector< std::string > &names)
 Initialize multiple integer decorators by a list of bare names.
SG::Decorator< int > * getIntDecorator (const std::string &name) const
 Retrieve a pointer to an integer decorator by bare name.
SG::Decorator< std::vector< int > > * getVectorIntDecorator (const std::string &name) const
 Retrieve a pointer to a vector-of-int decorator by bare name.
SG::Decorator< float > * getFloatDecorator (const std::string &name) const
 Retrieve a pointer to 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 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).
void decorateDefaultNoPdgId (const std::string &prefix)
 Decorate with default particle kinematics, no PDG ID (bare prefix).
void decorateCustom (const std::string &name, float value)
 Decorate with a custom float value (bare name).
void decorateCustom (const std::string &name, int value)
 Decorate with a custom integer value (bare name).
void decorateParticle (const std::string &prefix, const ROOT::Math::PtEtaPhiMVector &p)
 Decorate with particle kinematics, no PDG ID (bare prefix).
void decorateParticle (const std::string &prefix, const ROOT::Math::PtEtaPhiMVector &p, int pdgId)
 Decorate with particle kinematics and PDG ID (bare prefix).
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).

Public Attributes

std::map< std::string, std::unique_ptr< SG::Decorator< float > > > floatDecorators
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< float > > > > vectorfloatDecorators
std::map< std::string, std::unique_ptr< SG::Decorator< int > > > intDecorators
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< int > > > > vectorintDecorators

Private Member Functions

std::string fullName (const std::string &name) const
 Returns the full (prefixed) decorator key for internal use.

Private Attributes

std::string m_prefix
 Prefix prepended to all decorator names.
const xAOD::EventInfom_eventInfo
 Target object; set once per event via setEventInfo().

Detailed Description

Struct to manage and apply decorators to the EventInfo object.

PartonDecorator centralises all decoration of the xAOD::EventInfo for a single parton history instance. Two pieces of per-instance state are set once and reused:

  • Prefix (setPrefix): prepended to every decorator name so that multiple histories running in parallel do not overwrite each other's branches.
  • EventInfo (setEventInfo): the target object for all decorate* calls; set once per event at the start of runHistorySaver.

All decorate* methods therefore take only the branch name and the value(s) to write — no object pointer argument is needed at call sites.

Definition at line 221 of file DecoratorHelpers.h.

Member Function Documentation

◆ decorateCustom() [1/2]

void PartonDecorator::decorateCustom ( const std::string & name,
float value )
inline

Decorate with a custom float value (bare name).

Definition at line 402 of file DecoratorHelpers.h.

402 {
404 }
void FillParticleInfo(const SG::Decorator< T > &dec, const U &value, const V *object)
Template function to fill particle information into a given object.
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().

◆ decorateCustom() [2/2]

void PartonDecorator::decorateCustom ( const std::string & name,
int value )
inline

Decorate with a custom integer value (bare name).

Definition at line 407 of file DecoratorHelpers.h.

407 {
409 }
SG::Decorator< int > * getIntDecorator(const std::string &name) const
Retrieve a pointer to an integer decorator by bare name.

◆ decorateDefault()

void PartonDecorator::decorateDefault ( const std::string & prefix)
inline

Decorate with default particle kinematics (bare prefix).

Writes sentinel values: pt=-1, eta=-999, phi=-999, m=-1, pdgId=0.

Definition at line 374 of file DecoratorHelpers.h.

374 {
376 *getFloatDecorator(prefix + "_pt"), *getFloatDecorator(prefix + "_eta"),
377 *getFloatDecorator(prefix + "_phi"), *getFloatDecorator(prefix + "_m"),
378 *getIntDecorator(prefix + "_pdgId"), m_eventInfo);
379 }
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.

◆ decorateDefaultNoPdgId()

void PartonDecorator::decorateDefaultNoPdgId ( const std::string & prefix)
inline

Decorate with default particle kinematics, no PDG ID (bare prefix).

Definition at line 394 of file DecoratorHelpers.h.

394 {
396 *getFloatDecorator(prefix + "_eta"),
397 *getFloatDecorator(prefix + "_phi"),
398 *getFloatDecorator(prefix + "_m"), m_eventInfo);
399 }

◆ decorateParticle() [1/2]

void PartonDecorator::decorateParticle ( const std::string & prefix,
const ROOT::Math::PtEtaPhiMVector & p )
inline

Decorate with particle kinematics, no PDG ID (bare prefix).

Parameters
prefixBare decorator prefix.
pThe particle four-vector.

Definition at line 417 of file DecoratorHelpers.h.

418 {
419 FillParticleInfo(*getFloatDecorator(prefix + "_pt"),
420 *getFloatDecorator(prefix + "_eta"),
421 *getFloatDecorator(prefix + "_phi"),
422 *getFloatDecorator(prefix + "_m"), p, m_eventInfo);
423 }

◆ decorateParticle() [2/2]

void PartonDecorator::decorateParticle ( const std::string & prefix,
const ROOT::Math::PtEtaPhiMVector & p,
int pdgId )
inline

Decorate with particle kinematics and PDG ID (bare prefix).

Parameters
prefixBare decorator prefix.
pThe particle four-vector.
pdgIdThe PDG ID of the particle.

Definition at line 432 of file DecoratorHelpers.h.

433 {
435 *getFloatDecorator(prefix + "_pt"), *getFloatDecorator(prefix + "_eta"),
436 *getFloatDecorator(prefix + "_phi"), *getFloatDecorator(prefix + "_m"),
437 *getIntDecorator(prefix + "_pdgId"), p, pdgId, m_eventInfo);
438 }

◆ decorateVectorDefault()

void PartonDecorator::decorateVectorDefault ( const std::string & prefix)
inline

Decorate with default vector particle kinematics (bare prefix).

Definition at line 382 of file DecoratorHelpers.h.

382 {
384 *getVectorFloatDecorator(prefix + "_eta"),
385 *getVectorFloatDecorator(prefix + "_phi"),
386 *getVectorFloatDecorator(prefix + "_m"),
387 *getVectorIntDecorator(prefix + "_pdgId"),
389 }
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.
SG::Decorator< std::vector< int > > * getVectorIntDecorator(const std::string &name) const
Retrieve a pointer to a vector-of-int 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.

◆ decorateVectorParticle()

void PartonDecorator::decorateVectorParticle ( const std::string & prefix,
const std::vector< ROOT::Math::PtEtaPhiMVector > & vec_p,
const std::vector< int > & vec_pdgId )
inline

Decorate with a vector of particle kinematics and PDG IDs (bare prefix).

Parameters
prefixBare decorator prefix.
vec_pVector of particle four-vectors.
vec_pdgIdVector of PDG IDs.

Definition at line 448 of file DecoratorHelpers.h.

451 {
452 for (size_t i = 0; i < vec_p.size(); i++) {
454 *getVectorFloatDecorator(prefix + "_eta"),
455 *getVectorFloatDecorator(prefix + "_phi"),
456 *getVectorFloatDecorator(prefix + "_m"),
457 *getVectorIntDecorator(prefix + "_pdgId"),
458 vec_p.at(i), vec_pdgId.at(i), m_eventInfo);
459 }
460 }
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.

◆ fullName()

std::string PartonDecorator::fullName ( const std::string & name) const
inlineprivate

Returns the full (prefixed) decorator key for internal use.

Definition at line 470 of file DecoratorHelpers.h.

470 {
471 return m_prefix.empty() ? name : m_prefix + "_" + name;
472 }
std::string m_prefix
Prefix prepended to all decorator names.

◆ getFloatDecorator()

SG::Decorator< float > * PartonDecorator::getFloatDecorator ( const std::string & name) const
inline

Retrieve a pointer to a float decorator by bare name.

Exceptions
std::runtime_errorif the decorator is not found.

Definition at line 345 of file DecoratorHelpers.h.

345 {
346 const std::string key = fullName(name);
347 auto it = floatDecorators.find(key);
348 if (it != floatDecorators.end())
349 return it->second.get();
350 throw std::runtime_error("Decorator with name " + key + " not found.");
351 }
std::map< std::string, std::unique_ptr< SG::Decorator< float > > > floatDecorators
std::string fullName(const std::string &name) const
Returns the full (prefixed) decorator key for internal use.

◆ getIntDecorator()

SG::Decorator< int > * PartonDecorator::getIntDecorator ( const std::string & name) const
inline

Retrieve a pointer to an integer decorator by bare name.

Exceptions
std::runtime_errorif the decorator is not found.

Definition at line 320 of file DecoratorHelpers.h.

320 {
321 const std::string key = fullName(name);
322 auto it = intDecorators.find(key);
323 if (it != intDecorators.end())
324 return it->second.get();
325 throw std::runtime_error("Decorator with name " + key + " not found.");
326 }
std::map< std::string, std::unique_ptr< SG::Decorator< int > > > intDecorators

◆ getVectorFloatDecorator()

SG::Decorator< std::vector< float > > * PartonDecorator::getVectorFloatDecorator ( const std::string & name) const
inline

Retrieve a pointer to a vector-of-float decorator by bare name.

Exceptions
std::runtime_errorif the decorator is not found.

Definition at line 357 of file DecoratorHelpers.h.

358 {
359 const std::string key = fullName(name);
360 auto it = vectorfloatDecorators.find(key);
361 if (it != vectorfloatDecorators.end())
362 return it->second.get();
363 throw std::runtime_error("Decorator with name " + key + " not found.");
364 }
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< float > > > > vectorfloatDecorators

◆ getVectorIntDecorator()

SG::Decorator< std::vector< int > > * PartonDecorator::getVectorIntDecorator ( const std::string & name) const
inline

Retrieve a pointer to a vector-of-int decorator by bare name.

Exceptions
std::runtime_errorif the decorator is not found.

Definition at line 332 of file DecoratorHelpers.h.

333 {
334 const std::string key = fullName(name);
335 auto it = vectorintDecorators.find(key);
336 if (it != vectorintDecorators.end())
337 return it->second.get();
338 throw std::runtime_error("Decorator with name " + key + " not found.");
339 }
std::map< std::string, std::unique_ptr< SG::Decorator< std::vector< int > > > > vectorintDecorators

◆ initializeFloatDecorator() [1/2]

void PartonDecorator::initializeFloatDecorator ( const std::string & name)
inline

Initialize a float decorator by bare name.

Definition at line 254 of file DecoratorHelpers.h.

254 {
255 const std::string key = fullName(name);
256 floatDecorators[key] = std::make_unique<SG::Decorator<float>>(key);
257 }

◆ initializeFloatDecorator() [2/2]

void PartonDecorator::initializeFloatDecorator ( const std::vector< std::string > & names)
inline

Initialize multiple float decorators by a list of bare names.

Definition at line 267 of file DecoratorHelpers.h.

267 {
268 for (const auto& name : names)
270 }
void initializeFloatDecorator(const std::string &name)
Initialize a float decorator by bare name.

◆ initializeIntDecorator() [1/2]

void PartonDecorator::initializeIntDecorator ( const std::string & name)
inline

Initialize an integer decorator by bare name.

Definition at line 296 of file DecoratorHelpers.h.

296 {
297 const std::string key = fullName(name);
298 intDecorators[key] = std::make_unique<SG::Decorator<int>>(key);
299 }

◆ initializeIntDecorator() [2/2]

void PartonDecorator::initializeIntDecorator ( const std::vector< std::string > & names)
inline

Initialize multiple integer decorators by a list of bare names.

Definition at line 309 of file DecoratorHelpers.h.

309 {
310 for (const auto& name : names)
312 }
void initializeIntDecorator(const std::string &name)
Initialize an integer decorator by bare name.

◆ initializePtEtaPhiMDecorator()

void PartonDecorator::initializePtEtaPhiMDecorator ( const std::string & prefix)
inline

Initialize pt, eta, phi, m float decorators for a bare prefix.

Parameters
prefixBare prefix (e.g. "MC_Z_beforeFSR"); "_pt" etc. are appended.

Definition at line 277 of file DecoratorHelpers.h.

277 {
278 initializeFloatDecorator(prefix + "_pt");
279 initializeFloatDecorator(prefix + "_eta");
280 initializeFloatDecorator(prefix + "_phi");
281 initializeFloatDecorator(prefix + "_m");
282 }

◆ initializeVectorFloatDecorator()

void PartonDecorator::initializeVectorFloatDecorator ( const std::string & name)
inline

Initialize a vector-of-float decorator by bare name.

Definition at line 260 of file DecoratorHelpers.h.

260 {
261 const std::string key = fullName(name);
263 std::make_unique<SG::Decorator<std::vector<float>>>(key);
264 }

◆ initializeVectorIntDecorator()

void PartonDecorator::initializeVectorIntDecorator ( const std::string & name)
inline

Initialize a vector-of-int decorator by bare name.

Definition at line 302 of file DecoratorHelpers.h.

302 {
303 const std::string key = fullName(name);
305 std::make_unique<SG::Decorator<std::vector<int>>>(key);
306 }

◆ initializeVectorPtEtaPhiMDecorator()

void PartonDecorator::initializeVectorPtEtaPhiMDecorator ( const std::string & prefix)
inline

Initialize vector pt, eta, phi, m float decorators for a bare prefix.

Definition at line 288 of file DecoratorHelpers.h.

288 {
289 initializeVectorFloatDecorator(prefix + "_pt");
290 initializeVectorFloatDecorator(prefix + "_eta");
291 initializeVectorFloatDecorator(prefix + "_phi");
292 initializeVectorFloatDecorator(prefix + "_m");
293 }
void initializeVectorFloatDecorator(const std::string &name)
Initialize a vector-of-float decorator by bare name.

◆ setEventInfo()

void PartonDecorator::setEventInfo ( const xAOD::EventInfo * eventInfo)
inline

Set the EventInfo object to decorate for the current event.

Must be called once per event before any decorate*() calls. The pointer is not owned and must remain valid for the duration of event processing.

Parameters
eventInfoPointer to the current xAOD::EventInfo.

Definition at line 247 of file DecoratorHelpers.h.

247 {
248 m_eventInfo = eventInfo;
249 }

◆ setPrefix()

void PartonDecorator::setPrefix ( const std::string & prefix)
inline

Set the prefix prepended to all decorator names.

Must be called before any initialize*() calls. All public methods accept bare names (e.g. "MC_Z_beforeFSR") and the prefix is applied internally.

Parameters
prefixThe prefix string (e.g. "Tzq"). May be empty.

Definition at line 237 of file DecoratorHelpers.h.

Member Data Documentation

◆ floatDecorators

std::map<std::string, std::unique_ptr<SG::Decorator<float> > > PartonDecorator::floatDecorators

Definition at line 222 of file DecoratorHelpers.h.

◆ intDecorators

std::map<std::string, std::unique_ptr<SG::Decorator<int> > > PartonDecorator::intDecorators

Definition at line 225 of file DecoratorHelpers.h.

◆ m_eventInfo

const xAOD::EventInfo* PartonDecorator::m_eventInfo
private
Initial value:
{
nullptr}

Target object; set once per event via setEventInfo().

Definition at line 464 of file DecoratorHelpers.h.

464 {
465 nullptr};

◆ m_prefix

std::string PartonDecorator::m_prefix
private

Prefix prepended to all decorator names.

Definition at line 463 of file DecoratorHelpers.h.

◆ vectorfloatDecorators

std::map<std::string, std::unique_ptr<SG::Decorator<std::vector<float> > > > PartonDecorator::vectorfloatDecorators

Definition at line 224 of file DecoratorHelpers.h.

◆ vectorintDecorators

std::map<std::string, std::unique_ptr<SG::Decorator<std::vector<int> > > > PartonDecorator::vectorintDecorators

Definition at line 227 of file DecoratorHelpers.h.


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