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.1f),
27 m_maxEventHits(std::numeric_limits<unsigned int>::max()),
28 m_onlyAvailableCaloHits(true),
29 m_inputCaloHitListName(
"Input")
38 return STATUS_CODE_SUCCESS;
45 if (!this->
GetPandora().GetSettings()->SingleHitTypeClusteringMode())
47 std::cout <<
"PreProcessingAlgorithm: expect Pandora to be configured in SingleHitTypeClusteringMode." << std::endl;
48 return STATUS_CODE_FAILURE;
57 if (STATUS_CODE_OUT_OF_RANGE == statusCodeException.
GetStatusCode())
59 std::cout <<
"PreProcessingAlgorithm: Excessive number of hits in event, skipping the reconstruction" << std::endl;
74 return STATUS_CODE_SUCCESS;
84 if (pCaloHitList->empty())
90 CaloHitList selectedCaloHitListU, selectedCaloHitListV, selectedCaloHitListW;
92 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
105 if (pCaloHit->GetInputEnergy() < std::numeric_limits<float>::epsilon())
108 std::cout <<
"PreProcessingAlgorithm: found a hit with zero energy, will remove it" << std::endl;
117 std::cout <<
"PreProcessingAlgorithm: found a hit with extent " << pCaloHit->GetCellLengthScale() <<
", require ("
126 selectedCaloHitListU.push_back(pCaloHit);
128 else if (
TPC_VIEW_V == pCaloHit->GetHitType())
130 selectedCaloHitListV.push_back(pCaloHit);
132 else if (
TPC_VIEW_W == pCaloHit->GetHitType())
134 selectedCaloHitListW.push_back(pCaloHit);
138 CaloHitList filteredCaloHitListU, filteredCaloHitListV, filteredCaloHitListW;
144 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListU.begin(), filteredCaloHitListU.end());
145 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListV.begin(), filteredCaloHitListV.end());
146 filteredInputList.insert(filteredInputList.end(), filteredCaloHitListW.begin(), filteredCaloHitListW.end());
183 std::cout <<
"PreProcessingAlgorithm: Unable to create void calo hit lists" << std::endl;
195 kdTree.
build(hitKDNode2DList, hitsBoundingRegion2D);
198 for (
const CaloHit *
const pCaloHit1 : inputList)
204 kdTree.
search(searchRegionHits, found);
206 for (
const auto &hit : found)
208 const CaloHit *
const pCaloHit2(hit.data);
210 if (pCaloHit1 == pCaloHit2)
213 const float displacementSquared((pCaloHit2->
GetPositionVector() - pCaloHit1->GetPositionVector()).GetMagnitudeSquared());
215 if (displacementSquared < std::numeric_limits<float>::epsilon())
219 if ((deltaMip > std::numeric_limits<float>::epsilon()) ||
220 ((std::fabs(deltaMip) < std::numeric_limits<float>::epsilon()) &&
221 (outputList.end() != std::find(outputList.begin(), outputList.end(), pCaloHit2))))
231 outputList.push_back(pCaloHit1);
236 std::cout <<
"PreProcessingAlgorithm: found two hits in same location, will remove lowest pulse height" << std::endl;
274 return STATUS_CODE_SUCCESS;
Header file for the kd tree linker algo template class.
Header file for the cluster helper class.
Header file for the pre processing algorithm class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode SaveList(const pandora::Algorithm &algorithm, const T &t, const std::string &newListName)
Save a provided input object list under a new name.
static bool IsAvailable(const pandora::Algorithm &algorithm, const T *const pT)
Is object, or a list of objects, available as a building block.
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
Box structure used to define 2D field. It's used in KDTree building step to divide the detector space...
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".
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...
void ProcessCaloHits()
Build separate CaloHitLists for each view.
std::string m_currentCaloHitListReplacement
The name of the calo hit list to replace the current list (optional)
void PopulateVoidCaloHitLists() noexcept
Build empty calo hit lists.
void GetFilteredCaloHitList(const pandora::CaloHitList &inputList, pandora::CaloHitList &outputList)
Clean up the input CaloHitList.
std::string m_outputCaloHitListNameW
The output calo hit list name for TPC_VIEW_W hits.
std::string m_outputCaloHitListNameV
The output calo hit list name for TPC_VIEW_V hits.
float m_mipEquivalentCut
Minimum mip equivalent energy for calo hit.
std::string m_inputCaloHitListName
The input calo hit list name.
PreProcessingAlgorithm()
Default constructor.
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
pandora::StatusCode Run()
Run the algorithm.
pandora::CaloHitSet m_processedHits
The set of all previously processed calo hits.
bool m_onlyAvailableCaloHits
Whether to only include available calo hits.
float m_minCellLengthScale
The minimum length scale for calo hit.
unsigned int m_maxEventHits
The maximum number of hits in an event to proceed with the reconstruction.
std::string m_filteredCaloHitListName
The output calo hit list name for all U, V and W hits.
float m_maxCellLengthScale
The maximum length scale for calo hit.
std::vector< HitKDNode2D > HitKDNode2DList
std::string m_outputCaloHitListNameU
The output calo hit list name for TPC_VIEW_U hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StatusCode Reset()
Perform any operations when pandora is reset, typically at the end of each event.
const CartesianVector & GetPositionVector() const
Get the position vector of center of calorimeter cell, units mm.
float GetMipEquivalentEnergy() const
Get the calibrated mip equivalent energy.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
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
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.