29 m_nReclusteringProcesses(0),
30 m_pCurrentReclusterMetadata(nullptr)
64 inputIter->second->push_back(pCaloHit);
65 return STATUS_CODE_SUCCESS;
69 std::cout <<
"Failed to create calo hit: " << statusCodeException.
ToString() << std::endl;
80 return this->
Modifiable(pCaloHit)->AlterMetadata(metadata);
99 bool isAvailable(
true);
101 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
117 this->
Modifiable(pCaloHit)->SetAvailability(isAvailable);
118 return STATUS_CODE_SUCCESS;
129 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
130 this->
Modifiable(pCaloHit)->SetAvailability(isAvailable);
132 return STATUS_CODE_SUCCESS;
141 std::string &temporaryListName)
143 if (clusterList.empty())
144 return STATUS_CODE_NOT_INITIALIZED;
148 for (
const Cluster *
const pCluster : clusterList)
150 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
151 caloHitList.insert(caloHitList.end(), pCluster->GetIsolatedCaloHitList().begin(), pCluster->GetIsolatedCaloHitList().end());
175 if (caloHitToPfoTargetsMap.empty())
176 return STATUS_CODE_SUCCESS;
181 return STATUS_CODE_FAILURE;
183 for (
const CaloHit *
const pCaloHit : *inputIter->second)
185 UidToMCParticleWeightMap::const_iterator pfoTargetIter = caloHitToPfoTargetsMap.find(pCaloHit->GetParentAddress());
187 if (caloHitToPfoTargetsMap.end() == pfoTargetIter)
190 this->
Modifiable(pCaloHit)->SetMCParticleWeightMap(pfoTargetIter->second);
193 return STATUS_CODE_SUCCESS;
203 return STATUS_CODE_FAILURE;
205 for (
const CaloHit *
const pCaloHit : *inputIter->second)
206 this->
Modifiable(pCaloHit)->RemoveMCParticles();
208 return STATUS_CODE_SUCCESS;
216 pDaughterCaloHit1 =
nullptr; pDaughterCaloHit2 =
nullptr;
219 return STATUS_CODE_NOT_ALLOWED;
222 parameters1.m_pOriginalCaloHit = pOriginalCaloHit;
227 parameters2.m_pOriginalCaloHit = pOriginalCaloHit;
228 parameters2.
m_weight = 1.f - fraction1;
231 if (!pDaughterCaloHit1 || !pDaughterCaloHit2)
232 return STATUS_CODE_FAILURE;
235 caloHitReplacement.
m_oldCaloHits.push_back(pOriginalCaloHit);
247 return STATUS_CODE_SUCCESS;
255 pMergedCaloHit =
nullptr;
258 return STATUS_CODE_NOT_ALLOWED;
263 parameters.m_pOriginalCaloHit = pFragmentCaloHit1;
268 return STATUS_CODE_FAILURE;
283 return STATUS_CODE_SUCCESS;
290 if ((fraction1 < std::numeric_limits<float>::epsilon()) || (fraction1 > 1.f))
301 if (iter->second->end() == std::find(iter->second->begin(), iter->second->end(), pOriginalCaloHit))
311 if (pFragmentCaloHit1->
GetWeight() < std::numeric_limits<float>::epsilon())
325 if ((iter->second->end() == std::find(iter->second->begin(), iter->second->end(), pFragmentCaloHit1)) ||
326 (iter->second->end() == std::find(iter->second->begin(), iter->second->end(), pFragmentCaloHit2)))
337 const std::string &originalReclusterListName)
339 std::string caloHitListName;
347 originalReclusterListName,
false));
351 return STATUS_CODE_SUCCESS;
359 return STATUS_CODE_SUCCESS;
363 std::string caloHitListName;
369 newReclusterListName,
true));
371 return STATUS_CODE_SUCCESS;
379 return STATUS_CODE_SUCCESS;
383 pSelectedCaloHitMetaData));
400 pSelectedCaloHitMetaData->
Clear();
401 delete pSelectedCaloHitMetaData;
403 return STATUS_CODE_SUCCESS;
420 for (
const CaloHitUsageMap::value_type &mapEntry : caloHitUsageMap) caloHitVector.push_back(mapEntry.first);
423 for (
const CaloHit *
const pCaloHit : caloHitVector)
425 this->
Modifiable(pCaloHit)->SetAvailability(caloHitUsageMap.at(pCaloHit));
428 return STATUS_CODE_SUCCESS;
443 return STATUS_CODE_SUCCESS;
451 return STATUS_CODE_NOT_INITIALIZED;
454 return STATUS_CODE_FAILURE;
456 bool replacementFound(
false), allReplacementsFound(
true);
460 CaloHitList::iterator listIter = std::find(pCaloHitList->begin(), pCaloHitList->end(), pCaloHit);
462 if (pCaloHitList->end() != listIter)
464 listIter = pCaloHitList->erase(listIter);
465 replacementFound =
true;
469 allReplacementsFound =
false;
472 if (!replacementFound)
473 return STATUS_CODE_SUCCESS;
475 if (!allReplacementsFound)
476 std::cout <<
"CaloHitManager::Update - imperfect calo hit replacements made to list " << std::endl;
480 if (pCaloHitList->end() != std::find(pCaloHitList->begin(), pCaloHitList->end(), pCaloHit))
481 return STATUS_CODE_ALREADY_PRESENT;
483 pCaloHitList->push_back(pCaloHit);
486 return STATUS_CODE_SUCCESS;
Header file for the calo hit class.
Header file for the calo hit manager class.
Header file for the cluster class.
Header file for the object factory class.
Header file for the pandora class.
Header file defining relevant internal typedefs, sort and string conversion functions.
Header file for the pandora plugin manager class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Algorithm class. Algorithm addresses are held only by the algorithm manager. They have a fully define...
CellGeometry GetCellGeometry() const
Get the cell geometry.
const CartesianVector & GetPositionVector() const
Get the position vector of center of calorimeter cell, units mm.
float GetWeight() const
Get the calo hit weight, which may not be unity if the hit has been fragmented.
float m_weight
The calo hit weight, which may not be unity if the hit has been fragmented.
bool IsAvailable() const
Whether the calo hit is available to be added to a cluster (access this function via PandoraContentAP...
const void * GetParentAddress() const
Get the address of the parent calo hit in the user framework.
StatusCode PrepareForClustering(const Algorithm *const pAlgorithm, const std::string &newReclusterListName)
Prepare metadata to allow for construction of new recluster candidates.
StatusCode SetAvailability(const T *const pT, bool isAvailable)
Set availability of a calo hit, or a list of calo hits, to be added to a cluster.
StatusCode MatchCaloHitsToMCPfoTargets(const UidToMCParticleWeightMap &caloHitToPfoTargetsMap)
Match calo hits to their correct mc particles for particle flow.
ReclusterMetadata * m_pCurrentReclusterMetadata
Address of the current recluster metadata.
CaloHitManager(const Pandora *const pPandora)
Constructor.
bool CanFragmentCaloHit(const CaloHit *const pOriginalCaloHit, const float fraction1) const
Whether a calo hit can be fragmented into two daughter calo hits with the specified energy division.
StatusCode RemoveAllMCParticleRelationships()
Remove all mc particle associations that have been registered with calo hits.
StatusCode CreateTemporaryListAndSetCurrent(const Algorithm *const pAlgorithm, const ClusterList &clusterList, std::string &temporaryListName)
Change the current calo hit list to the constituent hits of a cluster list.
bool CanMergeCaloHitFragments(const CaloHit *const pFragmentCaloHit1, const CaloHit *const pFragmentCaloHit2) const
Whether two candidate calo hit fragments can be merged.
StatusCode FragmentCaloHit(const CaloHit *const pOriginalCaloHit, const float fraction1, const CaloHit *&pDaughterCaloHit1, const CaloHit *&pDaughterCaloHit2, const ObjectFactory< object_creation::CaloHitFragment::Parameters, object_creation::CaloHitFragment::Object > &factory)
Fragment a calo hit into two daughter calo hits, with a specified energy division.
unsigned int m_nReclusteringProcesses
The number of reclustering algorithms currently in operation.
bool IsAvailable(const T *const pT) const
Is a calo hit, or a list of calo hits, available to add to a cluster.
StatusCode EndReclustering(const Algorithm *const pAlgorithm, const std::string &selectedReclusterListName)
End reclustering operations and update calo hit lists accordingly.
StatusCode AlterMetadata(const CaloHit *const pCaloHit, const object_creation::CaloHit::Metadata &metadata) const
Alter the metadata information stored in a calo hit.
StatusCode Create(const object_creation::CaloHit::Parameters ¶meters, const CaloHit *&pCaloHit, const ObjectFactory< object_creation::CaloHit::Parameters, object_creation::CaloHit::Object > &factory)
Create calo hit.
ReclusterMetadataList m_reclusterMetadataList
The recluster metadata list.
StatusCode Update(const CaloHitMetadata &caloHitMetadata)
Update all calo hit lists to account for changes by daughter recluster processes.
StatusCode InitializeReclustering(const Algorithm *const pAlgorithm, const ClusterList &clusterList, const std::string &originalReclusterListName)
Initialize reclustering operations, preparing lists and metadata accordingly.
StatusCode MergeCaloHitFragments(const CaloHit *const pFragmentCaloHit1, const CaloHit *const pFragmentCaloHit2, const CaloHit *&pMergedCaloHit, const ObjectFactory< object_creation::CaloHitFragment::Parameters, object_creation::CaloHitFragment::Object > &factory)
Merge two calo hit fragments, originally from the same parent hit, to form a new calo hit.
~CaloHitManager()
Destructor.
StatusCode EraseAllContent()
Erase all calo hit manager content.
std::string m_currentListName
The name of the current list.
virtual T * Modifiable(const T *const pT) const
Access a modifiable object, when provided with address to const object.
const Pandora *const m_pPandora
The associated pandora object.
NameToListMap m_nameToListMap
The name to list map.
ObjectFactory class responsible for extended pandora object creation.
virtual StatusCode Create(const Parameters ¶meters, const Object *&pObject) const =0
Create an object with the given parameters.
const PluginManager * GetPlugins() const
Get the pandora plugin instance, providing access to user registered functions and calculators.
const PseudoLayerPlugin * GetPseudoLayerPlugin() const
Get the address of the pseudo layer plugin.
bool HasPseudoLayerPlugin() const
Whether the pseudo layer plugin is available.
Enable ordering of pointers based on properties of target objects.
virtual unsigned int GetPseudoLayer(const CartesianVector &positionVector) const =0
Get the appropriate pseudolayer for a specified position vector.
StatusCodeException class.
std::string ToString() const
Get status code as a string.
StatusCode GetStatusCode() const
Get status code.
std::vector< const CaloHit * > CaloHitVector
std::unordered_map< const CaloHit *, bool > CaloHitUsageMap
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< CaloHitReplacement * > CaloHitReplacementList
CaloHitList m_oldCaloHits
The list of old calo hits, to be replaced.
CaloHitList m_newCaloHits
The list new calo hits, to act as replacements.
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
std::unordered_map< Uid, MCParticleWeightMap > UidToMCParticleWeightMap
CaloHitReplacement class.