9#include <ir/simulation/SensitiveDetector.h>
10#include <ir/dataobjects/IRSimHit.h>
12#include <framework/logging/Logger.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/RelationArray.h>
15#include <framework/gearbox/Unit.h>
17#include <Math/Vector3D.h>
21#include <G4ThreeVector.hh>
23#include <G4VPhysicalVolume.hh>
25#include <G4UserLimits.hh>
39 Simulation::SensitiveDetectorBase(
"IR ",
Const::IR)
49 const G4Track& track = *
step->GetTrack();
50 const G4int trackID = track.GetTrackID();
51 const G4int partPDGCode = track.GetDefinition()->GetPDGEncoding();
53 const G4VPhysicalVolume& g4Volume = *track.GetVolume();
54 string Volname = g4Volume.GetName();
56 const G4double depEnergy =
step->GetTotalEnergyDeposit() *
Unit::MeV;
58 const G4StepPoint& preStep = *
step->GetPreStepPoint();
59 const G4StepPoint& postStep = *
step->GetPostStepPoint();
60 const G4ThreeVector& preStepPos = preStep.GetPosition();
61 const G4ThreeVector& postStepPos = postStep.GetPosition();
62 const G4ThreeVector momIn(preStep.GetMomentum());
63 const G4ThreeVector momOut(postStep.GetMomentum());
64 const G4ThreeVector preStepPosLocal = preStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(preStepPos);
65 const G4ThreeVector postStepPosLocal = postStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(postStepPos);
66 const G4ThreeVector momInLocal = preStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformAxis(momIn);
67 const G4ThreeVector momOutLocal = preStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformAxis(momOut);
68 ROOT::Math::XYZVector posInVec(preStepPosLocal.x() *
Unit::mm, preStepPosLocal.y() *
Unit::mm, preStepPosLocal.z() *
Unit::mm);
69 ROOT::Math::XYZVector posOutVec(postStepPosLocal.x() *
Unit::mm, postStepPosLocal.y() *
Unit::mm, postStepPosLocal.z() *
Unit::mm);
75 G4UserLimits* userLimits = g4Volume.GetLogicalVolume()->GetUserLimits();
77 B2DEBUG(100,
"Volume " << g4Volume.GetName() <<
": max. allowed step set to " << userLimits->GetMaxAllowedStep(track));
81 IRSimHit* simHit = irSimHits.
appendNew(posInVec, momInVec, posOutVec, momOutVec, partPDGCode, depEnergy, Volname);
This class provides a set of constants for the framework.
Class for saving raw hit data of the IR.
Low-level class to create/modify relations between StoreArrays.
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
static const double mm
[millimeters]
static const double MeV
[megaelectronvolt]
bool step(G4Step *aStep, G4TouchableHistory *) override
Process each step and calculate variables defined in IRSimHit.
SensitiveDetector()
Constructor.
Abstract base class for different kinds of events.