10 #include <klm/eklm/simulation/EKLMSensitiveDetector.h>
13 #include <klm/dbobjects/eklm/EKLMSimulationParameters.h>
16 #include <framework/database/DBObjPtr.h>
17 #include <framework/gearbox/Unit.h>
18 #include <framework/logging/Logger.h>
24 #include <CLHEP/Geometry/Point3D.h>
29 Simulation::SensitiveDetectorBase(name,
Const::KLM),
34 B2FATAL(
"EKLM simulation parameters are not available.");
48 const int stripLevel = 1;
49 int section, layer, sector, plane, strip, stripGlobal;
51 G4TouchableHandle hist = aStep->GetPreStepPoint()->GetTouchableHandle();
52 section = hist->GetVolume(stripLevel + 6)->GetCopyNo();
53 layer = hist->GetVolume(stripLevel + 5)->GetCopyNo();
54 sector = hist->GetVolume(stripLevel + 4)->GetCopyNo();
55 plane = hist->GetVolume(stripLevel + 3)->GetCopyNo();
56 strip = hist->GetVolume(stripLevel)->GetCopyNo();
57 stripGlobal = m_ElementNumbers->stripNumber(
58 section, layer, sector, plane, strip);
59 const G4double eDep = aStep->GetTotalEnergyDeposit();
63 const G4Track& track = * aStep->GetTrack();
64 const G4double hitTime = track.GetGlobalTime();
66 if (hitTime > m_ThresholdHitTime) {
67 B2INFO(
"EKLMSensitiveDetector: "
68 " ALL HITS WITH TIME > hitTimeThreshold ARE DROPPED!!");
72 gpos = 0.5 * (aStep->GetPostStepPoint()->GetPosition() +
73 aStep->GetPreStepPoint()->GetPosition());
74 lpos = hist->GetHistory()->GetTopTransform().TransformPoint(gpos);
77 CLHEP::Hep3Vector trackMomentum = track.GetMomentum();
78 hit->setMomentum(TLorentzVector(trackMomentum.x(), trackMomentum.y(),
79 trackMomentum.z(), track.GetTotalEnergy()));
80 hit->setTrackID(track.GetTrackID());
81 hit->setParentTrackID(track.GetParentID());
82 hit->setLocalPosition(lpos.x() / CLHEP::mm *
Unit::mm,
85 hit->setPosition(gpos.x() / CLHEP::mm *
Unit::mm,
88 hit->setEnergyDeposit(eDep);
89 hit->setPDG(track.GetDefinition()->GetPDGEncoding());
90 hit->setTime(hitTime);
93 hit->setSector(sector);
95 hit->setSection(section);
96 hit->setVolumeID(stripGlobal);
97 m_MCParticlesToSimHits.add(track.GetTrackID(), hit->getArrayIndex());
This class provides a set of constants for the framework.
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
Class EKLMSimHit stores information on particular Geant step; using information from TrackID and Pare...
bool step(G4Step *aStep, G4TouchableHistory *history) override
Process each step and calculate variables for EKLMSimHit store EKLMSimHit.
~EKLMSensitiveDetector()
Destructor.
EKLMSensitiveDetector(G4String name)
Constructor.
StoreArray< EKLMSimHit > m_SimHits
Simulation hits.
G4double m_ThresholdHitTime
All hits with time large than m_ThresholdHitTime will be dropped.
RelationArray m_MCParticlesToSimHits
Relation array between MCPartices and EKLMSimHits.
StoreArray< MCParticle > m_MCParticles
MC particles.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
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.
static const double mm
[millimeters]
Abstract base class for different kinds of events.