SG::AuxElement Class Reference

Base class for elements of a container that can have aux data. More...

#include <AuxElement.h>

Inheritance diagram for SG::AuxElement:
SG::IAuxElement xAOD::AFPData_v1 xAOD::AFPSiHit_v1 xAOD::AFPTrack_v1 xAOD::ALFAData_v1 xAOD::BCMRawData_v1 xAOD::BTagging_v1 xAOD::BTagVertex_v1 xAOD::BunchConf_v1 xAOD::CMMCPHits_v1 xAOD::CMMEtSums_v1 xAOD::CMMJetHits_v1 xAOD::CMMRoI_v1 xAOD::CMXCPHits_v1 xAOD::CMXCPTob_v1 xAOD::CMXEtSums_v1 xAOD::CMXJetHits_v1 xAOD::CMXJetTob_v1 xAOD::CMXRoI_v1 xAOD::CPMHits_v1 xAOD::CPMRoI_v1 xAOD::CPMTobRoI_v1 xAOD::CPMTower_v1 xAOD::CPMTower_v2 xAOD::CutBookkeeper_v1 xAOD::EmTauRoI_v1 xAOD::EmTauRoI_v2 xAOD::EnergySumRoI_v1 xAOD::EventInfo_v1 xAOD::EventShape_v1 xAOD::FileMetaData_v1 xAOD::ForwardEventInfo_v1 xAOD::HIEventShape_v1 xAOD::HIEventShape_v2 xAOD::IParticle xAOD::JEMEtSums_v1 xAOD::JEMEtSums_v2 xAOD::JEMHits_v1 xAOD::JEMRoI_v1 xAOD::JEMTobRoI_v1 xAOD::JetElement_v1 xAOD::JetElement_v2 xAOD::JetEtRoI_v1 xAOD::JetRoI_v1 xAOD::JetRoI_v2 xAOD::L1TopoRawData_v1 xAOD::LumiBlockRange_v1 xAOD::MBTSModule_v1 xAOD::MissingET_v1 xAOD::MissingETAssociation_v1 xAOD::MissingETComponent_v1 xAOD::MuonRoI_v1 xAOD::MuonSegment_v1 xAOD::RODHeader_v1 xAOD::RODHeader_v2 xAOD::RoiDescriptorStore_v1 xAOD::SCTRawHitValidation_v1 xAOD::SlowMuon_v1 xAOD::TrackMeasurementValidation_v1 xAOD::TrackParticleClusterAssociation_v1 xAOD::TrackStateValidation_v1 xAOD::TrigBphys_v1 xAOD::TrigCaloCluster_v1 xAOD::TrigComposite_v1 xAOD::TrigDecision_v1 xAOD::TriggerMenu_v1 xAOD::TriggerTower_v1 xAOD::TrigHisto2D_v1 xAOD::TrigMissingET_v1 xAOD::TrigNavigation_v1 xAOD::TrigPassBits_v1 xAOD::TrigRingerRings_v1 xAOD::TrigRingerRings_v2 xAOD::TrigRNNOutput_v1 xAOD::TrigRNNOutput_v2 xAOD::TrigSpacePointCounts_v1 xAOD::TrigT2MbtsBits_v1 xAOD::TrigT2ZdcSignals_v1 xAOD::TrigTrackCounts_v1 xAOD::TrigVertexCounts_v1 xAOD::TruthEventBase_v1 xAOD::TruthMetaData_v1 xAOD::TruthVertex_v1 xAOD::Vertex_v1 xAOD::ZdcModule_v1

List of all members.

Classes

class  Accessor
 Helper class to provide type-safe access to aux data. More...
class  ConstAccessor
 Helper class to provide constant type-safe access to aux data. More...
class  Decorator
 Helper class to provide type-safe access to aux data. More...
class  TypelessConstAccessor
 Helper class to provide const generic access to aux data. More...

Public Member Functions

 AuxElement ()
 Default constructor.
 AuxElement (const AuxElement &other)
 Copy Constructor.
AuxElementoperator= (const AuxElement &other)
 Assignment.
 ~AuxElement ()
 Destructor.
SG::AuxVectorDatacontainer ()
 Return the container holding this element.
const SG::AuxVectorDatacontainer () const
 Return the container holding this element.
size_t index () const
 Return the index of this element within its container.
template<class T >
AuxDataTraits< T >::reference_type auxdata (const std::string &name)
 Fetch an aux data variable, as a non-const reference.
template<class T >
AuxDataTraits< T >::reference_type auxdata (const std::string &name, const std::string &clsname)
 Fetch an aux data variable, as a non-const reference.
template<class T >
AuxDataTraits< T >
::const_reference_type 
auxdata (const std::string &name) const
 Fetch an aux data variable, as a const reference.
template<class T >
AuxDataTraits< T >
::const_reference_type 
auxdata (const std::string &name, const std::string &clsname) const
 Fetch an aux data variable, as a const reference.
template<class T >
AuxDataTraits< T >
::const_reference_type 
auxdataConst (const std::string &name) const
 Fetch an aux data variable, as a const reference.
template<class T >
AuxDataTraits< T >
::const_reference_type 
auxdataConst (const std::string &name, const std::string &clsname) const
 Fetch an aux data variable, as a const reference.
template<class T >
bool isAvailable (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for reading.
template<class T >
bool isAvailableWritable (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for writing.
template<class T >
bool isAvailableWritableAsDecoration (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for writing as a decoration.
template<class T >
AuxDataTraits< T >::reference_type auxdecor (const std::string &name) const
 Fetch an aux decoration, as a non-const reference.
template<class T >
AuxDataTraits< T >::reference_type auxdecor (const std::string &name, const std::string &clsname) const
 Fetch an aux decoration, as a non-const reference.
void makePrivateStore ()
 Create a new (empty) private store for this object.
template<class U1 >
void makePrivateStore (const U1 &other)
 Create a new private store for this object and copy aux data.
template<class U1 >
void makePrivateStore (const U1 *other)
 Create a new private store for this object and copy aux data.
void releasePrivateStore ()
 Release and free any private store associated with this object.
void setStore (const SG::IConstAuxStore *store)
 Set the store associated with this object.
void setStore (SG::IAuxStore *store)
 Set the store associated with this object.
void setStore (const DataLink< SG::IConstAuxStore > &store)
 Set the store associated with this object.
void setConstStore (const SG::IConstAuxStore *store)
 Synonym for setStore with IConstAuxStore.
void setNonConstStore (SG::IAuxStore *store)
 Synonym for setStore with IAuxStore.
bool usingPrivateStore () const
 Test to see if this object is currently using a private store.
bool usingStandaloneStore () const
 Test to see if this object is currently using a standalone store.
const SG::IConstAuxStoregetConstStore () const
 Return the current store, as a const interface.
SG::IAuxStoregetStore () const
 Return the current store, as a non-const interface.
void clearCache ()
 Clear the cached aux data pointers.
const SG::auxid_set_tgetAuxIDs () const
 Return a set of identifiers for existing data items for this object.
bool hasStore () const
 Return true if this object has an associated store.
bool hasNonConstStore () const
 Return true if this object has an associated non-const store.
void clearDecorations () const
 Clear all decorations.

Friends

class SG::AuxVectorBase
class SG::AuxVectorBase_test

Detailed Description

Base class for elements of a container that can have aux data.

Classes that want to have associated auxiliary data should derive from this class. (It is also possible to use this class directly, if you want a container that _only_ stores auxiliary data.)

The first thing that happens when you derive from AuxElement is that when an object is inserted into a DataVector, the vector will maintain information in the object telling were it is within the vector. For example:

  DataVector<SG::AuxElement> v (2);
  v[1] = new SG::AuxElement;
  assert (v[1]->index() == 1);
  assert (v[1]=>container() == &v);

As long as you don't use DataVector::stdcont or use unsafe casts, DataVector will correctly maintain this information.

When an object deriving from AuxElement is in a DataVector it may have auxiliary data associated with it; that is, named data objects of arbitrary type. The recommended way of accessing auxiliary data is through the Accessor and ConstAccessor classes, which cache the lookup between the aux data item name and its internal representation. The difference between these two is that ConstAccessor allows only const access to the element, while Accessor, which derives from it, allows non-const access as well. A given name must always have the same type, no matter where it is used (even across different classes); otherwise, an exception will be thrown. To help prevent conflicts between different classes, aux data item names may be optionally qualified with a class name. Here's an example of using ConstAccessor:

   // Only need to do this once.
   Myclass::ConstAccessor<int> vint1 ("myInt");
   ...
   const Myclass* m = ...;
   int x = vint1 (*m);

The auxdata methods can be used as a shortcut for this, but that's not recommended for anything for which performance is an issue.

You can also define getters/setters in your class:

  class Myclass {
    ...
    int get_x() const
    { static ConstAccessor<int> acc ("x", "Myclass");
      return acc (*this); }
    int& get_x()
    { static Accessor<int> acc ("x", "Myclass");
      return acc (*this); }

In addition, one sometimes wants to add additional auxiliary data to an existing const container; for example, after a container has been retrieved from StoreGate. This is called `decoration', and is handled by the Decorator object, which is much like Accessor and ConstAccessor. The difference is that Decorator can take a const container and return a non-const, modifiable reference. If the container has been locked by calling StoreGateSvc::setConst, then this is allowed only if this is a new auxiliary item, in which case it is marked as a decoration, or if it is already marked as a decoration. This prevents changing existing variables in a locked container. An auxdecor method is also available, analogous to auxdata.

In addition to the above, the class TypelessConstAccessor is a non-templated class that allows access to auxiliary data items directly as a `void *`. This is useful for code which operates on auxiliary data generically; it shouldn't really be used in other contexts.

Normally, an object can have auxiliary data only when it is part of a container. But sometimes it is useful to be able to associate aux data with an object before it has been added to a container. You can enable this by creating a `private store' for the object with makePrivateStore. This can optionally take an argument from which aux data should be copied. (Using a private store adds overhead, which is why it is not enabled by default.) Example:

  class Myclass : public SG::AuxElement { ... };
  ...
  Myclass::Accessor<int> myint ("myint");
  const Myclass* m = new Myclass;
  m->makePrivateStore();
  myint(*m) = 10;
  DataVector<Myclass> v;
  v.push_back(m);
  assert (myint(v[0]) == 10);

When an object with a private store is added to a container, the aux data is copied to the container and the private store is released. However, the fact that we had a private store is remembered; if the object is later removed from the container, the private store will be remade, and the aux data will be copied back from the container to the private store. To explicitly release the private store (so that it won't come back automatically), call releasePrivateStore.

If you add makePrivateStore calls to the constructors of your class, then you should be able to treat aux data as if it were part of the object itself; the required copying will be handled automatically.

  class Myclass : public SG::AuxElement
  {
  public:
    Myclass() { makePrivateStore(); }
    Myclass(const Myclass* other) { makePrivateStore(other); }

The SG::AuxElementComplete template class may be helpful in setting this up.

It is also possible to associate one of these objects with an external aux data store. This is the `standalone' mode. To do this, use the setStore methods, exactly as you would for a container that has aux data. setStore will throw an exception if the object is a member of a container or has a private store.

This class should not have any virtual methods (to avoid forcing derived classes to have a vtable).


Constructor & Destructor Documentation

SG::AuxElement::AuxElement ( const AuxElement other  )  [inline]

Copy Constructor.

Parameters:
other Object being copied.

We do not copy the container/index --- the new object is not yet in a container!

In the case of constructing an object with a private store, makePrivateStore will take care of copying the aux data.

SG::AuxElement::~AuxElement (  )  [inline]

Destructor.

Any private store is deleted.


Member Function Documentation

template<class T >
AuxDataTraits< T >::const_reference_type SG::AuxElement::auxdata ( const std::string &  name,
const std::string &  clsname 
) const [inline]

Fetch an aux data variable, as a const reference.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes above.

Reimplemented in xAOD::IParticle.

template<class T >
AuxDataTraits< T >::const_reference_type SG::AuxElement::auxdata ( const std::string &  name  )  const [inline]

Fetch an aux data variable, as a const reference.

Parameters:
name Name of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes above.

template<class T >
AuxDataTraits< T >::reference_type SG::AuxElement::auxdata ( const std::string &  name,
const std::string &  clsname 
) [inline]

Fetch an aux data variable, as a non-const reference.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

Reimplemented in xAOD::IParticle.

template<class T >
AuxDataTraits< T >::reference_type SG::AuxElement::auxdata ( const std::string &  name  )  [inline]

Fetch an aux data variable, as a non-const reference.

Parameters:
name Name of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

template<class T >
AuxDataTraits< T >::const_reference_type SG::AuxElement::auxdataConst ( const std::string &  name,
const std::string &  clsname 
) const [inline]

Fetch an aux data variable, as a const reference.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class above.

template<class T >
AuxDataTraits< T >::const_reference_type SG::AuxElement::auxdataConst ( const std::string &  name  )  const [inline]

Fetch an aux data variable, as a const reference.

Parameters:
name Name of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class above.

template<class T >
AuxDataTraits< T >::reference_type SG::AuxElement::auxdecor ( const std::string &  name,
const std::string &  clsname 
) const [inline]

Fetch an aux decoration, as a non-const reference.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

template<class T >
AuxDataTraits< T >::reference_type SG::AuxElement::auxdecor ( const std::string &  name  )  const [inline]

Fetch an aux decoration, as a non-const reference.

Parameters:
name Name of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

void SG::AuxElement::clearCache (  ) 

Clear the cached aux data pointers.

You should call this any time something changes in the aux store that could invalidate the vector pointers.

void SG::AuxElement::clearDecorations (  )  const

Clear all decorations.

Erase all decorations from an associated store, restoring the state to when lock was called.

const SG::auxid_set_t & SG::AuxElement::getAuxIDs (  )  const

Return a set of identifiers for existing data items for this object.

If this object has a private or standalone store, then information from that will be returned. Otherwise, if this element is part of a container, then information for the container will be returned. Otherwise, return an empty set.

const SG::IConstAuxStore * SG::AuxElement::getConstStore (  )  const

Return the current store, as a const interface.

This will be non-zero if either a const or non-const store is associated with this object. This will fetch either a private or standalone store.

SG::IAuxStore * SG::AuxElement::getStore (  )  const

Return the current store, as a non-const interface.

This will be non-zero if a non-const store is associated with this object. This will fetch either a private or standalone store.

bool SG::AuxElement::hasNonConstStore (  )  const

Return true if this object has an associated non-const store.

This will be true for either a private or standalone store.

bool SG::AuxElement::hasStore (  )  const

Return true if this object has an associated store.

This will be true for either a private or standalone store.

template<class T >
bool SG::AuxElement::isAvailable ( const std::string &  name,
const std::string &  clsname = "" 
) const [inline]

Check if an aux variable is available for reading.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

Reimplemented in xAOD::IParticle.

template<class T >
bool SG::AuxElement::isAvailableWritable ( const std::string &  name,
const std::string &  clsname = "" 
) const [inline]

Check if an aux variable is available for writing.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

Reimplemented in xAOD::IParticle.

template<class T >
bool SG::AuxElement::isAvailableWritableAsDecoration ( const std::string &  name,
const std::string &  clsname = "" 
) const [inline]

Check if an aux variable is available for writing as a decoration.

Parameters:
name Name of the aux variable.
clsname The name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class above.

template<class U1 >
void SG::AuxElement::makePrivateStore ( const U1 *  other  )  [inline]

Create a new private store for this object and copy aux data.

Parameters:
other The object from which aux data should be copied.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

If other is an object that has aux data, then those data will be copied; otherwise, nothing will be done.

template<class U1 >
void SG::AuxElement::makePrivateStore ( const U1 &  other  )  [inline]

Create a new private store for this object and copy aux data.

Parameters:
other The object from which aux data should be copied.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

If other is an object that has aux data, then those data will be copied; otherwise, nothing will be done.

void SG::AuxElement::makePrivateStore (  ) 

Create a new (empty) private store for this object.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

AuxElement & SG::AuxElement::operator= ( const AuxElement other  )  [inline]

Assignment.

Parameters:
other The object from which we're assigning.

We don't copy container/index, as assignment doesn't change where this object is. However, if we have aux data, then we copy aux data if we're copying from an object that also has it; otherwise, if we're copying from an object with no aux data, then we clear ours.

Reimplemented in xAOD::CaloCluster_v1, xAOD::Egamma_v1, xAOD::Electron_v1, xAOD::Photon_v1, xAOD::Jet_v1, xAOD::LumiBlockRange_v1, xAOD::MissingET_v1, xAOD::MissingETAssociation_v1, xAOD::MissingETComponent_v1, xAOD::NeutralParticle_v1, xAOD::TrackParticle_v1, xAOD::Vertex_v1, and xAOD::TriggerTower_v2.

void SG::AuxElement::releasePrivateStore (  ) 

Release and free any private store associated with this object.

ExcBadPrivateStore will be thrown if this object does not have a private store.

void SG::AuxElement::setConstStore ( const SG::IConstAuxStore store  )  [inline]

Synonym for setStore with IConstAuxStore.

Parameters:
store The new store.
void SG::AuxElement::setNonConstStore ( SG::IAuxStore store  )  [inline]

Synonym for setStore with IAuxStore.

Parameters:
store The new store.
void SG::AuxElement::setStore ( const DataLink< SG::IConstAuxStore > &  store  ) 

Set the store associated with this object.

Parameters:
store The new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

Parameters:
store Link to the new store.
void SG::AuxElement::setStore ( SG::IAuxStore store  ) 

Set the store associated with this object.

Parameters:
store The new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

void SG::AuxElement::setStore ( const SG::IConstAuxStore store  ) 

Set the store associated with this object.

Parameters:
store The new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

bool SG::AuxElement::usingStandaloneStore (  )  const

Test to see if this object is currently using a standalone store.

Test to see if this object is currently using a private store.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1