LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CheatingCosmicRayShowerMatchingAlg.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
14 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 StatusCode CheatingCosmicRayShowerMatchingAlg::Run()
23 {
24  ClusterList candidateClusterList;
25  this->GetCandidateClusters(candidateClusterList);
26 
27  const PfoList *pPfoList(nullptr);
28  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputPfoListName, pPfoList));
29 
30  for (const ParticleFlowObject *const pPfo : *pPfoList)
31  {
32  ClusterList twoDClusters;
33  LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusters);
34 
35  for (const Cluster *const pPfoCluster : twoDClusters)
36  this->CosmicRayShowerMatching(pPfo, pPfoCluster, candidateClusterList);
37  }
38 
39  return STATUS_CODE_SUCCESS;
40 }
41 
42 //------------------------------------------------------------------------------------------------------------------------------------------
43 
44 void CheatingCosmicRayShowerMatchingAlg::GetCandidateClusters(ClusterList &candidateClusterList) const
45 {
46  for (const std::string &clusterListName : m_inputClusterListNames)
47  {
48  const ClusterList *pClusterList(nullptr);
49 
50  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, clusterListName, pClusterList))
51  {
52  std::cout << "CheatingCosmicRayShowerMatchingAlg - Could not access cluster list with name " << clusterListName << std::endl;
53  continue;
54  }
55 
56  candidateClusterList.insert(candidateClusterList.end(), pClusterList->begin(), pClusterList->end());
57  }
58 }
59 
60 //------------------------------------------------------------------------------------------------------------------------------------------
61 
62 void CheatingCosmicRayShowerMatchingAlg::CosmicRayShowerMatching(const ParticleFlowObject *const pPfo, const Cluster *const pPfoCluster,
63  const ClusterList &candidateClusterList) const
64 {
65  try
66  {
67  const HitType pfoClusterHitType(LArClusterHelper::GetClusterHitType(pPfoCluster));
68  const MCParticle *const pPfoMCParticle(MCParticleHelper::GetMainMCParticle(pPfoCluster));
69  const MCParticle *const pPfoParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pPfoMCParticle));
70 
71  for (const Cluster *const pCandidateCluster : candidateClusterList)
72  {
73  if (pfoClusterHitType != LArClusterHelper::GetClusterHitType(pCandidateCluster))
74  continue;
75 
76  if (!PandoraContentApi::IsAvailable(*this, pCandidateCluster))
77  continue;
78 
79  if (pPfoCluster == pCandidateCluster)
80  continue;
81 
82  try
83  {
84  const MCParticle *const pMCParticle(MCParticleHelper::GetMainMCParticle(pCandidateCluster));
85  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
86 
87  if (!LArMCParticleHelper::IsNeutrino(pParentMCParticle) && (pPfoParentMCParticle == pParentMCParticle))
88  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfo, pCandidateCluster));
89  }
90  catch (const StatusCodeException &) {}
91  }
92  }
93  catch (const StatusCodeException &) {}
94 }
95 
96 //------------------------------------------------------------------------------------------------------------------------------------------
97 
98 StatusCode CheatingCosmicRayShowerMatchingAlg::ReadSettings(const TiXmlHandle xmlHandle)
99 {
100  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
101  "InputPfoListName", m_inputPfoListName));
102 
103  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
104  "InputClusterListNames", m_inputClusterListNames));
105 
106  return STATUS_CODE_SUCCESS;
107 }
108 
109 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cosmic ray shower matching cheater class.
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.