2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
8 #include "xAODPFlow/versions/PFOAttributesAccessor_v1.h"
12 template<class T> void PFO_v1::setAttribute(PFODetails::PFOAttributes AttributeType, const T& anAttribute) {
13 (*(PFOAttributesAccessor_v1<T>::constAccessor(AttributeType)))(*this) = anAttribute;
16 template<class T> bool PFO_v1::attribute(PFODetails::PFOAttributes AttributeType, T& anAttribute) const {
18 const ConstAccessor<T>* acc = PFOAttributesAccessor_v1<T>::constAccessor(AttributeType);
19 //check if accessor pointer is NULL
20 if( ! acc ) { return false ;}
21 //check if variable is avaialable
22 if( ! acc->isAvailable( *this ) ) return false;
23 //set variable and return true
24 anAttribute =( *acc )( *this );
28 template<class T> void PFO_v1::setAttribute(const std::string& AttributeType, const T& anAttribute) {
30 const static Accessor<T> acc(AttributeType);
31 acc(*this) = anAttribute;
35 template<class T> bool PFO_v1::attribute(const std::string& AttributeType, T& anAttribute) const {
36 const static ConstAccessor<T> acc(AttributeType);
37 //Check if variable is available
38 if( !acc.isAvailable( *this ) ) return false;
40 anAttribute = acc(*this);
45 // Not good enough to just define the specialisations in the source file -- they must be declared publicly
46 /** Setter specialisation for PFOLeptonType */
47 template<> void PFO_v1::setAttribute(const std::string& AttributeType, const xAOD::PFODetails::PFOLeptonType& anAttribute);
48 /** Getter specialisation for PFOLeptonType */
49 template<> bool PFO_v1::attribute(const std::string& AttributeType, xAOD::PFODetails::PFOLeptonType& anAttribute) const;
51 /** Setter specialisation for float */
52 template<> void PFO_v1::setAttribute(PFODetails::PFOAttributes AttributeType, const float& anAttribute);
53 /** Getter specialisation for float */
54 template<> bool PFO_v1::attribute(PFODetails::PFOAttributes AttributeType, float& anAttribute) const;
57 /** Setter specialisation for double with enum type argument */
58 template<> void PFO_v1::setAttribute(PFODetails::PFOAttributes AttributeType, const double& anAttribute);
59 /** Getter specialisation for double with enum type argument */
60 template<> bool PFO_v1::attribute(PFODetails::PFOAttributes AttributeType, double& anAttribute) const;
62 /** Setter specialisation for double with string type argument */
63 template<> void PFO_v1::setAttribute(const std::string& AttributeType, const double& anAttribute);
64 /** Getter specialisation for double with string type argument */
65 template<> bool PFO_v1::attribute(const std::string& AttributeType, double& anAttribute) const;
67 template<class T> void PFO_v1::convertLink(ElementLink<IParticleContainer>& IParticleLink, const ElementLink<T>& templateLink) {
68 ElementLink<T> tempLink;
69 tempLink.setElement(*templateLink);
70 tempLink.setStorableObject(templateLink.getStorableObjectRef());
71 tempLink.toPersistent();
72 IParticleLink.resetWithKeyAndIndex( tempLink.persKey(), tempLink.persIndex() );