LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
g4b::PrimaryParticleInformation Class Reference

#include "PrimaryParticleInformation.h"

Inheritance diagram for g4b::PrimaryParticleInformation:

Public Types

using GeneratedParticleIndex_t = simb::GeneratedParticleIndex_t
 Type of the stored index of particle within the truth record. More...
 

Public Member Functions

void * operator new (size_t)
 
void operator delete (void *)
 
const simb::MCTruthGetMCTruth () const
 
size_t const & MCTruthIndex () const
 
GeneratedParticleIndex_t MCParticleIndex () const
 Returns the index of the corresponding particle in truth record. More...
 
simb::MCParticle const * GetMCParticle () const
 
bool IsInMCTruth () const
 
void SetMCTruth (const simb::MCTruth *m, size_t idx=0, GeneratedParticleIndex_t indexInTruth=simb::NoGeneratedParticleIndex)
 
virtual void Print () const override
 

Private Attributes

const simb::MCTruthfMCTruth = nullptr
 
size_t fMCTIndex = 0
 
GeneratedParticleIndex_t fMCParticleIndex = simb::NoGeneratedParticleIndex
 Index within the truth record. More...
 

Detailed Description

Definition at line 57 of file PrimaryParticleInformation.h.

Member Typedef Documentation

Type of the stored index of particle within the truth record.

Definition at line 62 of file PrimaryParticleInformation.h.

Member Function Documentation

simb::MCParticle const * g4b::PrimaryParticleInformation::GetMCParticle ( ) const

Returns the original particle in the truth record.

Returns
pointer to the original particle, or nullptr if not available
See also
MCParticleIndex(), GetMCTruth()

Definition at line 16 of file PrimaryParticleInformation.cxx.

References GetMCTruth(), IsInMCTruth(), and MCParticleIndex().

17  {
18  if (!IsInMCTruth()) return nullptr;
19  auto const* truth = GetMCTruth();
20  if (!truth) return nullptr;
21  auto const index = MCParticleIndex();
22  if (index >= (std::size_t) truth->NParticles()) return nullptr; // or should we throw?
23  return &(truth->GetParticle(index));
24  } // PrimaryParticleInformation::GetMCParticle()
const simb::MCTruth * GetMCTruth() const
GeneratedParticleIndex_t MCParticleIndex() const
Returns the index of the corresponding particle in truth record.
const simb::MCTruth* g4b::PrimaryParticleInformation::GetMCTruth ( ) const
inline

Definition at line 68 of file PrimaryParticleInformation.h.

Referenced by GetMCParticle().

68 { return fMCTruth; }
bool g4b::PrimaryParticleInformation::IsInMCTruth ( ) const
inline

Returns whether this particle has a corresponding truth record item.

See also
MCParticleIndex(), GetMCTruth()

Definition at line 123 of file PrimaryParticleInformation.h.

References simb::NoGeneratedParticleIndex.

Referenced by GetMCParticle().

constexpr GeneratedParticleIndex_t NoGeneratedParticleIndex
Constant representing the absence of generator truth information.
Definition: simb.h:34
GeneratedParticleIndex_t MCParticleIndex() const
Returns the index of the corresponding particle in truth record.
GeneratedParticleIndex_t g4b::PrimaryParticleInformation::MCParticleIndex ( ) const
inline

Returns the index of the corresponding particle in truth record.

Returns
an index within truth record, NotInMCTruth otherwise
See also
IsInMCTruth(), GetMCTruth()

This method returns the index in the truth record pointed by GetMCTruth() of the particle (simb::MCParticle) corresponding to this object. If this information is not set, or if there is no such a particle at all, the special value NotInMCTruth is returned. This can be checked with the IsInMCTruth() method. T

Definition at line 82 of file PrimaryParticleInformation.h.

References simb::NoGeneratedParticleIndex, and pyG4Element::Print().

Referenced by GetMCParticle(), and larg4::ParticleListAction::PreTrackingAction().

83  { return fMCParticleIndex; }
GeneratedParticleIndex_t fMCParticleIndex
Index within the truth record.
size_t const& g4b::PrimaryParticleInformation::MCTruthIndex ( ) const
inline

Definition at line 69 of file PrimaryParticleInformation.h.

void g4b::PrimaryParticleInformation::operator delete ( void *  aPrimaryParticleInformation)
inline

Definition at line 145 of file PrimaryParticleInformation.h.

146  {
147  PrimaryParticleInformationAllocator.FreeSingle((PrimaryParticleInformation*) aPrimaryParticleInformation);
148  }
G4Allocator< PrimaryParticleInformation > PrimaryParticleInformationAllocator
void * g4b::PrimaryParticleInformation::operator new ( size_t  )
inline

Definition at line 138 of file PrimaryParticleInformation.h.

139  {
140  void *aPrimaryParticleInformation;
141  aPrimaryParticleInformation = (void *) PrimaryParticleInformationAllocator.MallocSingle();
142  return aPrimaryParticleInformation;
143  }
G4Allocator< PrimaryParticleInformation > PrimaryParticleInformationAllocator
void g4b::PrimaryParticleInformation::Print ( ) const
overridevirtual

Definition at line 28 of file PrimaryParticleInformation.cxx.

References fMCTruth.

29  {
30  if ( fMCTruth )
31  std::cout << *fMCTruth;
32  }
void g4b::PrimaryParticleInformation::SetMCTruth ( const simb::MCTruth m,
size_t  idx = 0,
GeneratedParticleIndex_t  indexInTruth = simb::NoGeneratedParticleIndex 
)
inline

Definition at line 127 of file PrimaryParticleInformation.h.

Referenced by g4b::ConvertMCTruthToG4::GeneratePrimaries().

132  {
133  fMCTruth = m;
134  fMCTIndex = idx;
135  fMCParticleIndex = indexInTruth;
136  }
GeneratedParticleIndex_t fMCParticleIndex
Index within the truth record.

Member Data Documentation

GeneratedParticleIndex_t g4b::PrimaryParticleInformation::fMCParticleIndex = simb::NoGeneratedParticleIndex
private

Index within the truth record.

Definition at line 114 of file PrimaryParticleInformation.h.

size_t g4b::PrimaryParticleInformation::fMCTIndex = 0
private

Definition at line 112 of file PrimaryParticleInformation.h.

const simb::MCTruth* g4b::PrimaryParticleInformation::fMCTruth = nullptr
private

Definition at line 111 of file PrimaryParticleInformation.h.

Referenced by Print().


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