Geant4_10
WLSPhotonDetSD.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: WLSPhotonDetSD.cc 69561 2013-05-08 12:25:56Z gcosmo $
27 //
30 //
31 //
32 #include "WLSPhotonDetSD.hh"
33 #include "WLSPhotonDetHit.hh"
35 
36 #include "G4Track.hh"
37 #include "G4ThreeVector.hh"
38 #include "G4Step.hh"
39 #include "G4ParticleDefinition.hh"
40 #include "G4VTouchable.hh"
41 #include "G4TouchableHistory.hh"
42 #include "G4ios.hh"
43 #include "G4ParticleTypes.hh"
44 #include "G4ParticleDefinition.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49  : G4VSensitiveDetector(name), fPhotonDetHitCollection(0)
50 {
51  collectionName.insert("PhotonDetHitCollection");
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  fPhotonDetHitCollection =
64  //Store collection with event and keep ID
65  static G4int HCID = -1;
66  if (HCID<0) HCID = GetCollectionID(0);
67  HCE->AddHitsCollection( HCID, fPhotonDetHitCollection );
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  return false;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
81 //Generates a hit and uses the postStepPoint; PostStepPoint because the hit
82 //is generated manually when the photon hits the detector
83 {
84  if (aStep == NULL) return false;
85  G4Track* theTrack = aStep->GetTrack();
86 
87  // Need to know if this is an optical photon
88  if(theTrack->GetDefinition()
90 
91  // Find out information regarding the hit
92  G4StepPoint* thePostPoint = aStep->GetPostStepPoint();
93 
94  WLSUserTrackInformation* trackInformation
96 
97  G4TouchableHistory* theTouchable
98  = (G4TouchableHistory*)(thePostPoint->GetTouchable());
99 
100  G4ThreeVector photonExit = trackInformation -> GetExitPosition();
101  G4ThreeVector photonArrive = thePostPoint -> GetPosition();
102  G4double arrivalTime = theTrack -> GetGlobalTime();
103 
104  // Convert the global coordinate for arriving photons into
105  // the local coordinate of the detector
106  photonArrive = theTouchable->GetHistory()->
107  GetTopTransform().TransformPoint(photonArrive);
108 
109  // Creating the hit and add it to the collection
110  fPhotonDetHitCollection->
111  insert(new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime));
112 
113  return true;
114 }
G4ParticleDefinition * GetDefinition() const
G4bool ProcessHits_constStep(const G4Step *, G4TouchableHistory *)
Definition of the WLSUserTrackInformation class.
Definition of the WLSPhotonDetHit class.
const XML_Char * name
Definition: expat.h:151
const G4VTouchable * GetTouchable() const
int G4int
Definition: G4Types.hh:78
virtual G4int GetCollectionID(G4int i)
G4VUserTrackInformation * GetUserInformation() const
bool G4bool
Definition: G4Types.hh:79
WLSPhotonDetSD(G4String)
Definition: G4Step.hh:76
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
G4StepPoint * GetPostStepPoint() const
virtual ~WLSPhotonDetSD()
G4THitsCollection< WLSPhotonDetHit > WLSPhotonDetHitsCollection
Definition of the WLSPhotonDetSD class.
virtual void Initialize(G4HCofThisEvent *)
G4CollectionNameVector collectionName
const G4NavigationHistory * GetHistory() const
static G4OpticalPhoton * OpticalPhotonDefinition()
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const