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
16 
17 
18 namespace xAOD {
19 
21  : IParticle(){
22  }
23 
25  : IParticle( tp ) {
27  }
28 
30  if(this == &tp) return *this;
31 
32  if(!hasStore() ) makePrivateStore();
33  this->IParticle::operator=( tp );
34 #ifndef XAOD_ANALYSIS
35  m_perigeeParameters.reset();
36 #endif // not XAOD_ANALYSIS
37  return *this;
38  }
39 
41  }
42 
43  double NeutralParticle_v1::pt() const {
44  return genvecP4().Pt();
45  }
46 
47  double NeutralParticle_v1::eta() const {
48  return genvecP4().Eta();
49  }
50 
52 
53 
56  }
57 
59 
60 
61  double NeutralParticle_v1::rapidity() const {
62  return genvecP4().Rapidity();
63  }
64 
66  using namespace std;
67  float p = 1/fabs(oneOverP());
68  float thetaT = theta();
69  float phiT = phi();
70  float sinTheta= sin(thetaT);
71  float px = p*sinTheta*cos(phiT);
72  float py = p*sinTheta*sin(phiT);
73  float pz = p*cos(thetaT);
74  return GenVecFourMom_t(px, py, pz, m());
75  }
76 
78  using namespace std;
79  FourMom_t p4;
80  float p = 1/fabs(oneOverP());
81  float thetaT = theta();
82  float phiT = phi();
83  float sinTheta= sin(thetaT);
84  float px = p*sinTheta*cos(phiT);
85  float py = p*sinTheta*sin(phiT);
86  float pz = p*cos(thetaT);
87  float e = pow (m(),2) +
88  pow( px,2) + pow( py,2) + pow( pz,2);
89  p4.SetPxPyPzE( px, py, pz, sqrt(e) );
90  return p4;
91  }
92 
94  return Type::NeutralParticle;
95  }
96 
97 
103 
104  const DefiningParameters_t NeutralParticle_v1::definingParameters() const{
105  DefiningParameters_t tmp;
106  tmp << d0(),z0(),phi0(),theta(),oneOverP();
107  return tmp;
108  }
109 
110  void NeutralParticle_v1::setDefiningParameters(float d0, float z0, float phi0, float theta, float oneOverP) {
111 #ifndef XAOD_ANALYSIS
112  if(m_perigeeParameters.isValid()) {
113  m_perigeeParameters.reset();
114  }
115 #endif // not XAOD_ANALYSIS
116  static const Accessor< float > acc1( "d0" );
117  acc1( *this ) = d0;
118 
119  static const Accessor< float > acc2( "z0" );
120  acc2( *this ) = z0;
121 
122  static const Accessor< float > acc3( "phi" );
123  acc3( *this ) = phi0;
124 
125  static const Accessor< float > acc4( "theta" );
126  acc4( *this ) = theta;
127 
128  static const Accessor< float > acc5( "oneOverP" );
129  acc5( *this ) = oneOverP;
130 
131  return;
132  }
133 
134  void NeutralParticle_v1::setDefiningParametersCovMatrix(const xAOD::ParametersCovMatrix_t& cov){
135 #ifndef XAOD_ANALYSIS
136  if(m_perigeeParameters.isValid()) {
137  m_perigeeParameters.reset();
138  }
139 #endif // not XAOD_ANALYSIS
140 
141  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
142  std::vector<float>& v = acc(*this);
143  v.reserve(15);
144  for (size_t irow = 0; irow<5; ++irow)
145  for (size_t icol =0; icol<=irow; ++icol)
146  v.push_back(cov(icol,irow));
147  }
148 
149  const xAOD::ParametersCovMatrix_t NeutralParticle_v1::definingParametersCovMatrix() const {
150  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
151  std::vector<float> v = acc(*this);
152  std::vector<float>::const_iterator it = v.begin();
153  xAOD::ParametersCovMatrix_t cov;
154  cov.setZero();
155  for (size_t irow = 0; irow<5; ++irow){
156  for (size_t icol =0; icol<=irow; ++icol){
157  cov.fillSymmetric(icol,irow, *it++);
158  }
159  }
160  return cov;
161  }
162 
163  const std::vector<float>& NeutralParticle_v1::definingParametersCovMatrixVec() const {
164  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
165  return acc(*this);
166  }
167 
169  static const Accessor< std::vector<float> > acc( "definingParametersCovMatrix" );
170  acc(*this)=cov;
171  }
172 
176 
177  void NeutralParticle_v1::setParametersOrigin(float x, float y, float z){
178  static const Accessor< float > acc1( "vx" );
179  acc1( *this ) = x;
180 
181  static const Accessor< float > acc2( "vy" );
182  acc2( *this ) = y;
183 
184  static const Accessor< float > acc3( "vz" );
185  acc3( *this ) = z;
186  }
187 
188 #ifndef XAOD_ANALYSIS
190 
191  // Require the cache to be valid and check if the cached pointer has been set
192  if(m_perigeeParameters.isValid()){
193  return *(m_perigeeParameters.ptr());
194  }
195  static const Accessor< float > acc1( "d0" );
196  static const Accessor< float > acc2( "z0" );
197  static const Accessor< float > acc3( "phi" );
198  static const Accessor< float > acc4( "theta" );
199  static const Accessor< float > acc5( "oneOverP" );
200  static const Accessor< std::vector<float> > acc6( "definingParametersCovMatrix" );
201  ParametersCovMatrix_t cov;
202  cov.setZero();
203  auto it= acc6(*this).begin();
204  for (size_t irow = 0; irow<5; ++irow){
205  for (size_t icol =0; icol<=irow; ++icol){
206  cov.fillSymmetric(irow,icol,*it++) ;
207  }
208  }
209  Trk::NeutralPerigee tmpPerigeeParameters(acc1(*this),acc2(*this),acc3(*this),acc4(*this),acc5(*this),
210  Trk::PerigeeSurface(Amg::Vector3D(vx(),vy(),vz())),std::move(cov));
211  m_perigeeParameters.set(tmpPerigeeParameters);
212  return *(m_perigeeParameters.ptr());
213  }
214 #endif // not XAOD_ANALYSIS
215 
217 #ifndef XAOD_ANALYSIS
218  m_perigeeParameters.reset();
219 #endif // not XAOD_ANALYSIS
220  }
221 
222 } // 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:177
test_pyathena.px
px
Definition: test_pyathena.py:18
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:104
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:149
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:189
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:163
skel.it
it
Definition: skel.GENtoEVGEN.py:407
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:200
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::NeutralParticle_v1::NeutralParticle_v1
NeutralParticle_v1()
Default constructor.
Definition: NeutralParticle_v1.cxx:20
xAOD::NeutralParticle_v1::m
virtual double m() const
The invariant mass of the particle..
Definition: NeutralParticle_v1.cxx:54
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:43
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:47
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:134
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:110
xAOD::NeutralParticle_v1::~NeutralParticle_v1
~NeutralParticle_v1()
Destructor.
Definition: NeutralParticle_v1.cxx:40
ParticleConstants::PDG2011::chargedPionMassInMeV
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)
Definition: ParticleConstants.h:41
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:168
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ParticleConstants.h
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:77
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:216
xAOD::NeutralParticle_v1::genvecP4
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form.
Definition: NeutralParticle_v1.cxx:65
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:93
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:29
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
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
xAOD::NeutralParticle_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.