Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExExChEventAction.cc
Go to the documentation of this file.
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 
30 #include "ExExChEventAction.hh"
31 
32 #include "G4RunManager.hh"
33 
34 #include "G4Event.hh"
35 #include "G4EventManager.hh"
36 #include "G4HCofThisEvent.hh"
37 #include "G4VHitsCollection.hh"
38 #include "G4TrajectoryContainer.hh"
39 #include "G4Trajectory.hh"
40 #include "G4VVisManager.hh"
41 #include "G4SDManager.hh"
42 #include "G4UImanager.hh"
43 #include "G4ios.hh"
44 #include "G4SystemOfUnits.hh"
45 
47 
48 #include "ExExChTrackingAction.hh"
49 #include "ExExChAnalysis.hh"
50 
52 {
53  fSD_ID = -1;
54  fVerboseLevel = 0;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58 
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
63 
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
68 
70 {
72 
73  if(fSD_ID == -1) {
74  G4String sdName;
75  if(SDman->FindSensitiveDetector(sdName="telescope",0)){
76  fSD_ID = SDman->GetCollectionID(sdName="telescope/collection");
77  }
78  }
79 
81 
82  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
83 
84  if(HCE)
85  {
86  if(fSD_ID != -1){
87  G4VHitsCollection* aHCSD = HCE->GetHC(fSD_ID);
89  }
90  }
91 
92  G4ThreeVector SSDposition[3];
93  SSDposition[0]= G4ThreeVector(0.,0.,0.);
94  SSDposition[1]= G4ThreeVector(0.,0.,0.);
95  SSDposition[2]= G4ThreeVector(0.,0.,0.);
96 
97  if(fSD)
98  {
99  int bTotalHits = 0;
100 
101  int n_hit_sd = fSD->entries();
102  for(int i2=0;i2<3;i2++){
103  for(int i1=0;i1<n_hit_sd;i1++)
104  {
105  ExExChSensitiveDetectorHit* aHit = (*fSD)[i1];
106  if(aHit->GetLayerID()==i2) {
107  SSDposition[i2] = aHit->GetWorldPos();
108  bTotalHits++;
109  }
110  }
111  }
112 
113  if(bTotalHits == 3){
114  double fAngXin = (SSDposition[1].x() - SSDposition[0].x());
115  fAngXin /= (SSDposition[1].z() - SSDposition[0].z());
116  double fAngYin = (SSDposition[1].y() - SSDposition[0].y());
117  fAngYin /= (SSDposition[1].z() - SSDposition[0].z());
118  double fPosXin = SSDposition[1].x();
119  double fPosYin = SSDposition[1].y();
120  double fAngXout = (SSDposition[2].x() - SSDposition[1].x());
121  fAngXout /= (SSDposition[2].z() - SSDposition[1].z());
122  double fAngYout = (SSDposition[2].y() - SSDposition[1].y());
123  fAngYout /= (SSDposition[2].z() - SSDposition[1].z());
124 
125  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
126 
127  analysisManager->FillNtupleDColumn(0, fAngXin * 1.E6 * CLHEP::rad);
128  analysisManager->FillNtupleDColumn(1, fAngYin * 1.E6 * CLHEP::rad);
129  analysisManager->FillNtupleDColumn(2, fPosXin / CLHEP::mm);
130  analysisManager->FillNtupleDColumn(3, fPosYin / CLHEP::mm);
131  analysisManager->FillNtupleDColumn(4, fAngXout * 1.E6 * CLHEP::rad);
132  analysisManager->FillNtupleDColumn(5, fAngYout * 1.E6 * CLHEP::rad);
133  analysisManager->AddNtupleRow();
134  }
135  }
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
CLHEP::Hep3Vector G4ThreeVector
virtual ~ExExChEventAction()
double x() const
static constexpr double rad
G4int entries() const
Definition of the ExExChSensitiveDetectorHit class.
double z() const
Definition of the ExExChAnalysis class.
G4bool FillNtupleDColumn(G4int id, G4double value)
static constexpr double mm
Definition: SystemOfUnits.h:95
Definition of the ExExChTrackingAction class.
Definition of the ExExChEventAction class.
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:128
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
double y() const
virtual void EndOfEventAction(const G4Event *)
virtual void BeginOfEventAction(const G4Event *)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185