Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-31 07:50:56

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 SteppingAction.cc
0027 /// \brief Implementation of the SteppingAction class
0028 
0029 #include "SteppingAction.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 #include "EventAction.hh"
0033 #include "Run.hh"
0034 
0035 #include "G4PhysicalConstants.hh"
0036 #include "G4Positron.hh"
0037 #include "G4RunManager.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
0042   : G4UserSteppingAction(), fDetector(det), fEventAct(evt)
0043 {}
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0048 {
0049   // track informations
0050   const G4StepPoint* prePoint = aStep->GetPreStepPoint();
0051 
0052   // if World, return
0053   //
0054   G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
0055   // if sum of absorbers do not fill exactly a layer: check material, not
0056   // volume.
0057   const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
0058   if (mat == fDetector->GetWorldMaterial()) return;
0059 
0060   const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
0061 
0062   // here we are in an absorber. Locate it
0063   //
0064   G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
0065   // G4int layerNum  = prePoint->GetTouchableHandle()->GetCopyNumber(1);
0066 
0067   // get Run
0068   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0069 
0070   // collect energy deposit taking into account track weight
0071   G4double edep = aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
0072 
0073   // collect step length of charged particles
0074   G4double stepl = 0.;
0075   if (particle->GetPDGCharge() != 0.) {
0076     stepl = aStep->GetStepLength();
0077     run->AddChargedStep();
0078   }
0079   else {
0080     run->AddNeutralStep();
0081   }
0082 
0083   // sum up per event
0084   fEventAct->SumEnergy(absorNum, edep, stepl);
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......