9 #include "Pandora/AlgorithmHeaders.h" 22 void CheatingEventSlicingTool::RunSlicing(
const Algorithm *
const pAlgorithm,
const HitTypeToNameMap &caloHitListNames,
25 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
26 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
29 this->InitializeMCParticleToSliceMap(pAlgorithm, caloHitListNames, mcParticleToSliceMap);
31 this->FillSlices(pAlgorithm, TPC_VIEW_U, caloHitListNames, mcParticleToSliceMap);
32 this->FillSlices(pAlgorithm, TPC_VIEW_V, caloHitListNames, mcParticleToSliceMap);
33 this->FillSlices(pAlgorithm, TPC_VIEW_W, caloHitListNames, mcParticleToSliceMap);
36 for (
const auto &mapEntry : mcParticleToSliceMap)
37 mcParticleVector.push_back(mapEntry.first);
38 std::sort(mcParticleVector.begin(), mcParticleVector.end(), LArMCParticleHelper::SortByMomentum);
40 for (
const MCParticle *
const pMCParticle : mcParticleVector)
42 const Slice &slice(mcParticleToSliceMap.at(pMCParticle));
44 if (!slice.m_caloHitListU.empty() || !slice.m_caloHitListV.empty() || !slice.m_caloHitListW.empty())
45 sliceList.push_back(slice);
51 void CheatingEventSlicingTool::InitializeMCParticleToSliceMap(
54 for (
const auto &mapEntry : caloHitListNames)
56 const CaloHitList *pCaloHitList(
nullptr);
57 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*pAlgorithm, mapEntry.second, pCaloHitList));
59 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
62 for (
const auto &weightMapEntry : pCaloHit->GetMCParticleWeightMap())
63 mcParticleVector.push_back(weightMapEntry.first);
64 std::sort(mcParticleVector.begin(), mcParticleVector.end(), LArMCParticleHelper::SortByMomentum);
66 for (
const MCParticle *
const pMCParticle : mcParticleVector)
68 const MCParticle *
const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
70 if (mcParticleToSliceMap.count(pParentMCParticle))
73 if (!mcParticleToSliceMap.insert(MCParticleToSliceMap::value_type(pParentMCParticle,
Slice())).second)
74 throw StatusCodeException(STATUS_CODE_FAILURE);
82 void CheatingEventSlicingTool::FillSlices(
const Algorithm *
const pAlgorithm,
const HitType hitType,
85 if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
86 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
88 const CaloHitList *pCaloHitList(
nullptr);
89 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*pAlgorithm, caloHitListNames.at(hitType), pCaloHitList));
91 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
95 const MCParticle *
const pMainMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
96 const MCParticle *
const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMainMCParticle));
100 if (mcParticleToSliceMap.end() == mapIter)
101 throw StatusCodeException(STATUS_CODE_FAILURE);
103 Slice &slice(mapIter->second);
104 CaloHitList &caloHitList((TPC_VIEW_U == hitType) ? slice.
m_caloHitListU 107 caloHitList.push_back(pCaloHit);
109 catch (
const StatusCodeException &statusCodeException)
111 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
112 throw statusCodeException;
119 StatusCode CheatingEventSlicingTool::ReadSettings(
const TiXmlHandle )
121 return STATUS_CODE_SUCCESS;
std::unordered_map< const pandora::MCParticle *, Slice > MCParticleToSliceMap
std::vector< Slice > SliceList
pandora::CaloHitList m_caloHitListW
The w calo hit list.
pandora::CaloHitList m_caloHitListU
The u calo hit list.
pandora::CaloHitList m_caloHitListV
The v calo hit list.
Header file for the lar monte carlo particle helper helper class.
std::map< pandora::HitType, std::string > HitTypeToNameMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector