Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/exoticphysics/channeling/src/EventAction.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 
27 #include "EventAction.hh"
28 
29 #include "G4RunManager.hh"
30 
31 #include "G4Event.hh"
32 #include "G4EventManager.hh"
33 #include "G4HCofThisEvent.hh"
34 #include "G4VHitsCollection.hh"
35 #include "G4TrajectoryContainer.hh"
36 #include "G4Trajectory.hh"
37 #include "G4VVisManager.hh"
38 #include "G4SDManager.hh"
39 #include "G4UImanager.hh"
40 #include "G4ios.hh"
41 #include "G4SystemOfUnits.hh"
42 
43 #include "SensitiveDetectorHit.hh"
44 
45 #include "Analysis.hh"
46 
48 fSDHT_ID(-1){}
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
60 void EventAction::EndOfEventAction(const G4Event* evt){
62 
63  G4ThreeVector ssd[3];
64  ssd[0]= G4ThreeVector(0.,0.,0.);
65  ssd[1]= G4ThreeVector(0.,0.,0.);
66  ssd[2]= G4ThreeVector(0.,0.,0.);
67 
68  if(fSDHT_ID == -1) {
69  G4String sdName;
70  if(SDman->FindSensitiveDetector(sdName="telescope",0)){
71  fSDHT_ID = SDman->GetCollectionID(sdName="telescope/collection");
72  }
73  }
74 
76  G4HCofThisEvent *hce = evt->GetHCofThisEvent();
77 
78  if(hce){
79  if(fSDHT_ID != -1){
80  G4VHitsCollection* aHCSD = hce->GetHC(fSDHT_ID);
81  sdht = (SensitiveDetectorHitsCollection*)(aHCSD);
82  }
83  }
84 
85  int bTotalHits = 0;
86  if(sdht){
87 
88  int n_hit_sd = sdht->entries();
89  for(int i2=0;i2<3;i2++){
90  for(int i1=0;i1<n_hit_sd;i1++)
91  {
92  SensitiveDetectorHit* aHit = (*sdht)[i1];
93  if(aHit->GetLayerID()==i2) {
94  ssd[i2] = aHit->GetWorldPos();
95  bTotalHits++;
96  }
97  }
98  }
99  }
100 
101  if(bTotalHits > 2){
102  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
103  G4double angXin = (ssd[1].x() - ssd[0].x()) / (ssd[1].z() - ssd[0].z());
104  G4double angYin = (ssd[1].y() - ssd[0].y()) / (ssd[1].z() - ssd[0].z());
105 
106  analysisManager->FillNtupleDColumn(0, angXin * 1.E6 * CLHEP::rad);
107  analysisManager->FillNtupleDColumn(1, angYin * 1.E6 * CLHEP::rad);
108 
109  double posXin = ssd[1].x() - angXin * ssd[1].z();
110  double posYin = ssd[1].y() - angYin * ssd[1].z();
111 
112  analysisManager->FillNtupleDColumn(2, posXin / CLHEP::mm);
113  analysisManager->FillNtupleDColumn(3, posYin / CLHEP::mm);
114 
115  G4double angXout = (ssd[2].x() - posXin) / (ssd[2].z());
116  G4double angYout = (ssd[2].y() - posYin) / (ssd[2].z());
117  analysisManager->FillNtupleDColumn(4, angXout * 1.E6 * CLHEP::rad);
118  analysisManager->FillNtupleDColumn(5, angYout * 1.E6 * CLHEP::rad);
119 
120  analysisManager->AddNtupleRow();
121  }
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
void EndOfEventAction(const G4Event *)
CLHEP::Hep3Vector G4ThreeVector
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:128
Double_t z
void BeginOfEventAction(const G4Event *)
double z() const
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static constexpr double mm
Definition: SystemOfUnits.h:95
double x() const
double y() const
static constexpr double rad