Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
factory/shared/src/ScreenSD.cc
이 파일의 문서화 페이지로 가기
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$
27 //
30 //
31 
32 #include "ScreenSD.hh"
33 #include "Analysis.hh"
34 
35 #include "G4VTouchable.hh"
36 #include "G4Step.hh"
37 #include "G4ios.hh"
38 #include "G4SystemOfUnits.hh"
39 
40 #include "G4VProcess.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45  : G4VSensitiveDetector(name)
46 {}
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
51 {}
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 {}
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  // Current track:
63  const G4Track* track = step->GetTrack();
64 
65  // Track ID:
66  G4int ID = track->GetTrackID();
67 
68  // code PDG:
69  G4int pdgCode = track->GetDefinition()->GetPDGEncoding();
70 
71  // Remember preStepPoint:
72  G4StepPoint* preStepPoint = step->GetPreStepPoint();
73 
74  // Ekin:
75  G4double Ekin = preStepPoint->GetKineticEnergy();
76 
77  // Obtain local coordinates:
78  const G4VTouchable* touchable = preStepPoint->GetTouchable();
79  G4ThreeVector globalPosition = preStepPoint->GetPosition();
80  G4ThreeVector localPosition
81  = touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
82  // // Example for obtaining the local direction:
83  // G4ThreeVector globalDirection = preStepPoint->GetMomentumDirection();
84  // G4ThreeVector localDirection
85  // = touchable->GetHistory()->GetTopTransform().TransformAxis(localDirection);
86 
87  // Time
88  G4double time = preStepPoint->GetGlobalTime();
89 
90  // Store hit in the ntuple
91  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
92  analysisManager->FillNtupleIColumn(0, ID);
93  analysisManager->FillNtupleIColumn(1, pdgCode);
94  analysisManager->FillNtupleDColumn(2, Ekin/MeV);
95  analysisManager->FillNtupleDColumn(3, localPosition.x()/cm);
96  analysisManager->FillNtupleDColumn(4, localPosition.y()/cm);
97  analysisManager->FillNtupleDColumn(5, time/ns);
98  analysisManager->AddNtupleRow();
99 
100  return true;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
106 {}
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
virtual void EndOfEvent(G4HCofThisEvent *hce)
const G4VTouchable * GetTouchable() const
ScreenSD(const G4String &name)
static constexpr double MeV
Definition: G4SIunits.hh:214
G4StepPoint * GetPreStepPoint() const
G4int GetTrackID() const
virtual void Initialize(G4HCofThisEvent *hce)
G4ParticleDefinition * GetDefinition() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
const G4ThreeVector & GetPosition() const
const G4AffineTransform & GetTopTransform() const
G4Track * GetTrack() const
G4double GetGlobalTime() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Step.hh:76
G4double GetKineticEnergy() const
int G4int
Definition: G4Types.hh:78
virtual G4bool ProcessHits(G4Step *step, G4TouchableHistory *history)
static constexpr double cm
Definition: G4SIunits.hh:119
double x() const
double y() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
virtual const G4NavigationHistory * GetHistory() const
Definition: G4VTouchable.cc:86
#define ns
Definition: xmlparse.cc:614