Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/electromagnetic/TestEm3/src/SteppingAction.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 //
28 //
29 // $Id: SteppingAction.cc 109096 2018-03-26 14:46:51Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 
36 #include "DetectorConstruction.hh"
37 #include "Run.hh"
38 #include "EventAction.hh"
39 #include "HistoManager.hh"
40 
41 #include "G4Positron.hh"
42 #include "G4RunManager.hh"
43 #include "G4PhysicalConstants.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :G4UserSteppingAction(),fDetector(det),fEventAct(evt)
49 { }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 { }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  //track informations
61  const G4StepPoint* prePoint = aStep->GetPreStepPoint();
62 
63  //if World, return
64  //
65  G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
66  //if sum of absorbers do not fill exactly a layer: check material, not volume.
67  const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
68  if (mat == fDetector->GetWorldMaterial()) return;
69 
70  const G4StepPoint* endPoint = aStep->GetPostStepPoint();
71  const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
72 
73  //here we are in an absorber. Locate it
74  //
75  G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
76  G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
77 
78  //get Run
79  Run* run = static_cast<Run*>(
81 
82  // collect energy deposit taking into account track weight
83  G4double edep = aStep->GetTotalEnergyDeposit()*aStep->GetTrack()->GetWeight();
84 
85  // collect step length of charged particles
86  G4double stepl = 0.;
87  if (particle->GetPDGCharge() != 0.) {
88  stepl = aStep->GetStepLength();
89  run->AddChargedStep();
90  } else { run->AddNeutralStep(); }
91 
92  // G4cout << "Nabs= " << absorNum << " edep(keV)= " << edep << G4endl;
93 
94  // sum up per event
95  fEventAct->SumEnergy(absorNum,edep,stepl);
96 
97  //longitudinal profile of edep per absorber
98  if (edep>0.) {
99  G4AnalysisManager::Instance()->FillH1(kMaxAbsor+absorNum,
100  G4double(layerNum+1), edep);
101  }
102  //energy flow
103  //
104  // unique identificator of layer+absorber
105  G4int Idnow = (fDetector->GetNbOfAbsor())*layerNum + absorNum;
106  G4int plane;
107  //
108  //leaving the absorber ?
109  if (endPoint->GetStepStatus() == fGeomBoundary) {
110  G4ThreeVector position = endPoint->GetPosition();
111  G4ThreeVector direction = endPoint->GetMomentumDirection();
112  G4double sizeYZ = 0.5*fDetector->GetCalorSizeYZ();
113  G4double Eflow = endPoint->GetKineticEnergy();
114  if(particle == G4Positron::Positron()) Eflow += 2*electron_mass_c2;
115  if((std::abs(position.y()) >= sizeYZ) || (std::abs(position.z()) >= sizeYZ))
116  run->SumLateralEleak(Idnow, Eflow);
117  else if (direction.x() >= 0.) run->SumEnergyFlow(plane=Idnow+1, Eflow);
118  else run->SumEnergyFlow(plane=Idnow, -Eflow);
119  }
120 
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
131 {
132  //Example of Birk attenuation law in organic scintillators.
133  //adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
134  //
135  G4Material* material = aStep->GetTrack()->GetMaterial();
136  G4double birk1 = material->GetIonisation()->GetBirksConstant();
137  G4double destep = aStep->GetTotalEnergyDeposit();
138  G4double stepl = aStep->GetStepLength();
139  G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
140  //
141  G4double response = destep;
142  if (birk1*destep*stepl*charge != 0.)
143  {
144  response = destep/(1. + birk1*destep/stepl);
145  }
146  return response;
147 }
148 
149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
150 
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
const DetectorConstruction * fDetector
G4LogicalVolume * GetLogicalVolume() const
void SumEnergy(G4int k, G4double de, G4double dl)
G4StepPoint * GetPreStepPoint() const
G4double GetPDGCharge() const
double z() const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
G4ParticleDefinition * GetDefinition() const
const G4TouchableHandle & GetTouchableHandle() const
G4Material * GetMaterial() const
G4double GetWeight() const
double G4double
Definition: G4Types.hh:76
G4StepStatus GetStepStatus() const
void SumEnergyFlow(G4int plane, G4double Eflow)
G4double GetStepLength() const
static constexpr double electron_mass_c2
const G4ThreeVector & GetPosition() const
G4Track * GetTrack() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetTotalEnergyDeposit() const
static G4Positron * Positron()
Definition: G4Positron.cc:94
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
Float_t mat
G4double GetBirksConstant() const
void UserSteppingAction(const G4Step *)
G4Material * GetMaterial() const
G4double GetKineticEnergy() const
G4int GetCopyNumber(G4int depth=0) const
G4double BirksAttenuation(const G4Step *)
Double_t edep
G4Run * GetNonConstCurrentRun() const
void SumLateralEleak(G4int cell, G4double Eflow)
int G4int
Definition: G4Types.hh:78
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:227
double x() const
double y() const
Simple detector construction with a box volume placed in a world.