Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 //
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 
47  : G4VSensitiveDetector(name),PhotonDetHitCollection(0)
48 {
49  collectionName.insert("PhotonDetHitCollection");
50 }
51 
53 
55 {
56  PhotonDetHitCollection =
58  //Store collection with event and keep ID
59  static G4int HCID = -1;
60  if (HCID<0) HCID = GetCollectionID(0);
61  HCE->AddHitsCollection( HCID, PhotonDetHitCollection );
62 }
63 
65 {
66  return false;
67 }
68 
69 //Generates a hit and uses the postStepPoint; PostStepPoint because the hit
70 //is generated manually when the photon hits the detector
73 {
74  if (aStep == NULL) return false;
75  G4Track* theTrack = aStep->GetTrack();
76 
77  // Need to know if this is an optical photon
78  if(theTrack->GetDefinition()
80 
81  // Find out information regarding the hit
82  G4StepPoint* thePostPoint = aStep->GetPostStepPoint();
83 
84  WLSUserTrackInformation* trackInformation
86 
87  G4TouchableHistory* theTouchable
88  = (G4TouchableHistory*)(thePostPoint->GetTouchable());
89 
90  G4ThreeVector photonExit = trackInformation -> GetExitPosition();
91  G4ThreeVector photonArrive = thePostPoint -> GetPosition();
92  G4double arrivalTime = theTrack -> GetGlobalTime();
93 
94  // Convert the global coordinate for arriving photons into
95  // the local coordinate of the detector
96  photonArrive = theTouchable->GetHistory()->
97  GetTopTransform().TransformPoint(photonArrive);
98 
99  // Creating the hit and add it to the collection
100  PhotonDetHitCollection->
101  insert(new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime));
102 
103  return true;
104 }
105 
107 
109 
111