Loading...
Searching...
No Matches
LXePMTSD.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27/// \file optical/LXe/src/LXePMTSD.cc
28/// \brief Implementation of the LXePMTSD class
29//
30//
31#include "LXePMTSD.hh"
32
34#include "LXePMTHit.hh"
36
37#include "G4ios.hh"
38#include "G4LogicalVolume.hh"
39#include "G4ParticleDefinition.hh"
40#include "G4ParticleTypes.hh"
41#include "G4SDManager.hh"
42#include "G4Step.hh"
43#include "G4TouchableHistory.hh"
44#include "G4Track.hh"
45#include "G4VPhysicalVolume.hh"
46#include "G4VTouchable.hh"
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49
52{
53 collectionName.insert("pmtHitCollection");
54}
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
59{
60 delete fPMTPositionsX;
61 delete fPMTPositionsY;
62 delete fPMTPositionsZ;
63}
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
67void LXePMTSD::SetPmtPositions(const std::vector<G4ThreeVector>& positions)
68{
69 for(size_t i = 0; i < positions.size(); ++i)
70 {
72 fPMTPositionsX->push_back(positions[i].x());
74 fPMTPositionsY->push_back(positions[i].y());
76 fPMTPositionsZ->push_back(positions[i].z());
77 }
78}
79
80//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81
83{
85 new LXePMTHitsCollection(SensitiveDetectorName, collectionName[0]);
86
87 if(fHitCID < 0)
88 {
89 fHitCID = G4SDManager::GetSDMpointer()->GetCollectionID(fPMTHitCollection);
90 }
91 hitsCE->AddHitsCollection(fHitCID, fPMTHitCollection);
92}
93
94//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95
97
98//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99
100// Generates a hit and uses the postStepPoint's mother volume replica number
101// PostStepPoint because the hit is generated manually when the photon is
102// absorbed by the photocathode
103
105{
106 // need to know if this is an optical photon
107 if(aStep->GetTrack()->GetDefinition() !=
108 G4OpticalPhoton::OpticalPhotonDefinition())
109 return false;
110
111 // User replica number 1 since photocathode is a daughter volume
112 // to the pmt which was replicated
113 G4int pmtNumber =
114 aStep->GetPostStepPoint()->GetTouchable()->GetReplicaNumber(1);
115 G4VPhysicalVolume* physVol =
116 aStep->GetPostStepPoint()->GetTouchable()->GetVolume(1);
117
118 // Find the correct hit collection
119 size_t n = fPMTHitCollection->entries();
120 LXePMTHit* hit = nullptr;
121 for(size_t i = 0; i < n; ++i)
122 {
123 if((*fPMTHitCollection)[i]->GetPMTNumber() == pmtNumber)
124 {
125 hit = (*fPMTHitCollection)[i];
126 break;
127 }
128 }
129
130 if(hit == nullptr)
131 { // this pmt wasn't previously hit in this event
132 hit = new LXePMTHit(); // so create new hit
133 hit->SetPMTNumber(pmtNumber);
134 hit->SetPMTPhysVol(physVol);
135 fPMTHitCollection->insert(hit);
136 hit->SetPMTPos((*fPMTPositionsX)[pmtNumber], (*fPMTPositionsY)[pmtNumber],
137 (*fPMTPositionsZ)[pmtNumber]);
138 }
139
140 hit->IncPhotonCount(); // increment hit for the selected pmt
141
143 {
144 hit->SetDrawit(true);
145 // If the sphere is disabled then this hit is automaticaly drawn
146 }
147 else
148 { // sphere enabled
149 auto trackInfo =
150 (LXeUserTrackInformation*) aStep->GetTrack()->GetUserInformation();
151 if(trackInfo->GetTrackStatus() & hitSphere)
152 // only draw this hit if the photon has hit the sphere first
153 hit->SetDrawit(true);
154 }
155
156 return true;
157}
Definition of the LXeDetectorConstruction class.
Definition of the LXePMTHit class.
G4THitsCollection< LXePMTHit > LXePMTHitsCollection
Definition LXePMTHit.hh:86
Definition of the LXePMTSD class.
Definition of the LXeUserTrackInformation class.
void IncPhotonCount()
Definition LXePMTHit.hh:59
void SetPMTPos(G4double x, G4double y, G4double z)
Definition LXePMTHit.hh:71
void SetPMTPhysVol(G4VPhysicalVolume *physVol)
Definition LXePMTHit.hh:65
void SetPMTNumber(G4int n)
Definition LXePMTHit.hh:62
void SetDrawit(G4bool b)
Definition LXePMTHit.hh:56
G4DataVector * fPMTPositionsX
Definition LXePMTSD.hh:76
G4DataVector * fPMTPositionsY
Definition LXePMTSD.hh:77
G4DataVector * fPMTPositionsZ
Definition LXePMTSD.hh:78
void Initialize(G4HCofThisEvent *) override
Definition LXePMTSD.cc:82
G4int fHitCID
Definition LXePMTSD.hh:80
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *) override
Definition LXePMTSD.cc:96
~LXePMTSD() override
Definition LXePMTSD.cc:58
LXePMTHitsCollection * fPMTHitCollection
Definition LXePMTSD.hh:74
void SetPmtPositions(const std::vector< G4ThreeVector > &positions)
Definition LXePMTSD.cc:67
G4bool ProcessHits_boundary(const G4Step *, G4TouchableHistory *)
Definition LXePMTSD.cc:104
LXePMTSD(G4String name)
Definition LXePMTSD.cc:50

Applications | User Support | Publications | Collaboration