ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScreenSD.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ScreenSD.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 //
29 //
30 
31 #include "ScreenSD.hh"
32 #include "Analysis.hh"
33 
34 #include "G4VTouchable.hh"
35 #include "G4Step.hh"
36 #include "G4ios.hh"
37 #include "G4SystemOfUnits.hh"
38 
39 #include "G4VProcess.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  : G4VSensitiveDetector(name)
45 {}
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 {}
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {}
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  // Current track:
62  const G4Track* track = step->GetTrack();
63 
64  // Track ID:
65  G4int ID = track->GetTrackID();
66 
67  // code PDG:
68  G4int pdgCode = track->GetDefinition()->GetPDGEncoding();
69 
70  // Remember preStepPoint:
71  G4StepPoint* preStepPoint = step->GetPreStepPoint();
72 
73  // Ekin:
74  G4double Ekin = preStepPoint->GetKineticEnergy();
75 
76  // Obtain local coordinates:
77  const G4VTouchable* touchable = preStepPoint->GetTouchable();
78  G4ThreeVector globalPosition = preStepPoint->GetPosition();
79  G4ThreeVector localPosition
80  = touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
81  // // Example for obtaining the local direction:
82  // G4ThreeVector globalDirection = preStepPoint->GetMomentumDirection();
83  // G4ThreeVector localDirection
84  // = touchable->GetHistory()->GetTopTransform().TransformAxis(localDirection);
85 
86  // Time
87  G4double time = preStepPoint->GetGlobalTime();
88 
89  // Store hit in the ntuple
91  analysisManager->FillNtupleIColumn(0, ID);
92  analysisManager->FillNtupleIColumn(1, pdgCode);
93  analysisManager->FillNtupleDColumn(2, Ekin/MeV);
94  analysisManager->FillNtupleDColumn(3, localPosition.x()/cm);
95  analysisManager->FillNtupleDColumn(4, localPosition.y()/cm);
96  analysisManager->FillNtupleDColumn(5, time/ns);
97  analysisManager->AddNtupleRow();
98 
99  return true;
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103 
105 {}
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......