Message: Re: Linear beam rotation using GPS Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Linear beam rotation using GPS 

Forum: Particles
Re: Question Linear beam rotation using GPS (Ibrahim)
Date: 26 Feb, 2015
From: C Mos <C Mos>

Here is an example of my gps gun macro. YOu can see that there is a direction command. If you keep the position the same and change the direction vector, you could accomplish a rotation of the gun. I hope this helps. If you want to rotate through multiples angles, you could use /control/loop and /control/foreach commands.

  bash-4.2$ more gpsGun.mac 
  #/control/verbose 0
  #/tracking/verbose 0
  #/event/verbose 0
  #/gps/verbose 2
  #==================================================
  /gps/particle neutron
  /gps/number 1
  #/gps/position 0. 0. 37. cm
  #/gps/direction 0. 0. 1.
  /gps/pos/type Point
  /gps/energy 1.0 MeV
  ###/gps/pos/centre 0. 0. 37. cm   ##DONE at primary generator action
  /gps/ang/type iso
  /gps/ene/type Mono
  #==================================================
  #/gps/pos/type Volume
  #/gps/pos/shape Sphere
  #/gps/pos/radius 0.25 cm
  #/gps/ang/type cos
  #/gps/ene/type Lin
  #/gps/ene/min 2 MeV
  #/gps/ene/max 10 MeV
  #/gps/ene/gradient 1
  #/gps/ene/intercept 1

You can do also something similar in the PrimaryGenAction (Notice I am omitting lines and definitions):

[Do the following in your constructor]

  gpsGun       = new G4GeneralParticleSource();

[Then in GeneratePrimaries memeber function you could do:]

  REFERENCE: 
  http://www-zeuthen.desy.de/geant4/geant4.9.3.b01/classG4GeneralParticleSource.html
  http://www-zeuthen.desy.de/geant4/geant4.9.3.b01/classG4SPSAngDistribution.html

    gpsGun->GetCurrentSource()->SetNumberOfParticles(1);
    gpsGun->GetCurrentSource()->SetParticleDefinition(fwdParticle);  // a neutron
    gpsGun->GetCurrentSource()->GetPosDist()->SetPosDisType("Point");
    gpsGun->GetCurrentSource()->GetPosDist()->SetCentreCoords(*dTposition); //vector field indicating pos in space
    gpsGun->GetCurrentSource()->GetAngDist()->SetAngDistType("iso");
    gpsGun->GetCurrentSource()->GetEneDist()->SetEnergyDisType("Mono");
    gpsGun->GetCurrentSource()->GetEneDist()->SetMonoEnergy(fwdParticleEkin);  //0.1*MeV
    gpsGun->GeneratePrimaryVertex(anEvent);

Notice my distribution is isotropic so setting up direction is meaningless. In your case, assuming you dont have an iso source, you could do:

  gpsGun->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(my_momentumAxis);  // Argument: G4ParticleMomentum aMomentumDirection

Not sure if there is documentation out there. You could give it a try to see if this helps.

Cheers,

C Mos

 Add Message Add Message
to: "Re: Linear beam rotation using GPS"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]