LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CheatingSliceIdBaseTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 void CheatingSliceIdBaseTool::GetTargetParticleWeight(const PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function<bool(const MCParticle *const)> fCriteria)
23 {
24  targetParticleWeight = 0.f; totalWeight = 0.f;
25 
26  for (const ParticleFlowObject *const pPfo : *pPfoList)
27  {
28  ClusterList twoDClusters;
29  LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusters);
30 
31  CaloHitList caloHitList;
32 
33  for (const Cluster *const pCluster : twoDClusters)
34  {
35  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
36 
37  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
38  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
39 
40  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
41  }
42 
43  for (const CaloHit *const pCaloHit : caloHitList)
44  {
45  float thisTargetParticleWeight = 0.f, thisTotalWeight = 0.f;
46  CheatingSliceIdBaseTool::GetTargetParticleWeight(pCaloHit, thisTargetParticleWeight, thisTotalWeight, fCriteria);
47 
48  targetParticleWeight += thisTargetParticleWeight;
49  totalWeight += thisTotalWeight;
50  }
51  }
52 }
53 
54 //------------------------------------------------------------------------------------------------------------------------------------------
55 
56 void CheatingSliceIdBaseTool::GetTargetParticleWeight(const CaloHit *const pCaloHit, float &targetParticleWeight, float &totalWeight, std::function<bool(const MCParticle *const)> fCriteria)
57 {
58  targetParticleWeight = 0.f; totalWeight = 0.f;
59  const MCParticleWeightMap &hitMCParticleWeightMap(pCaloHit->GetMCParticleWeightMap());
60 
61  if (hitMCParticleWeightMap.empty())
62  return;
63 
64  MCParticleList mcParticleList;
65  for (const auto &mapEntry : hitMCParticleWeightMap) mcParticleList.push_back(mapEntry.first);
66  mcParticleList.sort(LArMCParticleHelper::SortByMomentum);
67 
68  for (const MCParticle *const pMCParticle : mcParticleList)
69  {
70  const float weight(hitMCParticleWeightMap.at(pMCParticle));
71  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
72 
73  if (fCriteria(pParentMCParticle))
74  targetParticleWeight += weight;
75 
76  totalWeight += weight;
77  }
78 
79  // ATTN normalise arbitrary input weights at this point
80  if (totalWeight > std::numeric_limits<float>::epsilon())
81  {
82  targetParticleWeight *= 1.f / totalWeight;
83  totalWeight = 1.f;
84  }
85  else
86  {
87  targetParticleWeight = 0.f;
88  totalWeight = 0.f;
89  }
90 }
91 
92 //------------------------------------------------------------------------------------------------------------------------------------------
93 
94 StatusCode CheatingSliceIdBaseTool::ReadSettings(const TiXmlHandle /*xmlHandle*/)
95 {
96  return STATUS_CODE_SUCCESS;
97 }
98 
99 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cheating slice id base tool class.
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.
double weight
Definition: plottest35.C:25