Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:47

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