Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
InteractionSelectionAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
23
24//------------------------------------------------------------------------------------------------------------------------------------------
25
27{
28 const CaloHitList *pCaloHitList{nullptr};
29 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, "CaloHitList2D", pCaloHitList));
30
31 std::set<const MCParticle *> mcSet;
32 std::map<const MCParticle *, CaloHitList> mcHitMap;
33 for (const CaloHit *pCaloHit : *pCaloHitList)
34 {
35 const MCParticle *pMCParticle{MCParticleHelper::GetMainMCParticle(pCaloHit)};
36 if (!pMCParticle)
37 continue;
38 const MCParticle *pParent{pMCParticle};
39 while (!pParent->GetParentList().empty())
40 pParent = pParent->GetParentList().front();
42 {
43 mcSet.insert(pParent);
44 mcHitMap[pParent].emplace_back(pCaloHit);
45 }
46 }
47
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;
51
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"));
56
57 int i{0};
58 MCParticleList selectedNeutrinos;
59 CaloHitList caloHitListU, caloHitListV, caloHitListW, caloHitList2D;
60 for (auto &[pParent, caloHits] : mcHitMap)
61 {
62 if (std::find(m_interactionIds.begin(), m_interactionIds.end(), i) != m_interactionIds.end())
63 {
64 selectedNeutrinos.emplace_back(pParent);
65 for (const CaloHit *pCaloHit : caloHits)
66 {
67 switch (pCaloHit->GetHitType())
68 {
69 case TPC_VIEW_U:
70 caloHitListU.emplace_back(pCaloHit);
71 caloHitList2D.emplace_back(pCaloHit);
72 break;
73 case TPC_VIEW_V:
74 caloHitListV.emplace_back(pCaloHit);
75 caloHitList2D.emplace_back(pCaloHit);
76 break;
77 case TPC_VIEW_W:
78 caloHitListW.emplace_back(pCaloHit);
79 caloHitList2D.emplace_back(pCaloHit);
80 break;
81 default:
82 break;
83 }
84 }
85 }
86 std::cout << "MC: " << pParent << " (" << pParent->GetParticleId() << ") " << caloHits.size() << std::endl;
87 ++i;
88 }
89
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"));
95
96 return STATUS_CODE_SUCCESS;
97}
98
99//------------------------------------------------------------------------------------------------------------------------------------------
100
102{
103 (void)xmlHandle;
104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InteractionIds", m_interactionIds));
105
106 return STATUS_CODE_SUCCESS;
107}
108
109} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the post processing algorithm class.
Header file for the lar monte carlo particle helper helper class.
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode SaveList(const pandora::Algorithm &algorithm, const T &t, const std::string &newListName)
Save a provided input object list under a new name.
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.
CaloHit class.
Definition CaloHit.h:26
static const MCParticle * GetMainMCParticle(const T *const pT)
Find the mc particle making the largest contribution to a specified calo hit, track or cluster.
MCParticle class.
Definition MCParticle.h:26
const MCParticleList & GetParentList() const
Get list of parents of mc particle.
Definition MCParticle.h:299
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
MANAGED_CONTAINER< const MCParticle * > MCParticleList
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.