ATLAS Offline Software
FastCaloSimCaloExtrapolation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef FastCaloSimCaloExtrapolation_H
6 #define FastCaloSimCaloExtrapolation_H
7 
9 
14 
15 
17 
18 class TFCSTruthState;
19 class G4FieldTrack;
20 
21 
23 {
26  unsigned int number;
27 
28 };
29 
30 
31 class FastCaloSimCaloExtrapolation: public extends<AthAlgTool, IFastCaloSimCaloExtrapolation>
32 {
33 
34 public:
35 
36  FastCaloSimCaloExtrapolation(const std::string& t, const std::string& n, const IInterface* p);
38 
39  virtual StatusCode initialize() override final;
40  virtual StatusCode finalize() override final;
41 
42  enum SUBPOS {
43  SUBPOS_MID = TFCSExtrapolationState::SUBPOS_MID, //MID=middle of calo layer
44  SUBPOS_ENT = TFCSExtrapolationState::SUBPOS_ENT, //ENT=entrance of calo layer
45  SUBPOS_EXT = TFCSExtrapolationState::SUBPOS_EXT //EXT=exit of calo layer
46  };
47 
49  INSIDE, //hit position is inside cylinder bounds
50  OUTSIDE, //hit position is outside cylinder bounds
51  ON //hit position is on cylinder bounds
52  };
53 
54  virtual void extrapolate(TFCSExtrapolationState& result, const TFCSTruthState* truth, const std::vector<G4FieldTrack>& caloSteps) const override final;
55  virtual void extrapolate(TFCSExtrapolationState& result, const TFCSTruthState* truth) const override final;
56 
57 protected:
58 
59  const IFastCaloSimGeometryHelper* GetCaloGeometry() const {return &(*m_CaloGeometryHelper);};
60 
61  /*Main extrapolation methods*/
62 
64  bool extrapolateToCylinder(const std::vector<G4FieldTrack>& caloSteps, float cylR, float cylZ, Amg::Vector3D& extPos, Amg::Vector3D& momDir) const;
66  void extrapolateToID(TFCSExtrapolationState& result, const std::vector<G4FieldTrack>& caloSteps, const TFCSTruthState* truth) const;
68  void extrapolateToLayers(TFCSExtrapolationState& result, const std::vector<G4FieldTrack>& caloSteps, const TFCSTruthState* truth) const;
69 
70  /*Extrapolator helper methods*/
71 
73  void findPCA(float cylR, float cylZ, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2, Amg::Vector3D& PCA) const;
75  static double getPointLineSegmentDistance(Amg::Vector3D& point, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2) ;
77  void getIterativePCA(float cylR, float cylZ, Amg::Vector3D& BoundA, Amg::Vector3D& BoundB, Amg::Vector3D& PCA) const;
79  static bool isOnSegment(Amg::Vector3D& point, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2) ;
81  static bool cylinderEndcapIntersection(float cylR, float cylZ, bool positiveEndcap, Amg::Vector3D& pointA, Amg::Vector3D& pointB, Amg::Vector3D& intersection) ;
84  bool extrapolateWithIntersection(const std::vector<G4FieldTrack>& caloSteps, float cylR, float cylZ, Amg::Vector3D& extPos, Amg::Vector3D& momDir) const;
86  bool extrapolateWithPCA(const std::vector<G4FieldTrack>& caloSteps, float cylR, float cylZ, Amg::Vector3D& extPos, Amg::Vector3D& momDir) const;
88  static bool doesTravelThroughSurface(float cylR, float cylZ, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2) ;
90  int whichIntersection(float cylR, float cylZ, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2, Amg::Vector3D& intersectionA, Amg::Vector3D intersectionB) const;
92  int circleLineIntersection2D(float circR, Amg::Vector3D& pointA, Amg::Vector3D& pointB, Amg::Vector3D& intersectA, Amg::Vector3D& intersectB) const;
94  int cylinderLineIntersection(float cylR, float cylZ, Amg::Vector3D& pointA, Amg::Vector3D& pointB, Amg::Vector3D& intersectA, Amg::Vector3D& intersectB) const;
96  static enum HITPOSITION whereOnCylinder(float cylR, float cylZ, Amg::Vector3D& hitPos) ;
98  static Amg::Vector3D projectOnCylinder(float cylR, float cylZ, Amg::Vector3D& hitPos) ;
100  CylinderIntersections getCylinderIntersections(float cylR, float cylZ, Amg::Vector3D& hitPos1, Amg::Vector3D& hitPos2) const;
101 
102  //helper methods for calo geometry
103  void minmaxeta(int sample, double eta, double& mineta, double& maxeta) const;
104  bool isCaloBarrel(int sample) const;
105  double deta (int sample, double eta) const;
106  double rzmid(int sample, double eta) const;
107  double rzent(int sample, double eta) const;
108  double rzext(int sample, double eta) const;
109  double rmid (int sample, double eta) const;
110  double rent (int sample, double eta) const;
111  double rext (int sample, double eta) const;
112  double zmid (int sample, double eta) const;
113  double zent (int sample, double eta) const;
114  double zext (int sample, double eta) const;
115  double rpos (int sample, double eta, int subpos = CaloSubPos::SUBPOS_MID) const;
116  double zpos (int sample, double eta, int subpos = CaloSubPos::SUBPOS_MID) const;
117  double rzpos(int sample, double eta, int subpos = CaloSubPos::SUBPOS_MID) const;
118 
119  HepPDT::ParticleDataTable* m_particleDataTable{nullptr};
120 
121  //uniquely defined ID-Calo surfaces
122  FloatArrayProperty m_CaloBoundaryR{this, "CaloBoundaryR", {1148.0,120.0,41.0}};
123  FloatArrayProperty m_CaloBoundaryZ{this, "CaloBoundaryZ", {3550.0,4587.0,4587.0}};
124 
125  // FastCaloSim particle transport with ATLAS tracking tools
126  PublicToolHandle<IFastCaloSimCaloTransportation> m_CaloTransportation{this, "CaloTransportation", "FastCaloSimCaloTransportation"};
127  // FastCaloSim geometry helper
128  PublicToolHandle<IFastCaloSimGeometryHelper> m_CaloGeometryHelper{this, "CaloGeometryHelper", "FastCaloSimGeometryHelper"};
129 
130 };
131 
132 #endif // FastCaloSimCaloExtrapolation_H
FastCaloSimCaloExtrapolation::rzext
double rzext(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:930
FastCaloSimCaloExtrapolation
Definition: FastCaloSimCaloExtrapolation.h:32
FastCaloSimCaloExtrapolation::doesTravelThroughSurface
static bool doesTravelThroughSurface(float cylR, float cylZ, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2)
Returns true if the line segment spanned by hitPos1 and hitPos2 crosses the cylinder surface,...
Definition: FastCaloSimCaloExtrapolation.cxx:866
get_generator_info.result
result
Definition: get_generator_info.py:21
IFastCaloSimCaloExtrapolation.h
FastCaloSimCaloExtrapolation::SUBPOS_EXT
@ SUBPOS_EXT
Definition: FastCaloSimCaloExtrapolation.h:45
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
FastCaloSimCaloExtrapolation::deta
double deta(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:880
FastCaloSimCaloExtrapolation::rext
double rext(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:920
FastCaloSimCaloExtrapolation::circleLineIntersection2D
int circleLineIntersection2D(float circR, Amg::Vector3D &pointA, Amg::Vector3D &pointB, Amg::Vector3D &intersectA, Amg::Vector3D &intersectB) const
Analytically computes 2D intersections between circle of radius circR and (infinite) line spanned by ...
Definition: FastCaloSimCaloExtrapolation.cxx:565
FastCaloSimCaloExtrapolation::isOnSegment
static bool isOnSegment(Amg::Vector3D &point, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2)
Returns true if point lies on the line segment spanned by hitPos1 and hitPos2, otherwise returns fals...
Definition: FastCaloSimCaloExtrapolation.cxx:871
FastCaloSimCaloExtrapolation::zpos
double zpos(int sample, double eta, int subpos=CaloSubPos::SUBPOS_MID) const
Definition: FastCaloSimCaloExtrapolation.cxx:940
CylinderIntersections::second
Amg::Vector3D second
Definition: FastCaloSimCaloExtrapolation.h:25
TFCSExtrapolationState::SUBPOS_ENT
@ SUBPOS_ENT
Definition: TFCSExtrapolationState.h:21
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TFCSExtrapolationState::SUBPOS_MID
@ SUBPOS_MID
Definition: TFCSExtrapolationState.h:20
FastCaloSimCaloExtrapolation::FastCaloSimCaloExtrapolation
FastCaloSimCaloExtrapolation(const std::string &t, const std::string &n, const IInterface *p)
Definition: FastCaloSimCaloExtrapolation.cxx:47
TFCSExtrapolationState::SUBPOS_EXT
@ SUBPOS_EXT
Definition: TFCSExtrapolationState.h:22
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
FastCaloSimCaloExtrapolation::extrapolateWithIntersection
bool extrapolateWithIntersection(const std::vector< G4FieldTrack > &caloSteps, float cylR, float cylZ, Amg::Vector3D &extPos, Amg::Vector3D &momDir) const
Extrapolates position on cylinder by finding intersections of subsequent hit positions,...
Definition: FastCaloSimCaloExtrapolation.cxx:264
FastCaloSimCaloExtrapolation::initialize
virtual StatusCode initialize() override final
Definition: FastCaloSimCaloExtrapolation.cxx:52
FastCaloSimCaloExtrapolation::projectOnCylinder
static Amg::Vector3D projectOnCylinder(float cylR, float cylZ, Amg::Vector3D &hitPos)
Projects position hitPos onto the cylinder surface and returns projected position.
Definition: FastCaloSimCaloExtrapolation.cxx:614
CylinderIntersections::first
Amg::Vector3D first
Definition: FastCaloSimCaloExtrapolation.h:24
CachedPointer.h
Cached pointer with atomic update.
FastCaloSimCaloExtrapolation::findPCA
void findPCA(float cylR, float cylZ, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2, Amg::Vector3D &PCA) const
Finds Point of Closest Approach (PCA) on the cylinder defined by radius cylR and half-length cylZ of ...
Definition: FastCaloSimCaloExtrapolation.cxx:382
FastCaloSimCaloExtrapolation::zext
double zext(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:925
FastCaloSimCaloExtrapolation::getCylinderIntersections
CylinderIntersections getCylinderIntersections(float cylR, float cylZ, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2) const
Analytically computes the intersection between the (infinite) line spanned by hitPos1 and hitPos2 wit...
Definition: FastCaloSimCaloExtrapolation.cxx:649
FastCaloSimCaloExtrapolation::finalize
virtual StatusCode finalize() override final
Definition: FastCaloSimCaloExtrapolation.cxx:66
FastCaloSimCaloExtrapolation::SUBPOS_ENT
@ SUBPOS_ENT
Definition: FastCaloSimCaloExtrapolation.h:44
FastCaloSimCaloExtrapolation::m_CaloBoundaryR
FloatArrayProperty m_CaloBoundaryR
Definition: FastCaloSimCaloExtrapolation.h:122
SUBPOS_MID
@ SUBPOS_MID
Definition: FastCaloSim_CaloCell_ID.h:11
GeoPrimitives.h
FastCaloSimCaloExtrapolation::zent
double zent(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:910
IFastCaloSimCaloTransportation.h
FastCaloSimCaloExtrapolation::getPointLineSegmentDistance
static double getPointLineSegmentDistance(Amg::Vector3D &point, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2)
Computes the distance between a point and the line segment spanned by hitPos1 and hitPos2.
Definition: FastCaloSimCaloExtrapolation.cxx:834
FastCaloSimCaloExtrapolation::INSIDE
@ INSIDE
Definition: FastCaloSimCaloExtrapolation.h:49
IFastCaloSimGeometryHelper.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
FastCaloSimCaloExtrapolation::ON
@ ON
Definition: FastCaloSimCaloExtrapolation.h:51
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
FastCaloSimCaloExtrapolation::isCaloBarrel
bool isCaloBarrel(int sample) const
Definition: FastCaloSimCaloExtrapolation.cxx:875
beamspotman.n
n
Definition: beamspotman.py:731
FastCaloSimCaloExtrapolation::~FastCaloSimCaloExtrapolation
~FastCaloSimCaloExtrapolation()=default
FastCaloSimCaloExtrapolation::rmid
double rmid(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:890
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FastCaloSimCaloExtrapolation::m_particleDataTable
HepPDT::ParticleDataTable * m_particleDataTable
Definition: FastCaloSimCaloExtrapolation.h:119
FastCaloSimCaloExtrapolation::whichIntersection
int whichIntersection(float cylR, float cylZ, Amg::Vector3D &hitPos1, Amg::Vector3D &hitPos2, Amg::Vector3D &intersectionA, Amg::Vector3D intersectionB) const
Returns ID of more sensible intersection between line segment spanned by hitPos1 and hitPos2 and cyli...
Definition: FastCaloSimCaloExtrapolation.cxx:796
FastCaloSimCaloExtrapolation::rzent
double rzent(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:915
FastCaloSimCaloExtrapolation::whereOnCylinder
static enum HITPOSITION whereOnCylinder(float cylR, float cylZ, Amg::Vector3D &hitPos)
Checks if position of hitPos is inside, outside or on the cylinder bounds.
Definition: FastCaloSimCaloExtrapolation.cxx:849
FastCaloSimCaloExtrapolation::m_CaloBoundaryZ
FloatArrayProperty m_CaloBoundaryZ
Definition: FastCaloSimCaloExtrapolation.h:123
FastCaloSimCaloExtrapolation::rzpos
double rzpos(int sample, double eta, int subpos=CaloSubPos::SUBPOS_MID) const
Definition: FastCaloSimCaloExtrapolation.cxx:945
FastCaloSimCaloExtrapolation::OUTSIDE
@ OUTSIDE
Definition: FastCaloSimCaloExtrapolation.h:50
FastCaloSimCaloExtrapolation::m_CaloGeometryHelper
PublicToolHandle< IFastCaloSimGeometryHelper > m_CaloGeometryHelper
Definition: FastCaloSimCaloExtrapolation.h:128
CylinderIntersections::number
unsigned int number
Definition: FastCaloSimCaloExtrapolation.h:26
FastCaloSimCaloExtrapolation::cylinderEndcapIntersection
static bool cylinderEndcapIntersection(float cylR, float cylZ, bool positiveEndcap, Amg::Vector3D &pointA, Amg::Vector3D &pointB, Amg::Vector3D &intersection)
Computes intersection between the (infinite) line spanned by pointA and pointB with the positive (neg...
Definition: FastCaloSimCaloExtrapolation.cxx:772
IFastCaloSimGeometryHelper
Definition: IFastCaloSimGeometryHelper.h:18
FastCaloSimCaloExtrapolation::cylinderLineIntersection
int cylinderLineIntersection(float cylR, float cylZ, Amg::Vector3D &pointA, Amg::Vector3D &pointB, Amg::Vector3D &intersectA, Amg::Vector3D &intersectB) const
Analytically computes the intersection between the (infinite) line defined by pointA and pointB and t...
Definition: FastCaloSimCaloExtrapolation.cxx:730
FastCaloSimCaloExtrapolation::rzmid
double rzmid(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:900
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
FastCaloSimCaloExtrapolation::m_CaloTransportation
PublicToolHandle< IFastCaloSimCaloTransportation > m_CaloTransportation
Definition: FastCaloSimCaloExtrapolation.h:126
FastCaloSimCaloExtrapolation::extrapolate
virtual void extrapolate(TFCSExtrapolationState &result, const TFCSTruthState *truth, const std::vector< G4FieldTrack > &caloSteps) const override final
Definition: FastCaloSimCaloExtrapolation.cxx:72
FastCaloSimCaloExtrapolation::extrapolateToLayers
void extrapolateToLayers(TFCSExtrapolationState &result, const std::vector< G4FieldTrack > &caloSteps, const TFCSTruthState *truth) const
Extrapolates to all other layers of the calorimeter.
Definition: FastCaloSimCaloExtrapolation.cxx:166
FastCaloSimCaloExtrapolation::SUBPOS_MID
@ SUBPOS_MID
Definition: FastCaloSimCaloExtrapolation.h:43
TFCSExtrapolationState.h
FastCaloSimCaloExtrapolation::rpos
double rpos(int sample, double eta, int subpos=CaloSubPos::SUBPOS_MID) const
Definition: FastCaloSimCaloExtrapolation.cxx:935
CylinderIntersections
Definition: FastCaloSimCaloExtrapolation.h:23
FastCaloSimCaloExtrapolation::getIterativePCA
void getIterativePCA(float cylR, float cylZ, Amg::Vector3D &BoundA, Amg::Vector3D &BoundB, Amg::Vector3D &PCA) const
Finds PCA iteratively given two bounds A and B on a line segment, used for (rare) cases with no easy ...
Definition: FastCaloSimCaloExtrapolation.cxx:488
FastCaloSimCaloExtrapolation::extrapolateToCylinder
bool extrapolateToCylinder(const std::vector< G4FieldTrack > &caloSteps, float cylR, float cylZ, Amg::Vector3D &extPos, Amg::Vector3D &momDir) const
Finds best extrapolation extPos from the caloSteps for a cylinder defined by radius cylR and half-len...
Definition: FastCaloSimCaloExtrapolation.cxx:237
FastCaloSimCaloExtrapolation::zmid
double zmid(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:895
FastCaloSimCaloExtrapolation::GetCaloGeometry
const IFastCaloSimGeometryHelper * GetCaloGeometry() const
Definition: FastCaloSimCaloExtrapolation.h:59
FastCaloSimCaloExtrapolation::rent
double rent(int sample, double eta) const
Definition: FastCaloSimCaloExtrapolation.cxx:905
TFCSTruthState
Definition: TFCSTruthState.h:13
FastCaloSimCaloExtrapolation::SUBPOS
SUBPOS
Definition: FastCaloSimCaloExtrapolation.h:42
FastCaloSimCaloExtrapolation::extrapolateToID
void extrapolateToID(TFCSExtrapolationState &result, const std::vector< G4FieldTrack > &caloSteps, const TFCSTruthState *truth) const
Extrapolates to ID using three uniquely defined cylinder surfaces.
Definition: FastCaloSimCaloExtrapolation.cxx:94
FastCaloSimCaloExtrapolation::minmaxeta
void minmaxeta(int sample, double eta, double &mineta, double &maxeta) const
Definition: FastCaloSimCaloExtrapolation.cxx:885
FastCaloSimCaloExtrapolation::HITPOSITION
HITPOSITION
Definition: FastCaloSimCaloExtrapolation.h:48
FastCaloSimCaloExtrapolation::extrapolateWithPCA
bool extrapolateWithPCA(const std::vector< G4FieldTrack > &caloSteps, float cylR, float cylZ, Amg::Vector3D &extPos, Amg::Vector3D &momDir) const
Extrapolates to the cylinder using the PCA to the polygon spanned by the individual line segments fro...
Definition: FastCaloSimCaloExtrapolation.cxx:342