LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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

Constructor & Destructor Documentation

lar_content::MCParticleMonitoringAlgorithm::MCParticleMonitoringAlgorithm ( )

Default constructor.

Definition at line 26 of file MCParticleMonitoringAlgorithm.cc.

26  :
29 {
30 }
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 114 of file MCParticleMonitoringAlgorithm.cc.

References lar_content::LArMonitoringHelper::CountHitsByType(), and m_minHitsForDisplay.

Referenced by PrintPrimaryMCParticles().

116 {
117  const CaloHitList &caloHitList(mcToTrueHitListMap.count(pMCParticle) ? mcToTrueHitListMap.at(pMCParticle) : CaloHitList());
118 
119  if (caloHitList.size() >= m_minHitsForDisplay)
120  {
121  if (depth > 1)
122  {
123  for (int iDepth = 1; iDepth < depth - 1; ++iDepth) std::cout << " ";
124  std::cout << "\\_ ";
125  }
126 
127  std::cout << "MCPDG " << pMCParticle->GetParticleId() << ", Energy " << pMCParticle->GetEnergy()
128  << ", Dist. " << (pMCParticle->GetEndpoint() - pMCParticle->GetVertex()).GetMagnitude() << ", nMCHits " << caloHitList.size()
129  << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, caloHitList)
130  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, caloHitList)
131  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, caloHitList) << ")" << std::endl;
132  }
133 
134  for (const MCParticle *const pDaughterParticle : pMCParticle->GetDaughterList())
135  this->PrintMCParticle(pDaughterParticle, mcToTrueHitListMap, depth + 1);
136 }
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.
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 82 of file MCParticleMonitoringAlgorithm.cc.

References lar_content::LArMonitoringHelper::CountHitsByType(), lar_content::LArMCParticleHelper::GetMCParticleToCaloHitMatches(), lar_content::LArMonitoringHelper::GetOrderedMCParticleVector(), m_minHitsForDisplay, and PrintMCParticle().

Referenced by Run().

83 {
84  MCParticleVector mcPrimaryVector;
85  LArMonitoringHelper::GetOrderedMCParticleVector({mcContributionMap}, mcPrimaryVector);
86 
87  unsigned int index(0);
88 
89  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
90  {
91  const CaloHitList &caloHitList(mcContributionMap.at(pMCPrimary));
92 
93  if (caloHitList.size() >= m_minHitsForDisplay)
94  {
95  std::cout << std::endl << "--Primary " << index << ", MCPDG " << pMCPrimary->GetParticleId() << ", Energy " << pMCPrimary->GetEnergy()
96  << ", Dist. " << (pMCPrimary->GetEndpoint() - pMCPrimary->GetVertex()).GetMagnitude() << ", nMCHits " << caloHitList.size()
97  << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, caloHitList)
98  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, caloHitList)
99  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, caloHitList) << ")" << std::endl;
100 
101  LArMCParticleHelper::MCRelationMap mcToPrimaryMCMap;
102  LArMCParticleHelper::CaloHitToMCMap caloHitToPrimaryMCMap;
103  LArMCParticleHelper::MCContributionMap mcToTrueHitListMap;
104  LArMCParticleHelper::GetMCParticleToCaloHitMatches(&caloHitList, mcToPrimaryMCMap, caloHitToPrimaryMCMap, mcToTrueHitListMap);
105  this->PrintMCParticle(pMCPrimary, mcToTrueHitListMap, 1);
106  }
107 
108  ++index;
109  }
110 }
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.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::unordered_map< const pandora::CaloHit *, const pandora::MCParticle * > CaloHitToMCMap
static void GetMCParticleToCaloHitMatches(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToPrimaryMCMap, CaloHitToMCMap &hitToMCMap, MCContributionMap &mcToTrueHitListMap)
Match calo hits to their parent particles.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
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.
StatusCode lar_content::MCParticleMonitoringAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 140 of file MCParticleMonitoringAlgorithm.cc.

References m_caloHitListName, m_mcParticleListName, m_minHitsForDisplay, and m_useTrueNeutrinosOnly.

141 {
142  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
143  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
144 
145  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
146  "UseTrueNeutrinosOnly", m_useTrueNeutrinosOnly));
147 
148  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
149  "MinHitsForDisplay", m_minHitsForDisplay));
150 
151  return STATUS_CODE_SUCCESS;
152 }
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 34 of file MCParticleMonitoringAlgorithm.cc.

References lar_content::LArMCParticleHelper::IsBeamNeutrinoFinalState(), lar_content::LArMCParticleHelper::IsBeamParticle(), lar_content::LArMCParticleHelper::IsCosmicRay(), m_caloHitListName, m_mcParticleListName, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, m_useTrueNeutrinosOnly, PrintPrimaryMCParticles(), and lar_content::LArMCParticleHelper::SelectReconstructableMCParticles().

35 {
36  std::cout << "---MC-PARTICLE-MONITORING-----------------------------------------------------------------------" << std::endl;
37  const MCParticleList *pMCParticleList = nullptr;
38  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
39 
40  const CaloHitList *pCaloHitList = nullptr;
41  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
42 
43  LArMCParticleHelper::PrimaryParameters parameters;
44  parameters.m_minHitSharingFraction = 0.f;
45 
46  LArMCParticleHelper::MCContributionMap nuMCParticlesToGoodHitsMap;
47  LArMCParticleHelper::MCContributionMap beamMCParticlesToGoodHitsMap;
48  LArMCParticleHelper::MCContributionMap crMCParticlesToGoodHitsMap;
49  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsBeamNeutrinoFinalState, nuMCParticlesToGoodHitsMap);
50 
52  {
53  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsBeamParticle, beamMCParticlesToGoodHitsMap);
54  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsCosmicRay, crMCParticlesToGoodHitsMap);
55  }
56 
57  if (!nuMCParticlesToGoodHitsMap.empty())
58  {
59  std::cout << std::endl << "BeamNeutrinos: " << std::endl;
60  this->PrintPrimaryMCParticles(nuMCParticlesToGoodHitsMap);
61  }
62 
63  if (!beamMCParticlesToGoodHitsMap.empty())
64  {
65  std::cout << std::endl << "BeamParticles: " << std::endl;
66  this->PrintPrimaryMCParticles(beamMCParticlesToGoodHitsMap);
67  }
68 
69  if (!crMCParticlesToGoodHitsMap.empty())
70  {
71  std::cout << std::endl << "CosmicRays: " << std::endl;
72  this->PrintPrimaryMCParticles(crMCParticlesToGoodHitsMap);
73  }
74 
75  std::cout << "------------------------------------------------------------------------------------------------" << std::endl;
76 
77  return STATUS_CODE_SUCCESS;
78 }
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 primary, reconstructable mc particles that match given criteria.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
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.

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.

Referenced by ReadSettings(), and Run().

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

Name of input MC particle list.

Definition at line 51 of file MCParticleMonitoringAlgorithm.h.

Referenced by ReadSettings(), and Run().

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.

Referenced by PrintMCParticle(), PrintPrimaryMCParticles(), and ReadSettings().

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.

Referenced by ReadSettings(), and Run().


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