Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:03

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 //
0027 /// \file UserMoleculeGun.cc
0028 /// \brief Implementation of the UserMoleculeGun class
0029 
0030 #include "UserMoleculeGun.hh"
0031 #include "UserMolecule.hh"
0032 
0033 #include "G4MoleculeTable.hh"
0034 #include "G4SystemOfUnits.hh"
0035 #include "G4VITTrackHolder.hh"
0036 #include "G4H2O.hh"
0037 #include "G4Track.hh"
0038 
0039 UserMoleculeShoot::UserMoleculeShoot() :
0040 G4enable_shared_from_this<UserMoleculeShoot>()
0041 {
0042     fMoleculeName = "";
0043     fTime = 0;
0044     fNumber = 1;
0045     fBoxSize = 0;
0046     fCopyNumber = -1;
0047     fStrand = -1;
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 UserMoleculeShoot::~UserMoleculeShoot()
0053 {
0054     if(fBoxSize) delete fBoxSize;
0055 }
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 template<>
0060 void TUserMoleculeShoot<G4Track>::ShootAtRandomPosition(UserMoleculeGun* gun)
0061 {
0062     G4ThreeVector positionInLocalCoordinate;
0063 
0064     for(int i = 0; i < fNumber; ++i)
0065     {
0066         RandomPosInBox(*fBoxSize, positionInLocalCoordinate);
0067         if(fStrand<=0)
0068         gun->BuildAndPushTrack(fMoleculeName,
0069         fPosition + positionInLocalCoordinate,
0070         fTime);
0071     else
0072         gun->BuildAndPushTrack(fMoleculeName,
0073         fPosition + positionInLocalCoordinate,
0074         fTime,fCopyNumber,fStrand);
0075     }
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 template<>
0081 void TUserMoleculeShoot<G4Track>::ShootAtFixedPosition(UserMoleculeGun* gun)
0082 {
0083     for(int i = 0; i < fNumber; ++i)
0084     {
0085         if(fStrand<=0)
0086         gun->BuildAndPushTrack(fMoleculeName, fPosition, fTime);
0087         else
0088         gun->BuildAndPushTrack(fMoleculeName,fPosition,fTime,fCopyNumber,fStrand);
0089     }
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 template<>
0095 void TUserMoleculeShoot<G4Track>::MyShoot(UserMoleculeGun* gun)
0096 {
0097     if(fBoxSize) ShootAtRandomPosition(gun);
0098     else ShootAtFixedPosition(gun);
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 void UserMoleculeGun::DefineTracks()
0104 {
0105     for (size_t i = 0; i < fShoots.size(); i++)
0106     {
0107         fShoots[i]->MyShoot(this);
0108     }
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0112 
0113 void UserMoleculeGun::AddMolecule(const G4String& name,
0114     const G4ThreeVector& position,
0115     G4double time,
0116     G4int copyNumber,
0117     G4int strand)
0118 {
0119     G4shared_ptr<UserMoleculeShoot> shoot(new TUserMoleculeShoot<G4Track>());
0120     shoot->fMoleculeName = name;
0121     shoot->fPosition = position;
0122     shoot->fTime = time;
0123     shoot->fCopyNumber = copyNumber;
0124     shoot->fStrand = strand;
0125     fShoots.push_back(shoot);
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0129 
0130 void UserMoleculeGun::AddWaterMolecule(const G4ThreeVector& position,
0131     G4int trackId,
0132     ElectronicModification elecModif,
0133     G4int electronicLevel)
0134 {
0135     UserMolecule * H2O = new UserMolecule (G4H2O::Definition() );
0136     switch (elecModif)
0137     {
0138         case eDissociativeAttachment:
0139         H2O -> AddElectron(5,1);
0140         break;
0141         case eExcitedMolecule :
0142         H2O -> ExciteMolecule(electronicLevel);
0143         break;
0144         case eIonizedMolecule :
0145         H2O -> IonizeMolecule(electronicLevel);
0146         break;
0147     }
0148     
0149     G4Track * H2OTrack = H2O->BuildTrack(1*picosecond, position);
0150     H2OTrack->SetParentID(trackId);
0151     H2OTrack->SetTrackStatus(fStopButAlive);
0152     H2OTrack->SetKineticEnergy(0.);
0153     G4VITTrackHolder::Instance()->Push(H2OTrack);
0154 }
0155 
0156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0157 
0158 void UserMoleculeGun::BuildAndPushTrack(const G4String& name,
0159     const G4ThreeVector& position,
0160     G4double time)
0161 {
0162     G4MolecularConfiguration* conf =
0163     G4MoleculeTable::Instance()->GetConfiguration(name);
0164     assert(conf != 0);
0165     UserMolecule* molecule = new UserMolecule(conf);
0166     PushTrack(molecule->BuildTrack(time, position));
0167 }
0168 
0169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0170 
0171 void UserMoleculeGun::BuildAndPushTrack(const G4String& name,
0172     const G4ThreeVector& position,
0173     G4double time,
0174     G4int copyNumber,
0175     G4int strand)
0176 {
0177     G4MoleculeDefinition* def = G4MoleculeTable::Instance()->GetMoleculeDefinition(name);
0178     assert(def != 0);
0179     UserMolecule* molecule = new UserMolecule(def);
0180     molecule->SetCopyNumber(copyNumber);
0181     molecule->SetStrand(strand);
0182 
0183     PushTrack(molecule->BuildTrack(time, position));
0184 }
0185 
0186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......