ATLAS Offline Software
NeutralParticle_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Misc includes
6 #include <bitset>
7 #include <vector>
8 
9 // EDM include(s):
11 
12 // Local include(s):
14 // #include "xAODTracking/VertexContainer.h" FIXME - need to get ELs working to vertices for neutrals - currently causes compilation failure EJWM
15 
16 
17 namespace xAOD {
18 
20  : IParticle(){
21  }
22 
24  : IParticle( tp ) {
26  }
27 
29  if(this == &tp) return *this;
30 
31  if(!hasStore() ) makePrivateStore();
32  this->IParticle::operator=( tp );
33 #ifndef XAOD_ANALYSIS
34  m_perigeeParameters.reset();
35 #endif // not XAOD_ANALYSIS
36  return *this;
37  }
38 
40  }
41 
42  double NeutralParticle_v1::pt() const {
43  return genvecP4().Pt();
44  }
45 
46  double NeutralParticle_v1::eta() const {
47  return genvecP4().Eta();
48  }
49 
51 
52 
54  return 139.570;
55  }
56 
58 
59 
60  double NeutralParticle_v1::rapidity() const {
61  return genvecP4().Rapidity();
62  }
63 
65  using namespace std;
66  float p = 1/fabs(oneOverP());
67  float thetaT = theta();
68  float phiT = phi();
69  float sinTheta= sin(thetaT);
70  float px = p*sinTheta*cos(phiT);
71  float py = p*sinTheta*sin(phiT);
72  float pz = p*cos(thetaT);
73  return GenVecFourMom_t(px, py, pz, m());
74  }
75 
77  using namespace std;
78  FourMom_t p4;
79  float p = 1/fabs(oneOverP());
80  float thetaT = theta();
81  float phiT = phi();
82  float sinTheta= sin(thetaT);
83  float px = p*sinTheta*cos(phiT);
84  float py = p*sinTheta*sin(phiT);
85  float pz = p*cos(thetaT);
86  float e = pow (m(),2) +
87  pow( px,2) + pow( py,2) + pow( pz,2);
88  p4.SetPxPyPzE( px, py, pz, sqrt(e) );
89  return p4;
90  }
91 
93  return Type::NeutralParticle;
94  }
95 
96 
102 
103  const DefiningParameters_t NeutralParticle_v1::definingParameters() const{
104  DefiningParameters_t tmp;
105  tmp << d0(),z0(),phi0(),theta(),oneOverP();
106  return tmp;
107  }
108 
109  void NeutralParticle_v1::setDefiningParameters(float d0, float z0, float phi0, float theta, float oneOverP) {
110 #ifndef XAOD_ANALYSIS
111  if(m_perigeeParameters.isValid()) {
112  m_perigeeParameters.reset();
113  }
114 #endif // not XAOD_ANALYSIS
115  static const Accessor< float > acc1( "d0" );
116  acc1( *this ) = d0;
117 
118  static const Accessor< float > acc2( "z0" );
119  acc2( *this ) = z0;
120 
121  static const Accessor< float > acc3( "phi" );
122  acc3( *this ) = phi0;
123 
124  static const Accessor< float > acc4( "theta" );
125  acc4( *this ) = theta;
126 
127  static const Accessor< float > acc5( "oneOverP" );
128  acc5( *this ) = oneOverP;
129 
130  return;
131  }
132 
133  void NeutralParticle_v1::setDefiningParametersCovMatrix(const xAOD::ParametersCovMatrix_t& cov){
134 #ifndef XAOD_ANALYSIS
135  if(m_perigeeParameters.isValid()) {
136  m_perigeeParameters.reset();
137  }
138 #endif // not XAOD_ANALYSIS
139 
140  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
141  std::vector<float>& v = acc(*this);
142  v.reserve(15);
143  for (size_t irow = 0; irow<5; ++irow)
144  for (size_t icol =0; icol<=irow; ++icol)
145  v.push_back(cov(icol,irow));
146  }
147 
148  const xAOD::ParametersCovMatrix_t NeutralParticle_v1::definingParametersCovMatrix() const {
149  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
150  std::vector<float> v = acc(*this);
151  std::vector<float>::const_iterator it = v.begin();
152  xAOD::ParametersCovMatrix_t cov;
153  cov.setZero();
154  for (size_t irow = 0; irow<5; ++irow){
155  for (size_t icol =0; icol<=irow; ++icol){
156  cov.fillSymmetric(icol,irow, *it++);
157  }
158  }
159  return cov;
160  }
161 
162  const std::vector<float>& NeutralParticle_v1::definingParametersCovMatrixVec() const {
163  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
164  return acc(*this);
165  }
166 
168  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
169  acc(*this)=cov;
170  }
171 
175 
176  void NeutralParticle_v1::setParametersOrigin(float x, float y, float z){
177  static const Accessor< float > acc1( "vx" );
178  acc1( *this ) = x;
179 
180  static const Accessor< float > acc2( "vy" );
181  acc2( *this ) = y;
182 
183  static const Accessor< float > acc3( "vz" );
184  acc3( *this ) = z;
185  }
186 
187 #ifndef XAOD_ANALYSIS
189 
190  // Require the cache to be valid and check if the cached pointer has been set
191  if(m_perigeeParameters.isValid()){
192  return *(m_perigeeParameters.ptr());
193  }
194  static const Accessor< float > acc1( "d0" );
195  static const Accessor< float > acc2( "z0" );
196  static const Accessor< float > acc3( "phi" );
197  static const Accessor< float > acc4( "theta" );
198  static const Accessor< float > acc5( "oneOverP" );
199  static const Accessor< std::vector<float> > acc6( "definingParametersCovMatrix" );
200  ParametersCovMatrix_t cov;
201  cov.setZero();
202  auto it= acc6(*this).begin();
203  for (size_t irow = 0; irow<5; ++irow){
204  for (size_t icol =0; icol<=irow; ++icol){
205  cov.fillSymmetric(irow,icol,*it++) ;
206  }
207  }
208  Trk::NeutralPerigee tmpPerigeeParameters(acc1(*this),acc2(*this),acc3(*this),acc4(*this),acc5(*this),
209  Trk::PerigeeSurface(Amg::Vector3D(vx(),vy(),vz())),std::move(cov));
210  m_perigeeParameters.set(tmpPerigeeParameters);
211  return *(m_perigeeParameters.ptr());
212  }
213 #endif // not XAOD_ANALYSIS
214 
216 #ifndef XAOD_ANALYSIS
217  m_perigeeParameters.reset();
218 #endif // not XAOD_ANALYSIS
219  }
220 
221 } // namespace xAOD
python.CaloBCIDAvgAlgConfig.acc3
def acc3
Definition: CaloBCIDAvgAlgConfig.py:69
xAOD::NeutralParticle_v1::setParametersOrigin
void setParametersOrigin(float x, float y, float z)
Set the origin for the parameters.
Definition: NeutralParticle_v1.cxx:176
test_pyathena.px
px
Definition: test_pyathena.py:18
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::NeutralParticle_v1::FourMom_t
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
Definition: NeutralParticle_v1.h:69
xAOD::NeutralParticle_v1::definingParameters
const DefiningParameters_t definingParameters() const
Returns a SVector of the Perigee track parameters.
Definition: NeutralParticle_v1.cxx:103
SG::Accessor< float >
AuxStoreAccessorMacros.h
xAOD::NeutralParticle_v1::definingParametersCovMatrix
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
Definition: NeutralParticle_v1.cxx:148
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
xAOD::NeutralParticle_v1::perigeeParameters
const Trk::NeutralPerigee & perigeeParameters() const
Returns the Trk::NeutralPerigee track parameters.
Definition: NeutralParticle_v1.cxx:188
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
xAOD::NeutralParticle_v1::definingParametersCovMatrixVec
const std::vector< float > & definingParametersCovMatrixVec() const
Returns the vector of the covariance values - 15 elements.
Definition: NeutralParticle_v1.cxx:162
skel.it
it
Definition: skel.GENtoEVGEN.py:396
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::NeutralParticle_v1::NeutralParticle_v1
NeutralParticle_v1()
Default constructor.
Definition: NeutralParticle_v1.cxx:19
xAOD::NeutralParticle_v1::m
virtual double m() const
The invariant mass of the particle..
Definition: NeutralParticle_v1.cxx:53
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::NeutralParticle_v1::z0
float z0() const
Returns the parameter.
xAOD::NeutralParticle_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: NeutralParticle_v1.cxx:42
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
xAOD::NeutralParticle_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: NeutralParticle_v1.cxx:46
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::NeutralParticle_v1::e
virtual double e() const
The total energy of the particle.
x
#define x
xAOD::py
py
Definition: CompositeParticle_v1.cxx:160
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:69
xAOD::NeutralParticle_v1::phi0
float phi0() const
Returns the parameter, which has range to .
xAOD::NeutralParticle_v1::setDefiningParametersCovMatrix
void setDefiningParametersCovMatrix(const ParametersCovMatrix_t &cov)
Set the defining parameters covariance matrix.
Definition: NeutralParticle_v1.cxx:133
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::NeutralParticle_v1::d0
float d0() const
Returns the parameter.
xAOD::NeutralParticle_v1::setDefiningParameters
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
Definition: NeutralParticle_v1.cxx:109
xAOD::NeutralParticle_v1::~NeutralParticle_v1
~NeutralParticle_v1()
Destructor.
Definition: NeutralParticle_v1.cxx:39
xAOD::NeutralParticle_v1::setDefiningParametersCovMatrixVec
void setDefiningParametersCovMatrixVec(const std::vector< float > &cov)
Set the defining parameters covariance matrix using a length 15 vector.
Definition: NeutralParticle_v1.cxx:167
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
z
#define z
xAOD::NeutralParticle_v1::vy
float vy() const
The y origin for the parameters.
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
xAOD::NeutralParticle_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: NeutralParticle_v1.cxx:76
python.CaloBCIDAvgAlgConfig.acc1
def acc1
Definition: CaloBCIDAvgAlgConfig.py:49
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
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
python.CaloBCIDAvgAlgConfig.acc2
def acc2
Definition: CaloBCIDAvgAlgConfig.py:59
xAOD::NeutralParticle_v1::resetCache
void resetCache()
Reset the internal cache of the object.
Definition: NeutralParticle_v1.cxx:215
xAOD::NeutralParticle_v1::genvecP4
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form.
Definition: NeutralParticle_v1.cxx:64
xAOD::NeutralParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
xAOD::NeutralParticle_v1::vz
float vz() const
The z origin for the parameters.
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
xAOD::NeutralParticle
NeutralParticle_v1 NeutralParticle
Reference the current persistent version:
Definition: NeutralParticle.h:13
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
xAOD::NeutralParticle_v1::oneOverP
float oneOverP() const
Returns the parameter.
python.LArRecUtilsConfig.acc4
def acc4
Definition: LArRecUtilsConfig.py:196
python.LArRecUtilsConfig.acc5
def acc5
Definition: LArRecUtilsConfig.py:205
xAOD::NeutralParticle_v1::GenVecFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzM4D< double > > GenVecFourMom_t
Base 4 Momentum type for TrackParticle.
Definition: NeutralParticle_v1.h:75
python.LuminosityCondAlgConfig.acc6
def acc6
Definition: LuminosityCondAlgConfig.py:260
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
xAOD::NeutralParticle_v1::type
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition: NeutralParticle_v1.cxx:92
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
NeutralParticle_v1.h
xAOD::NeutralParticle_v1::vx
float vx() const
The x origin for the parameters.
SG::AuxElement::hasStore
bool hasStore() const
Return true if this object has an associated store.
Definition: AuxElement.cxx:398
python.PyAthena.v
v
Definition: PyAthena.py:154
y
#define y
xAOD::NeutralParticle_v1::operator=
NeutralParticle_v1 & operator=(const NeutralParticle_v1 &tp)
Assignment operator. This can involve creating and copying an Auxilary store, and so should be used s...
Definition: NeutralParticle_v1.cxx:28
AUXSTORE_PRIMITIVE_GETTER
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
Definition: AuxStoreAccessorMacros.h:59
xAOD::NeutralParticle_v1::m_perigeeParameters
CxxUtils::CachedValue< Trk::NeutralPerigee > m_perigeeParameters
Cached NeutralPerigee, built from this object.
Definition: NeutralParticle_v1.h:144
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
xAOD::NeutralParticle_v1
Class describing a NeutralParticle.
Definition: NeutralParticle_v1.h:40
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
xAOD::IParticle::operator=
IParticle & operator=(const IParticle &)=default
xAOD::NeutralParticle_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.