Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
RE01StackingAction.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: RE01StackingAction.cc 90679 2015-06-08 07:58:19Z gcosmo $
30 //
31 
32 #include "RE01StackingAction.hh"
33 #include "RE01TrackInformation.hh"
34 #include "RE01CalorimeterHit.hh"
35 
36 #include "G4SDManager.hh"
37 #include "G4RunManager.hh"
38 #include "G4Event.hh"
39 #include "G4HCofThisEvent.hh"
40 #include "G4Track.hh"
41 #include "G4TrackStatus.hh"
42 #include "G4ParticleDefinition.hh"
43 #include "G4ParticleTypes.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4ios.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50  fStage(0),fCalorimeterHitsColID(-1)
51 {;}
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 {;}
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 ::ClassifyNewTrack(const G4Track * aTrack)
60 {
61  G4ClassificationOfNewTrack classification = fUrgent;
62 
63  if(fStage==0)
64  {
65  RE01TrackInformation* trackInfo;
66  if(aTrack->GetTrackStatus()==fSuspend) // Track reached to calorimeter
67  {
68  trackInfo = (RE01TrackInformation*)(aTrack->GetUserInformation());
69  trackInfo->SetTrackingStatus(0);
70  trackInfo->SetSourceTrackInformation(aTrack);
71 // G4cout << "Track " << aTrack->GetTrackID()
72 // << " (parentID " << aTrack->GetParentID()
73 // << ") has reached to calorimeter and has been suspended at "
74 // << aTrack->GetPosition() << G4endl;
75  classification = fWaiting;
76  }
77  else if(aTrack->GetParentID()==0) // Primary particle
78  {
79  trackInfo = new RE01TrackInformation(aTrack);
80  trackInfo->SetTrackingStatus(1);
81  G4Track* theTrack = (G4Track*)aTrack;
82  theTrack->SetUserInformation(trackInfo);
83  }
84  }
85  return classification;
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 {
94  { fCalorimeterHitsColID = SDMan->GetCollectionID("calCollection"); }
96  {
97  const G4Event* currentEvent = runMan->GetCurrentEvent();
98  G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
99  return HCE->GetHC(fCalorimeterHitsColID);
100  }
101  return 0;
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 {
107  // G4cout << "+++++++++++ Stage " << fStage << G4endl;
108  if(fStage==0)
109  {
110  // display trajetory information in the tracking region
111  G4cout << G4endl;
112  G4cout << "Tracks in tracking region have been processed. -- Stage 0 over."
113  << G4endl;
114  G4cout << G4endl;
115  }
116  else
117  {
118  // display calorimeter information caused by a "source" track
119  // in the tracker region
120  // G4cout << G4endl;
121  // G4cout << "Processing one shower originated by a source track "
122  // << "in tracker region is over." << G4endl;
123  // G4cout << G4endl;
126  if(CHC)
127  {
128  int n_hit = CHC->entries();
129  G4double totE = 0;
130  G4int n_hitByATrack = 0;
131  for(int i=0;i<n_hit;i++)
132  {
133  G4double edepByATrack = (*CHC)[i]->GetEdepByATrack();
134  if(edepByATrack>0.)
135  {
136  totE += edepByATrack;
137  if(n_hitByATrack==0)
138  { (*CHC)[i]->GetTrackInformation()->Print(); }
139  n_hitByATrack++;
140  G4cout << "Cell[" << (*CHC)[i]->GetZ() << ","
141  << (*CHC)[i]->GetPhi() << "] "
142  << edepByATrack/GeV << " [GeV]" << G4endl;
143  (*CHC)[i]->ClearEdepByATrack();
144  }
145  }
146  if(n_hitByATrack>0)
147  {
148  G4cout <<
149  "### Total energy deposition in calorimeter by a source track in "
150  << n_hitByATrack << " cells : " << totE / GeV << " (GeV)"
151  << G4endl;
152  G4cout << G4endl;
153  }
154  }
155  }
156 
158  {
159  // Transfer all tracks in Urgent stack to Waiting stack, since all tracks
160  // in Waiting stack have already been transfered to Urgent stack before
161  // invokation of this method.
163 
164  // Then, transfer only one track to Urgent stack.
166 
167  fStage++;
168  }
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
173 {
174  fStage = 0;
175 }
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
G4VHitsCollection * GetCalCollection()
#define G4endl
Definition: G4ios.hh:61
void SetSourceTrackInformation(const G4Track *aTrack)
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76
void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
G4int GetNUrgentTrack() const
const G4Event * GetCurrentEvent() const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
Definition of the RE01TrackInformation class.
G4StackManager * stackManager
virtual void PrepareNewEvent()
G4GLOB_DLL std::ostream G4cout
Definition of the RE01CalorimeterHit class.
G4VUserTrackInformation * GetUserInformation() const
void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
G4TrackStatus GetTrackStatus() const
Definition of the RE01StackingAction class.
static constexpr double GeV
Definition: G4SIunits.hh:217
void SetUserInformation(G4VUserTrackInformation *aValue) const
G4int GetParentID() const