Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:30:38

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