LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArEventTopology::Particle Class Reference

Public Member Functions

 Particle (const pandora::MCParticle *const pRoot)
 Default constructor. More...
 
 Particle (const pandora::MCParticle *const pRoot, const pandora::CaloHitList &caloHitList)
 Default constructor. More...
 
virtual ~Particle ()
 Destructor. More...
 
void AddChild (Particle *pChild)
 Add a child particle to this particle. More...
 
void GetVertices (pandora::CartesianPointVector &vertices) const
 Extract the clear topological vertices from the event. More...
 
void Parse (const MCHitMap &mcHitMap)
 Assess this child particle and its descendents to see if it is topologically significant either indepednently or within the context of downstream activity. More...
 
void Prune ()
 Prune particles from the hierarchy if they are not deemed topologically significant. More...
 
const std::string Print (const MCHitMap &mcHitMap, const std::string &indent) const
 Print the visible hierarchy. More...
 

Private Attributes

pandora::MCParticleList m_particles
 
pandora::CaloHitList m_caloHits
 
std::list< Particle * > m_children
 
bool m_fold
 

Detailed Description

Definition at line 26 of file LArEventTopology.h.

Constructor & Destructor Documentation

lar_content::LArEventTopology::Particle::Particle ( const pandora::MCParticle *const  pRoot)

Default constructor.

Referenced by lar_content::LArEventTopology::PruneHierarchy().

lar_content::LArEventTopology::Particle::Particle ( const pandora::MCParticle *const  pRoot,
const pandora::CaloHitList &  caloHitList 
)

Default constructor.

Parameters
pRootThe MC particle
caloHitListThe list of hits associated with this particle
lar_content::LArEventTopology::Particle::~Particle ( )
virtual

Destructor.

Definition at line 149 of file LArEventTopology.cc.

150 {
151  for (Particle *pParticle : m_children)
152  delete pParticle;
153 }
Particle(const pandora::MCParticle *const pRoot)
Default constructor.

Member Function Documentation

void lar_content::LArEventTopology::Particle::AddChild ( Particle pChild)

Add a child particle to this particle.

Parameters
pChildThe child particle to add

Definition at line 157 of file LArEventTopology.cc.

Referenced by lar_content::LArEventTopology::Print().

158 {
159  m_children.emplace_back(pChild);
160 }
void lar_content::LArEventTopology::Particle::GetVertices ( pandora::CartesianPointVector &  vertices) const

Extract the clear topological vertices from the event.

Definition at line 164 of file LArEventTopology.cc.

References util::abs(), and lar_content::LArMCParticleHelper::IsNeutrino().

Referenced by lar_content::LArEventTopology::GetVertices().

165 {
166  const MCParticle *const pMC{m_particles.front()};
168  {
169  if (std::find(vertices.begin(), vertices.end(), pMC->GetVertex()) == vertices.end())
170  vertices.emplace_back(pMC->GetVertex());
171  }
172  else
173  {
174  // Consider vertex
175  const MCParticle *const pParentMC{pMC->GetParentList().front()};
176  if (LArMCParticleHelper::IsNeutrino(pParentMC))
177  {
178  if (std::find(vertices.begin(), vertices.end(), pMC->GetVertex()) == vertices.end())
179  vertices.emplace_back(pMC->GetVertex());
180  }
181  else
182  {
183  const CartesianVector &momParent{pParentMC->GetMomentum().GetUnitVector()};
184  const CartesianVector &mom{pMC->GetMomentum().GetUnitVector()};
185  if ((pMC->GetParticleId() != pParentMC->GetParticleId()) || (mom.GetDotProduct(momParent) < 0.996f))
186  {
187  // Visible photon vertices occur at the endpoint, not the vertex, so skip photons here
188  if (pMC->GetParticleId() != PHOTON && std::find(vertices.begin(), vertices.end(), pMC->GetVertex()) == vertices.end())
189  vertices.emplace_back(pMC->GetVertex());
190  }
191  }
192  // Consider end point
193  int nTrackLikeChildren{0};
194  for (const Particle *const pChild : m_children)
195  {
196  const MCParticle *const pChildMC{pChild->m_particles.front()};
197  const int pdg{std::abs(pChildMC->GetParticleId())};
198  if (!(pdg == PHOTON || pdg == E_MINUS))
199  ++nTrackLikeChildren;
200  }
201  // If only shower children, or if more than 1 track, tag the endpoint as a vertex
202  // If we have exactly 1 track child, then downstream vertex checks will take care of this
203  // Also note that the endpoint of a photon actually marks the start of the associated hit deposition
204  if (nTrackLikeChildren != 1)
205  {
206  if (std::find(vertices.begin(), vertices.end(), pMC->GetEndpoint()) == vertices.end())
207  vertices.emplace_back(pMC->GetEndpoint());
208  }
209  }
210 
211  for (const Particle *const pChild : m_children)
212  pChild->GetVertices(vertices);
213 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
Particle(const pandora::MCParticle *const pRoot)
Default constructor.
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.
void lar_content::LArEventTopology::Particle::Parse ( const MCHitMap mcHitMap)

Assess this child particle and its descendents to see if it is topologically significant either indepednently or within the context of downstream activity.

Parameters
mcHitMapThe map from MC particles to hits

Definition at line 217 of file LArEventTopology.cc.

References util::abs(), and target.

Referenced by lar_content::LArEventTopology::PruneHierarchy().

218 {
219  const MCParticle *const pMC{m_particles.front()};
220  const CaloHitList &caloHitList{mcHitMap.find(pMC) != mcHitMap.end() ? mcHitMap.at(pMC) : CaloHitList()};
221  int uHits{0}, vHits{0}, wHits{0};
222  for (const CaloHit *const pCaloHit : caloHitList)
223  {
224  switch (pCaloHit->GetHitType())
225  {
226  case TPC_VIEW_U:
227  ++uHits;
228  break;
229  case TPC_VIEW_V:
230  ++vHits;
231  break;
232  case TPC_VIEW_W:
233  ++wHits;
234  break;
235  default:
236  break;
237  }
238  }
239 
240  const int pdg{std::abs(pMC->GetParticleId())};
241  const int target{pdg == PHOTON || pdg == E_MINUS ? 8 : 5};
242  const int totalHits{uHits + vHits + wHits};
243  int goodViews{uHits >= target ? 1 : 0};
244  goodViews += vHits >= target ? 1 : 0;
245  goodViews += wHits >= target ? 1 : 0;
246 
247  if (totalHits < (3 * target) || goodViews < 2)
248  m_fold = true;
249 
250  for (Particle *const pChild : m_children)
251  pChild->Parse(mcHitMap);
252 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
Particle(const pandora::MCParticle *const pRoot)
Default constructor.
cout<< "-> Edep in the target
Definition: analysis.C:53
const std::string lar_content::LArEventTopology::Particle::Print ( const MCHitMap mcHitMap,
const std::string &  indent 
) const

Print the visible hierarchy.

Parameters
mcHitMapThe map from MC particles to hits
indentThe level of indent for printing
Returns
The string representation of this particle and its children

Definition at line 273 of file LArEventTopology.cc.

Referenced by lar_content::LArEventTopology::Print().

274 {
275  const MCParticle *const pMC{m_particles.front()};
276  const CaloHitList &caloHitList{mcHitMap.find(pMC) != mcHitMap.end() ? mcHitMap.at(pMC) : CaloHitList()};
277  int uHits{0}, vHits{0}, wHits{0};
278  for (const CaloHit *const pCaloHit : caloHitList)
279  {
280  switch (pCaloHit->GetHitType())
281  {
282  case TPC_VIEW_U:
283  ++uHits;
284  break;
285  case TPC_VIEW_V:
286  ++vHits;
287  break;
288  case TPC_VIEW_W:
289  ++wHits;
290  break;
291  default:
292  break;
293  }
294  }
295 
296  std::ostringstream os;
297  os << indent << pMC->GetParticleId() << ": E: " << pMC->GetEnergy() << " GeV";
298  os << " (" << uHits << "," << vHits << "," << wHits << ") " << (m_fold ? "[fold]" : "") << "\n";
299  for (const Particle *const pChild : m_children)
300  os << pChild->Print(mcHitMap, indent + " ");
301 
302  return os.str();
303 }
std::string indent(std::size_t const i)
Particle(const pandora::MCParticle *const pRoot)
Default constructor.
void lar_content::LArEventTopology::Particle::Prune ( )

Prune particles from the hierarchy if they are not deemed topologically significant.

Definition at line 256 of file LArEventTopology.cc.

Referenced by lar_content::LArEventTopology::PruneHierarchy().

257 {
258  for (Particle *const pChild : m_children)
259  pChild->Prune();
260 
261  std::list<Particle> toPrune;
262  for (auto iter = m_children.begin(); iter != m_children.end();)
263  {
264  if ((*iter)->m_fold && (*iter)->m_children.empty())
265  iter = m_children.erase(iter);
266  else
267  ++iter;
268  }
269 }
Particle(const pandora::MCParticle *const pRoot)
Default constructor.

Member Data Documentation

pandora::CaloHitList lar_content::LArEventTopology::Particle::m_caloHits
private

Definition at line 84 of file LArEventTopology.h.

std::list<Particle *> lar_content::LArEventTopology::Particle::m_children
private

Definition at line 85 of file LArEventTopology.h.

bool lar_content::LArEventTopology::Particle::m_fold
private

Definition at line 86 of file LArEventTopology.h.

pandora::MCParticleList lar_content::LArEventTopology::Particle::m_particles
private

Definition at line 83 of file LArEventTopology.h.


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