Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:46

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 scavenger/src/PrimaryKiller.cc
0027 /// \brief Implementation of the scavenger::PrimaryKiller class
0028 
0029 #include "PrimaryKiller.hh"
0030 
0031 #include "G4Event.hh"
0032 #include "G4RunManager.hh"
0033 #include "G4UIcmdWith3VectorAndUnit.hh"
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UnitsTable.hh"
0036 
0037 namespace scavenger
0038 {
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0041 
0042 PrimaryKiller::PrimaryKiller(const G4String& name, const G4int& depth)
0043   : G4VPrimitiveScorer(name, depth),
0044     G4UImessenger(),
0045     fpELossUI(new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMin", this)),
0046     fpAbortEventIfELossUpperThan(new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMax", this)),
0047     fpMinKineticE(new G4UIcmdWithADoubleAndUnit("/primaryKiller/minKineticE", this)),
0048     fpSizeUI(new G4UIcmdWith3VectorAndUnit("/primaryKiller/setSize", this))
0049 {
0050   fpSizeUI->SetDefaultUnit("um");
0051 }
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0054 
0055 void PrimaryKiller::SetNewValue(G4UIcommand* command, G4String newValue)
0056 {
0057   if (command == fpELossUI.get()) {
0058     fELossRange_Min = fpELossUI->GetNewDoubleValue(newValue);
0059   }
0060   else if (command == fpAbortEventIfELossUpperThan.get()) {
0061     fELossRange_Max = fpAbortEventIfELossUpperThan->GetNewDoubleValue(newValue);
0062   }
0063   else if (command == fpSizeUI.get()) {
0064     fPhantomSize = fpSizeUI->GetNew3VectorValue(newValue);
0065   }
0066 }
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0069 
0070 G4bool PrimaryKiller::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0071 {
0072   const G4Track* track = aStep->GetTrack();
0073   G4ThreeVector pos = aStep->GetPostStepPoint()->GetPosition();
0074   if (std::abs(pos.x()) > fPhantomSize.getX() / 2 || std::abs(pos.y()) > fPhantomSize.getY() / 2
0075       || std::abs(pos.z()) > fPhantomSize.getZ() / 2)
0076   {
0077     ((G4Track*)track)->SetTrackStatus(fStopAndKill);
0078     return false;
0079   }
0080   if (track->GetTrackID() != 1) {
0081     return FALSE;
0082   }
0083   G4double kineticE = aStep->GetPostStepPoint()->GetKineticEnergy();
0084   G4double eLoss = aStep->GetPreStepPoint()->GetKineticEnergy() - kineticE;
0085   if (eLoss == 0.) {
0086     return FALSE;
0087   }
0088   fELoss += eLoss;
0089   if (fELoss > fELossRange_Max) {
0090     G4RunManager::GetRunManager()->AbortEvent();
0091   }
0092   if (fELoss >= fELossRange_Min || kineticE <= fKineticE_Min) {
0093     ((G4Track*)track)->SetTrackStatus(fStopAndKill);
0094   }
0095   return TRUE;
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0099 
0100 void PrimaryKiller::Initialize(G4HCofThisEvent* /*HCE*/)
0101 {
0102   fELoss = 0.;
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0106 
0107 }  // namespace scavenger