Back to home page

EIC code displayed by LXR

 
 

    


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

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