ATLAS Offline Software
FPTracker/src/Particle.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "FPTracker/Particle.h"
8 #include <sstream>
9 #include <cmath>
10 #include <iomanip>
11 #include <iostream>
12 namespace FPTracker{
14  m_position(0., 0., 0.),
15  m_momentum(0),
16  m_direction( Point(0., 0., 0.) ),
17  m_outOfAperture(false)
18  {
19  }
20 
21  Particle::Particle(double x, double y, double z, double px, double py, double pz):
22  m_position(x, y, z),
23  m_momentum(std::sqrt(px*px+py*py+pz*pz)),
24  m_direction(Point(px/m_momentum, py/m_momentum, pz/m_momentum)),
25  m_outOfAperture(m_position.perp2()>FPTrackerConstants::beamPipeRadius2 ? true:false){
26  }
27 
28  const Point& Particle::position() const { return m_position; }
31 
34  }
35 
37  m_position[0] = disp[0] - m_beamCoordinateShift[0]; // when the disp from mag center = beam axis, part. position = 0 in global coor
38  m_position[1] = disp[1] - m_beamCoordinateShift[1];
39  }
40 
43  }
44 
46  m_beamCoordinateShift = -1.*(be->position()).transverse();
47  }
48 
50  return m_position.transverse();
51  }
52  const Point& Particle::direction() const {return m_direction;}
54  double Particle::z() const {return m_position.z();}
55  double& Particle::z() {return m_position[2];}
56  double Particle::momentum() const {return m_momentum;}
58 
59  void Particle::setOutOfAperture(bool out){if(out){m_outOfAperture = true;}} //once out, always out
60  void Particle::addMsg( const std::string& msg){ m_msg += msg; }
61  std::string Particle::str() const{
62  std::ostringstream ost;
63  ost<<"Part: pos:"<<std::setprecision(4)<<std::fixed<<std::boolalpha//<<std::right
64  <<" x "<<std::setw(9)<<std::setprecision(6)<<m_position.x()
65  <<" y "<<std::setw(9)<<m_position.y()
66  <<" z "<<std::setw(7)<<std::setprecision(2)<<m_position.z()
67  <<" dir "<<std::setprecision(6)
68  <<" xp "<<std::setw(9)<<m_direction.x()
69  <<" yp "<<std::setw(9)<<m_direction.y()
70  <<" zp "<<std::setw(9)<<m_direction.z()
71  << " mom: "<<std::setprecision(0)<<m_momentum
72  <<" lost "<<m_outOfAperture
73  <<" offx "<<std::setprecision(6)<<std::setw(9)<<m_beamCoordinateShift.x()
74  <<" offy "<<std::setprecision(6)<<std::setw(9)<<m_beamCoordinateShift.y()
75  <<'\n'
76  <<" xrb "<<std::setw(9)<<std::setprecision(6)<<this->positionRelBeam().x()
77  <<" yrb "<<std::setw(9)<<this->positionRelBeam().y()
78  <<" zrb "<<std::setw(7)<<std::setprecision(2)<<this->positionRelBeam().z();
79  if( not m_msg.empty() )
80  {
81  ost<<"\n msg " <<m_msg;
82  }
83  return ost.str();
84  }
85 }
FPTracker::IBeamElement
Definition: FPTracker/FPTracker/IBeamElement.h:23
FPTracker::Particle::Particle
Particle()
Definition: FPTracker/src/Particle.cxx:13
FPTracker::Particle::transversePosition
TransversePoint transversePosition() const
Definition: FPTracker/src/Particle.cxx:49
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
test_pyathena.px
px
Definition: test_pyathena.py:18
FPTracker::Point::x
double x() const
Definition: FPTracker/src/Point.cxx:17
FPTracker::Particle::setOutOfAperture
void setOutOfAperture(bool out)
Definition: FPTracker/src/Particle.cxx:59
FPTracker::Particle::m_msg
std::string m_msg
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:59
FPTracker::Particle::m_momentum
double m_momentum
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:55
FPTracker::Point::transverse
TransversePoint transverse() const
Definition: FPTracker/src/Point.cxx:23
FPTracker::Point::y
double y() const
Definition: FPTracker/src/Point.cxx:18
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
FPTracker::Particle::m_outOfAperture
bool m_outOfAperture
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:57
FPTracker::Particle::positionRelBeam
Point positionRelBeam() const
Definition: FPTracker/src/Particle.cxx:30
perp2
Scalar perp2() const
perp2 method - perpendicular length squared
Definition: AmgMatrixBasePlugin.h:36
FPTracker::Particle::isOutOfAperture
bool isOutOfAperture() const
Definition: FPTracker/src/Particle.cxx:57
x
#define x
FPTracker::Particle::m_position
Point m_position
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:51
FPTracker::Particle::addMsg
void addMsg(const std::string &)
Definition: FPTracker/src/Particle.cxx:60
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
FPTrackerConstants.h
FPTracker::Particle::position
const Point & position() const
Definition: FPTracker/src/Particle.cxx:28
z
#define z
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
FPTracker::Particle::updatePositionFromDisplacement
void updatePositionFromDisplacement(const TransversePoint &)
Definition: FPTracker/src/Particle.cxx:36
FPTracker::Particle::momentum
double momentum() const
Definition: FPTracker/src/Particle.cxx:56
FPTracker::Point::z
double z() const
Definition: FPTracker/src/Point.cxx:19
FPTracker::Particle::direction
const Point & direction() const
Definition: FPTracker/src/Particle.cxx:52
FPTracker::Particle::m_direction
Point m_direction
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:56
Amg::py
@ py
Definition: GeoPrimitives.h:39
FPTracker::Point
Definition: FPTracker/FPTracker/Point.h:14
FPTracker::TransversePoint::x
double x() const
Definition: FPTracker/src/TransversePoint.cxx:16
FPTracker::FPTrackerConstants
Definition: FPTrackerConstants.h:13
IBeamElement.h
y
#define y
FPTracker::Particle::displacement
TransversePoint displacement() const
Definition: FPTracker/src/Particle.cxx:32
Particle.h
FPTracker
Definition: FPTracker/FPTracker/Beamline.h:12
FPTracker::Particle::str
std::string str() const
Definition: FPTracker/src/Particle.cxx:61
FPTracker::TransversePoint::y
double y() const
Definition: FPTracker/src/TransversePoint.cxx:17
FPTracker::TransversePoint
Definition: FPTracker/FPTracker/TransversePoint.h:12
PlotCalibFromCool.be
be
Definition: PlotCalibFromCool.py:398
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
FPTracker::Particle::setBeamCoordinateShift
void setBeamCoordinateShift(const TransversePoint &)
Definition: FPTracker/src/Particle.cxx:41
FPTracker::Particle::z
double z() const
Definition: FPTracker/src/Particle.cxx:54
FPTracker::Particle::m_beamCoordinateShift
TransversePoint m_beamCoordinateShift
Definition: ForwardDetectors/FPTracker/FPTracker/Particle.h:54