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 | #include "LXePMTSD.hh" |
---|
27 | #include "LXePMTHit.hh" |
---|
28 | #include "LXeDetectorConstruction.hh" |
---|
29 | #include "LXeUserTrackInformation.hh" |
---|
30 | |
---|
31 | #include "G4VPhysicalVolume.hh" |
---|
32 | #include "G4LogicalVolume.hh" |
---|
33 | #include "G4Track.hh" |
---|
34 | #include "G4Step.hh" |
---|
35 | #include "G4ParticleDefinition.hh" |
---|
36 | #include "G4VTouchable.hh" |
---|
37 | #include "G4TouchableHistory.hh" |
---|
38 | #include "G4ios.hh" |
---|
39 | #include "G4ParticleTypes.hh" |
---|
40 | #include "G4ParticleDefinition.hh" |
---|
41 | |
---|
42 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
43 | LXePMTSD::LXePMTSD(G4String name) |
---|
44 | :G4VSensitiveDetector(name),pmtHitCollection(0),pmtPositionsX(0) |
---|
45 | ,pmtPositionsY(0),pmtPositionsZ(0) |
---|
46 | { |
---|
47 | collectionName.insert("pmtHitCollection"); |
---|
48 | } |
---|
49 | |
---|
50 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
51 | LXePMTSD::~LXePMTSD() |
---|
52 | {} |
---|
53 | |
---|
54 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
55 | void LXePMTSD::Initialize(G4HCofThisEvent* HCE){ |
---|
56 | pmtHitCollection = new LXePMTHitsCollection |
---|
57 | (SensitiveDetectorName,collectionName[0]); |
---|
58 | //Store collection with event and keep ID |
---|
59 | static G4int HCID = -1; |
---|
60 | if(HCID<0){ |
---|
61 | HCID = GetCollectionID(0); |
---|
62 | } |
---|
63 | HCE->AddHitsCollection( HCID, pmtHitCollection ); |
---|
64 | } |
---|
65 | |
---|
66 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
67 | G4bool LXePMTSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist){ |
---|
68 | return ProcessHits_constStep(aStep,ROhist); |
---|
69 | } |
---|
70 | |
---|
71 | //Generates a hit and uses the postStepPoint's mother volume replica number |
---|
72 | //PostStepPoint because the hit is generated manually when the photon is |
---|
73 | //absorbed by the photocathode |
---|
74 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
75 | G4bool LXePMTSD::ProcessHits_constStep(const G4Step* aStep, |
---|
76 | G4TouchableHistory* ){ |
---|
77 | |
---|
78 | //need to know if this is an optical photon |
---|
79 | if(aStep->GetTrack()->GetDefinition() |
---|
80 | != G4OpticalPhoton::OpticalPhotonDefinition()) return false; |
---|
81 | |
---|
82 | //User replica number 1 since photocathode is a daughter volume |
---|
83 | //to the pmt which was replicated |
---|
84 | G4int pmtNumber= |
---|
85 | aStep->GetPostStepPoint()->GetTouchable()->GetReplicaNumber(1); |
---|
86 | G4VPhysicalVolume* physVol= |
---|
87 | aStep->GetPostStepPoint()->GetTouchable()->GetVolume(1); |
---|
88 | |
---|
89 | //Find the correct hit collection |
---|
90 | G4int n=pmtHitCollection->entries(); |
---|
91 | LXePMTHit* hit=NULL; |
---|
92 | for(G4int i=0;i<n;i++){ |
---|
93 | if((*pmtHitCollection)[i]->GetPMTNumber()==pmtNumber){ |
---|
94 | hit=(*pmtHitCollection)[i]; |
---|
95 | break; |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | if(hit==NULL){//this pmt wasnt previously hit in this event |
---|
100 | hit = new LXePMTHit(); //so create new hit |
---|
101 | hit->SetPMTNumber(pmtNumber); |
---|
102 | hit->SetPMTPhysVol(physVol); |
---|
103 | pmtHitCollection->insert(hit); |
---|
104 | hit->SetPMTPos((*pmtPositionsX)[pmtNumber],(*pmtPositionsY)[pmtNumber], |
---|
105 | (*pmtPositionsZ)[pmtNumber]); |
---|
106 | } |
---|
107 | |
---|
108 | hit->IncPhotonCount(); //increment hit for the selected pmt |
---|
109 | |
---|
110 | if(!LXeDetectorConstruction::GetSphereOn()){ |
---|
111 | hit->SetDrawit(true); |
---|
112 | //If the sphere is disabled then this hit is automaticaly drawn |
---|
113 | } |
---|
114 | else{//sphere enabled |
---|
115 | LXeUserTrackInformation* trackInfo= |
---|
116 | (LXeUserTrackInformation*)aStep->GetTrack()->GetUserInformation(); |
---|
117 | if(trackInfo->GetTrackStatus()&hitSphere) |
---|
118 | //only draw this hit if the photon has hit the sphere first |
---|
119 | hit->SetDrawit(true); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | return true; |
---|
124 | } |
---|
125 | |
---|
126 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
127 | void LXePMTSD::EndOfEvent(G4HCofThisEvent* ){ |
---|
128 | } |
---|
129 | |
---|
130 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
131 | void LXePMTSD::clear(){ |
---|
132 | } |
---|
133 | |
---|
134 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
135 | void LXePMTSD::DrawAll(){ |
---|
136 | } |
---|
137 | |
---|
138 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
139 | void LXePMTSD::PrintAll(){ |
---|
140 | } |
---|
141 | |
---|