Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:53

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