Loading...
Searching...
No Matches
SAXSSensitiveDetector.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/// \file SAXSSensitiveDetector.cc
27/// \brief Implementation of the SAXSSensitiveDetector class
28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
30
33
34#include "G4HCofThisEvent.hh"
35#include "G4TouchableHistory.hh"
36#include "G4Track.hh"
37#include "G4Step.hh"
38#include "G4SDManager.hh"
39#include "G4Navigator.hh"
40#include "G4ios.hh"
41
42//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43
46{
47 G4String HCname;
48 collectionName.insert(HCname="collection");
49 fHCID = -1;
50
51 fVarStopAndKill = true;
52
54}
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
57
59
60//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61
63{
65 new SensitiveDetectorHitsCollection(SensitiveDetectorName,collectionName[0]);
66 if(fHCID<0)
67 fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
68 HCE->AddHitsCollection(fHCID,fHitsCollection);
69}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
72
74{
75 G4Track* vTrack = aStep->GetTrack();
76
77 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
78
79 G4ThreeVector worldPosition = preStepPoint->GetPosition();
80 G4ThreeVector localPosition = preStepPoint->GetTouchableHandle()->
81 GetHistory()->GetTopTransform().TransformPoint(worldPosition);
82
83 G4ThreeVector mom = preStepPoint->GetMomentumDirection();
84
85 //if the partcile is not on the boundary of the sensitive detector, return
86 if (!(preStepPoint->GetStepStatus() == fGeomBoundary)) {return false;}
87
88 G4int vType = -1;
89 if(preStepPoint->GetMass() == 0 && preStepPoint->GetCharge() == 0) {
90 vType = 0;
91 }
92 else if(preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() == 0) {
93 vType = 1;
94 }
95 else if(preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() > 0) {
96 vType = 2;
97 }
98 else if(preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() < 0) {
99 vType = 3;
100 }
101
102 //insert a hit
104 aHit->SetPos(localPosition);
105 aHit->SetMom(mom);
106 aHit->SetType(vType);
107 aHit->SetEnergy(preStepPoint->GetKineticEnergy());
108 aHit->SetTime(preStepPoint->GetGlobalTime());
109 aHit->SetTrackID(vTrack->GetTrackID());
110 aHit->SetWeight(vTrack->GetWeight());
111 fHitsCollection->insert(aHit);
112
113 if (fVarStopAndKill) {vTrack->SetTrackStatus(fStopAndKill);}
114
115 return true;
116}
117//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
118
120
121//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122
Definition of the SAXSSensitiveDetectorHit class.
G4THitsCollection< SAXSSensitiveDetectorHit > SensitiveDetectorHitsCollection
Definition of the SAXSSensitiveDetector class.
SAXSSensitiveDetectorMessenger * fSDMessenger
virtual void Initialize(G4HCofThisEvent *)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
SensitiveDetectorHitsCollection * fHitsCollection
virtual void EndOfEvent(G4HCofThisEvent *)

Applications | User Support | Publications | Collaboration