Belle II Software development
MaterialScanBase Class Referenceabstract

Base class for Material Scans. More...

#include <MaterialScan.h>

Inheritance diagram for MaterialScanBase:
MaterialScan2D MaterialScanRay MaterialScanPlanar MaterialScanSpherical

Public Member Functions

 MaterialScanBase (TFile *rootFile, const std::string &name, const std::string &axisLabel)
 This is indeed the constructor and it creates a TDirectory in the output root file and sets all variables.
 
std::string getName () const
 Return the name of the scan.
 
virtual int getNRays () const =0
 Return the number of rays necessary to perform the scan.
 
virtual bool createNext (G4ThreeVector &origin, G4ThreeVector &direction)=0
 Belle2::MaterialScanBase::createNext() implemention Get the origin and direction for the next scan particle.
 

Protected Member Functions

bool checkStep (const G4Step *step)
 check for stuck tracks by looking at the step length
 

Protected Attributes

TFile * m_rootFile
 Pointer to the root file for the histograms.
 
std::string m_name
 Name of the scan, will be prefixed to all histogram names.
 
std::string m_axisLabel
 Labels for the coordinate axes.
 

Private Attributes

int m_zeroSteps {0}
 Count the number of steps with (almost) zero length.
 

Static Private Attributes

static constexpr double c_zeroTolerance = 1e-6
 maximum Step length to be considered zero
 
static constexpr int c_maxZeroStepsNudge = 10
 maximum number of consecutive zero steps before nudging the track along
 
static constexpr int c_maxZeroStepsKill = 20
 maximum number of consecutive zero steps before killing the track
 

Detailed Description

Base class for Material Scans.

Definition at line 33 of file MaterialScan.h.

Constructor & Destructor Documentation

◆ MaterialScanBase()

MaterialScanBase ( TFile *  rootFile,
const std::string &  name,
const std::string &  axisLabel 
)
inline

This is indeed the constructor and it creates a TDirectory in the output root file and sets all variables.

Definition at line 37 of file MaterialScan.h.

37 :
38 m_rootFile(rootFile), m_name(name), m_axisLabel(axisLabel)
39 {
40 m_rootFile->mkdir(name.c_str());
41 }
TFile * m_rootFile
Pointer to the root file for the histograms.
Definition: MaterialScan.h:60
std::string m_axisLabel
Labels for the coordinate axes.
Definition: MaterialScan.h:64
std::string m_name
Name of the scan, will be prefixed to all histogram names.
Definition: MaterialScan.h:62

Member Function Documentation

◆ checkStep()

bool checkStep ( const G4Step *  step)
protected

check for stuck tracks by looking at the step length

Definition at line 44 of file MaterialScan.cc.

45{
46 double stlen = step->GetStepLength();
47 G4StepPoint* preStepPoint = step->GetPreStepPoint();
48 G4Region* region = preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
49 if (stlen < c_zeroTolerance) {
51 } else {
52 m_zeroSteps = 0;
53 }
56 B2ERROR("Track is stuck at " << preStepPoint->GetPosition() << " in volume '"
57 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName()
58 << " (" << region->GetName() << "): "
59 << m_zeroSteps << " consecutive steps with length less then "
60 << c_zeroTolerance << " mm, killing it");
61 step->GetTrack()->SetTrackStatus(fStopAndKill);
62 } else {
63 B2WARNING("Track is stuck at " << preStepPoint->GetPosition() << " in volume '"
64 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName()
65 << " (" << region->GetName() << "): "
66 << m_zeroSteps << " consecutive steps with length less then "
67 << c_zeroTolerance << " mm, nudging it along");
68 G4ThreeVector pos = step->GetTrack()->GetPosition();
69 G4ThreeVector dir = step->GetTrack()->GetMomentumDirection();
70 step->GetTrack()->SetPosition(pos + c_zeroTolerance * dir);
71 }
72 return false;
73 }
74 return true;
75}
int m_zeroSteps
Count the number of steps with (almost) zero length.
Definition: MaterialScan.h:73
static constexpr int c_maxZeroStepsNudge
maximum number of consecutive zero steps before nudging the track along
Definition: MaterialScan.h:69
static constexpr int c_maxZeroStepsKill
maximum number of consecutive zero steps before killing the track
Definition: MaterialScan.h:71
static constexpr double c_zeroTolerance
maximum Step length to be considered zero
Definition: MaterialScan.h:67

◆ createNext()

virtual bool createNext ( G4ThreeVector &  origin,
G4ThreeVector &  direction 
)
pure virtual

Belle2::MaterialScanBase::createNext() implemention Get the origin and direction for the next scan particle.

Parameters
originOrigin of the next scan particle
directionDirection of the next scan particle
Returns
false if the scan is finished

Implemented in MaterialScan2D, and MaterialScanRay.

◆ getName()

std::string getName ( ) const
inline

Return the name of the scan.

Definition at line 43 of file MaterialScan.h.

43{ return m_name; }

◆ getNRays()

virtual int getNRays ( ) const
pure virtual

Return the number of rays necessary to perform the scan.

Implemented in MaterialScan2D, and MaterialScanRay.

Member Data Documentation

◆ c_maxZeroStepsKill

constexpr int c_maxZeroStepsKill = 20
staticconstexprprivate

maximum number of consecutive zero steps before killing the track

Definition at line 71 of file MaterialScan.h.

◆ c_maxZeroStepsNudge

constexpr int c_maxZeroStepsNudge = 10
staticconstexprprivate

maximum number of consecutive zero steps before nudging the track along

Definition at line 69 of file MaterialScan.h.

◆ c_zeroTolerance

constexpr double c_zeroTolerance = 1e-6
staticconstexprprivate

maximum Step length to be considered zero

Definition at line 67 of file MaterialScan.h.

◆ m_axisLabel

std::string m_axisLabel
protected

Labels for the coordinate axes.

Definition at line 64 of file MaterialScan.h.

◆ m_name

std::string m_name
protected

Name of the scan, will be prefixed to all histogram names.

Definition at line 62 of file MaterialScan.h.

◆ m_rootFile

TFile* m_rootFile
protected

Pointer to the root file for the histograms.

Definition at line 60 of file MaterialScan.h.

◆ m_zeroSteps

int m_zeroSteps {0}
private

Count the number of steps with (almost) zero length.

Definition at line 73 of file MaterialScan.h.


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