LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::CheatingEventSlicingTool Class Reference

CheatingEventSlicingTool class. More...

#include "CheatingEventSlicingTool.h"

Inheritance diagram for lar_content::CheatingEventSlicingTool:
lar_content::EventSlicingBaseTool

Public Member Functions

void RunSlicing (const pandora::Algorithm *const pAlgorithm, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, const SlicingAlgorithm::HitTypeToNameMap &clusterListNames, SlicingAlgorithm::SliceList &sliceList)
 Run the slicing tool. More...
 

Private Types

typedef std::unordered_map< const pandora::MCParticle *, SlicingAlgorithm::SliceMCParticleToSliceMap
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void InitializeMCParticleToSliceMap (const pandora::Algorithm *const pAlgorithm, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, MCParticleToSliceMap &mcParticleToSliceMap) const
 Initialize the map from parent mc particles to slice objects. More...
 
void FillSlices (const pandora::Algorithm *const pAlgorithm, const pandora::HitType hitType, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, MCParticleToSliceMap &mcParticleToSliceMap) const
 Fill slices using hits from a specified view. More...
 

Detailed Description

CheatingEventSlicingTool class.

Definition at line 21 of file CheatingEventSlicingTool.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::MCParticle*, SlicingAlgorithm::Slice> lar_content::CheatingEventSlicingTool::MCParticleToSliceMap
private

Definition at line 30 of file CheatingEventSlicingTool.h.

Member Function Documentation

void lar_content::CheatingEventSlicingTool::FillSlices ( const pandora::Algorithm *const  pAlgorithm,
const pandora::HitType  hitType,
const SlicingAlgorithm::HitTypeToNameMap caloHitListNames,
MCParticleToSliceMap mcParticleToSliceMap 
) const
private

Fill slices using hits from a specified view.

Parameters
pAlgorithmaddress of the calling algorithm
hitTypethe hit type (i.e. view)
caloHitListNamesthe hit type to calo hit list name map
mcParticleToSliceMapto receive the parent mc particle to slice map

Definition at line 84 of file CheatingEventSlicingTool.cc.

References lar_content::SlicingAlgorithm::Slice::m_caloHitListU, lar_content::SlicingAlgorithm::Slice::m_caloHitListV, and lar_content::SlicingAlgorithm::Slice::m_caloHitListW.

86 {
87  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
88  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
89 
90  const CaloHitList *pCaloHitList(nullptr);
91  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*pAlgorithm, caloHitListNames.at(hitType), pCaloHitList));
92 
93  for (const CaloHit *const pCaloHit : *pCaloHitList)
94  {
95  try
96  {
97  const MCParticle *const pMainMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
98  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMainMCParticle));
99 
100  MCParticleToSliceMap::iterator mapIter = mcParticleToSliceMap.find(pParentMCParticle);
101 
102  if (mcParticleToSliceMap.end() == mapIter)
103  throw StatusCodeException(STATUS_CODE_FAILURE);
104 
105  Slice &slice(mapIter->second);
106  CaloHitList &caloHitList((TPC_VIEW_U == hitType) ? slice.m_caloHitListU : (TPC_VIEW_V == hitType) ? slice.m_caloHitListV : slice.m_caloHitListW);
107  caloHitList.push_back(pCaloHit);
108  }
109  catch (const StatusCodeException &statusCodeException)
110  {
111  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
112  throw statusCodeException;
113  }
114  }
115 }
SlicingAlgorithm::Slice Slice
intermediate_table::iterator iterator
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
void lar_content::CheatingEventSlicingTool::InitializeMCParticleToSliceMap ( const pandora::Algorithm *const  pAlgorithm,
const SlicingAlgorithm::HitTypeToNameMap caloHitListNames,
MCParticleToSliceMap mcParticleToSliceMap 
) const
private

Initialize the map from parent mc particles to slice objects.

Parameters
pAlgorithmaddress of the calling algorithm
caloHitListNamesthe hit type to calo hit list name map
mcParticleToSliceMapto receive the parent mc particle to slice map

Definition at line 54 of file CheatingEventSlicingTool.cc.

56 {
57  for (const auto &mapEntry : caloHitListNames)
58  {
59  const CaloHitList *pCaloHitList(nullptr);
60  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*pAlgorithm, mapEntry.second, pCaloHitList));
61 
62  for (const CaloHit *const pCaloHit : *pCaloHitList)
63  {
64  MCParticleVector mcParticleVector;
65  for (const auto &weightMapEntry : pCaloHit->GetMCParticleWeightMap()) mcParticleVector.push_back(weightMapEntry.first);
66  std::sort(mcParticleVector.begin(), mcParticleVector.end(), LArMCParticleHelper::SortByMomentum);
67 
68  for (const MCParticle *const pMCParticle : mcParticleVector)
69  {
70  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
71 
72  if (mcParticleToSliceMap.count(pParentMCParticle))
73  continue;
74 
75  if (!mcParticleToSliceMap.insert(MCParticleToSliceMap::value_type(pParentMCParticle, Slice())).second)
76  throw StatusCodeException(STATUS_CODE_FAILURE);
77  }
78  }
79  }
80 }
SlicingAlgorithm::Slice Slice
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.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
StatusCode lar_content::CheatingEventSlicingTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 119 of file CheatingEventSlicingTool.cc.

120 {
121  return STATUS_CODE_SUCCESS;
122 }
void lar_content::CheatingEventSlicingTool::RunSlicing ( const pandora::Algorithm *const  pAlgorithm,
const SlicingAlgorithm::HitTypeToNameMap caloHitListNames,
const SlicingAlgorithm::HitTypeToNameMap clusterListNames,
SlicingAlgorithm::SliceList sliceList 
)
virtual

Run the slicing tool.

Parameters
pAlgorithmaddress of the calling algorithm
caloHitListNamesthe hit type to calo hit list name map
clusterListNamesthe hit type to cluster list name map
sliceListto receive the populated slice list

Implements lar_content::EventSlicingBaseTool.

Definition at line 26 of file CheatingEventSlicingTool.cc.

28 {
29  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
30  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
31 
32  MCParticleToSliceMap mcParticleToSliceMap;
33  this->InitializeMCParticleToSliceMap(pAlgorithm, caloHitListNames, mcParticleToSliceMap);
34 
35  this->FillSlices(pAlgorithm, TPC_VIEW_U, caloHitListNames, mcParticleToSliceMap);
36  this->FillSlices(pAlgorithm, TPC_VIEW_V, caloHitListNames, mcParticleToSliceMap);
37  this->FillSlices(pAlgorithm, TPC_VIEW_W, caloHitListNames, mcParticleToSliceMap);
38 
39  MCParticleVector mcParticleVector;
40  for (const auto &mapEntry : mcParticleToSliceMap) mcParticleVector.push_back(mapEntry.first);
41  std::sort(mcParticleVector.begin(), mcParticleVector.end(), LArMCParticleHelper::SortByMomentum);
42 
43  for (const MCParticle *const pMCParticle : mcParticleVector)
44  {
45  const Slice &slice(mcParticleToSliceMap.at(pMCParticle));
46 
47  if (!slice.m_caloHitListU.empty() || !slice.m_caloHitListV.empty() || !slice.m_caloHitListW.empty())
48  sliceList.push_back(slice);
49  }
50 }
SlicingAlgorithm::Slice Slice
void FillSlices(const pandora::Algorithm *const pAlgorithm, const pandora::HitType hitType, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, MCParticleToSliceMap &mcParticleToSliceMap) const
Fill slices using hits from a specified view.
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 InitializeMCParticleToSliceMap(const pandora::Algorithm *const pAlgorithm, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, MCParticleToSliceMap &mcParticleToSliceMap) const
Initialize the map from parent mc particles to slice objects.
std::unordered_map< const pandora::MCParticle *, SlicingAlgorithm::Slice > MCParticleToSliceMap

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