Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file optical/wls/src/WLSPhotonDetSD.cc << 28 /// \brief Implementation of the WLSPhotonDetS << 29 // 27 // 30 // << 31 #include "WLSPhotonDetSD.hh" << 32 28 >> 29 #include "WLSPhotonDetSD.hh" 33 #include "WLSPhotonDetHit.hh" 30 #include "WLSPhotonDetHit.hh" 34 #include "WLSUserTrackInformation.hh" 31 #include "WLSUserTrackInformation.hh" 35 32 36 #include "G4OpticalPhoton.hh" << 37 #include "G4SDManager.hh" << 38 #include "G4Step.hh" << 39 #include "G4ThreeVector.hh" << 40 #include "G4TouchableHistory.hh" << 41 #include "G4Track.hh" 33 #include "G4Track.hh" >> 34 #include "G4ThreeVector.hh" >> 35 #include "G4Step.hh" >> 36 #include "G4ParticleDefinition.hh" 42 #include "G4VTouchable.hh" 37 #include "G4VTouchable.hh" >> 38 #include "G4TouchableHistory.hh" >> 39 #include "G4ios.hh" >> 40 #include "G4ParticleTypes.hh" >> 41 #include "G4ParticleDefinition.hh" 43 42 44 //....oooOO0OOooo........oooOO0OOooo........oo << 43 WLSPhotonDetSD::WLSPhotonDetSD(G4String name) 45 << 44 : G4VSensitiveDetector(name),PhotonDetHitCollection(0) 46 WLSPhotonDetSD::WLSPhotonDetSD(G4String name) << 47 { 45 { 48 collectionName.insert("PhotonDetHitCollectio 46 collectionName.insert("PhotonDetHitCollection"); 49 } 47 } 50 48 51 //....oooOO0OOooo........oooOO0OOooo........oo << 49 WLSPhotonDetSD::~WLSPhotonDetSD() { } 52 50 53 void WLSPhotonDetSD::Initialize(G4HCofThisEven 51 void WLSPhotonDetSD::Initialize(G4HCofThisEvent* HCE) 54 { 52 { 55 fPhotonDetHitCollection = << 53 PhotonDetHitCollection = 56 new WLSPhotonDetHitsCollection(SensitiveDe << 54 new WLSPhotonDetHitsCollection(SensitiveDetectorName,collectionName[0]); 57 << 55 //Store collection with event and keep ID 58 if (fHCID < 0) { << 56 static G4int HCID = -1; 59 fHCID = G4SDManager::GetSDMpointer()->GetC << 57 if (HCID<0) HCID = GetCollectionID(0); 60 } << 58 HCE->AddHitsCollection( HCID, PhotonDetHitCollection ); 61 HCE->AddHitsCollection(fHCID, fPhotonDetHitC << 62 } 59 } 63 60 64 //....oooOO0OOooo........oooOO0OOooo........oo << 61 G4bool WLSPhotonDetSD::ProcessHits(G4Step* , G4TouchableHistory* ) >> 62 { >> 63 return false; >> 64 } 65 65 66 G4bool WLSPhotonDetSD::ProcessHits(G4Step* aSt << 66 //Generates a hit and uses the postStepPoint; PostStepPoint because the hit >> 67 //is generated manually when the photon hits the detector >> 68 G4bool WLSPhotonDetSD::ProcessHits_constStep(const G4Step* aStep, >> 69 G4TouchableHistory* ) 67 { 70 { 68 if (!aStep) return false; << 71 if (aStep == NULL) return false; 69 G4Track* theTrack = aStep->GetTrack(); 72 G4Track* theTrack = aStep->GetTrack(); 70 73 71 // Need to know if this is an optical photon 74 // Need to know if this is an optical photon 72 if (theTrack->GetDefinition() != G4OpticalPh << 75 if(theTrack->GetDefinition() 73 return false; << 76 != G4OpticalPhoton::OpticalPhotonDefinition()) return false; 74 } << 75 77 76 // Find out information regarding the hit 78 // Find out information regarding the hit 77 G4StepPoint* thePostPoint = aStep->GetPostSt 79 G4StepPoint* thePostPoint = aStep->GetPostStepPoint(); 78 << 80 79 auto trackInformation = (WLSUserTrackInforma << 81 WLSUserTrackInformation* trackInformation 80 << 82 = (WLSUserTrackInformation*)theTrack->GetUserInformation(); 81 auto theTouchable = (G4TouchableHistory*)(th << 83 82 << 84 G4TouchableHistory* theTouchable 83 G4ThreeVector photonExit = trackInformation- << 85 = (G4TouchableHistory*)(thePostPoint->GetTouchable()); 84 G4ThreeVector photonArrive = thePostPoint->G << 86 85 G4double arrivalTime = theTrack->GetGlobalTi << 87 G4ThreeVector photonExit = trackInformation -> GetExitPosition(); 86 G4double energy = theTrack->GetTotalEnergy() << 88 G4ThreeVector photonArrive = thePostPoint -> GetPosition(); >> 89 G4double arrivalTime = theTrack -> GetGlobalTime(); 87 90 88 // Convert the global coordinate for arrivin 91 // Convert the global coordinate for arriving photons into 89 // the local coordinate of the detector 92 // the local coordinate of the detector 90 photonArrive = theTouchable->GetHistory()->G << 93 photonArrive = theTouchable->GetHistory()-> >> 94 GetTopTransform().TransformPoint(photonArrive); 91 95 92 // Creating the hit and add it to the collec 96 // Creating the hit and add it to the collection 93 fPhotonDetHitCollection->insert( << 97 PhotonDetHitCollection-> 94 new WLSPhotonDetHit(photonExit, photonArri << 98 insert(new WLSPhotonDetHit(photonExit, photonArrive, arrivalTime)); 95 99 96 return true; 100 return true; 97 } 101 } 98 102 99 void WLSPhotonDetSD::EndOfEvent(G4HCofThisEven << 103 void WLSPhotonDetSD::EndOfEvent(G4HCofThisEvent* ){ } 100 { << 104 101 if (verboseLevel > 1) { << 105 void WLSPhotonDetSD::clear(){ } 102 G4int nofHits = fPhotonDetHitCollection->e << 106 103 G4cout << G4endl << "-------->Hits Collect << 107 void WLSPhotonDetSD::DrawAll(){ } 104 << " hits in the photon detector: " << 108 105 for (G4int i = 0; i < nofHits; i++) << 109 void WLSPhotonDetSD::PrintAll(){ } 106 (*fPhotonDetHitCollection)[i]->Print(); << 107 } << 108 } << 109 110