ATLAS Offline Software
Loading...
Searching...
No Matches
FlowElement_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
7#include "AthLinks/ElementLink.h"
8
9
10// Local include(s):
12
13#include "Math/Vector4D.h"
14
15using ROOT::Math::PtEtaPhiMVector ;
16
17namespace xAOD {
18
19
24
26 return PtEtaPhiMVector(pt(), eta(), phi(), m() ).E();
27 }
28
29 double FlowElement_v1::rapidity() const {
30 return PtEtaPhiMVector(pt(), eta(), phi(), m() ).Rapidity();
31 }
32
35 p4.SetPtEtaPhiE( pt(), eta(), phi(), e() );
36 return p4;
37 }
38
39 void FlowElement_v1::setP4(float pt, float eta, float phi, float m){
40 static const Accessor< float > acc1( "pt" );
41 acc1( *this ) = pt;
42 static const Accessor< float > acc2( "eta" );
43 acc2( *this ) = eta;
44 static const Accessor< float > acc3( "phi" );
45 acc3( *this ) = phi;
46 static const Accessor< float > acc4( "m" );
47 acc4( *this ) = m;
48
49 }
50
52 setP4(p4.Pt(), p4.Eta(), p4.Phi(), p4.M());
53 }
54
57
58
59
62
64 return (vertexType()==vxtype);
65 }
66
67
68 Type::ObjectType FlowElement_v1::type() const {
69 return Type::FlowElement;
70 }
71
72
73
74
77 chargedObjectLinks,
78 setChargedObjectLinks)
79
80
81 AUXSTORE_OBJECT_GETTER( FlowElement_v1, std::vector<float>, chargedObjectWeights)
82
83 void FlowElement_v1::setChargedObjectLinks(const std::vector<ElementLink<IParticleContainer>> & elV, const std::vector<float> & wV){
84 if(elV.size() != wV.size() ){
85 throw std::runtime_error("FlowElement::setChargedObjectLinks : Can not set vectors of links and weights with different sizes");
86 }
88 static const SG::AuxElement::Accessor< std::vector<float> > accW( "chargedObjectWeights" );
89 accL(*this) = elV;
90 accW(*this) = wV;
91 }
92
93
94 std::vector<const xAOD::IParticle*> FlowElement_v1::chargedObjects() const {
95 const auto & elV = chargedObjectLinks();
96 std::vector<const xAOD::IParticle*> result;
97 result.reserve( elV.size() );
98 for(const auto& el: elV ){
99 result.push_back( el.isValid() ? *el : nullptr ) ;
100 }
101 return result;
102 }
103
104 std::vector<std::pair<const xAOD::IParticle*,float> > FlowElement_v1::chargedObjectsAndWeights() const {
105
106 const auto & elV = chargedObjectLinks();
107 const std::vector<float> & wV = chargedObjectWeights();
108 std::vector< std::pair<const xAOD::IParticle*,float> > result;
109 result.reserve( elV.size() );
110 if(wV.empty()) {
111 for(const auto& el: elV ){
112 result.emplace_back( el.isValid() ? *el : nullptr , 1. ) ;
113 }
114 } else {
115 for(size_t i=0;i<elV.size();i++){
116 const xAOD::IParticle* p = elV[i].isValid() ? *(elV[i]) : nullptr;
117 result.emplace_back(p , wV[i] );
118 }
119 }
120 return result;
121 }
122
124 return chargedObjectLinks().size();
125 }
126
127 const xAOD::IParticle* FlowElement_v1::chargedObject( std::size_t i ) const{
128 const auto & elV = chargedObjectLinks();
129 // should we check if i >= size() and throw ourselves ? or trust the user ?
130 return elV[i].isValid()? *(elV[i]) : nullptr ;
131 }
132
133 std::pair<const xAOD::IParticle*, float > FlowElement_v1::chargedObjectAndWeight( std::size_t i ) const {
134 const auto & elV = chargedObjectLinks();
135 const std::vector<float> & wV = chargedObjectWeights();
136
137 if( elV[i].isValid() ) return { *(elV[i]), wV[i] } ;
138 else return {nullptr, wV[i] } ;
139 }
140
141
142
143
144
147 otherObjectLinks,
148 setOtherObjectLinks)
149 AUXSTORE_OBJECT_GETTER( FlowElement_v1, std::vector<float>, otherObjectWeights)
150
151 void FlowElement_v1::setOtherObjectLinks(const std::vector<ElementLink<IParticleContainer>> & elV, const std::vector<float> & wV){
152 if(elV.size() != wV.size() ){
153 throw std::runtime_error("FlowElement::setOtherObjectLinks : Can not set vectors of links and weights with different sizes");
154 return;
155 }
157 static const SG::AuxElement::Accessor< std::vector<float> > accW( "otherObjectWeights" );
158 accL(*this) = elV;
159 accW(*this) = wV;
160 }
161
162
163 std::vector<const xAOD::IParticle*> FlowElement_v1::otherObjects() const {
164 const auto & elV = otherObjectLinks();
165 std::vector<const xAOD::IParticle*> result;
166 result.reserve( elV.size() );
167 for(const auto& el: elV ){
168 result.push_back( el.isValid() ? *el : nullptr ) ;
169 }
170 return result;
171 }
172
173 std::vector<std::pair<const xAOD::IParticle*,float> > FlowElement_v1::otherObjectsAndWeights() const {
174
175 const auto & elV = otherObjectLinks();
176 const std::vector<float> & wV = otherObjectWeights();
177 std::vector< std::pair<const xAOD::IParticle*,float> > result;
178 result.reserve( elV.size() );
179 if(wV.empty()) {
180 for(const auto& el: elV ){
181 result.emplace_back( el.isValid() ? *el : nullptr , 1. ) ;
182 }
183 } else {
184 for(size_t i=0;i<elV.size();i++){
185 const xAOD::IParticle* p = elV[i].isValid() ? *(elV[i]) : nullptr;
186 result.emplace_back(p , wV[i] );
187 }
188 }
189 return result;
190 }
191
192 std::size_t FlowElement_v1::nOtherObjects() const {
193 return otherObjectLinks().size();
194 }
195
196 const xAOD::IParticle* FlowElement_v1::otherObject( std::size_t i ) const{
197 const auto & elV = otherObjectLinks();
198 // should we check if i >= size() and throw ourselves ? or trust the user ?
199 return elV[i].isValid()? *(elV[i]) : nullptr ;
200 }
201
202 std::pair< const xAOD::IParticle*, float > FlowElement_v1::otherObjectAndWeight( std::size_t i ) const {
203 const auto & elV = otherObjectLinks();
204 const std::vector<float> & wV = otherObjectWeights();
205
206 if( elV[i].isValid() ) return { *(elV[i]), wV[i] };
207 else return {nullptr, wV[i] } ;
208 }
209
210
211}
Scalar eta() const
pseudorapidity method
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME)
Macro creating a getter function with a type conversion.
#define AUXSTORE_OBJECT_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a complex auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
A detector object made of other lower level object(s)
std::size_t nChargedObjects() const
std::size_t nOtherObjects() const
std::vector< const xAOD::IParticle * > chargedObjects() const
virtual double rapidity() const override
The true rapidity (y) of the particle.
std::vector< const xAOD::IParticle * > otherObjects() const
const std::vector< float > & chargedObjectWeights() const
virtual double pt() const override
void setP4(float pt, float eta, float phi, float m)
virtual double m() const override
The invariant mass of the particle.
bool isMatchedToPV(MatchedPVType vxtype=HardScatter) const
const std::vector< ElementLink< IParticleContainer > > & otherObjectLinks() const
virtual double phi() const override
The azimuthal angle ( ) of the particle.
MatchedPVType
Enum to encode high-level information on the vertex associated to this FlowElement.
const std::vector< ElementLink< IParticleContainer > > & chargedObjectLinks() const
Access to the EL.
virtual double eta() const override
The pseudorapidity ( ) of the particle.
signal_t signalType() const
std::vector< std::pair< const xAOD::IParticle *, float > > otherObjectsAndWeights() const
void setChargedObjectLinks(const std::vector< ElementLink< IParticleContainer > > &elV)
std::pair< const xAOD::IParticle *, float > chargedObjectAndWeight(std::size_t i) const
TLorentzVector FourMom_t
Definition of the 4-momentum type.
const std::vector< float > & otherObjectWeights() const
const xAOD::IParticle * chargedObject(std::size_t i) const
unsigned long signal_t
virtual Type::ObjectType type() const override
The type of the object as a simple enumeration.
void setOtherObjectLinks(const std::vector< ElementLink< IParticleContainer > > &elV)
virtual double e() const override
The total energy of the particle.
const xAOD::IParticle * otherObject(std::size_t i) const
std::vector< std::pair< const xAOD::IParticle *, float > > chargedObjectsAndWeights() const
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
std::pair< const xAOD::IParticle *, float > otherObjectAndWeight(std::size_t i) const
Class providing the definition of the 4-vector interface.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setRcore setEtHad setFside pt
setBGCode setTAP setLVL2ErrorBits bool