LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PrimaryParticleInformation.cxx
Go to the documentation of this file.
1 //
9 
10 namespace g4b{
11 
12  //-------------------------------------------------
13  G4Allocator<PrimaryParticleInformation> PrimaryParticleInformationAllocator;
14 
15  //-------------------------------------------------
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()
25 
26 
27  //-------------------------------------------------
29  {
30  if ( fMCTruth )
31  std::cout << *fMCTruth;
32  }
33 
34 }// namespace
const simb::MCTruth * GetMCTruth() const
simb::MCParticle const * GetMCParticle() const
G4Allocator< PrimaryParticleInformation > PrimaryParticleInformationAllocator
basic interface to Geant4 for ART-based software
GeneratedParticleIndex_t MCParticleIndex() const
Returns the index of the corresponding particle in truth record.