9 #include "Pandora/AlgorithmHeaders.h" 22 PreProcessingAlgorithm::PreProcessingAlgorithm() :
23 m_mipEquivalentCut(
std::numeric_limits<float>::epsilon()),
24 m_minCellLengthScale(
std::numeric_limits<float>::epsilon()),
25 m_maxCellLengthScale(3.
f),
26 m_searchRegion1D(0.1
f),
27 m_onlyAvailableCaloHits(true),
28 m_inputCaloHitListName(
"Input")
37 return STATUS_CODE_SUCCESS;
44 if (!this->GetPandora().GetSettings()->SingleHitTypeClusteringMode())
46 std::cout <<
"PreProcessingAlgorithm: expect Pandora to be configured in SingleHitTypeClusteringMode." << std::endl;
47 return STATUS_CODE_FAILURE;
54 catch (StatusCodeException &)
62 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
67 return STATUS_CODE_SUCCESS;
74 const CaloHitList *pCaloHitList(
nullptr);
75 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
m_inputCaloHitListName, pCaloHitList));
77 if (pCaloHitList->empty())
80 CaloHitList selectedCaloHitListU, selectedCaloHitListV, selectedCaloHitListW;
82 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
95 if (pCaloHit->GetInputEnergy() < std::numeric_limits<float>::epsilon())
97 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
98 std::cout <<
"PreProcessingAlgorithm: found a hit with zero energy, will remove it" << std::endl;
105 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
107 std::cout <<
"PreProcessingAlgorithm: found a hit with extent " << pCaloHit->GetCellLengthScale()
114 if (TPC_VIEW_U == pCaloHit->GetHitType())
116 selectedCaloHitListU.push_back(pCaloHit);
118 else if (TPC_VIEW_V == pCaloHit->GetHitType())
120 selectedCaloHitListV.push_back(pCaloHit);
122 else if (TPC_VIEW_W == pCaloHit->GetHitType())
124 selectedCaloHitListW.push_back(pCaloHit);
128 CaloHitList filteredCaloHitListU, filteredCaloHitListV, filteredCaloHitListW;
133 CaloHitList filteredInputList;
134 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListU.begin(), filteredCaloHitListU.end());
135 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListV.begin(), filteredCaloHitListV.end());
136 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListW.begin(), filteredCaloHitListW.end());
139 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, filteredInputList,
m_filteredCaloHitListName));
142 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, filteredCaloHitListU,
m_outputCaloHitListNameU));
145 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, filteredCaloHitListV,
m_outputCaloHitListNameV));
148 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, filteredCaloHitListW,
m_outputCaloHitListNameW));
159 kdTree.
build(hitKDNode2DList, hitsBoundingRegion2D);
162 for (
const CaloHit *
const pCaloHit1 : inputList)
168 kdTree.
search(searchRegionHits, found);
170 for (
const auto &
hit : found)
172 const CaloHit *
const pCaloHit2(
hit.data);
174 if (pCaloHit1 == pCaloHit2)
177 const float displacementSquared((pCaloHit2->GetPositionVector() - pCaloHit1->GetPositionVector()).GetMagnitudeSquared());
179 if (displacementSquared < std::numeric_limits<float>::epsilon())
181 const float deltaMip(pCaloHit2->GetMipEquivalentEnergy() > pCaloHit1->GetMipEquivalentEnergy());
183 if ((deltaMip > std::numeric_limits<float>::epsilon()) ||
184 ((std::fabs(deltaMip) < std::numeric_limits<float>::epsilon()) && (outputList.end() != std::find(outputList.begin(), outputList.end(), pCaloHit2))))
194 outputList.push_back(pCaloHit1);
198 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
199 std::cout <<
"PreProcessingAlgorithm: found two hits in same location, will remove lowest pulse height" << std::endl;
208 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
211 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
214 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
217 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
220 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
223 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
226 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
229 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
232 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
235 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
238 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
241 return STATUS_CODE_SUCCESS;
std::string m_outputCaloHitListNameV
The output calo hit list name for TPC_VIEW_V hits.
Header file for the kd tree linker algo template class.
pandora::StatusCode Reset()
void GetFilteredCaloHitList(const pandora::CaloHitList &inputList, pandora::CaloHitList &outputList)
Clean up the input CaloHitList.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
Box structure used to define 2D field. It's used in KDTree building step to divide the detector space...
float m_maxCellLengthScale
The maximum length scale for calo hit.
float m_mipEquivalentCut
Minimum mip equivalent energy for calo hit.
std::string m_currentCaloHitListReplacement
The name of the calo hit list to replace the current list (optional)
void search(const KDTreeBoxT< DIM > &searchBox, std::vector< KDTreeNodeInfoT< DATA, DIM > > &resRecHitList)
Search in the KDTree for all points that would be contained in the given searchbox The founded points...
std::string m_outputCaloHitListNameW
The output calo hit list name for TPC_VIEW_W hits.
Header file for the cluster helper class.
std::vector< HitKDNode2D > HitKDNode2DList
std::string m_filteredCaloHitListName
The output calo hit list name for all U, V and W hits.
float m_minCellLengthScale
The minimum length scale for calo hit.
std::string m_outputCaloHitListNameU
The output calo hit list name for TPC_VIEW_U hits.
Detector simulation of raw signals on wires.
std::string m_inputCaloHitListName
The input calo hit list name.
pandora::StatusCode Run()
void ProcessCaloHits()
Build separate CaloHitLists for each view.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 > > &nodes)
fill_and_bound_2d_kd_tree
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
Header file for the pre processing algorithm class.
pandora::CaloHitSet m_processedHits
The set of all previously processed calo hits.
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
bool m_onlyAvailableCaloHits
Whether to only include available calo hits.
void build(std::vector< KDTreeNodeInfoT< DATA, DIM > > &eltList, const KDTreeBoxT< DIM > ®ion)
Build the KD tree from the "eltList" in the space define by "region".