Geant4  10.02.p01
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 //
26 
27 #include "ExExChEventAction.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 
44 
45 #include "ExExChTrackingAction.hh"
46 #include "ExExChAnalysis.hh"
47 
49 {
50  fSD_ID = -1;
51  fVerboseLevel = 0;
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65 
67 {
69 
70  if(fSD_ID == -1) {
71  G4String sdName;
72  if(SDman->FindSensitiveDetector(sdName="telescope",0)){
73  fSD_ID = SDman->GetCollectionID(sdName="telescope/collection");
74  }
75  }
76 
78 
79  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
80 
81  if(HCE)
82  {
83  if(fSD_ID != -1){
84  G4VHitsCollection* aHCSD = HCE->GetHC(fSD_ID);
86  }
87  }
88 
89  G4ThreeVector SSDposition[3];
90  SSDposition[0]= G4ThreeVector(0.,0.,0.);
91  SSDposition[1]= G4ThreeVector(0.,0.,0.);
92  SSDposition[2]= G4ThreeVector(0.,0.,0.);
93 
94  if(fSD)
95  {
96  int bTotalHits = 0;
97 
98  int n_hit_sd = fSD->entries();
99  for(int i2=0;i2<3;i2++){
100  for(int i1=0;i1<n_hit_sd;i1++)
101  {
102  ExExChSensitiveDetectorHit* aHit = (*fSD)[i1];
103  if(aHit->GetLayerID()==i2) {
104  SSDposition[i2] = aHit->GetWorldPos();
105  bTotalHits++;
106  }
107  }
108  }
109 
110  if(bTotalHits == 3){
111  double fAngXin = (SSDposition[1].x() - SSDposition[0].x());
112  fAngXin /= (SSDposition[1].z() - SSDposition[0].z());
113  double fAngYin = (SSDposition[1].y() - SSDposition[0].y());
114  fAngYin /= (SSDposition[1].z() - SSDposition[0].z());
115  double fPosXin = SSDposition[1].x();
116  double fPosYin = SSDposition[1].y();
117  double fAngXout = (SSDposition[2].x() - SSDposition[1].x());
118  fAngXout /= (SSDposition[2].z() - SSDposition[1].z());
119  double fAngYout = (SSDposition[2].y() - SSDposition[1].y());
120  fAngYout /= (SSDposition[2].z() - SSDposition[1].z());
121 
122  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
123 
124  analysisManager->FillNtupleDColumn(0, fAngXin * 1.E6 * CLHEP::rad);
125  analysisManager->FillNtupleDColumn(1, fAngYin * 1.E6 * CLHEP::rad);
126  analysisManager->FillNtupleDColumn(2, fPosXin / CLHEP::mm);
127  analysisManager->FillNtupleDColumn(3, fPosYin / CLHEP::mm);
128  analysisManager->FillNtupleDColumn(4, fAngXout * 1.E6 * CLHEP::rad);
129  analysisManager->FillNtupleDColumn(5, fAngYout * 1.E6 * CLHEP::rad);
130  analysisManager->AddNtupleRow();
131  }
132  }
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
CLHEP::Hep3Vector G4ThreeVector
virtual ~ExExChEventAction()
G4int entries() const
G4bool FillNtupleDColumn(G4int id, G4double value)
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:124
static const double rad
Definition: G4SIunits.hh:148
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual void EndOfEventAction(const G4Event *)
virtual void BeginOfEventAction(const G4Event *)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
static const double mm
Definition: G4SIunits.hh:114