LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 
14 #include "Geant4/G4SDManager.hh"
18 
19 namespace {
20 
22  constexpr double Wavelength(double energy);
23 
24 } // local namespace
25 
26 namespace larg4 {
27 
29  bool useLitePhotons /* = false */)
30  : G4VSensitiveDetector(DetectorUniqueName), fUseLitePhotons(useLitePhotons)
31  {
32  // Register self with sensitive detector manager
33  G4SDManager::GetSDMpointer()->AddNewDetector(this);
34 
35  // Get instances of singleton classes
38  }
39 
40  //--------------------------------------------------------
41 
42  void OpDetSensitiveDetector::AddLitePhoton(G4Step const* aStep, int OpDet)
43  {
44 
45  double const time = aStep->GetTrack()->GetGlobalTime();
46 
47  // the guideline: if it's VUV (~128 nm) is direct, otherwise it is reflected
48  double const energy = aStep->GetTrack()->GetVertexKineticEnergy() / CLHEP::eV;
49  bool const reflected = Wavelength(energy) > 200.0; // nm
50 
51  // Add this photon to the detected photons table
52  fThePhotonTable->AddLitePhoton(OpDet, static_cast<int>(time), 1, reflected);
53 
54  } // OpDetSensitiveDetector::AddLitePhoton()
55 
56  //--------------------------------------------------------
57 
58  void OpDetSensitiveDetector::AddPhoton(G4Step const* aStep, int OpDet)
59  {
60  sim::OnePhoton ThePhoton;
61 
62  // Get photon data to store in the hit
63 
64  ThePhoton.SetInSD = true;
65 
66  auto const& track = *(aStep->GetTrack());
67  auto const& startPos = track.GetVertexPosition();
68  ThePhoton.InitialPosition = {startPos.x(), startPos.y(), startPos.z()};
69 
70  //ThePhoton.Time = track.GetGlobalTime() - fGlobalTimeOffset;
71  ThePhoton.Time = track.GetGlobalTime();
72 
73  ThePhoton.Energy = track.GetVertexKineticEnergy();
74 
75  // Lookup which OpDet we are in
76  G4StepPoint const* preStepPoint = aStep->GetPreStepPoint();
77 
78  // Store relative position on the photon detector
79  G4ThreeVector worldPosition = preStepPoint->GetPosition();
80  G4ThreeVector localPosition =
81  preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
82  worldPosition);
83  ThePhoton.FinalLocalPosition = {
84  localPosition.x() / CLHEP::cm, localPosition.y() / CLHEP::cm, localPosition.z() / CLHEP::cm};
85 
86  // Add this photon to the detected photons table
87  fThePhotonTable->AddPhoton(OpDet, std::move(ThePhoton));
88 
89  } // OpDetSensitiveDetector::AddPhoton()
90 
91  //--------------------------------------------------------
92 
93  G4bool OpDetSensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
94  {
95  // Lookup which OpDet we are in
96  int const OpDet = fTheOpDetLookup->GetOpDet(aStep->GetPreStepPoint()->GetPhysicalVolume());
97 
98  // Add this photon to the detected photons table
99  if (fUseLitePhotons)
100  AddLitePhoton(aStep, OpDet);
101  else
102  AddPhoton(aStep, OpDet);
103 
104  // Kill this photon track
105  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
106 
107  return true;
108  }
109 
110  //--------------------------------------------------------
111 
113 
114 }
115 
116 //--------------------------------------------------------
117 namespace {
118 
119  constexpr double Wavelength(double energy)
120  {
121 
122  // SI 2019 (eV nm):
123  constexpr double hc = 6.62607015e-34 * 299792458.0 / 1.602176634e-19 * 1e9;
124 
125  return hc / energy; // nm
126 
127  } // Wavelength()
128 
129 } // local namespace
130 
131 //--------------------------------------------------------
bool const fUseLitePhotons
Fill simplified lite photons instead of full information photons.
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:60
Geant4 interface.
void AddLitePhoton(G4Step const *aStep, int OpDet)
Adds the photon at the specified step with reduced information.
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
Definition: SimPhotons.h:63
Simulation objects for optical detectors.
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon, bool Reflected=false)
double energy
Definition: plottest35.C:25
int GetOpDet(G4VPhysicalVolume const *)
Definition: OpDetLookup.cxx:44
void AddLitePhoton(int opchannel, int time, int nphotons, bool Reflected=false)
static OpDetLookup * Instance()
Definition: OpDetLookup.cxx:31
void AddPhoton(G4Step const *aStep, int OpDet)
Adds the photon at the specified step with full information.
static OpDetPhotonTable * Instance(bool LitePhotons=false)
bool SetInSD
Whether the photon reaches the sensitive detector.
Definition: SimPhotons.h:84
geo::OpticalPoint_t FinalLocalPosition
Where photon enters the optical detector in local coordinates [cm].
Definition: SimPhotons.h:71
virtual void Initialize(G4HCofThisEvent *)
OpDetSensitiveDetector(G4String name, bool useLitePhotons=false)
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:78
Float_t track
Definition: plot.C:35
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)