Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-05 07:50:35

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 "DetectorConstruction.hh"
0032 #include "HistoManager.hh"
0033 #include "Run.hh"
0034 #include "TrackingAction.hh"
0035 
0036 #include "G4Gamma.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SteppingManager.hh"
0039 #include "G4UnitsTable.hh"
0040 
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0042 
0043 SteppingAction::SteppingAction(DetectorConstruction* det, TrackingAction* TrAct)
0044   : fDetector(det), fTrackAction(TrAct), fWall(0), fCavity(0)
0045 {
0046   first = true;
0047   fTrackSegm = 0.;
0048   fDirectionIn = G4ThreeVector(0., 0., 0.);
0049 }
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 SteppingAction::~SteppingAction() {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 void SteppingAction::UserSteppingAction(const G4Step* step)
0058 {
0059   // get fDetector pointers
0060   if (first) {
0061     fWall = fDetector->GetWall();
0062     fCavity = fDetector->GetCavity();
0063     first = false;
0064   }
0065 
0066   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0067 
0068   // histograms
0069   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0070 
0071   // get volume
0072   //
0073   G4StepPoint* point1 = step->GetPreStepPoint();
0074   G4VPhysicalVolume* volume = point1->GetTouchableHandle()->GetVolume();
0075 
0076   // count processes
0077   //
0078   G4StepPoint* point2 = step->GetPostStepPoint();
0079   const G4VProcess* process = point2->GetProcessDefinedStep();
0080   if (process) run->CountProcesses(process->GetProcessName());
0081 
0082   // energy deposit in fCavity
0083   //
0084   if (volume == fCavity) {
0085     G4double edep = step->GetTotalEnergyDeposit();
0086     if (edep > 0.) fTrackAction->AddEdepCavity(edep);
0087   }
0088 
0089   // keep only charged particles
0090   //
0091   if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
0092 
0093   // step size of charged particles
0094   //
0095   G4int id;
0096   G4double steplen = step->GetStepLength();
0097   if (volume == fWall) {
0098     run->StepInWall(steplen);
0099     id = 9;
0100   }
0101   else {
0102     run->StepInCavity(steplen);
0103     id = 10;
0104   }
0105   analysisManager->FillH1(id, steplen);
0106 
0107   // last step before hitting the fCavity
0108   //
0109   if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) {
0110     fDirectionIn = point1->GetMomentumDirection();
0111   }
0112 
0113   // keep only charged particles within fCavity
0114   //
0115   if (volume == fWall) return;
0116 
0117   G4double ekin1 = point1->GetKineticEnergy();
0118   G4double ekin2 = point2->GetKineticEnergy();
0119 
0120   // first step in cavity
0121   //
0122   if (point1->GetStepStatus() == fGeomBoundary) {
0123     fTrackSegm = 0.;
0124     G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
0125     analysisManager->FillH1(4, vertex.z());
0126     run->FlowInCavity(0, ekin1);
0127     analysisManager->FillH1(5, ekin1);
0128     if (steplen > 0.) {
0129       G4ThreeVector directionOut = (point2->GetPosition() - point1->GetPosition()).unit();
0130       G4ThreeVector normal =
0131         point1->GetTouchableHandle()->GetSolid()->SurfaceNormal(point1->GetPosition());
0132       analysisManager->FillH1(6, std::acos(-fDirectionIn * normal));
0133       analysisManager->FillH1(7, std::acos(-directionOut * normal));
0134     }
0135   }
0136 
0137   // within cavity
0138   //
0139   if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.;
0140   fTrackSegm += steplen;
0141   if (ekin2 <= 0.) {
0142     run->AddTrakCavity(fTrackSegm);
0143     analysisManager->FillH1(8, fTrackSegm);
0144   }
0145 
0146   // exit cavity
0147   //
0148   if (point2->GetStepStatus() == fGeomBoundary) {
0149     run->FlowInCavity(1, ekin2);
0150     run->AddTrakCavity(fTrackSegm);
0151     analysisManager->FillH1(8, fTrackSegm);
0152   }
0153 }
0154 
0155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......