Geant4.10
 All Data Structures 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 //
26 // $Id: LXePMTSD.cc 73915 2013-09-17 07:32:26Z gcosmo $
27 //
28 /// \file optical/LXe/src/LXePMTSD.cc
29 /// \brief Implementation of the LXePMTSD class
30 //
31 //
32 #include "LXePMTSD.hh"
33 #include "LXePMTHit.hh"
36 
37 #include "G4VPhysicalVolume.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4Track.hh"
40 #include "G4Step.hh"
41 #include "G4VTouchable.hh"
42 #include "G4TouchableHistory.hh"
43 #include "G4ios.hh"
44 #include "G4ParticleTypes.hh"
45 #include "G4ParticleDefinition.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  : G4VSensitiveDetector(name),fPMTHitCollection(0),fPMTPositionsX(0)
51  ,fPMTPositionsY(0),fPMTPositionsZ(0)
52 {
53  collectionName.insert("pmtHitCollection");
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
62 void LXePMTSD::SetPmtPositions(const std::vector<G4ThreeVector>& positions)
63 {
64  for (G4int i=0; i<G4int(positions.size()); ++i) {
65  if(fPMTPositionsX)fPMTPositionsX->push_back(positions[i].x());
66  if(fPMTPositionsY)fPMTPositionsY->push_back(positions[i].y());
67  if(fPMTPositionsZ)fPMTPositionsZ->push_back(positions[i].z());
68  }
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74  fPMTHitCollection = new LXePMTHitsCollection
76  //Store collection with event and keep ID
77  static G4int hitCID = -1;
78  if(hitCID<0){
79  hitCID = GetCollectionID(0);
80  }
81  hitsCE->AddHitsCollection( hitCID, fPMTHitCollection );
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87  return false;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
92 //Generates a hit and uses the postStepPoint's mother volume replica number
93 //PostStepPoint because the hit is generated manually when the photon is
94 //absorbed by the photocathode
95 
98 
99  //need to know if this is an optical photon
100  if(aStep->GetTrack()->GetDefinition()
101  != G4OpticalPhoton::OpticalPhotonDefinition()) return false;
102 
103  //User replica number 1 since photocathode is a daughter volume
104  //to the pmt which was replicated
105  G4int pmtNumber=
107  G4VPhysicalVolume* physVol=
108  aStep->GetPostStepPoint()->GetTouchable()->GetVolume(1);
109 
110  //Find the correct hit collection
111  G4int n=fPMTHitCollection->entries();
112  LXePMTHit* hit=NULL;
113  for(G4int i=0;i<n;i++){
114  if((*fPMTHitCollection)[i]->GetPMTNumber()==pmtNumber){
115  hit=(*fPMTHitCollection)[i];
116  break;
117  }
118  }
119 
120  if(hit==NULL){//this pmt wasnt previously hit in this event
121  hit = new LXePMTHit(); //so create new hit
122  hit->SetPMTNumber(pmtNumber);
123  hit->SetPMTPhysVol(physVol);
124  fPMTHitCollection->insert(hit);
125  hit->SetPMTPos((*fPMTPositionsX)[pmtNumber],(*fPMTPositionsY)[pmtNumber],
126  (*fPMTPositionsZ)[pmtNumber]);
127  }
128 
129  hit->IncPhotonCount(); //increment hit for the selected pmt
130 
132  hit->SetDrawit(true);
133  //If the sphere is disabled then this hit is automaticaly drawn
134  }
135  else{//sphere enabled
136  LXeUserTrackInformation* trackInfo=
138  if(trackInfo->GetTrackStatus()&hitSphere)
139  //only draw this hit if the photon has hit the sphere first
140  hit->SetDrawit(true);
141  }
142 
143  return true;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151 
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 
G4ParticleDefinition * GetDefinition() const
virtual void clear()
Definition: LXePMTSD.cc:152
virtual void Initialize(G4HCofThisEvent *)
Definition: LXePMTSD.cc:73
virtual void EndOfEvent(G4HCofThisEvent *)
Definition: LXePMTSD.cc:148
void SetPMTNumber(G4int n)
Definition: LXePMTHit.hh:71
G4double z
Definition: TRTMaterials.hh:39
const XML_Char * name
Definition of the LXeDetectorConstruction class.
void SetDrawit(G4bool b)
Definition: LXePMTHit.hh:65
const G4VTouchable * GetTouchable() const
G4bool ProcessHits_constStep(const G4Step *, G4TouchableHistory *)
Definition: LXePMTSD.cc:96
int G4int
Definition: G4Types.hh:78
virtual G4int GetCollectionID(G4int i)
G4VUserTrackInformation * GetUserInformation() const
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *)
Definition: LXePMTSD.cc:86
Definition of the LXePMTSD class.
void DrawAll()
Definition: LXePMTSD.cc:156
bool G4bool
Definition: G4Types.hh:79
Definition of the LXePMTHit class.
Definition of the LXeUserTrackInformation class.
Definition: G4Step.hh:76
void IncPhotonCount()
Definition: LXePMTHit.hh:68
const G4int n
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
void SetPmtPositions(const std::vector< G4ThreeVector > &positions)
Definition: LXePMTSD.cc:62
virtual ~LXePMTSD()
Definition: LXePMTSD.cc:58
void PrintAll()
Definition: LXePMTSD.cc:160
void SetPMTPhysVol(G4VPhysicalVolume *physVol)
Definition: LXePMTHit.hh:74
G4THitsCollection< LXePMTHit > LXePMTHitsCollection
Definition: LXePMTHit.hh:93
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
G4StepPoint * GetPostStepPoint() const
virtual G4int GetReplicaNumber(G4int depth=0) const
Definition: G4VTouchable.cc:58
void SetPMTPos(G4double x, G4double y, G4double z)
Definition: LXePMTHit.hh:77
G4CollectionNameVector collectionName
static G4OpticalPhoton * OpticalPhotonDefinition()
G4Track * GetTrack() const
LXePMTSD(G4String name)
Definition: LXePMTSD.cc:49