Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lar_content::CheatingClusterCreationAlgorithm Class Reference

CheatingClusterCreationAlgorithm class. More...

#include <CheatingClusterCreationAlgorithm.h>

Inheritance diagram for lar_content::CheatingClusterCreationAlgorithm:

Public Member Functions

 CheatingClusterCreationAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCParticleToHitListMap
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void GetMCParticleToHitListMap (MCParticleToHitListMap &mcParticleToHitListMap) const
 Create map between each (primary) MC particle and associated calo hits. More...
 
void SimpleMCParticleCollection (const pandora::CaloHit *const pCaloHit, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap, MCParticleToHitListMap &mcParticleToHitListMap) const
 Simple mc particle collection, using main mc particle associated with each calo hit. More...
 
bool SelectMCParticlesForClustering (const pandora::MCParticle *const pMCParticle) const
 Check whether mc particle is of a type specified for inclusion in cheated clustering. More...
 
void CreateClusters (const MCParticleToHitListMap &mcParticleToHitListMap) const
 Create clusters based on information in the mc particle to hit list map. More...
 

Private Attributes

bool m_collapseToPrimaryMCParticles
 Whether to collapse mc particle hierarchies to primary particles. More...
 
std::string m_mcParticleListName
 The mc particle list name, required if want to collapse mc particle hierarchy. More...
 
pandora::IntVector m_particleIdList
 list of particle ids of MCPFOs to be selected More...
 

Detailed Description

CheatingClusterCreationAlgorithm class.

Definition at line 23 of file CheatingClusterCreationAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::MCParticle *, pandora::CaloHitList> lar_content::CheatingClusterCreationAlgorithm::MCParticleToHitListMap
private

Definition at line 35 of file CheatingClusterCreationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::CheatingClusterCreationAlgorithm::CheatingClusterCreationAlgorithm ( )

Default constructor.

Definition at line 18 of file CheatingClusterCreationAlgorithm.cc.

19 {
20 }
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.

Member Function Documentation

void lar_content::CheatingClusterCreationAlgorithm::CreateClusters ( const MCParticleToHitListMap mcParticleToHitListMap) const
private

Create clusters based on information in the mc particle to hit list map.

Parameters
mcParticleToHitListMapthe mc particle to hit list map

Definition at line 106 of file CheatingClusterCreationAlgorithm.cc.

107 {
108  MCParticleVector mcParticleVector;
109  for (const auto &mapEntry : mcParticleToHitListMap)
110  mcParticleVector.push_back(mapEntry.first);
111  std::sort(mcParticleVector.begin(), mcParticleVector.end(), LArMCParticleHelper::SortByMomentum);
112 
113  for (const MCParticle *const pMCParticle : mcParticleVector)
114  {
115  const CaloHitList &caloHitList(mcParticleToHitListMap.at(pMCParticle));
116 
117  if (caloHitList.empty())
118  continue;
119 
120  const Cluster *pCluster(nullptr);
121  PandoraContentApi::Cluster::Parameters parameters;
122  parameters.m_caloHitList = caloHitList;
123  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pCluster));
124 
125  PandoraContentApi::Cluster::Metadata metadata;
126 
127  switch (pMCParticle->GetParticleId())
128  {
129  case PHOTON:
130  case E_PLUS:
131  case E_MINUS:
132  case MU_PLUS:
133  case MU_MINUS:
134  metadata.m_particleId = pMCParticle->GetParticleId();
135  break;
136  default:
137  break;
138  }
139 
140  if (metadata.m_particleId.IsInitialized())
141  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pCluster, metadata));
142  }
143 }
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
void lar_content::CheatingClusterCreationAlgorithm::GetMCParticleToHitListMap ( MCParticleToHitListMap mcParticleToHitListMap) const
private

Create map between each (primary) MC particle and associated calo hits.

Parameters
mcParticleToHitListMapto receive the mc particle to hit list map

Definition at line 35 of file CheatingClusterCreationAlgorithm.cc.

36 {
38 
40  {
41  const MCParticleList *pMCParticleList(nullptr);
42  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
43 
44  LArMCParticleHelper::GetMCPrimaryMap(pMCParticleList, mcPrimaryMap);
45  }
46 
47  const CaloHitList *pCaloHitList(nullptr);
48  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pCaloHitList));
49 
50  for (const CaloHit *const pCaloHit : *pCaloHitList)
51  {
52  try
53  {
54  if (!PandoraContentApi::IsAvailable(*this, pCaloHit))
55  continue;
56 
57  this->SimpleMCParticleCollection(pCaloHit, mcPrimaryMap, mcParticleToHitListMap);
58  }
59  catch (const StatusCodeException &)
60  {
61  }
62  }
63 }
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
void SimpleMCParticleCollection(const pandora::CaloHit *const pCaloHit, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap, MCParticleToHitListMap &mcParticleToHitListMap) const
Simple mc particle collection, using main mc particle associated with each calo hit.
static void GetMCPrimaryMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcPrimaryMap)
Get mapping from individual mc particles (in a provided list) and their primary parent mc particles...
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
StatusCode lar_content::CheatingClusterCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 147 of file CheatingClusterCreationAlgorithm.cc.

148 {
149  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
150  XmlHelper::ReadValue(xmlHandle, "CollapseToPrimaryMCParticles", m_collapseToPrimaryMCParticles));
151 
153  {
154  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
155  }
156 
157  PANDORA_RETURN_RESULT_IF_AND_IF(
158  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ParticleIdList", m_particleIdList));
159 
160  return STATUS_CODE_SUCCESS;
161 }
pandora::IntVector m_particleIdList
list of particle ids of MCPFOs to be selected
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
StatusCode lar_content::CheatingClusterCreationAlgorithm::Run ( )
private

Definition at line 24 of file CheatingClusterCreationAlgorithm.cc.

25 {
26  MCParticleToHitListMap mcParticleToHitListMap;
27  this->GetMCParticleToHitListMap(mcParticleToHitListMap);
28  this->CreateClusters(mcParticleToHitListMap);
29 
30  return STATUS_CODE_SUCCESS;
31 }
void GetMCParticleToHitListMap(MCParticleToHitListMap &mcParticleToHitListMap) const
Create map between each (primary) MC particle and associated calo hits.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCParticleToHitListMap
void CreateClusters(const MCParticleToHitListMap &mcParticleToHitListMap) const
Create clusters based on information in the mc particle to hit list map.
bool lar_content::CheatingClusterCreationAlgorithm::SelectMCParticlesForClustering ( const pandora::MCParticle *const  pMCParticle) const
private

Check whether mc particle is of a type specified for inclusion in cheated clustering.

Parameters
pMCParticlethe mc particle to hit list map
Returns
boolean

Definition at line 90 of file CheatingClusterCreationAlgorithm.cc.

91 {
92  if (m_particleIdList.empty())
93  return true;
94 
95  for (const int particleId : m_particleIdList)
96  {
97  if (pMCParticle->GetParticleId() == particleId)
98  return true;
99  }
100 
101  return false;
102 }
pandora::IntVector m_particleIdList
list of particle ids of MCPFOs to be selected
void lar_content::CheatingClusterCreationAlgorithm::SimpleMCParticleCollection ( const pandora::CaloHit *const  pCaloHit,
const LArMCParticleHelper::MCRelationMap mcPrimaryMap,
MCParticleToHitListMap mcParticleToHitListMap 
) const
private

Simple mc particle collection, using main mc particle associated with each calo hit.

Parameters
pCaloHitaddress of the calo hit
mcPrimaryMapthe mapping between mc particles and their parents
mcParticleToHitListMapthe mc particle to hit list map

Definition at line 67 of file CheatingClusterCreationAlgorithm.cc.

69 {
70  const MCParticle *pMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
71 
72  if (!this->SelectMCParticlesForClustering(pMCParticle))
73  return;
74 
76  {
77  LArMCParticleHelper::MCRelationMap::const_iterator primaryIter = mcPrimaryMap.find(pMCParticle);
78 
79  if (mcPrimaryMap.end() == primaryIter)
80  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
81 
82  pMCParticle = primaryIter->second;
83  }
84 
85  mcParticleToHitListMap[pMCParticle].push_back(pCaloHit);
86 }
intermediate_table::const_iterator const_iterator
bool SelectMCParticlesForClustering(const pandora::MCParticle *const pMCParticle) const
Check whether mc particle is of a type specified for inclusion in cheated clustering.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.

Member Data Documentation

bool lar_content::CheatingClusterCreationAlgorithm::m_collapseToPrimaryMCParticles
private

Whether to collapse mc particle hierarchies to primary particles.

Definition at line 70 of file CheatingClusterCreationAlgorithm.h.

std::string lar_content::CheatingClusterCreationAlgorithm::m_mcParticleListName
private

The mc particle list name, required if want to collapse mc particle hierarchy.

Definition at line 71 of file CheatingClusterCreationAlgorithm.h.

pandora::IntVector lar_content::CheatingClusterCreationAlgorithm::m_particleIdList
private

list of particle ids of MCPFOs to be selected

Definition at line 73 of file CheatingClusterCreationAlgorithm.h.


The documentation for this class was generated from the following files: