11 #include <beast/microtpc/simulation/SensitiveDetector.h>
12 #include <beast/microtpc/dataobjects/MicrotpcSimHit.h>
13 #include <beast/microtpc/dataobjects/TPCG4TrackInfo.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/RelationArray.h>
30 Simulation::SensitiveDetectorBase(
"MicrotpcSensitiveDetector", Const::invalidDetector)
34 StoreArray<MCParticle> mcParticles;
35 StoreArray<MicrotpcSimHit> simHits;
36 StoreArray<TPCG4TrackInfo> TPCG4TrackInfos;
40 mcParticles.registerInDataStore();
41 simHits.registerInDataStore();
42 relMCSimHit.registerInDataStore();
43 TPCG4TrackInfos.registerInDataStore();
55 const G4Track& track = *
step->GetTrack();
56 const int trackID = track.GetTrackID();
57 const double depEnergy =
step->GetTotalEnergyDeposit() * CLHEP::MeV;
58 const double nielEnergy =
step->GetNonIonizingEnergyDeposit() * CLHEP::MeV;
59 const G4ThreeVector G4tkPos =
step->GetTrack()->GetPosition();
61 tkPos[0] = G4tkPos.x() * CLHEP::cm;
62 tkPos[1] = G4tkPos.y() * CLHEP::cm;
63 tkPos[2] = G4tkPos.z() * CLHEP::cm;
64 const G4ThreeVector G4tkMom =
step->GetTrack()->GetMomentum();
66 tkMom[0] = G4tkMom.x() * CLHEP::MeV;
67 tkMom[1] = G4tkMom.y() * CLHEP::MeV;
68 tkMom[2] = G4tkMom.z() * CLHEP::MeV;
69 const G4ThreeVector G4tkMomDir =
step->GetTrack()->GetMomentumDirection();
71 tkMomDir[0] = G4tkMomDir.x() * CLHEP::MeV;
72 tkMomDir[1] = G4tkMomDir.y() * CLHEP::MeV;
73 tkMomDir[2] = G4tkMomDir.z() * CLHEP::MeV;
74 const int tkPDG =
step->GetTrack()->GetDefinition()->GetPDGEncoding();
75 const double tkKEnergy =
step->GetTrack()->GetKineticEnergy();
76 const int detNb =
step->GetTrack()->GetVolume()->GetCopyNo();
77 const double GlTime =
step->GetPreStepPoint()->GetGlobalTime();
95 if (m_trackID != track.GetTrackID()) {
97 m_trackID = track.GetTrackID();
101 if (track.GetNextVolume() != track.GetVolume() || track.GetTrackStatus() >= fStopAndKill) {
103 int PDG = mcparticle.getPDG();
104 float Mass = mcparticle.getMass();
105 float Energy = mcparticle.getEnergy();
107 vtx[0] = mcparticle.getProductionVertex().X();
108 vtx[1] = mcparticle.getProductionVertex().Y();
109 vtx[2] = mcparticle.getProductionVertex().Z();
111 mom[0] = mcparticle.getMomentum().X();
112 mom[1] = mcparticle.getMomentum().Y();
113 mom[2] = mcparticle.getMomentum().Z();
135 relMCSimHit.add(trackID, hit->getArrayIndex(), 1.0);
155 int simhitNumber = TPCG4TrackInfos.
getEntries() - 1;
157 return (simhitNumber);