Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
DeltaRayShowerHitsTool.cc
Go to the documentation of this file.
1
10
14
17
18using namespace pandora;
19
20namespace lar_content
21{
22
24 const CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
25{
27 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
28
29 try
30 {
31 if (!LArPfoHelper::IsShower(pPfo) || (1 != pPfo->GetParentPfoList().size()))
32 return;
33
34 const ParticleFlowObject *const pParentPfo(pPfo->GetParentPfoList().front());
35
36 CaloHitList parentHitList3D;
37 LArPfoHelper::GetCaloHits(pParentPfo, TPC_3D, parentHitList3D);
38
39 if (parentHitList3D.empty())
40 return;
41
42 CaloHitVector parentHitVector3D(parentHitList3D.begin(), parentHitList3D.end());
43 std::sort(parentHitVector3D.begin(), parentHitVector3D.end(), LArClusterHelper::SortHitsByPosition);
44
45 this->CreateDeltaRayShowerHits3D(inputTwoDHits, parentHitVector3D, protoHitVector);
46 }
47 catch (StatusCodeException &)
48 {
49 }
50}
51
52//------------------------------------------------------------------------------------------------------------------------------------------
53
55 const CaloHitVector &inputTwoDHits, const CaloHitVector &parentHits3D, ProtoHitVector &protoHitVector) const
56{
57 for (const CaloHit *const pCaloHit2D : inputTwoDHits)
58 {
59 try
60 {
61 const HitType hitType(pCaloHit2D->GetHitType());
62 const HitType hitType1((TPC_VIEW_U == hitType) ? TPC_VIEW_V : (TPC_VIEW_V == hitType) ? TPC_VIEW_W : TPC_VIEW_U);
63 const HitType hitType2((TPC_VIEW_U == hitType) ? TPC_VIEW_W : (TPC_VIEW_V == hitType) ? TPC_VIEW_U : TPC_VIEW_V);
64
65 bool foundClosestPosition(false);
66 float closestDistanceSquared(std::numeric_limits<float>::max());
67 CartesianVector closestPosition3D(0.f, 0.f, 0.f);
68
69 for (const CaloHit *const pCaloHit3D : parentHits3D)
70 {
71 const CartesianVector thisPosition3D(pCaloHit3D->GetPositionVector());
72 const CartesianVector thisPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), thisPosition3D, hitType));
73 const float thisDistanceSquared((pCaloHit2D->GetPositionVector() - thisPosition2D).GetMagnitudeSquared());
74
75 if (thisDistanceSquared < closestDistanceSquared)
76 {
77 foundClosestPosition = true;
78 closestDistanceSquared = thisDistanceSquared;
79 closestPosition3D = thisPosition3D;
80 }
81 }
82
83 if (!foundClosestPosition)
84 continue;
85
86 const CartesianVector position1(LArGeometryHelper::ProjectPosition(this->GetPandora(), closestPosition3D, hitType1));
87 const CartesianVector position2(LArGeometryHelper::ProjectPosition(this->GetPandora(), closestPosition3D, hitType2));
88
89 ProtoHit protoHit(pCaloHit2D);
90 this->GetBestPosition3D(hitType1, hitType2, position1, position2, protoHit);
91
92 if (protoHit.IsPositionSet())
93 protoHitVector.push_back(protoHit);
94 }
95 catch (StatusCodeException &)
96 {
97 }
98 }
99}
100
101} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the delta ray shower hits tool.
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the pfo helper class.
Header file for the three dimensional hit creation algorithm class.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
void CreateDeltaRayShowerHits3D(const pandora::CaloHitVector &inputTwoDHits, const pandora::CaloHitVector &parentHits3D, ProtoHitVector &protoHitVector) const
Create three dimensional hits, using a list of input two dimensional hits and the 3D hits from the pa...
virtual void Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
Run the algorithm tool.
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
virtual void GetBestPosition3D(const pandora::HitType hitType1, const pandora::HitType hitType2, const pandora::CartesianPointVector &fitPositionList1, const pandora::CartesianPointVector &fitPositionList2, ProtoHit &protoHit) const
Get the three dimensional position using a provided two dimensional calo hit and candidate fit positi...
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
Proto hits are temporary constructs to be used during iterative 3D hit procedure.
bool IsPositionSet() const
Whether the proto hit position is set.
ThreeDHitCreationAlgorithm::Algorithm class.
CaloHit class.
Definition CaloHit.h:26
CartesianVector class.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetParentPfoList() const
Get the parent pfo list.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::vector< const CaloHit * > CaloHitVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList