Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 //
30 #include "LXePMTSD.hh"
31 #include "LXePMTHit.hh"
34 
35 #include "G4VPhysicalVolume.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4Track.hh"
38 #include "G4Step.hh"
39 #include "G4VTouchable.hh"
40 #include "G4TouchableHistory.hh"
41 #include "G4ios.hh"
42 #include "G4ParticleTypes.hh"
43 #include "G4ParticleDefinition.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48  : G4VSensitiveDetector(name),fPMTHitCollection(0),fPMTPositionsX(0)
49  ,fPMTPositionsY(0),fPMTPositionsZ(0)
50 {
51  collectionName.insert("pmtHitCollection");
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61  fPMTHitCollection = new LXePMTHitsCollection
63  //Store collection with event and keep ID
64  static G4int hitCID = -1;
65  if(hitCID<0){
66  hitCID = GetCollectionID(0);
67  }
68  hitsCE->AddHitsCollection( hitCID, fPMTHitCollection );
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74  return false;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
79 //Generates a hit and uses the postStepPoint's mother volume replica number
80 //PostStepPoint because the hit is generated manually when the photon is
81 //absorbed by the photocathode
82 
85 
86  //need to know if this is an optical photon
87  if(aStep->GetTrack()->GetDefinition()
89 
90  //User replica number 1 since photocathode is a daughter volume
91  //to the pmt which was replicated
92  G4int pmtNumber=
94  G4VPhysicalVolume* physVol=
95  aStep->GetPostStepPoint()->GetTouchable()->GetVolume(1);
96 
97  //Find the correct hit collection
98  G4int n=fPMTHitCollection->entries();
99  LXePMTHit* hit=NULL;
100  for(G4int i=0;i<n;i++){
101  if((*fPMTHitCollection)[i]->GetPMTNumber()==pmtNumber){
102  hit=(*fPMTHitCollection)[i];
103  break;
104  }
105  }
106 
107  if(hit==NULL){//this pmt wasnt previously hit in this event
108  hit = new LXePMTHit(); //so create new hit
109  hit->SetPMTNumber(pmtNumber);
110  hit->SetPMTPhysVol(physVol);
111  fPMTHitCollection->insert(hit);
112  hit->SetPMTPos((*fPMTPositionsX)[pmtNumber],(*fPMTPositionsY)[pmtNumber],
113  (*fPMTPositionsZ)[pmtNumber]);
114  }
115 
116  hit->IncPhotonCount(); //increment hit for the selected pmt
117 
119  hit->SetDrawit(true);
120  //If the sphere is disabled then this hit is automaticaly drawn
121  }
122  else{//sphere enabled
123  LXeUserTrackInformation* trackInfo=
125  if(trackInfo->GetTrackStatus()&hitSphere)
126  //only draw this hit if the photon has hit the sphere first
127  hit->SetDrawit(true);
128  }
129 
130  return true;
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 
140 
141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142 
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146