LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::InteractionSelectionAlgorithm Class Reference

InteractionSelectionAlgorithm class. More...

#include "InteractionSelectionAlgorithm.h"

Inheritance diagram for lar_content::InteractionSelectionAlgorithm:

Public Member Functions

 InteractionSelectionAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

pandora::IntVector m_interactionIds
 

Detailed Description

Constructor & Destructor Documentation

lar_content::InteractionSelectionAlgorithm::InteractionSelectionAlgorithm ( )

Default constructor.

Definition at line 20 of file InteractionSelectionAlgorithm.cc.

21 {
22 }

Member Function Documentation

StatusCode lar_content::InteractionSelectionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 101 of file InteractionSelectionAlgorithm.cc.

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 }
StatusCode lar_content::InteractionSelectionAlgorithm::Run ( )
private

Definition at line 26 of file InteractionSelectionAlgorithm.cc.

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 }
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.

Member Data Documentation

pandora::IntVector lar_content::InteractionSelectionAlgorithm::m_interactionIds
private

Definition at line 32 of file InteractionSelectionAlgorithm.h.


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