Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:30:54

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 "HistoManager.hh"
0032 #include "Run.hh"
0033 
0034 #include "G4RunManager.hh"
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0039 {
0040   const G4StepPoint* endPoint = aStep->GetPostStepPoint();
0041   G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
0042 
0043   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0044 
0045   G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary);
0046   if (transmit) {
0047     run->CountProcesses(procName);
0048   }
0049   else {
0050     // count real processes and sum track length
0051     G4double stepLength = aStep->GetStepLength();
0052     run->CountProcesses(procName);
0053     run->SumTrack(stepLength);
0054   }
0055 
0056   // plot final state
0057   //
0058   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0059 
0060   // scattered primary particle
0061   //
0062   G4int id = 1;
0063   if (aStep->GetTrack()->GetTrackStatus() == fAlive) {
0064     G4double energy = endPoint->GetKineticEnergy();
0065     analysisManager->FillH1(id, energy);
0066 
0067     id = 2;
0068     G4ThreeVector direction = endPoint->GetMomentumDirection();
0069     G4double costeta = direction.x();
0070     analysisManager->FillH1(id, costeta);
0071   }
0072 
0073   // secondaries
0074   //
0075   const std::vector<const G4Track*>* secondary = aStep->GetSecondaryInCurrentStep();
0076   for (size_t lp = 0; lp < (*secondary).size(); lp++) {
0077     G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge();
0078     if (charge != 0.) {
0079       id = 3;
0080     }
0081     else {
0082       id = 5;
0083     }
0084     G4double energy = (*secondary)[lp]->GetKineticEnergy();
0085     analysisManager->FillH1(id, energy);
0086 
0087     ++id;
0088     G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection();
0089     G4double costeta = direction.x();
0090     analysisManager->FillH1(id, costeta);
0091 
0092     // energy tranferred to charged secondaries
0093     if (charge != 0.) {
0094       run->SumeTransf(energy);
0095     }
0096   }
0097 
0098   // kill event after first interaction
0099   //
0100   G4RunManager::GetRunManager()->AbortEvent();
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......