Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:51:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file ScreenSD.cc
0027 /// \brief Implementation of the ScreenSD class
0028 
0029 #include "ScreenSD.hh"
0030 
0031 #include "G4AnalysisManager.hh"
0032 #include "G4Step.hh"
0033 #include "G4SystemOfUnits.hh"
0034 #include "G4VProcess.hh"
0035 #include "G4VTouchable.hh"
0036 #include "G4ios.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 ScreenSD::ScreenSD(const G4String& name) : G4VSensitiveDetector(name) {}
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 void ScreenSD::Initialize(G4HCofThisEvent* /*hce*/) {}
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 G4bool ScreenSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
0049 {
0050   // Current track:
0051   const G4Track* track = step->GetTrack();
0052 
0053   // Track ID:
0054   G4int ID = track->GetTrackID();
0055 
0056   // code PDG:
0057   G4int pdgCode = track->GetDefinition()->GetPDGEncoding();
0058 
0059   // Remember preStepPoint:
0060   G4StepPoint* preStepPoint = step->GetPreStepPoint();
0061 
0062   // Ekin:
0063   G4double Ekin = preStepPoint->GetKineticEnergy();
0064 
0065   // Obtain local coordinates:
0066   const G4VTouchable* touchable = preStepPoint->GetTouchable();
0067   G4ThreeVector globalPosition = preStepPoint->GetPosition();
0068   G4ThreeVector localPosition =
0069     touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
0070   // // Example for obtaining the local direction:
0071   // G4ThreeVector globalDirection = preStepPoint->GetMomentumDirection();
0072   // G4ThreeVector localDirection
0073   //   = touchable->GetHistory()->GetTopTransform().TransformAxis(localDirection);
0074 
0075   // Time
0076   G4double time = preStepPoint->GetGlobalTime();
0077 
0078   // Store hit in the ntuple
0079   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0080   analysisManager->FillNtupleIColumn(0, ID);
0081   analysisManager->FillNtupleIColumn(1, pdgCode);
0082   analysisManager->FillNtupleDColumn(2, Ekin / MeV);
0083   analysisManager->FillNtupleDColumn(3, localPosition.x() / cm);
0084   analysisManager->FillNtupleDColumn(4, localPosition.y() / cm);
0085   analysisManager->FillNtupleDColumn(5, time / ns);
0086   analysisManager->AddNtupleRow();
0087 
0088   return true;
0089 }
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 
0093 void ScreenSD::EndOfEvent(G4HCofThisEvent* /*hce*/) {}
0094 
0095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......