9 #include "Pandora/AlgorithmHeaders.h" 22 void CheatingSliceIdBaseTool::GetTargetParticleWeight(
const PfoList *
const pPfoList,
float &targetParticleWeight,
float &totalWeight, std::function<
bool(
const MCParticle *
const)> fCriteria)
24 targetParticleWeight = 0.f; totalWeight = 0.f;
26 for (
const ParticleFlowObject *
const pPfo : *pPfoList)
28 ClusterList twoDClusters;
29 LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusters);
31 CaloHitList caloHitList;
33 for (
const Cluster *
const pCluster : twoDClusters)
35 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
37 if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
38 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
40 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
43 for (
const CaloHit *
const pCaloHit : caloHitList)
45 float thisTargetParticleWeight = 0.f, thisTotalWeight = 0.f;
46 CheatingSliceIdBaseTool::GetTargetParticleWeight(pCaloHit, thisTargetParticleWeight, thisTotalWeight, fCriteria);
48 targetParticleWeight += thisTargetParticleWeight;
49 totalWeight += thisTotalWeight;
56 void CheatingSliceIdBaseTool::GetTargetParticleWeight(
const CaloHit *
const pCaloHit,
float &targetParticleWeight,
float &totalWeight, std::function<
bool(
const MCParticle *
const)> fCriteria)
58 targetParticleWeight = 0.f; totalWeight = 0.f;
59 const MCParticleWeightMap &hitMCParticleWeightMap(pCaloHit->GetMCParticleWeightMap());
61 if (hitMCParticleWeightMap.empty())
64 MCParticleList mcParticleList;
65 for (
const auto &mapEntry : hitMCParticleWeightMap) mcParticleList.push_back(mapEntry.first);
66 mcParticleList.sort(LArMCParticleHelper::SortByMomentum);
68 for (
const MCParticle *
const pMCParticle : mcParticleList)
70 const float weight(hitMCParticleWeightMap.at(pMCParticle));
71 const MCParticle *
const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
73 if (fCriteria(pParentMCParticle))
74 targetParticleWeight +=
weight;
80 if (totalWeight > std::numeric_limits<float>::epsilon())
82 targetParticleWeight *= 1.f / totalWeight;
87 targetParticleWeight = 0.f;
94 StatusCode CheatingSliceIdBaseTool::ReadSettings(
const TiXmlHandle )
96 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.