Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
B5::HodoscopeSD Class Reference

Hodoscope sensitive detector. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B5::HodoscopeSD:
G4VSensitiveDetector

Public Member Functions

 HodoscopeSD (G4String name)
 
 ~HodoscopeSD () override=default
 
void Initialize (G4HCofThisEvent *HCE) override
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override
 

Private Attributes

HodoscopeHitsCollectionfHitsCollection = nullptr
 
G4int fHCID = -1
 

Detailed Description

Hodoscope sensitive detector.

Definition at line 195 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ HodoscopeSD()

B5::HodoscopeSD::HodoscopeSD ( G4String  name)

Definition at line 45 of file HodoscopeSD.cc.

47{
48 collectionName.insert( "hodoscopeColl");
49}

◆ ~HodoscopeSD()

B5::HodoscopeSD::~HodoscopeSD ( )
overridedefault

Member Function Documentation

◆ Initialize()

void B5::HodoscopeSD::Initialize ( G4HCofThisEvent HCE)
override

Definition at line 53 of file HodoscopeSD.cc.

54{
56 (SensitiveDetectorName,collectionName[0]);
57 if (fHCID<0) {
58 fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
59 }
60 hce->AddHitsCollection(fHCID,fHitsCollection);
61}
HodoscopeHitsCollection * fHitsCollection
G4THitsCollection< HodoscopeHit > HodoscopeHitsCollection

◆ ProcessHits()

G4bool B5::HodoscopeSD::ProcessHits ( G4Step aStep,
G4TouchableHistory ROhist 
)
override

Definition at line 65 of file HodoscopeSD.cc.

66{
67 auto edep = step->GetTotalEnergyDeposit();
68 if (edep==0.) return true;
69
70 auto preStepPoint = step->GetPreStepPoint();
71 auto touchable = preStepPoint->GetTouchable();
72 auto copyNo = touchable->GetVolume()->GetCopyNo();
73 auto hitTime = preStepPoint->GetGlobalTime();
74
75 // check if this finger already has a hit
76 auto ix = -1;
77 for (std::size_t i=0;i<fHitsCollection->entries();++i) {
78 if ((*fHitsCollection)[i]->GetID()==copyNo) {
79 ix = i;
80 break;
81 }
82 }
83
84 if (ix>=0) {
85 // if it has, then take the earlier time
86 if ((*fHitsCollection)[ix]->GetTime()>hitTime) {
87 (*fHitsCollection)[ix]->SetTime(hitTime);
88 }
89 }
90 else {
91 // if not, create a new hit and set it to the collection
92 auto hit = new HodoscopeHit(copyNo,hitTime);
93 auto physical = touchable->GetVolume();
94 hit->SetLogV(physical->GetLogicalVolume());
95 auto transform = touchable->GetHistory()->GetTopTransform();
96 transform.Invert();
97 hit->SetRot(transform.NetRotation());
98 hit->SetPos(transform.NetTranslation());
99 fHitsCollection->insert(hit);
100 }
101 return true;
102}

Member Data Documentation

◆ fHitsCollection

HodoscopeHitsCollection* B5::HodoscopeSD::fHitsCollection = nullptr
private

Definition at line 55 of file HodoscopeSD.hh.

◆ fHCID

G4int B5::HodoscopeSD::fHCID = -1
private

Definition at line 56 of file HodoscopeSD.hh.


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

Applications | User Support | Publications | Collaboration