9 #include "Pandora/AlgorithmHeaders.h" 20 InteractionSelectionAlgorithm::InteractionSelectionAlgorithm()
26 StatusCode InteractionSelectionAlgorithm::Run()
28 const CaloHitList *pCaloHitList{
nullptr};
29 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
"CaloHitList2D", pCaloHitList));
31 std::set<const MCParticle *> mcSet;
32 std::map<const MCParticle *, CaloHitList> mcHitMap;
33 for (
const CaloHit *pCaloHit : *pCaloHitList)
35 const MCParticle *pMCParticle{MCParticleHelper::GetMainMCParticle(pCaloHit)};
38 const MCParticle *pParent{pMCParticle};
39 while (!pParent->GetParentList().empty())
40 pParent = pParent->GetParentList().front();
41 if (LArMCParticleHelper::IsNeutrino(pParent))
43 mcSet.insert(pParent);
44 mcHitMap[pParent].emplace_back(pCaloHit);
48 std::cout <<
"Num hits: " << pCaloHitList->size() <<
" Num MC: " << mcSet.size() << std::endl;
49 for (
auto &[pParent, caloHits] : mcHitMap)
50 std::cout <<
"MC: " << pParent <<
" (" << pParent->GetParticleId() <<
") " << caloHits.size() << std::endl;
52 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RenameList<CaloHitList>(*
this,
"CaloHitList2D",
"InputCaloHitList2D"));
53 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RenameList<CaloHitList>(*
this,
"CaloHitListU",
"InputCaloHitU"));
54 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RenameList<CaloHitList>(*
this,
"CaloHitListV",
"InputCaloHitV"));
55 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RenameList<CaloHitList>(*
this,
"CaloHitListW",
"InputCaloHitW"));
58 MCParticleList selectedNeutrinos;
59 CaloHitList caloHitListU, caloHitListV, caloHitListW, caloHitList2D;
60 for (
auto &[pParent, caloHits] : mcHitMap)
62 if (std::find(m_interactionIds.begin(), m_interactionIds.end(), i) != m_interactionIds.end())
64 selectedNeutrinos.emplace_back(pParent);
65 for (
const CaloHit *pCaloHit : caloHits)
67 switch (pCaloHit->GetHitType())
70 caloHitListU.emplace_back(pCaloHit);
71 caloHitList2D.emplace_back(pCaloHit);
74 caloHitListV.emplace_back(pCaloHit);
75 caloHitList2D.emplace_back(pCaloHit);
78 caloHitListW.emplace_back(pCaloHit);
79 caloHitList2D.emplace_back(pCaloHit);
86 std::cout <<
"MC: " << pParent <<
" (" << pParent->GetParticleId() <<
") " << caloHits.size() << std::endl;
90 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, selectedNeutrinos,
"SelectedNeutrinos"));
91 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, caloHitList2D,
"CaloHitList2D"));
92 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, caloHitListU,
"CaloHitListU"));
93 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, caloHitListV,
"CaloHitListV"));
94 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, caloHitListW,
"CaloHitListW"));
96 return STATUS_CODE_SUCCESS;
101 StatusCode InteractionSelectionAlgorithm::ReadSettings(
const TiXmlHandle xmlHandle)
104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
"InteractionIds", m_interactionIds));
106 return STATUS_CODE_SUCCESS;
Header file for the post processing algorithm class.
Header file for the lar monte carlo particle helper helper class.