Back to home page

EIC code displayed by LXR

 
 

    


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

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