CheatingCosmicRayShowerMatchingAlg.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArCheating/CosmicRayShowerMatchingAlg.cc
3  *
4  * @brief Implementation of the cheater for the cosmic ray shower matching algorithm class.
5  *
6  * $Log: $
7  */
8 
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(
63  const ParticleFlowObject *const pPfo, const Cluster *const pPfoCluster, 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  }
94  }
95  catch (const StatusCodeException &)
96  {
97  }
98 }
99 
100 //------------------------------------------------------------------------------------------------------------------------------------------
101 
102 StatusCode CheatingCosmicRayShowerMatchingAlg::ReadSettings(const TiXmlHandle xmlHandle)
103 {
104  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputPfoListName", m_inputPfoListName));
105 
106  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputClusterListNames", m_inputClusterListNames));
107 
108  return STATUS_CODE_SUCCESS;
109 }
110 
111 } // namespace lar_content
Header file for the pfo helper class.
bool IsNeutrino(int pdgc)
Definition: PDGUtils.cxx:107
enum cvn::HType HitType
std::string string
Definition: nybbler.cc:12
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.
QTextStream & endl(QTextStream &s)