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

MCParticleMonitoringAlgorithm class. More...

#include <MCParticleMonitoringAlgorithm.h>

Inheritance diagram for lar_content::MCParticleMonitoringAlgorithm:

Public Member Functions

 MCParticleMonitoringAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void PrintPrimaryMCParticles (const LArMCParticleHelper::MCContributionMap &mcContributionMap) const
 Extract details of each mc primary in a given mc contribution map. More...
 
void PrintMCParticle (const pandora::MCParticle *const pMCParticle, const LArMCParticleHelper::MCContributionMap &mcToTrueHitListMap, const int depth) const
 Print information for a given mc particle to screen. More...
 

Private Attributes

std::string m_caloHitListName
 Name of input calo hit list. More...
 
std::string m_mcParticleListName
 Name of input MC particle list. More...
 
bool m_useTrueNeutrinosOnly
 Whether to consider only mc particles that were neutrino induced. More...
 
unsigned int m_minHitsForDisplay
 Min hits associated with mc particle to warrant display to terminal. More...
 

Detailed Description

MCParticleMonitoringAlgorithm class.

Definition at line 21 of file MCParticleMonitoringAlgorithm.h.

Constructor & Destructor Documentation

lar_content::MCParticleMonitoringAlgorithm::MCParticleMonitoringAlgorithm ( )

Default constructor.

Definition at line 26 of file MCParticleMonitoringAlgorithm.cc.

27 {
28 }
bool m_useTrueNeutrinosOnly
Whether to consider only mc particles that were neutrino induced.
unsigned int m_minHitsForDisplay
Min hits associated with mc particle to warrant display to terminal.

Member Function Documentation

void lar_content::MCParticleMonitoringAlgorithm::PrintMCParticle ( const pandora::MCParticle *const  pMCParticle,
const LArMCParticleHelper::MCContributionMap mcToTrueHitListMap,
const int  depth 
) const
private

Print information for a given mc particle to screen.

Parameters
pMCParticlethe address of the mc particle
mcToTrueHitListMapthe mc to true hit list map
depththe depth in the mc particle decay hierarchy

Definition at line 116 of file MCParticleMonitoringAlgorithm.cc.

118 {
119  const CaloHitList &caloHitList(mcToTrueHitListMap.count(pMCParticle) ? mcToTrueHitListMap.at(pMCParticle) : CaloHitList());
120 
121  if (caloHitList.size() >= m_minHitsForDisplay)
122  {
123  if (depth > 1)
124  {
125  for (int iDepth = 1; iDepth < depth - 1; ++iDepth)
126  std::cout << " ";
127  std::cout << "\\_ ";
128  }
129 
130  std::cout << "MCPDG " << pMCParticle->GetParticleId() << ", Energy " << pMCParticle->GetEnergy() << ", Dist. "
131  << (pMCParticle->GetEndpoint() - pMCParticle->GetVertex()).GetMagnitude() << ", nMCHits " << caloHitList.size() << " ("
132  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, caloHitList) << ", "
133  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, caloHitList) << ", "
134  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, caloHitList) << ")" << std::endl;
135  }
136 
137  for (const MCParticle *const pDaughterParticle : pMCParticle->GetDaughterList())
138  this->PrintMCParticle(pDaughterParticle, mcToTrueHitListMap, depth + 1);
139 }
unsigned int m_minHitsForDisplay
Min hits associated with mc particle to warrant display to terminal.
void PrintMCParticle(const pandora::MCParticle *const pMCParticle, const LArMCParticleHelper::MCContributionMap &mcToTrueHitListMap, const int depth) const
Print information for a given mc particle to screen.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
QTextStream & endl(QTextStream &s)
void lar_content::MCParticleMonitoringAlgorithm::PrintPrimaryMCParticles ( const LArMCParticleHelper::MCContributionMap mcContributionMap) const
private

Extract details of each mc primary in a given mc contribution map.

Parameters
mcContributionMapthe mc contribution map

Definition at line 83 of file MCParticleMonitoringAlgorithm.cc.

84 {
85  MCParticleVector mcPrimaryVector;
86  LArMonitoringHelper::GetOrderedMCParticleVector({mcContributionMap}, mcPrimaryVector);
87 
88  unsigned int index(0);
89 
90  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
91  {
92  const CaloHitList &caloHitList(mcContributionMap.at(pMCPrimary));
93 
94  if (caloHitList.size() >= m_minHitsForDisplay)
95  {
96  std::cout << std::endl
97  << "--Primary " << index << ", MCPDG " << pMCPrimary->GetParticleId() << ", Energy " << pMCPrimary->GetEnergy()
98  << ", Dist. " << (pMCPrimary->GetEndpoint() - pMCPrimary->GetVertex()).GetMagnitude() << ", nMCHits "
99  << caloHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, caloHitList) << ", "
100  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, caloHitList) << ", "
101  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, caloHitList) << ")" << std::endl;
102 
103  LArMCParticleHelper::MCRelationMap mcToPrimaryMCMap;
104  LArMCParticleHelper::CaloHitToMCMap caloHitToPrimaryMCMap;
105  LArMCParticleHelper::MCContributionMap mcToTrueHitListMap;
106  LArMCParticleHelper::GetMCParticleToCaloHitMatches(&caloHitList, mcToPrimaryMCMap, caloHitToPrimaryMCMap, mcToTrueHitListMap);
107  this->PrintMCParticle(pMCPrimary, mcToTrueHitListMap, 1);
108  }
109 
110  ++index;
111  }
112 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::unordered_map< const pandora::CaloHit *, const pandora::MCParticle * > CaloHitToMCMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
unsigned int m_minHitsForDisplay
Min hits associated with mc particle to warrant display to terminal.
static void GetOrderedMCParticleVector(const LArMCParticleHelper::MCContributionMapVector &selectedMCParticleToGoodHitsMaps, pandora::MCParticleVector &orderedMCParticleVector)
Order input MCParticles by their number of hits.
void PrintMCParticle(const pandora::MCParticle *const pMCParticle, const LArMCParticleHelper::MCContributionMap &mcToTrueHitListMap, const int depth) const
Print information for a given mc particle to screen.
static void GetMCParticleToCaloHitMatches(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToTargetMCMap, CaloHitToMCMap &hitToMCMap, MCContributionMap &mcToTrueHitListMap)
Match calo hits to their parent particles.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
QTextStream & endl(QTextStream &s)
StatusCode lar_content::MCParticleMonitoringAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 143 of file MCParticleMonitoringAlgorithm.cc.

144 {
145  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
146  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
147 
148  PANDORA_RETURN_RESULT_IF_AND_IF(
149  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "UseTrueNeutrinosOnly", m_useTrueNeutrinosOnly));
150 
151  PANDORA_RETURN_RESULT_IF_AND_IF(
152  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinHitsForDisplay", m_minHitsForDisplay));
153 
154  return STATUS_CODE_SUCCESS;
155 }
bool m_useTrueNeutrinosOnly
Whether to consider only mc particles that were neutrino induced.
unsigned int m_minHitsForDisplay
Min hits associated with mc particle to warrant display to terminal.
std::string m_caloHitListName
Name of input calo hit list.
std::string m_mcParticleListName
Name of input MC particle list.
StatusCode lar_content::MCParticleMonitoringAlgorithm::Run ( )
private

Definition at line 32 of file MCParticleMonitoringAlgorithm.cc.

33 {
34  std::cout << "---MC-PARTICLE-MONITORING-----------------------------------------------------------------------" << std::endl;
35  const MCParticleList *pMCParticleList = nullptr;
36  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
37 
38  const CaloHitList *pCaloHitList = nullptr;
39  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
40 
41  LArMCParticleHelper::PrimaryParameters parameters;
42  parameters.m_minHitSharingFraction = 0.f;
43 
44  LArMCParticleHelper::MCContributionMap nuMCParticlesToGoodHitsMap;
45  LArMCParticleHelper::MCContributionMap beamMCParticlesToGoodHitsMap;
46  LArMCParticleHelper::MCContributionMap crMCParticlesToGoodHitsMap;
48  pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsBeamNeutrinoFinalState, nuMCParticlesToGoodHitsMap);
49 
51  {
53  pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsBeamParticle, beamMCParticlesToGoodHitsMap);
55  pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsCosmicRay, crMCParticlesToGoodHitsMap);
56  }
57 
58  if (!nuMCParticlesToGoodHitsMap.empty())
59  {
60  std::cout << std::endl << "BeamNeutrinos: " << std::endl;
61  this->PrintPrimaryMCParticles(nuMCParticlesToGoodHitsMap);
62  }
63 
64  if (!beamMCParticlesToGoodHitsMap.empty())
65  {
66  std::cout << std::endl << "BeamParticles: " << std::endl;
67  this->PrintPrimaryMCParticles(beamMCParticlesToGoodHitsMap);
68  }
69 
70  if (!crMCParticlesToGoodHitsMap.empty())
71  {
72  std::cout << std::endl << "CosmicRays: " << std::endl;
73  this->PrintPrimaryMCParticles(crMCParticlesToGoodHitsMap);
74  }
75 
76  std::cout << "------------------------------------------------------------------------------------------------" << std::endl;
77 
78  return STATUS_CODE_SUCCESS;
79 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
bool m_useTrueNeutrinosOnly
Whether to consider only mc particles that were neutrino induced.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters &parameters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
std::string m_caloHitListName
Name of input calo hit list.
void PrintPrimaryMCParticles(const LArMCParticleHelper::MCContributionMap &mcContributionMap) const
Extract details of each mc primary in a given mc contribution map.
std::string m_mcParticleListName
Name of input MC particle list.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::string lar_content::MCParticleMonitoringAlgorithm::m_caloHitListName
private

Name of input calo hit list.

Definition at line 50 of file MCParticleMonitoringAlgorithm.h.

std::string lar_content::MCParticleMonitoringAlgorithm::m_mcParticleListName
private

Name of input MC particle list.

Definition at line 51 of file MCParticleMonitoringAlgorithm.h.

unsigned int lar_content::MCParticleMonitoringAlgorithm::m_minHitsForDisplay
private

Min hits associated with mc particle to warrant display to terminal.

Definition at line 54 of file MCParticleMonitoringAlgorithm.h.

bool lar_content::MCParticleMonitoringAlgorithm::m_useTrueNeutrinosOnly
private

Whether to consider only mc particles that were neutrino induced.

Definition at line 53 of file MCParticleMonitoringAlgorithm.h.


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