9 #include "Pandora/AlgorithmHeaders.h" 22 void CheatingSliceIdBaseTool::GetTargetParticleWeight(
23 const PfoList *
const pPfoList,
float &targetParticleWeight,
float &totalWeight,
std::function<
bool(
const MCParticle *
const)> fCriteria)
25 targetParticleWeight = 0.f;
28 for (
const ParticleFlowObject *
const pPfo : *pPfoList)
30 ClusterList twoDClusters;
31 LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusters);
33 CaloHitList caloHitList;
35 for (
const Cluster *
const pCluster : twoDClusters)
37 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
39 if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
40 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
42 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
45 for (
const CaloHit *
const pCaloHit : caloHitList)
47 float thisTargetParticleWeight = 0.f, thisTotalWeight = 0.f;
48 CheatingSliceIdBaseTool::GetTargetParticleWeight(pCaloHit, thisTargetParticleWeight, thisTotalWeight, fCriteria);
50 targetParticleWeight += thisTargetParticleWeight;
51 totalWeight += thisTotalWeight;
58 void CheatingSliceIdBaseTool::GetTargetParticleWeight(
59 const CaloHit *
const pCaloHit,
float &targetParticleWeight,
float &totalWeight,
std::function<
bool(
const MCParticle *
const)> fCriteria)
61 targetParticleWeight = 0.f;
63 const MCParticleWeightMap &hitMCParticleWeightMap(pCaloHit->GetMCParticleWeightMap());
65 if (hitMCParticleWeightMap.empty())
68 MCParticleList mcParticleList;
69 for (
const auto &mapEntry : hitMCParticleWeightMap)
70 mcParticleList.push_back(mapEntry.first);
71 mcParticleList.sort(LArMCParticleHelper::SortByMomentum);
73 for (
const MCParticle *
const pMCParticle : mcParticleList)
75 const float weight(hitMCParticleWeightMap.at(pMCParticle));
76 const MCParticle *
const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
78 if (fCriteria(pParentMCParticle))
79 targetParticleWeight +=
weight;
85 if (totalWeight > std::numeric_limits<float>::epsilon())
87 targetParticleWeight *= 1.f / totalWeight;
92 targetParticleWeight = 0.f;
99 StatusCode CheatingSliceIdBaseTool::ReadSettings(
const TiXmlHandle )
101 return STATUS_CODE_SUCCESS;
Header file for the pfo helper class.
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.
void function(int client, int *resource, int parblock, int *test, int p)