LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TransverseTrackHitsBaseTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 void TransverseTrackHitsBaseTool::GetTrackHits3D(const CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap,
22  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 
43 void 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 
64 double TransverseTrackHitsBaseTool::GetTransverseChi2(const CartesianVector &position2D, const TwoDSlidingFitResult &fitResult) const
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()) &&
73  ((position2D.GetX() - maxX) < +std::numeric_limits<float>::epsilon()))
74  return 0.;
75 
76  const float minLayerDistanceSquared((position2D - fitResult.GetGlobalMinLayerPosition()).GetMagnitudeSquared());
77  const float maxLayerDistanceSquared((position2D - fitResult.GetGlobalMaxLayerPosition()).GetMagnitudeSquared());
78 
79  double px(0.), pz(0.);
80 
81  if (minLayerDistanceSquared < maxLayerDistanceSquared)
82  {
83  px = fitResult.GetGlobalMinLayerDirection().GetX();
84  pz = fitResult.GetGlobalMinLayerDirection().GetZ();
85  }
86  else if (maxLayerDistanceSquared < minLayerDistanceSquared)
87  {
88  px = fitResult.GetGlobalMaxLayerDirection().GetX();
89  pz = fitResult.GetGlobalMaxLayerDirection().GetZ();
90  }
91 
92  if (std::fabs(px) > std::numeric_limits<double>::epsilon())
93  {
94  return (0.5 * (pz * pz) / (px * px)); // TODO: Figure out the appropriate scale factor
95  }
96 
97  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
98 }
99 
100 } // namespace lar_content
Header file for the transverse track hits base tool.
Proto hits are temporary constructs to be used during iterative 3D hit procedure. ...
std::map< pandora::HitType, TwoDSlidingFitResult > MatchedSlidingFitMap
const pandora::CaloHit * GetParentCaloHit2D() const
Get the address of the parent 2D calo hit.
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
bool IsPositionSet() const
Whether the proto hit position is set.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
const pandora::CartesianVector & GetPosition3D() const
Get the output 3D position.
Header file for the three dimensional hit creation algorithm class.
Header file for the geometry helper class.
Int_t max
Definition: plot.C:27
double GetChi2() const
Get the chi squared value.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
Int_t min
Definition: plot.C:26
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
Set position 3D.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.