Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:29:10

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 XPhononStackingAction.cc
0027 /// \brief Implementation of the XPhononStackingAction class
0028 
0029 ///     This stacking action is necessary to ensure that velocity and
0030 ///     propagation direction are set properly for phonons created with
0031 ///     G4ParticleGun
0032 //
0033 //
0034 
0035 #include "XPhononStackingAction.hh"
0036 
0037 #include "G4LatticeManager.hh"
0038 #include "G4PhononLong.hh"
0039 #include "G4PhononPolarization.hh"
0040 #include "G4PhononTrackMap.hh"
0041 #include "G4PhononTransFast.hh"
0042 #include "G4PhononTransSlow.hh"
0043 #include "G4RandomDirection.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4ThreeVector.hh"
0046 #include "G4Track.hh"
0047 #include "G4TrackStatus.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0050 
0051 XPhononStackingAction::XPhononStackingAction()
0052 {
0053   ;
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0057 
0058 XPhononStackingAction::~XPhononStackingAction()
0059 {
0060   ;
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0064 
0065 G4ClassificationOfNewTrack XPhononStackingAction::ClassifyNewTrack(const G4Track* aTrack)
0066 {
0067   G4ClassificationOfNewTrack classification = fUrgent;
0068 
0069   if (aTrack->GetParentID() == 0) {
0070     // Obtain LatticeManager for phonon dynamics
0071     G4LatticeManager* LM = G4LatticeManager::GetLatticeManager();
0072 
0073     G4int pol = G4PhononPolarization::Get(aTrack->GetDefinition());
0074 
0075     // Compute random wave-vector (override whatever ParticleGun did)
0076     G4ThreeVector Ran = G4RandomDirection();
0077 
0078     // Store wave-vector as track information
0079     G4PhononTrackMap* theKmap = G4PhononTrackMap::GetPhononTrackMap();
0080     theKmap->SetK(aTrack, Ran);
0081 
0082     // Compute direction of propagation from wave vector
0083     G4ThreeVector momentumDir = LM->MapKtoVDir(aTrack->GetVolume(), pol, Ran);
0084 
0085     // Compute true velocity of propagation
0086     G4double velocity = LM->MapKtoV(aTrack->GetVolume(), pol, Ran);
0087 
0088     // cast to non-const pointer so we can set the velocity
0089     G4Track* theTrack = const_cast<G4Track*>(aTrack);
0090 
0091     theTrack->SetMomentumDirection(momentumDir);
0092     theTrack->SetVelocity(velocity);
0093     theTrack->UseGivenVelocity(true);
0094   }
0095 
0096   return classification;
0097 }
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....