9 #include "Pandora/AlgorithmHeaders.h" 26 m_slidingFitWindow(20),
27 m_minClusterCaloHits(5),
28 m_minClusterLengthSquared(3.
f * 3.
f)
47 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
57 bool changesMade(
false);
59 ClusterList splitClusters;
60 for (
const auto &mapEntry : splitPositionMap) splitClusters.push_back(mapEntry.first);
63 for (
const Cluster *pCurrentCluster : splitClusters)
65 CartesianPointVector splitPositions(splitPositionMap.at(pCurrentCluster));
71 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
72 throw StatusCodeException(STATUS_CODE_FAILURE);
74 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*
this, clusterListName));
78 const Cluster *pLowXCluster(NULL), *pHighXCluster(NULL);
81 if (this->
MakeClusterSplit(*sIter, pCurrentCluster, pLowXCluster, pHighXCluster))
86 pCurrentCluster = pHighXCluster;
100 template <
typename T>
102 const Cluster *&pHighXCluster)
const 104 CartesianVector lowXEnd(0.
f, 0.
f, 0.
f), highXEnd(0.
f, 0.
f, 0.
f);
113 catch (
const StatusCodeException &) {
return false;}
115 const CartesianVector lowXUnitVector((lowXEnd - splitPosition).GetUnitVector());
116 const CartesianVector highXUnitVector((highXEnd - splitPosition).GetUnitVector());
118 CaloHitList caloHitList;
119 pCurrentCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
121 std::string originalListName, fragmentListName;
122 const ClusterList clusterList(1, pCurrentCluster);
123 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*
this, clusterList, originalListName, fragmentListName));
126 pHighXCluster = NULL;
130 const CaloHit *
const pCaloHit = *hIter;
131 const CartesianVector unitVector((pCaloHit->GetPositionVector() - splitPosition).GetUnitVector());
133 const float dotProductLowX(unitVector.GetDotProduct(lowXUnitVector));
134 const float dotProductHighX(unitVector.GetDotProduct(highXUnitVector));
135 const Cluster *&pClusterToModify((dotProductLowX > dotProductHighX) ? pLowXCluster : pHighXCluster);
137 if (NULL == pClusterToModify)
139 PandoraContentApi::Cluster::Parameters parameters;
140 parameters.m_caloHitList.push_back(pCaloHit);
141 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, parameters, pClusterToModify));
145 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*
this, pClusterToModify, pCaloHit));
149 if ((NULL == pLowXCluster) || (NULL == pHighXCluster))
151 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*
this, originalListName, fragmentListName));
155 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*
this, fragmentListName, originalListName));
161 template <
typename T>
164 return (lhs.GetX() < rhs.GetX());
176 catch (StatusCodeException &statusCodeException)
178 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
179 throw statusCodeException;
198 template <
typename T>
203 const Cluster *
const pCluster = *iter;
205 if (!pCluster->IsAvailable())
214 selectedClusterList.push_back(pCluster);
224 pfoParameters.m_particleId = MU_MINUS;
225 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
226 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
227 pfoParameters.m_energy = 0.f;
228 pfoParameters.m_momentum = CartesianVector(0.
f, 0.
f, 0.
f);
229 pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.
m_clusterListU.begin(), protoParticle.
m_clusterListU.end());
230 pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.
m_clusterListV.begin(), protoParticle.
m_clusterListV.end());
231 pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.
m_clusterListW.begin(), protoParticle.
m_clusterListW.end());
249 for (
ClusterList::iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; )
251 const Cluster *
const pCluster(*iter);
258 catch (StatusCodeException &statusCodeException)
260 clusterList.erase(iter++);
262 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
263 throw statusCodeException;
285 if (!
m_slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult)).second)
286 throw StatusCodeException(STATUS_CODE_FAILURE);
305 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
308 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
312 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
313 "MinClusterLength", minClusterLength));
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
const std::string & GetClusterListNameU() const
Get the name of the u cluster list.
pandora::ClusterList m_clusterListW
The selected modified cluster list W.
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > SplitPositionMap
Header file for the lar pointing cluster class.
virtual bool MakeClusterSplits(const SplitPositionMap &splitPositionMap)
Make cluster splits.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const std::string & GetClusterListNameV() const
Get the name of the v cluster list.
LArPointingCluster class.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
virtual void TidyUp()
Tidy member variables in derived class.
TwoDSlidingFitResultMap m_slidingFitResultMap
The sliding fit result map.
ThreeDTransverseTracksAlgorithm class.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
static bool SortSplitPositions(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort split position cartesian vectors by increasing x coordinate.
pandora::ClusterList m_clusterListV
The selected modified cluster list V.
Header file for the geometry helper class.
pandora::ClusterList m_clusterListW
List of 2D W clusters in a 3D proto particle.
const std::string & GetClusterListNameW() const
Get the name of the w cluster list.
virtual void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
Header file for the cluster helper class.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
const Vertex & GetOuterVertex() const
Get the outer vertex.
const Vertex & GetInnerVertex() const
Get the inner vertex.
pandora::ClusterList m_clusterListV
List of 2D V clusters in a 3D proto particle.
pandora::ClusterList m_clusterListU
List of 2D U clusters in a 3D proto particle.
virtual void TidyUp()
Tidy member variables in derived class.
virtual void PreparationStep()
Perform any preparatory steps required, e.g. caching expensive fit results for clusters.
virtual ~ThreeDTracksBaseAlgorithm()
Destructor.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
Header file for the lar track overlap result class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
virtual bool MakeClusterSplit(const pandora::CartesianVector &splitPosition, const pandora::Cluster *&pCurrentCluster, const pandora::Cluster *&pLowXCluster, const pandora::Cluster *&pHighXCluster) const
Make a cluster split.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
pandora::ClusterList m_clusterListU
The selected modified cluster list U.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
Header file for the three dimensional tracks algorithm base class.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
const pandora::CartesianVector & GetPosition() const
Get the vertex position.
TwoDSlidingFitResult class.
virtual void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Calculate Pfo properties from proto particle.
void RemoveFromSlidingFitCache(const pandora::Cluster *const pCluster)
Remova an existing sliding fit result, for the specified cluster, from the algorithm cache...