Loading...
Searching...
No Matches
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//
27/// \file optical/wls/src/WLSPhotonDetSD.cc
28/// \brief Implementation of the WLSPhotonDetSD class
29//
30//
31#include "WLSPhotonDetSD.hh"
32
33#include "WLSPhotonDetHit.hh"
35
36#include "G4OpticalPhoton.hh"
37#include "G4SDManager.hh"
38#include "G4Step.hh"
39#include "G4ThreeVector.hh"
40#include "G4TouchableHistory.hh"
41#include "G4Track.hh"
42#include "G4VTouchable.hh"
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
48{
49 collectionName.insert("PhotonDetHitCollection");
50}
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53
55{
57 new WLSPhotonDetHitsCollection(SensitiveDetectorName, collectionName[0]);
58
59 if(fHCID < 0)
60 {
61 fHCID =
62 G4SDManager::GetSDMpointer()->GetCollectionID(fPhotonDetHitCollection);
63 }
64 HCE->AddHitsCollection(fHCID, fPhotonDetHitCollection);
65}
66
67//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68
70{
71 if(!aStep)
72 return false;
73 G4Track* theTrack = aStep->GetTrack();
74
75 // Need to know if this is an optical photon
76 if(theTrack->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())
77 {
78 return false;
79 }
80
81 // Find out information regarding the hit
82 G4StepPoint* thePostPoint = aStep->GetPostStepPoint();
83
84 auto trackInformation =
85 (WLSUserTrackInformation*) theTrack->GetUserInformation();
86
87 auto theTouchable = (G4TouchableHistory*) (thePostPoint->GetTouchable());
88
89 G4ThreeVector photonExit = trackInformation->GetExitPosition();
90 G4ThreeVector photonArrive = thePostPoint->GetPosition();
91 G4double arrivalTime = theTrack->GetGlobalTime();
92 G4double energy = theTrack->GetTotalEnergy();
93
94 // Convert the global coordinate for arriving photons into
95 // the local coordinate of the detector
96 photonArrive =
97 theTouchable->GetHistory()->GetTopTransform().TransformPoint(photonArrive);
98
99 // Creating the hit and add it to the collection
101 new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime, energy));
102
103 return true;
104}
105
107{
108 if ( verboseLevel>1 ) {
109 G4int nofHits = fPhotonDetHitCollection->entries();
110 G4cout << G4endl
111 << "-------->Hits Collection: in this event there are " << nofHits
112 << " hits in the photon detector: " << G4endl;
113 for ( G4int i=0; i<nofHits; i++ ) (*fPhotonDetHitCollection)[i]->Print();
114 }
115}
116
Definition of the WLSPhotonDetHit class.
G4THitsCollection< WLSPhotonDetHit > WLSPhotonDetHitsCollection
Definition of the WLSPhotonDetSD class.
Definition of the WLSUserTrackInformation class.
WLSPhotonDetSD(G4String)
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override
void EndOfEvent(G4HCofThisEvent *) override
WLSPhotonDetHitsCollection * fPhotonDetHitCollection
void Initialize(G4HCofThisEvent *) override

Applications | User Support | Publications | Collaboration