Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 08:29:30

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 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // and the DNA geometry given in the Geom_DNA example
0032 // shall cite the following Geant4-DNA collaboration publications:
0033 // [1] NIM B 298 (2013) 47-54
0034 // [2] Med. Phys. 37 (2010) 4692-4708
0035 // The Geant4-DNA web site is available at http://geant4-dna.org
0036 //
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0038 
0039 #include "SteppingAction.hh"
0040 
0041 // G4
0042 #include "CommandLineParser.hh"
0043 
0044 #include "G4AnalysisManager.hh"
0045 
0046 #include <G4SystemOfUnits.hh>
0047 #include <G4Track.hh>
0048 #include <G4VProcess.hh>
0049 #include <globals.hh>
0050 
0051 using namespace G4DNAPARSER;
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0054 
0055 SteppingAction::SteppingAction() : G4UserSteppingAction() {}
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 SteppingAction::~SteppingAction() {}
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void SteppingAction::UserSteppingAction(const G4Step* step)
0064 {
0065   G4double flagParticle = 0.;
0066   G4double flagProcess = 0.;
0067   G4double flagVolume = 0.;
0068   G4double x, y, z, xp, yp, zp;
0069   G4double dE;
0070 
0071   dE = step->GetTotalEnergyDeposit() / eV;
0072 
0073   const G4String& particleName =
0074     step->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName();
0075 
0076   const G4String& processName = step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
0077 
0078   const G4String& volumeName = step->GetPreStepPoint()->GetPhysicalVolume()->GetName();
0079 
0080   if (particleName == "e-")
0081     flagParticle = 10;
0082   else if (particleName == "proton")
0083     flagParticle = 20;
0084   else if (particleName == "hydrogen")
0085     flagParticle = 30;
0086   else if (particleName == "alpha")
0087     flagParticle = 40;
0088   else if (particleName == "alpha+")
0089     flagParticle = 50;
0090   else if (particleName == "helium")
0091     flagParticle = 60;
0092 
0093   if (processName == "e-_G4DNAElastic")
0094     flagProcess = 11;
0095   else if (processName == "e-_G4DNAExcitation")
0096     flagProcess = 12;
0097   else if (processName == "e-_G4DNAIonisation")
0098     flagProcess = 13;
0099   else if (processName == "e-_G4DNAAttachment")
0100     flagProcess = 14;
0101   else if (processName == "e-_G4DNAVibExcitation")
0102     flagProcess = 15;
0103   else if (processName == "eCapture")
0104     flagProcess = 16;
0105   //  if (step->GetPostStepPoint()->GetProcessDefinedStep()
0106   // ->GetProcessName()=="msc")        flagProcess =17;
0107 
0108   else if (processName == "proton_G4DNAExcitation")
0109     flagProcess = 21;
0110   else if (processName == "proton_G4DNAIonisation")
0111     flagProcess = 22;
0112   else if (processName == "proton_G4DNAChargeDecrease")
0113     flagProcess = 23;
0114 
0115   else if (processName == "hydrogen_G4DNAExcitation")
0116     flagProcess = 31;
0117   else if (processName == "hydrogen_G4DNAIonisation")
0118     flagProcess = 32;
0119   else if (processName == "hydrogen_G4DNAChargeIncrease")
0120     flagProcess = 33;
0121 
0122   else if (processName == "alpha_G4DNAExcitation")
0123     flagProcess = 41;
0124   else if (processName == "alpha_G4DNAIonisation")
0125     flagProcess = 42;
0126   else if (processName == "alpha_G4DNAChargeDecrease")
0127     flagProcess = 43;
0128 
0129   else if (processName == "alpha+_G4DNAExcitation")
0130     flagProcess = 51;
0131   else if (processName == "alpha+_G4DNAIonisation")
0132     flagProcess = 52;
0133   else if (processName == "alpha+_G4DNAChargeDecrease")
0134     flagProcess = 53;
0135   else if (processName == "alpha+_G4DNAChargeIncrease")
0136     flagProcess = 54;
0137 
0138   else if (processName == "helium_G4DNAExcitation")
0139     flagProcess = 61;
0140   else if (processName == "helium_G4DNAIonisation")
0141     flagProcess = 62;
0142   else if (processName == "helium_G4DNAChargeIncrease")
0143     flagProcess = 63;
0144 
0145   // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
0146   //  GetProcessName()=="hIoni")        flagProcess =24;
0147   // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
0148   //  GetProcessName()=="eIoni")        flagProcess =18;
0149 
0150   if (volumeName == "physi sugar 2")
0151     flagVolume = 1;
0152   else if (volumeName == "physi sugar 4")
0153     flagVolume = 2;
0154 
0155   if (flagVolume != 0 && dE != 0) {
0156     x = step->GetPreStepPoint()->GetPosition().x() / nanometer;
0157     y = step->GetPreStepPoint()->GetPosition().y() / nanometer;
0158     z = step->GetPreStepPoint()->GetPosition().z() / nanometer;
0159     xp = step->GetPostStepPoint()->GetPosition().x() / nanometer;
0160     yp = step->GetPostStepPoint()->GetPosition().y() / nanometer;
0161     zp = step->GetPostStepPoint()->GetPosition().z() / nanometer;
0162 
0163     // The lines below could be put upper to gain time in the simulation
0164     // Added here for testing that all the retrieve information are
0165     // correctly working
0166     CommandLineParser* parser = CommandLineParser::GetParser();
0167     Command* command(0);
0168     if ((command = parser->GetCommandIfActive("-out")) == 0) return;
0169 
0170     // get analysis manager
0171     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0172 
0173     analysisManager->FillNtupleDColumn(0, flagParticle);
0174     analysisManager->FillNtupleDColumn(1, flagProcess);
0175     analysisManager->FillNtupleDColumn(2, flagVolume);
0176     analysisManager->FillNtupleDColumn(3, xp);
0177     analysisManager->FillNtupleDColumn(4, yp);
0178     analysisManager->FillNtupleDColumn(5, zp);
0179     analysisManager->FillNtupleDColumn(6, dE);
0180     analysisManager->FillNtupleDColumn(
0181       7, std::sqrt((x - xp) * (x - xp) + (y - yp) * (y - yp) + (z - zp) * (z - zp)));
0182 
0183     analysisManager->AddNtupleRow();
0184   }
0185 }