Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::garg4::EnergyDepositAction Class Reference

list of energy deposits from Geant4 More...

#include <EnergyDepositAction.h>

Inheritance diagram for gar::garg4::EnergyDepositAction:

Public Member Functions

 EnergyDepositAction (CLHEP::HepRandomEngine *engine, fhicl::ParameterSet const &pset)
 
virtual ~EnergyDepositAction ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void BeginOfEventAction (const G4Event *)
 
void EndOfEventAction (const G4Event *)
 
void PreTrackingAction (const G4Track *)
 
void PostTrackingAction (const G4Track *)
 
void SteppingAction (const G4Step *)
 
std::string GetVolumeName (const G4Track *track)
 
std::vector< gar::sdp::EnergyDeposit > const & EnergyDeposits () const
 

Private Member Functions

void AddEnergyDeposition (const G4Step *step)
 

Private Attributes

double fEnergyCut
 be included in the list. More...
 
std::vector< std::stringfVolumeName
 volume we will record energy depositions in More...
 
std::string fMaterialMatchString
 Energy deposition will be recorded for materials that match this. More...
 
std::vector< gar::sdp::EnergyDepositfDeposits
 energy fDeposits More...
 

Detailed Description

list of energy deposits from Geant4

Definition at line 35 of file EnergyDepositAction.h.

Constructor & Destructor Documentation

gar::garg4::EnergyDepositAction::EnergyDepositAction ( CLHEP::HepRandomEngine *  engine,
fhicl::ParameterSet const &  pset 
)

Definition at line 38 of file EnergyDepositAction.cxx.

41  {
42  this->reconfigure(pset);
43  }
void reconfigure(fhicl::ParameterSet const &pset)
gar::garg4::EnergyDepositAction::~EnergyDepositAction ( )
virtual

Definition at line 47 of file EnergyDepositAction.cxx.

48  {
49  // Delete anything that we created with "new'.
50  }

Member Function Documentation

void gar::garg4::EnergyDepositAction::AddEnergyDeposition ( const G4Step *  step)
private

Definition at line 147 of file EnergyDepositAction.cxx.

148  {
149  // get the track id for this step
150  auto trackID = ParticleListAction::GetCurrentTrackID();
151 
152  // first check that we are not dealing with ionization, ie delta rays
153  // if we have one of those, set the trackID to be the ID of the parent
154  //if(trackID < 0)
155  // MF_LOG_VERBATIM("EnergyDepositAction")
156  // << "TrackID "
157  // << trackID
158  // << " was created by process "
159  // << step->GetTrack()->GetCreatorProcess()->GetProcessName();
160  //else
161  // MF_LOG_VERBATIM("EnergyDepositAction")
162  // << "TrackID "
163  // << trackID
164  // << " is a primary particle ";
165 
166  // the step mid point is used for the position of the deposit
167  auto midPoint = 0.5 * (step->GetPreStepPoint()->GetPosition() +
168  step->GetPostStepPoint()->GetPosition() );
169  float time = step->GetPreStepPoint()->GetGlobalTime();
170 
171  fDeposits.emplace_back(trackID,
172  time,
173  step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV,
174  midPoint.x() / CLHEP::cm,
175  midPoint.y() / CLHEP::cm,
176  midPoint.z() / CLHEP::cm,
177  step->GetStepLength() / CLHEP::cm,
178  (trackID > 0));
179 
180  return;
181  }
static constexpr double cm
Definition: Units.h:68
static constexpr double MeV
Definition: Units.h:129
static constexpr double GeV
Definition: Units.h:28
std::vector< gar::sdp::EnergyDeposit > fDeposits
energy fDeposits
void gar::garg4::EnergyDepositAction::BeginOfEventAction ( const G4Event *  )

Definition at line 67 of file EnergyDepositAction.cxx.

68  {
69  // Clear any previous information.
70  fDeposits.clear();
71  }
std::vector< gar::sdp::EnergyDeposit > fDeposits
energy fDeposits
void gar::garg4::EnergyDepositAction::EndOfEventAction ( const G4Event *  )

Definition at line 184 of file EnergyDepositAction.cxx.

185  {
186  // sort the EnergyDeposit lists in each EnergyDeposits object
187  std::sort(fDeposits.begin(), fDeposits.end());
188  }
std::vector< gar::sdp::EnergyDeposit > fDeposits
energy fDeposits
std::vector<gar::sdp::EnergyDeposit> const& gar::garg4::EnergyDepositAction::EnergyDeposits ( ) const
inline

Definition at line 57 of file EnergyDepositAction.h.

57 { return fDeposits; }
std::vector< gar::sdp::EnergyDeposit > fDeposits
energy fDeposits
std::string gar::garg4::EnergyDepositAction::GetVolumeName ( const G4Track *  track)

Definition at line 191 of file EnergyDepositAction.cxx.

192  {
193  std::string VolName = track->GetVolume()->GetName();
194  VolName.erase(VolName.length()-3, 3);
195  return VolName;
196  }
std::string string
Definition: nybbler.cc:12
void gar::garg4::EnergyDepositAction::PostTrackingAction ( const G4Track *  )

Definition at line 79 of file EnergyDepositAction.cxx.

80  {
81  }
void gar::garg4::EnergyDepositAction::PreTrackingAction ( const G4Track *  )

Definition at line 74 of file EnergyDepositAction.cxx.

75  {
76  }
void gar::garg4::EnergyDepositAction::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 53 of file EnergyDepositAction.cxx.

54  {
55  fEnergyCut = pset.get< double >("EnergyCut");
56  fVolumeName = pset.get< std::vector<std::string> >("GArVolumeName");
57  fMaterialMatchString = pset.get< std::string >("GArMaterialMatchString");
58 
59  // std::cout << "EnergyDepositAction: Name of the Volumes to track for the GArTPC" << std::endl;
60  // for(unsigned int i = 0; i < fVolumeName.size(); i++) std::cout << fVolumeName.at(i) << " ";
61  // std::cout << std::endl;
62 
63  return;
64  }
std::string string
Definition: nybbler.cc:12
double fEnergyCut
be included in the list.
std::string fMaterialMatchString
Energy deposition will be recorded for materials that match this.
std::vector< std::string > fVolumeName
volume we will record energy depositions in
void gar::garg4::EnergyDepositAction::SteppingAction ( const G4Step *  step)

Definition at line 85 of file EnergyDepositAction.cxx.

86  {
87  MF_LOG_DEBUG("EnergyDepositAction")
88  << "EnergyDepositAction::SteppingAction";
89 
91  TGeoManager *geomanager = geo->ROOTGeoManager();
92 
93  // Get the pointer to the track
94  G4Track *track = step->GetTrack();
95 
96  const CLHEP::Hep3Vector &start = step->GetPreStepPoint()->GetPosition();
97  const CLHEP::Hep3Vector &stop = track->GetPosition();
98 
99  // If it's a null step, don't use it.
100  if(start == stop) return;
101  if(step->GetTotalEnergyDeposit() == 0) return;
102 
103  // check that we are in the correct material to record a hit
104  std::string VolumeName = this->GetVolumeName(track);
105 
106  if( std::find( fVolumeName.begin(), fVolumeName.end(), VolumeName ) == fVolumeName.end() )
107  return;
108 
109  // check the material
110  auto pos = 0.5 * (start + stop);
111  TGeoNode *node = geomanager->FindNode(pos.x()/CLHEP::cm, pos.y()/CLHEP::cm, pos.z()/CLHEP::cm);//Node in cm
112 
113  if(!node){
114  MF_LOG_DEBUG("EnergyDepositAction")
115  << "Node not found in "
116  << pos.x() << " mm "
117  << pos.y() << " mm "
118  << pos.z() << " mm";
119  return;
120  }
121 
122  std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
123  if ( ! std::regex_match(volmaterial, std::regex(fMaterialMatchString)) ) return;
124 
125  // only worry about energy depositions larger than the minimum required
126  if(step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV > fEnergyCut ){
127 
128  MF_LOG_DEBUG("EnergyDepositAction")
129  << "In volume "
130  << VolumeName
131  << " step size is "
132  << step->GetStepLength() / CLHEP::cm
133  << " cm and deposited "
134  << step->GetTotalEnergyDeposit()
135  << " MeV of energy with a minimum of "
136  << fEnergyCut
137  << " required.";
138 
139  // save this deposition
140  this->AddEnergyDeposition(step);
141 
142  } // end if enough energy to worry about this step
143 
144  }// end of EnergyDepositAction::SteppingAction
static constexpr double cm
Definition: Units.h:68
std::string GetVolumeName(const G4Track *track)
std::string string
Definition: nybbler.cc:12
static constexpr double MeV
Definition: Units.h:129
double fEnergyCut
be included in the list.
static constexpr double GeV
Definition: Units.h:28
std::string fMaterialMatchString
Energy deposition will be recorded for materials that match this.
std::vector< std::string > fVolumeName
volume we will record energy depositions in
#define MF_LOG_DEBUG(id)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void AddEnergyDeposition(const G4Step *step)

Member Data Documentation

std::vector<gar::sdp::EnergyDeposit> gar::garg4::EnergyDepositAction::fDeposits
private

energy fDeposits

Definition at line 68 of file EnergyDepositAction.h.

double gar::garg4::EnergyDepositAction::fEnergyCut
private

be included in the list.

The minimum energy in GeV for a deposit to

Definition at line 63 of file EnergyDepositAction.h.

std::string gar::garg4::EnergyDepositAction::fMaterialMatchString
private

Energy deposition will be recorded for materials that match this.

Definition at line 66 of file EnergyDepositAction.h.

std::vector<std::string> gar::garg4::EnergyDepositAction::fVolumeName
private

volume we will record energy depositions in

Definition at line 65 of file EnergyDepositAction.h.


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