ATLAS Offline Software
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 
15 using ROOT::Math::PtEtaPhiMVector ;
16 
17 namespace xAOD {
18 
19 
20  AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(FlowElement_v1, float, double, pt)
21  AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(FlowElement_v1, float, double, eta)
22  AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(FlowElement_v1, float, double, phi)
23  AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(FlowElement_v1, float, double, m)
24 
25  double FlowElement_v1::e() const {
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 
34  FourMom_t p4;
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 
56  bool FlowElement_v1::isCharged() const { return !bool( signalType()& Neutral );}
57 
58 
59 
62 
63  bool FlowElement_v1::isMatchedToPV(MatchedPVType vxtype) const {
64  return (vertexType()==vxtype);
65  }
66 
67 
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  }
87  static const SG::AuxElement::Accessor< std::vector<ElementLink< xAOD::IParticleContainer >> > accL( "chargedObjectLinks" );
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 
123  std::size_t FlowElement_v1::nChargedObjects() const {
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  }
156  static const SG::AuxElement::Accessor< std::vector<ElementLink< xAOD::IParticleContainer > > > accL( "otherObjectLinks" );
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 }
python.CaloBCIDAvgAlgConfig.acc3
def acc3
Definition: CaloBCIDAvgAlgConfig.py:68
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
xAOD::FlowElement_v1::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:68
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
xAOD::FlowElement_v1::rapidity
virtual double rapidity() const override
The true rapidity (y) of the particle.
Definition: FlowElement_v1.cxx:29
xAOD::FlowElement_v1::m
virtual double m() const override
The invariant mass of the particle.
SG::Accessor< float >
AuxStoreAccessorMacros.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::FlowElement_v1::nOtherObjects
std::size_t nOtherObjects() const
Definition: FlowElement_v1.cxx:192
xAOD::FlowElement_v1::otherObjectsAndWeights
std::vector< std::pair< const xAOD::IParticle *, float > > otherObjectsAndWeights() const
Definition: FlowElement_v1.cxx:173
xAOD::FlowElement_v1::chargedObjectLinks
const std::vector< ElementLink< IParticleContainer > > & chargedObjectLinks() const
Access to the EL.
xAOD::FlowElement_v1::otherObjectLinks
const std::vector< ElementLink< IParticleContainer > > & otherObjectLinks() const
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::FlowElement_v1::phi
virtual double phi() const override
The azimuthal angle ( ) of the particle.
xAOD::FlowElement_v1::pt
virtual double pt() const override
xAOD::pt
setRcore setEtHad setFside pt
Definition: TrigPhoton_v1.cxx:106
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
xAOD::FlowElement_v1::setOtherObjectLinks
void setOtherObjectLinks(const std::vector< ElementLink< IParticleContainer >> &elV)
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::FlowElement_v1::nChargedObjects
std::size_t nChargedObjects() const
Definition: FlowElement_v1.cxx:123
xAOD::FlowElement_v1::signal_t
unsigned long signal_t
Definition: FlowElement_v1.h:30
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:68
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::FlowElement_v1::otherObjectAndWeight
std::pair< const xAOD::IParticle *, float > otherObjectAndWeight(std::size_t i) const
Definition: FlowElement_v1.cxx:202
xAOD::FlowElement_v1::chargedObjectsAndWeights
std::vector< std::pair< const xAOD::IParticle *, float > > chargedObjectsAndWeights() const
Definition: FlowElement_v1.cxx:104
xAOD::FlowElement_v1::MatchedPVType
MatchedPVType
Enum to encode high-level information on the vertex associated to this FlowElement.
Definition: FlowElement_v1.h:62
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
python.CaloBCIDAvgAlgConfig.acc1
def acc1
Definition: CaloBCIDAvgAlgConfig.py:48
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition: FlowElement.h:16
xAOD::AUXSTORE_PRIMITIVE_GETTER_WITH_CAST
AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Muon_v1, uint8_t, Muon_v1::EnergyLossType, energyLossType) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Muon_v1
xAOD::charge
charge
Definition: TrigElectron_v1.cxx:85
python.CaloBCIDAvgAlgConfig.acc2
def acc2
Definition: CaloBCIDAvgAlgConfig.py:58
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
xAOD::FlowElement_v1::vertex_t
short vertex_t
Definition: FlowElement_v1.h:31
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
python.LArRecUtilsConfig.acc4
def acc4
Definition: LArRecUtilsConfig.py:196
xAOD::FlowElement_v1::chargedObject
const xAOD::IParticle * chargedObject(std::size_t i) const
Definition: FlowElement_v1.cxx:127
xAOD::FlowElement_v1::setChargedObjectLinks
void setChargedObjectLinks(const std::vector< ElementLink< IParticleContainer >> &elV)
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition: FlowElement_v1.cxx:25
xAOD::FlowElement_v1::chargedObjects
std::vector< const xAOD::IParticle * > chargedObjects() const
Definition: FlowElement_v1.cxx:94
xAOD::vertexType
vertexType
Definition: Vertex_v1.cxx:166
xAOD::FlowElement_v1::eta
virtual double eta() const override
The pseudorapidity ( ) of the particle.
xAOD::FlowElement_v1::chargedObjectAndWeight
std::pair< const xAOD::IParticle *, float > chargedObjectAndWeight(std::size_t i) const
Definition: FlowElement_v1.cxx:133
xAOD::FlowElement_v1::p4
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Definition: FlowElement_v1.cxx:33
isCharged
bool isCharged(const T &p)
Definition: AtlasPID.h:496
xAOD::FlowElement_v1::chargedObjectWeights
const std::vector< float > & chargedObjectWeights() const
xAOD::FlowElement_v1::otherObject
const xAOD::IParticle * otherObject(std::size_t i) const
Definition: FlowElement_v1.cxx:196
xAOD::AUXSTORE_OBJECT_GETTER
AUXSTORE_OBJECT_GETTER(TrigComposite_v1, std::vector< std::string >, linkColNames) AUXSTORE_OBJECT_GETTER(TrigComposite_v1
xAOD::FlowElement_v1::setP4
void setP4(float pt, float eta, float phi, float m)
Definition: FlowElement_v1.cxx:39
xAOD::FlowElement_v1::otherObjectWeights
const std::vector< float > & otherObjectWeights() const
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
xAOD::FlowElement_v1::type
virtual Type::ObjectType type() const override
The type of the object as a simple enumeration.
Definition: FlowElement_v1.cxx:68
FlowElement_v1.h
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
xAOD::FlowElement_v1::otherObjects
std::vector< const xAOD::IParticle * > otherObjects() const
Definition: FlowElement_v1.cxx:163
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25