ATLAS Offline Software
Loading...
Searching...
No Matches
Jet_v1.icc
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id: Jet_v1.h 569930 2013-11-12 14:50:19Z delsart $
8
9#include "JetAccessorMap_v1.h"
10namespace xAOD {
11
12 //////////////////////////////////////////////////
13 // Implement getters
14
15 template<class T>
16 bool Jet_v1::getAttribute(const std::string &name, T& value) const{
17 // build an accessor. AccessorWrapper is nothing more than a standard SG::AuxElement::Accessor for simpe types
18 const JetAttributeAccessor::AccessorWrapper<T> a(name);
19 if(! a.isAvailable( *this) ) { return false;}
20 a.getAttribute(*this,value);
21 return true;
22 }
23
24 template<class T>
25 T Jet_v1::getAttribute(const std::string &name) const {
26 // build an accessor. AccessorWrapper is nothing more than a standard SG::AuxElement::Accessor for simpe types
27 const JetAttributeAccessor::AccessorWrapper<T> a(name);
28 return a.getAttribute(*this);
29 }
30
31 template<class T>
32 bool Jet_v1::getAttribute( AttributeID type, T & value ) const {
33 // Get the moment accessor by asking the map :
34 const JetAttributeAccessor::AccessorWrapper< T >* acc = xAOD::JetAttributeAccessor::AccessorMap_v1<T>::accessor( type );
35 if( ! acc ) { return false ;}
36
37 // Check if the moment is available:
38 if( ! acc->isAvailable( *this ) ) return false;
39
40 // Retrieve the moment:
41 acc->getAttribute(*this,value);
42 //value =( *acc )( *this );
43 return true;
44 }
45
46 template<class T>
47 T Jet_v1::getAttribute(AttributeID type) const {
48 const JetAttributeAccessor::AccessorWrapper< T >* acc = xAOD::JetAttributeAccessor::AccessorMap_v1<T>::accessor( type );
49 if( ! acc ) {throw std::string("Jet_v1::getAttribute(type) with unknown type");} // need a better exception
50 return acc->getAttribute(*this);
51 }
52 //////////////////////////////////////////////////
53
54
55
56
57 //////////////////////////////////////////////////
58 // implement setters
59 template<class T>
60 void Jet_v1::setAttribute(const std::string &name, const T& v){
61 // build an accessor. AccessorWrapper is nothing more than a standard SG::AuxElement::Accessor for simpe types
62 JetAttributeAccessor::AccessorWrapper<T> a(name);
63 a.setAttribute(*this,v);
64 }
65
66 template<class T>
67 void Jet_v1::setAttribute( AttributeID type, const T& value ){
68 xAOD::JetAttributeAccessor::AccessorMap_v1<T>::accessor( type )->setAttribute(*this,value);
69 return;
70 }
71 //////////////////////////////////////////////////
72
73
74
75
76
77
78 //////////////////////////////////////////////////
79
80
81 template<typename T>
82 std::vector<const T*> Jet_v1::getAssociatedObjects( const std::string &name) const {
83 const JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > a(name);
84 return a.getAttribute(*this);
85 }
86
87 template<typename T>
88 std::vector<const T*> Jet_v1::getAssociatedObjects( AssoParticlesID type) const {
89 const JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< std::vector<const T*> >::accessor(type) ;
90
91 if(acc) {
92 return acc->getAttribute(*this);
93 }
94 return std::vector<const T*>();
95 }
96
97
98 template<typename T>
99 bool Jet_v1::getAssociatedObjects( const std::string &name, std::vector<const T*>& vec) const {
100 const JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > a(name);
101 if(! a.isAvailable(*this) ) return false;
102 a.getAttribute(*this, vec );
103 return true;
104 }
105
106 template<typename T>
107 bool Jet_v1::getAssociatedObjects( AssoParticlesID type, std::vector<const T*>& vec) const {
108 const JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< std::vector<const T*> >::accessor(type) ;
109 if(!acc) return false;
110 if(! acc->isAvailable(*this) ) return false;
111 acc->getAttribute(*this, vec );
112 return true;
113 }
114
115
116 template<typename T>
117 void Jet_v1::setAssociatedObjects( const std::string &name, const std::vector<const T*>& vec) {
118 JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > a(name);
119 a.setAttribute(*this, vec);
120 }
121
122 template<typename T>
123 void Jet_v1::setAssociatedObjects( AssoParticlesID type, const std::vector<const T*>& vec) {
124 JetAttributeAccessor::ObjectAccessorWrapper<std::vector<const T*> > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< std::vector<const T*> >::accessor(type) ;
125 if(acc) acc->setAttribute(*this, vec);
126
127 }
128
129
130 template<typename T>
131 const T* Jet_v1::getAssociatedObject( const std::string &name) const {
132 const JetAttributeAccessor::ObjectAccessorWrapper< T > a(name);
133 return a.getAttribute(*this);
134 }
135
136 template<typename T>
137 const T* Jet_v1::getAssociatedObject( AssoParticlesID type) const {
138 const JetAttributeAccessor::ObjectAccessorWrapper<T > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< T >::accessor(type) ;
139
140 if(acc) {
141 return acc->getAttribute(*this);
142 }
143 return NULL;
144 }
145
146 template<typename T>
147 bool Jet_v1::getAssociatedObject( const std::string &name, const T*& vec) const {
148 const JetAttributeAccessor::ObjectAccessorWrapper<T > a(name);
149 if(! a.isAvailable(*this) ) return false;
150 a.getAttribute(*this, vec );
151 return true;
152 }
153
154 template<typename T>
155 bool Jet_v1::getAssociatedObject( AssoParticlesID type, const T*& vec) const {
156 const JetAttributeAccessor::ObjectAccessorWrapper<T > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< T >::accessor(type) ;
157 if(!acc) return false;
158 if(! acc->isAvailable(*this) ) return false;
159 acc->getAttribute(*this, vec );
160 return true;
161 }
162
163 template<typename T>
164 void Jet_v1::setAssociatedObject( const std::string &name, const T* vec) {
165 JetAttributeAccessor::ObjectAccessorWrapper<T > a(name);
166 a.setAttribute(*this, vec);
167 }
168
169 template<typename T>
170 void Jet_v1::setAssociatedObject( AssoParticlesID type, const T* vec) {
171 JetAttributeAccessor::ObjectAccessorWrapper<T > * acc = JetAttributeAccessor::ObjectAccessorMap_v1< T >::accessor(type) ;
172 if(acc) acc->setAttribute(*this, vec);
173 }
174
175}
176