Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TransverseTrackHitsBaseTool.cc
Go to the documentation of this file.
1
10
13
15
16using namespace pandora;
17
18namespace lar_content
19{
20
22 const CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const
23{
24 for (const CaloHit *const pCaloHit2D : inputTwoDHits)
25 {
26 try
27 {
28 ProtoHit protoHit(pCaloHit2D);
29 this->GetTransverseTrackHit3D(matchedSlidingFitMap, protoHit);
30 this->AddTransverseChi2(matchedSlidingFitMap, protoHit);
31
32 if (protoHit.IsPositionSet() && (protoHit.GetChi2() < m_chiSquaredCut))
33 protoHitVector.push_back(protoHit);
34 }
35 catch (StatusCodeException &)
36 {
37 }
38 }
39}
40
41//------------------------------------------------------------------------------------------------------------------------------------------
42
43void TransverseTrackHitsBaseTool::AddTransverseChi2(const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const
44{
45 // TODO Develop a proper treatment of the |dz/dx| * sigmaX uncertainty
46 double chiSquared(protoHit.GetChi2());
47 const HitType inputHitType(protoHit.GetParentCaloHit2D()->GetHitType());
48 const CartesianVector &inputPosition3D(protoHit.GetPosition3D());
49
50 for (const MatchedSlidingFitMap::value_type &mapEntry : matchedSlidingFitMap)
51 {
52 if (mapEntry.first == inputHitType)
53 continue;
54
55 const CartesianVector inputPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), inputPosition3D, mapEntry.first));
56 chiSquared += this->GetTransverseChi2(inputPosition2D, mapEntry.second);
57 }
58
59 protoHit.SetPosition3D(inputPosition3D, chiSquared);
60}
61
62//------------------------------------------------------------------------------------------------------------------------------------------
63
65{
66 const float minLayerX(fitResult.GetGlobalMinLayerPosition().GetX());
67 const float maxLayerX(fitResult.GetGlobalMaxLayerPosition().GetX());
68
69 const float minX(std::min(minLayerX, maxLayerX));
70 const float maxX(std::max(minLayerX, maxLayerX));
71
72 if (((position2D.GetX() - minX) > -std::numeric_limits<float>::epsilon()) && ((position2D.GetX() - maxX) < +std::numeric_limits<float>::epsilon()))
73 return 0.;
74
75 const float minLayerDistanceSquared((position2D - fitResult.GetGlobalMinLayerPosition()).GetMagnitudeSquared());
76 const float maxLayerDistanceSquared((position2D - fitResult.GetGlobalMaxLayerPosition()).GetMagnitudeSquared());
77
78 double px(0.), pz(0.);
79
80 if (minLayerDistanceSquared < maxLayerDistanceSquared)
81 {
82 px = fitResult.GetGlobalMinLayerDirection().GetX();
83 pz = fitResult.GetGlobalMinLayerDirection().GetZ();
84 }
85 else if (maxLayerDistanceSquared < minLayerDistanceSquared)
86 {
87 px = fitResult.GetGlobalMaxLayerDirection().GetX();
88 pz = fitResult.GetGlobalMaxLayerDirection().GetZ();
89 }
90
91 if (std::fabs(px) > std::numeric_limits<double>::epsilon())
92 {
93 return (0.5 * (pz * pz) / (px * px)); // TODO: Figure out the appropriate scale factor
94 }
95
96 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
97}
98
99} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the geometry helper class.
Header file for the three dimensional hit creation algorithm class.
Header file for the transverse track hits base tool.
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
double m_chiSquaredCut
The chi squared cut (accept only values below the cut value)
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
Proto hits are temporary constructs to be used during iterative 3D hit procedure.
void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
Set position 3D.
bool IsPositionSet() const
Whether the proto hit position is set.
const pandora::CaloHit * GetParentCaloHit2D() const
Get the address of the parent 2D calo hit.
const pandora::CartesianVector & GetPosition3D() const
Get the output 3D position.
std::map< pandora::HitType, TwoDSlidingFitResult > MatchedSlidingFitMap
virtual void GetTransverseTrackHit3D(const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const =0
Get the three dimensional position using a provided two dimensional calo hit and sliding linear fits ...
virtual void AddTransverseChi2(const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const
Calculate an additional contribution to the chi-squared based on the steepness of the track.
double GetTransverseChi2(const pandora::CartesianVector &position2D, const TwoDSlidingFitResult &fitResult) const
Calculate an additional contribution to the chi-squared based on the steepness of the track.
virtual void GetTrackHits3D(const pandora::CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const
Calculate 3D hits from an input list of 2D hits.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
CaloHit class.
Definition CaloHit.h:26
HitType GetHitType() const
Get the calorimeter hit type.
Definition CaloHit.h:441
CartesianVector class.
float GetX() const
Get the cartesian x coordinate.
float GetZ() const
Get the cartesian z coordinate.
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::vector< const CaloHit * > CaloHitVector