LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
OpDetSensitiveDetector.cxx
Go to the documentation of this file.
1 //
6 // Implementation of the OpDetSensitiveDetector
7 //
8 // See comments in OpDetSensitiveDetector.h
9 //
10 // Ben Jones, MIT, 06/04/2010
11 //
12 
13 
14 
19 #include "Geant4/G4SDManager.hh"
20 
21 namespace larg4{
22 
23 
25  : G4VSensitiveDetector(DetectorUniqueName)
26  {
27  // Register self with sensitive detector manager
28  G4SDManager::GetSDMpointer()->AddNewDetector(this);
29 
30  // Get instances of singleton classes
33 
34  }
35 
36 
37  //--------------------------------------------------------
38 
39  G4bool OpDetSensitiveDetector::ProcessHits(G4Step * aStep, G4TouchableHistory *)
40  {
41  sim::OnePhoton ThePhoton;
42 
43 
44  // Get photon data to store in the hit
45 
46  ThePhoton.SetInSD = true;
47 
48  ThePhoton.InitialPosition = TVector3(
49  aStep->GetTrack()->GetVertexPosition().x(),
50  aStep->GetTrack()->GetVertexPosition().y(),
51  aStep->GetTrack()->GetVertexPosition().z()
52  );
53 
54  //ThePhoton.Time = aStep->GetTrack()->GetGlobalTime() - fGlobalTimeOffset;
55  ThePhoton.Time = aStep->GetTrack()->GetGlobalTime();
56 
57 
58  ThePhoton.Energy = aStep->GetTrack()->GetVertexKineticEnergy();
59 
60  // Lookup which OpDet we are in
61  G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
62 
63  int OpDet = fTheOpDetLookup->GetOpDet(preStepPoint->GetPhysicalVolume());
64 
65  // Store relative position on the photon detector
66  G4ThreeVector worldPosition = preStepPoint->GetPosition();
67  G4ThreeVector localPosition = preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(worldPosition);
68  ThePhoton.FinalLocalPosition = TVector3(localPosition.x()/CLHEP::cm, localPosition.y()/CLHEP::cm, localPosition.z()/CLHEP::cm);
69 
70 
71  // Add this photon to the detected photons table
72  fThePhotonTable->AddPhoton(OpDet, std::move(ThePhoton));
73 
74  // Kill this photon track
75  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
76 
77  return true;
78 
79 
80  }
81 
82  //--------------------------------------------------------
83 
85  {
86 
87  }
88 
89 }
Geant4 interface.
contains objects relating to OpDet hits
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon, bool Reflected=false)
static OpDetLookup * Instance()
Definition: OpDetLookup.cxx:31
int GetOpDet(G4VPhysicalVolume *)
Definition: OpDetLookup.cxx:46
static OpDetPhotonTable * Instance(bool LitePhotons=false)
TVector3 InitialPosition
Definition: SimPhotons.h:49
TVector3 FinalLocalPosition
Definition: SimPhotons.h:50
virtual void Initialize(G4HCofThisEvent *)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)