Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
RE01EventAction.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: RE01EventAction.cc 97383 2016-06-02 09:56:35Z gcosmo $
30 //
31 
32 #include "RE01EventAction.hh"
33 #include "RE01TrackerHit.hh"
34 #include "RE01CalorimeterHit.hh"
35 
36 #include "G4Event.hh"
37 #include "G4EventManager.hh"
38 #include "G4HCofThisEvent.hh"
39 #include "G4VHitsCollection.hh"
40 #include "G4TrajectoryContainer.hh"
41 #include "G4VVisManager.hh"
42 #include "G4SDManager.hh"
43 #include "G4UImanager.hh"
44 #include "G4ios.hh"
45 #include "RE01Trajectory.hh"
46 #include "G4PrimaryVertex.hh"
47 #include "G4PrimaryParticle.hh"
48 #include "G4SystemOfUnits.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53  fTrackerCollID(-1),fCalorimeterCollID(-1)
54 {;}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 {;}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 {
65  {
66  G4String colNam;
67  fTrackerCollID = SDman->GetCollectionID(colNam="trackerCollection");
68  fCalorimeterCollID = SDman->GetCollectionID(colNam="calCollection");
69  }
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 {
75  G4cout << ">>> Summary of Event " << evt->GetEventID() << G4endl;
76  if(evt->GetNumberOfPrimaryVertex()==0)
77  {
78  G4cout << "Event is empty." << G4endl;
79  return;
80  }
81 
82  if(fTrackerCollID<0||fCalorimeterCollID<0) return;
83 
84  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
87  if(HCE)
88  {
91  }
92 
93  if(THC)
94  {
95  int n_hit = THC->entries();
96  G4cout << G4endl;
97  G4cout << "Tracker hits " <<
98  "--------------------------------------------------------------"
99  << G4endl;
100  G4cout << n_hit << " hits are stored in RE01TrackerHitsCollection."
101  << G4endl;
103  {
104  G4cout << "List of hits in tracker" << G4endl;
105  for(int i=0;i<n_hit;i++)
106  { (*THC)[i]->Print(); }
107  }
108  }
109  if(CHC)
110  {
111  int n_hit = CHC->entries();
112  G4cout << G4endl;
113  G4cout << "Calorimeter hits "<<
114  "--------------------------------------------------------------"
115  << G4endl;
116  G4cout << n_hit << " hits are stored in RE01CalorimeterHitsCollection."
117  << G4endl;
118  G4double totE = 0;
119  for(int i=0;i<n_hit;i++)
120  { totE += (*CHC)[i]->GetEdep(); }
121  G4cout << " Total energy deposition in calorimeter : "
122  << totE / GeV << " (GeV)" << G4endl;
123  }
124 
125  // get number of stored trajectories
126  G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
127  G4int n_trajectories = 0;
128  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
129  // extract the trajectories and print them out
130  G4cout << G4endl;
131  G4cout << "Trajectories in tracker "<<
132  "--------------------------------------------------------------"
133  << G4endl;
135  {
136  for(G4int i=0; i<n_trajectories; i++)
137  {
138  RE01Trajectory* trj =
139  (RE01Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
140  trj->ShowTrajectory();
141  }
142  }
143 
144  G4cout << G4endl;
145  G4cout << "Primary particles "<<
146  "--------------------------------------------------------------"
147  << G4endl;
148  G4int n_vertex = evt->GetNumberOfPrimaryVertex();
149  for(G4int iv=0;iv<n_vertex;iv++)
150  {
151  G4PrimaryVertex* pv = evt->GetPrimaryVertex(iv);
152  G4cout << G4endl;
153  G4cout << "Primary vertex "
154  << G4ThreeVector(pv->GetX0(),pv->GetY0(),pv->GetZ0())
155  << " at t = " << (pv->GetT0())/ns << " [ns]" << G4endl;
157  {
159  while(pp)
160  {
161  PrintPrimary(pp,0);
162  pp = pp->GetNext();
163  }
164  }
165  }
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 {
171  for(G4int ii=0;ii<=ind;ii++)
172  { G4cout << " "; }
173  G4cout << "==PDGcode " << pp->GetPDGcode() << " ";
174  if(pp->GetG4code()!=0)
175  { G4cout << "(" << pp->GetG4code()->GetParticleName() << ")"; }
176  else
177  { G4cout << "is not defined in G4"; }
178  G4cout << " " << pp->GetMomentum()/GeV << " [GeV] ";
179  if(pp->GetTrackID()<0)
180  { G4cout << G4endl; }
181  else
182  { G4cout << ">>> G4Track ID " << pp->GetTrackID() << G4endl; }
183 
184  G4PrimaryParticle* daughter = pp->GetDaughter();
185  while(daughter)
186  {
187  PrintPrimary(daughter,ind+1);
188  daughter = daughter->GetNext();
189  }
190 }
191 
192 
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
Definition of the RE01EventAction class.
G4ThreeVector GetMomentum() const
G4PrimaryParticle * GetPrimary(G4int i=0) const
Definition of the RE01Trajectory class.
CLHEP::Hep3Vector G4ThreeVector
virtual void EndOfEventAction(const G4Event *)
G4int GetEventID() const
Definition: G4Event.hh:151
G4double GetY0() const
#define G4endl
Definition: G4ios.hh:61
void PrintPrimary(G4PrimaryParticle *pp, G4int ind)
Definition of the RE01TrackerHit class.
G4int GetTrackID() const
const G4String & GetParticleName() const
G4double GetX0() const
virtual void BeginOfEventAction(const G4Event *)
G4PrimaryParticle * GetDaughter() const
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
virtual void ShowTrajectory(std::ostream &os=G4cout) const
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:167
G4int GetVerboseLevel()
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetG4code() const
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:189
G4int GetPDGcode() const
G4EventManager * fpEventManager
G4PrimaryParticle * GetNext() const
G4double GetT0() const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
G4int GetNumberOfPrimaryVertex() const
Definition: G4Event.hh:164
G4double GetZ0() const
G4GLOB_DLL std::ostream G4cout
Definition of the RE01CalorimeterHit class.
static constexpr double GeV
Definition: G4SIunits.hh:217
#define ns
Definition: xmlparse.cc:614
virtual ~RE01EventAction()