Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22: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 #ifdef USE_INFERENCE
0027 #  include "Par04MLFastSimModel.hh"
0028 
0029 #  include "Par04InferenceSetup.hh"  // for Par04InferenceSetup
0030 
0031 #  include "G4Electron.hh"  // for G4Electron
0032 #  include "G4FastHit.hh"  // for G4FastHit
0033 #  include "G4FastSimHitMaker.hh"  // for G4FastSimHitMaker
0034 #  include "G4Gamma.hh"  // for G4Gamma
0035 #  include "G4Positron.hh"  // for G4Positron
0036 
0037 #  include <G4FastStep.hh>  // for G4FastStep
0038 #  include <G4FastTrack.hh>  // for G4FastTrack
0039 #  include <G4Track.hh>  // for G4Track
0040 #  include <G4VFastSimulationModel.hh>  // for G4VFastSimulationModel
0041 #  include <stddef.h>  // for size_t
0042 class G4ParticleDefinition;
0043 class G4Region;
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName, G4Region* aEnvelope)
0048   : G4VFastSimulationModel(aModelName, aEnvelope),
0049     fInference(new Par04InferenceSetup),
0050     fHitMaker(new G4FastSimHitMaker),
0051     fParallelHitMaker(new G4FastSimHitMaker)
0052 {
0053   fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName)
0059   : G4VFastSimulationModel(aModelName),
0060     fInference(new Par04InferenceSetup),
0061     fHitMaker(new G4FastSimHitMaker),
0062     fParallelHitMaker(new G4FastSimHitMaker)
0063 {
0064   fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 Par04MLFastSimModel::~Par04MLFastSimModel() {}
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 G4bool Par04MLFastSimModel::IsApplicable(const G4ParticleDefinition& aParticleType)
0074 {
0075   return &aParticleType == G4Electron::ElectronDefinition()
0076          || &aParticleType == G4Positron::PositronDefinition()
0077          || &aParticleType == G4Gamma::GammaDefinition();
0078 }
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 
0082 G4bool Par04MLFastSimModel::ModelTrigger(const G4FastTrack& aFastTrack)
0083 {
0084   return fInference->IfTrigger(aFastTrack.GetPrimaryTrack()->GetKineticEnergy());
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 void Par04MLFastSimModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0090 {
0091   // remove particle from further processing by G4
0092   aFastStep.KillPrimaryTrack();
0093   aFastStep.SetPrimaryTrackPathLength(0.0);
0094   G4double energy = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
0095   aFastStep.SetTotalEnergyDeposited(energy);
0096   G4ThreeVector position = aFastTrack.GetPrimaryTrack()->GetPosition();
0097   G4ThreeVector direction = aFastTrack.GetPrimaryTrack()->GetMomentumDirection();
0098 
0099   // calculate the incident angle
0100   G4float angle = direction.theta();
0101 
0102   // calculate how to deposit energy within the detector
0103   // get it from inference model
0104   fInference->GetEnergies(fEnergies, energy, angle);
0105   fInference->GetPositions(fPositions, position, direction);
0106 
0107   // deposit energy in the detector using calculated values of energy deposits
0108   // and positions
0109   for (size_t iHit = 0; iHit < fPositions.size(); iHit++) {
0110     if (fEnergies[iHit] > 0.0005) {
0111       // Place hit in the physical readout of the detector
0112       fParallelHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0113       // Place hit in the virtual grid, for validation purposes
0114       fHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0115     }
0116   }
0117 }
0118 #endif