9#include <top/simulation/SensitiveBar.h>
11#include <simulation/kernel/UserInfo.h>
14#include <G4UnitsTable.hh>
15#include <G4ParticleDefinition.hh>
16#include <G4ParticleTypes.hh>
18#include <framework/logging/Logger.h>
19#include <framework/gearbox/Unit.h>
21#include <Math/Vector3D.h>
22#include <Math/Point3D.h>
36 Simulation::SensitiveDetectorBase(
"TOP",
Const::TOP)
59 G4Track* aTrack = aStep->GetTrack();
60 G4ParticleDefinition* particle = aTrack->GetDefinition();
64 if (particle == G4OpticalPhoton::OpticalPhotonDefinition()) {
66 if (!info)
return false;
67 if (info->getStatus() < 2) {
70 double fraction = info->getFraction();
71 if (qeffi == 0 or gRandom->Uniform() * fraction > qeffi) {
72 aTrack->SetTrackStatus(fStopAndKill);
76 info->setFraction(qeffi);
83 G4StepPoint* PrePosition = aStep->GetPreStepPoint();
84 if (PrePosition->GetStepStatus() != fGeomBoundary)
return false;
90 int moduleID = PrePosition->GetTouchableHandle()->GetReplicaNumber(
m_replicaDepth);
92 if (!geo->isModuleIDValid(moduleID)) {
93 B2ERROR(
"TOP::SensitiveBar: undefined module ID."
94 <<
LogVar(
"moduleID", moduleID));
98 int trackID = aTrack->GetTrackID();
99 if (trackID ==
m_trackIDs[moduleID - 1])
return false;
105 G4ThreeVector worldPosition = PrePosition->GetPosition();
106 double tracklength = aTrack->GetTrackLength() - aStep->GetStepLength();
107 double globalTime = PrePosition->GetGlobalTime();
108 G4ThreeVector momentum = PrePosition->GetMomentum();
110 ROOT::Math::XYZPoint TPosition(worldPosition.x(), worldPosition.y(), worldPosition.z());
111 ROOT::Math::XYZVector TMomentum(momentum.x(), momentum.y(), momentum.z());
112 ROOT::Math::XYZPoint TOrigin(aTrack->GetVertexPosition().x(),
113 aTrack->GetVertexPosition().y(),
114 aTrack->GetVertexPosition().z());
120 tracklength = tracklength *
Unit::mm;
122 const auto& module = geo->getModule(moduleID);
123 auto locPosition = module.pointToLocal(TPosition);
124 auto locMomentum = module.momentumToLocal(TMomentum);
125 double theta = locMomentum.Theta();
126 double phi = locMomentum.Phi();
128 int PDG = (int)(particle->GetPDGEncoding());
131 auto* hit =
m_barHits.appendNew(moduleID, PDG, TOrigin, TPosition, TMomentum,
132 globalTime, tracklength, locPosition,
This class provides a set of constants for the framework.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
bool step(G4Step *aStep, G4TouchableHistory *) override
Process each step and fill TOPBarHits.
int m_replicaDepth
replica depth of module volume
std::vector< int > m_trackIDs
track ID's
RelationArray m_relParticleHit
relations
SensitiveBar()
Constructor.
TOPGeometryPar * m_topgp
geometry parameters
StoreArray< MCParticle > m_mcParticles
collection of MC particles
StoreArray< TOPBarHit > m_barHits
collection of entrance-to-bar hits
double getPMTEfficiencyEnvelope(double energy) const
Returns PMT efficiency envelope, e.g.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static const double mm
[millimeters]
static const double eV
[electronvolt]
static const double MeV
[megaelectronvolt]
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.