Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
CheatingSliceIdBaseTool.cc
Go to the documentation of this file.
1
10
12
16
17using namespace pandora;
18
19namespace lar_content
20{
21
23 const PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function<bool(const MCParticle *const)> fCriteria)
24{
25 targetParticleWeight = 0.f;
26 totalWeight = 0.f;
27
28 for (const ParticleFlowObject *const pPfo : *pPfoList)
29 {
30 ClusterList twoDClusters;
31 LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusters);
32
33 CaloHitList caloHitList;
34
35 for (const Cluster *const pCluster : twoDClusters)
36 {
37 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
38
39 if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
40 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
41
42 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
43 }
44
45 for (const CaloHit *const pCaloHit : caloHitList)
46 {
47 float thisTargetParticleWeight = 0.f, thisTotalWeight = 0.f;
48 CheatingSliceIdBaseTool::GetTargetParticleWeight(pCaloHit, thisTargetParticleWeight, thisTotalWeight, fCriteria);
49
50 targetParticleWeight += thisTargetParticleWeight;
51 totalWeight += thisTotalWeight;
52 }
53 }
54}
55
56//------------------------------------------------------------------------------------------------------------------------------------------
57
59 const CaloHit *const pCaloHit, float &targetParticleWeight, float &totalWeight, std::function<bool(const MCParticle *const)> fCriteria)
60{
61 targetParticleWeight = 0.f;
62 totalWeight = 0.f;
63 const MCParticleWeightMap &hitMCParticleWeightMap(pCaloHit->GetMCParticleWeightMap());
64
65 if (hitMCParticleWeightMap.empty())
66 return;
67
68 MCParticleList mcParticleList;
69 for (const auto &mapEntry : hitMCParticleWeightMap)
70 mcParticleList.push_back(mapEntry.first);
71 mcParticleList.sort(LArMCParticleHelper::SortByMomentum);
72
73 for (const MCParticle *const pMCParticle : mcParticleList)
74 {
75 const float weight(hitMCParticleWeightMap.at(pMCParticle));
76 const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
77
78 if (fCriteria(pParentMCParticle))
79 targetParticleWeight += weight;
80
81 totalWeight += weight;
82 }
83
84 // ATTN normalise arbitrary input weights at this point
85 if (totalWeight > std::numeric_limits<float>::epsilon())
86 {
87 targetParticleWeight *= 1.f / totalWeight;
88 totalWeight = 1.f;
89 }
90 else
91 {
92 targetParticleWeight = 0.f;
93 totalWeight = 0.f;
94 }
95}
96
97//------------------------------------------------------------------------------------------------------------------------------------------
98
100{
101 return STATUS_CODE_SUCCESS;
102}
103
104} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cheating slice id base tool class.
Header file for the cluster helper class.
Header file for the lar monte carlo particle helper helper class.
Header file for the pfo helper class.
static void GetTargetParticleWeight(const pandora::PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Get the target particle weight in a list of pfos.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
CaloHit class.
Definition CaloHit.h:26
const MCParticleWeightMap & GetMCParticleWeightMap() const
Get mc particle weight map for the calo hit.
Definition CaloHit.h:525
Cluster class.
Definition Cluster.h:31
MCParticle class.
Definition MCParticle.h:26
ParticleFlowObject class.
StatusCodeException class.
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const MCParticle * > MCParticleList
std::unordered_map< const MCParticle *, float > MCParticleWeightMap
MANAGED_CONTAINER< const Cluster * > ClusterList
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList