LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artg4tk::ArtG4tkParticle Class Reference

#include "ArtG4tkParticle.hh"

Public Member Functions

 ArtG4tkParticle ()
 
 ArtG4tkParticle (const int, const CLHEP::HepLorentzVector &)
 
 ArtG4tkParticle (const int, const CLHEP::Hep3Vector &)
 
 ArtG4tkParticle (const ArtG4tkParticle &)
 
 ~ArtG4tkParticle ()
 
ArtG4tkParticleoperator= (const ArtG4tkParticle &other)
 
void SetPDG (const int)
 
void SetMomentum (const CLHEP::HepLorentzVector &)
 
void SetMomentum (const CLHEP::Hep3Vector &)
 
int GetPDG () const
 
std::string GetName () const
 
const CLHEP::HepLorentzVector & GetMomentum () const
 
bool operator< (const ArtG4tkParticle &) const
 

Private Attributes

int fPDG
 
CLHEP::HepLorentzVector fMomentum
 

Detailed Description

Definition at line 10 of file ArtG4tkParticle.hh.

Constructor & Destructor Documentation

artg4tk::ArtG4tkParticle::ArtG4tkParticle ( )

Definition at line 8 of file ArtG4tkParticle.cc.

References fPDG.

9 {
10 
11  fPDG = 0;
12 }
artg4tk::ArtG4tkParticle::ArtG4tkParticle ( const int  pdg,
const CLHEP::HepLorentzVector &  mom 
)

Definition at line 14 of file ArtG4tkParticle.cc.

References fMomentum, and fPDG.

15 {
16 
17  fPDG = pdg;
18  fMomentum = mom;
19 }
CLHEP::HepLorentzVector fMomentum
artg4tk::ArtG4tkParticle::ArtG4tkParticle ( const int  pdg,
const CLHEP::Hep3Vector &  mom 
)

Definition at line 21 of file ArtG4tkParticle.cc.

References SetMomentum(), and SetPDG().

22 {
23 
24  SetPDG(pdg);
25  SetMomentum(mom);
26 }
void SetMomentum(const CLHEP::HepLorentzVector &)
artg4tk::ArtG4tkParticle::ArtG4tkParticle ( const ArtG4tkParticle other)

Definition at line 28 of file ArtG4tkParticle.cc.

29  : fPDG(other.fPDG), fMomentum(other.fMomentum)
30 {}
CLHEP::HepLorentzVector fMomentum
artg4tk::ArtG4tkParticle::~ArtG4tkParticle ( )
inline

Definition at line 17 of file ArtG4tkParticle.hh.

17 {}

Member Function Documentation

const CLHEP::HepLorentzVector& artg4tk::ArtG4tkParticle::GetMomentum ( ) const
inline

Definition at line 38 of file ArtG4tkParticle.hh.

References fMomentum.

39  {
40  return fMomentum;
41  }
CLHEP::HepLorentzVector fMomentum
std::string artg4tk::ArtG4tkParticle::GetName ( ) const

Definition at line 81 of file ArtG4tkParticle.cc.

References fPDG.

Referenced by GetPDG().

82 {
83 
84  // NOTE(JVY): again, this a bit of "risky business" when it comes
85  // to ions/nuclei that can be produced during Geant4 sim.
86  // It all works fine if the analyzer runs in the same job
87  // as Geant4 app because G4IonTable gets populated with
88  // newly produced ions as they appears (on-the-fly).
89  // (Elementary) Particles can be added to the table at the
90  // very start of the job, that's no problem.
91  // But when reading back evt.products, it's NOT the case.
92  // And somehow even G4IonTable::CreateAll<...> doesn't help.
93  //
94  // Maybe better to just store the name as a data member ???
95 
96  assert(fPDG != 0);
97  G4ParticleTable* ptable = G4ParticleTable::GetParticleTable();
98  G4ParticleDefinition* g4pd = ptable->FindParticle(fPDG);
99 
100  // assert(g4pd);
101 
102  if (fPDG > 1000000000 && !g4pd) {
103  return "GenericIon";
104  } else {
105  return std::string(g4pd->GetParticleName().c_str());
106  }
107 }
int artg4tk::ArtG4tkParticle::GetPDG ( ) const
inline

Definition at line 32 of file ArtG4tkParticle.hh.

References fPDG, and GetName().

33  {
34  return fPDG;
35  }
bool artg4tk::ArtG4tkParticle::operator< ( const ArtG4tkParticle ) const
inline

Definition at line 51 of file ArtG4tkParticle.hh.

52  {
53  return true;
54  }
ArtG4tkParticle& artg4tk::ArtG4tkParticle::operator= ( const ArtG4tkParticle other)
inline

Definition at line 20 of file ArtG4tkParticle.hh.

References fMomentum, fPDG, SetMomentum(), and SetPDG().

21  {
22  fPDG = other.fPDG;
23  fMomentum = other.fMomentum;
24  return *this;
25  }
CLHEP::HepLorentzVector fMomentum
void artg4tk::ArtG4tkParticle::SetMomentum ( const CLHEP::HepLorentzVector &  mom)

Definition at line 50 of file ArtG4tkParticle.cc.

References fMomentum.

Referenced by ArtG4tkParticle(), operator=(), and artg4tk::ArtG4tkVtx::SetIncoming().

51 {
52 
53  fMomentum = mom;
54  return;
55 }
CLHEP::HepLorentzVector fMomentum
void artg4tk::ArtG4tkParticle::SetMomentum ( const CLHEP::Hep3Vector &  mom)

Definition at line 58 of file ArtG4tkParticle.cc.

References e, fMomentum, and fPDG.

59 {
60 
61  // NOTE(JVY): A bit of "risky business" in case of ions (apart from
62  // the 6 most basic ones) because they're added "on the fly"
63  // during Geant4 simulation... so if used in the job where
64  // Geant4 sim is also running, it's OK; otherwse better avoid.
65  //
66  assert(fPDG != 0);
67  G4ParticleTable* ptable = G4ParticleTable::GetParticleTable();
68  G4ParticleDefinition* g4pd = ptable->FindParticle(fPDG);
69  assert(g4pd);
70  double mass = g4pd->GetPDGMass();
71  double e = std::sqrt(mom.mag2() + mass * mass);
72  fMomentum.setX(mom.x());
73  fMomentum.setY(mom.y());
74  fMomentum.setZ(mom.z());
75  fMomentum.setE(e);
76 
77  return;
78 }
CLHEP::HepLorentzVector fMomentum
Float_t e
Definition: plot.C:35
void artg4tk::ArtG4tkParticle::SetPDG ( const int  pdg)

Definition at line 42 of file ArtG4tkParticle.cc.

References fPDG.

Referenced by ArtG4tkParticle(), operator=(), and artg4tk::ArtG4tkVtx::SetIncoming().

43 {
44 
45  fPDG = pdg;
46  return;
47 }

Member Data Documentation

CLHEP::HepLorentzVector artg4tk::ArtG4tkParticle::fMomentum
private

Definition at line 60 of file ArtG4tkParticle.hh.

Referenced by ArtG4tkParticle(), GetMomentum(), operator=(), and SetMomentum().

int artg4tk::ArtG4tkParticle::fPDG
private

Definition at line 59 of file ArtG4tkParticle.hh.

Referenced by ArtG4tkParticle(), GetName(), GetPDG(), operator=(), SetMomentum(), and SetPDG().


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