13 #include "montecarlo/dataobjs/GGSTHadrIntInfo.h"
18 #include "G4StepPoint.hh"
19 #include "G4SystemOfUnits.hh"
28 : _outBase(
""), _outTreeName(
""), _outRootFile(NULL), _outTree(NULL), _kinetic(true), _tolerance(0.1 * cm) {
35 G4ThreeVector physicalWorldPos = detConstruction->
GetPhysicalWorld()->GetObjectTranslation();
36 G4Box *solidWorld = (G4Box *)(detConstruction->
GetPhysicalWorld()->GetLogicalVolume()->GetSolid());
38 _worldXMin = physicalWorldPos[0] - solidWorld->GetXHalfLength();
39 _worldXMax = physicalWorldPos[0] + solidWorld->GetXHalfLength();
40 _worldYMin = physicalWorldPos[1] - solidWorld->GetYHalfLength();
41 _worldYMax = physicalWorldPos[1] + solidWorld->GetYHalfLength();
42 _worldZMin = physicalWorldPos[2] - solidWorld->GetZHalfLength();
43 _worldZMax = physicalWorldPos[2] + solidWorld->GetZHalfLength();
51 delete _lostEnergyInfo;
58 const G4StepPoint *stepPoint = track->GetStep()->GetPostStepPoint();
61 if (stepPoint->GetProcessDefinedStep()->GetProcessType() == fTransportation) {
62 const G4ThreeVector position = stepPoint->GetPosition();
63 bool charged = track->GetParticleDefinition()->GetPDGCharge() != 0;
66 energy = stepPoint->GetKineticEnergy();
69 energy = stepPoint->GetTotalEnergy();
77 if (fabs(position[2] - _worldZMin) < _tolerance)
86 else if (fabs(position[0] - _worldXMax) < _tolerance)
95 else if (fabs(position[0] - _worldXMin) < _tolerance)
104 else if (fabs(position[1] - _worldYMax) < _tolerance)
113 else if (fabs(position[1] - _worldYMin) < _tolerance)
122 else if (fabs(position[2] - _worldZMax) < _tolerance) {
156 if (_outTreeName !=
"") {
168 if (_outTreeName ==
"") {
170 _outTree->SetTitle(TString(_outTree->GetTitle()) +
"LostEn ");
172 _outTree =
new TTree(_outTreeName.data(),
"Energy lost by escaping particles");
174 _outTree->Branch(
"lostEnergyInfo",
"GGSTLostEnergyInfo", &_lostEnergyInfo);
181 if (_outTreeName !=
"") {
TFile * GetFileForThisRun(const path &baseName, const G4Run *run)
Opens a file for a given run and returns a pointer to it.
void Reset()
Resets all the members.
Float_t chargedRight
Energy lost due to charged particles escaping the world volume from right (positive Y)...
A simple class to carry informations about lost energy.
const G4VPhysicalVolume * GetPhysicalWorld() const
Returns a pointer to the physical world volume.
Float_t neutralBack
Energy lost due to neutral particles escaping the world volume from back (negative X)...
Float_t neutralBottom
Energy lost due to neutral particles escaping the world volume from bottom (negative Z)...
void CloseFileForThisRun(const path &baseName)
Closes the ROOT output file.
Int_t energyType
Type of lost energy: 0 = total, 1 = kinetic.
Class for GGS detector construction.
Float_t chargedLeft
Energy lost due to charged particles escaping the world volume from left (negative Y)...
void PostUserTrackingAction(const G4Track *track)
Check the track end.
void EndOfRunAction(const G4Run *run)
Closes the output file for the current run.
Float_t neutralRight
Energy lost due to neutral particles escaping the world volume from right (positive Y)...
void EndOfEventAction(const G4Event *event)
Converts energies to GeV and fills the tree.
static GGSRunManager * GetRunManager()
Static getter function the run manager.
Float_t neutralTop
Energy lost due to neutral particles escaping the world volume from top (positive Z)...
void BeginOfEventAction(const G4Event *event)
Resets the GGSTLostEnergyInfo buffer.
Float_t chargedBack
Energy lost due to charged particles escaping the world volume from back (negative X)...
TTree * GetDefaultTree(TFile *file)
Gets the default tree for this file.
virtual ~GGSLostEnergyAction()
Destructor.
static GGSRootFileService & GetInstance()
Get reference to GGSRootFileService unique instance.
UInt_t nCharged
Total number of escaped charged particles.
void BeginOfRunAction(const G4Run *run)
Opens the output file for the current run and prepares the output tree.
A control messenger for GGSLostEnergyAction.
GGSLostEnergyAction()
Constructor.
#define RegisterUA(uaClassName)
Macro for registration of user actions classes.
Float_t chargedFront
Energy lost due to charged particles escaping the world volume from front (positive X)...
Computes the lost energy due to particles escaping the world volume.
Float_t neutralLeft
Energy lost due to neutral particles escaping the world volume from left (negative Y)...
Float_t chargedBottom
Energy lost due to charged particles escaping the world volume from bottom (negative Z)...
Float_t chargedTop
Energy lost due to charged particles escaping the world volume from top (positive Z)...
Float_t neutralFront
Energy lost due to neutral particles escaping the world volume from front (positive X)...
UInt_t nNeutrals
Total number of escaped neutral particles.