musrPrimaryGeneratorAction Class Reference

#include <musrPrimaryGeneratorAction.hh>

List of all members.

Public Member Functions

 musrPrimaryGeneratorAction (musrDetectorConstruction *)
 ~musrPrimaryGeneratorAction ()
void GeneratePrimaries (G4Event *)
void SetRndmFlag (G4String val)
void Setxvertex (G4double x)
void Setyvertex (G4double y)
void Setzvertex (G4double z)
void Setpxanglevertex (G4double px)
void Setpyanglevertex (G4double py)
void SetMomentum (G4double p)
void SetBeamWidth (G4double w)

Static Public Member Functions

static G4String GetPrimaryName ()

Public Attributes

G4double decaytime
HepRandomEngine * theEngine


Detailed Description

Definition at line 16 of file musrPrimaryGeneratorAction.hh.


Constructor & Destructor Documentation

musrPrimaryGeneratorAction::musrPrimaryGeneratorAction musrDetectorConstruction  ) 
 

Definition at line 21 of file musrPrimaryGeneratorAction.cc.

00023   :musrDetector(musrDC),rndmFlag("off"),xvertex(0.),yvertex(0.),zvertex(0.), 
00024  xyvertexdefined(false), zvertexdefined(false),pxanglevertex(0.),pyanglevertex(0.),pvertexdefined(false),
00025    pMomentum(0.),pMomentumdefined(false),TheSetWidth(0.),Widthdefined(false)
00026 {
00027   G4int n_particle = 1;
00028   particleGun  = new musrParticleGun(n_particle);
00029   
00030   //create a messenger for this class
00031   gunMessenger = new musrPrimaryGeneratorMessenger(this);
00032 
00033   // default particle kinematic
00034 
00035   G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
00036   G4ParticleDefinition* particle= particleTable->FindParticle("mu+");
00037   particleGun->SetParticleDefinition(particle);
00038 
00039 } 

musrPrimaryGeneratorAction::~musrPrimaryGeneratorAction  ) 
 

Definition at line 43 of file musrPrimaryGeneratorAction.cc.

00044 {
00045   delete particleGun;
00046   delete gunMessenger;
00047 }


Member Function Documentation

void musrPrimaryGeneratorAction::GeneratePrimaries G4Event *   ) 
 

Definition at line 51 of file musrPrimaryGeneratorAction.cc.

References decaytime, musrParticleGun::GeneratePrimaryVertex(), musrParticleGun::SetDecayTime(), and theEngine.

00052 {
00053  
00054 
00055 
00056  //this function is called at the begining of event
00057   // 
00058 
00059 
00060     G4double tau=0.000002197;
00061     G4double rnddecaytime = -tau*log(1-G4UniformRand());
00062     decaytime = rnddecaytime*s;
00063     particleGun->SetDecayTime(decaytime);
00064 
00065 
00066   //Set the initial particle position
00067      const double stdFWHMfactor=sqrt(2*log(2));
00068      G4double TheWidth;
00069 
00070      if(Widthdefined)
00071        {
00072     TheWidth=TheSetWidth;
00073        }
00074      else
00075        {
00076     TheWidth=40.*mm;
00077        }
00078 
00079 
00080     G4double xbeamwidthFWHM = TheWidth;
00081     G4double ybeamwidthFWHM = TheWidth;
00082 
00083     G4double x0,y0,z0 ;
00084 
00085 
00086     G4double xstdposition =  xbeamwidthFWHM/(2*stdFWHMfactor);
00087     G4double ystdposition =  ybeamwidthFWHM/(2*stdFWHMfactor);
00088     G4RandGauss* jRndGauss = new G4RandGauss(theEngine, 0, xstdposition);
00089     G4double xrndposition = jRndGauss->shoot(0, xstdposition);
00090     G4double yrndposition = jRndGauss->shoot(0, ystdposition);
00091     G4double xposition = xrndposition*mm;
00092     G4double yposition = yrndposition*mm;
00093 
00094 
00095     // temporary lines
00096     //          xposition = xbeamwidthFWHM/2.0;
00097     //  yposition = ybeamwidthFWHM/2.0;
00098 
00099 
00100 
00101         //      G4cout<<"Initial muon position = " << xposition <<", " 
00102         //    << yposition << "mm \n" <<G4endl;
00103 
00104 
00105 
00106   if(xyvertexdefined)
00107   {
00108     x0 = xvertex ;
00109     y0 = yvertex ;
00110   }
00111   else
00112   {
00113     x0 = xposition ;
00114     y0 = yposition ;
00115   }
00116 
00117 
00118   if(zvertexdefined)
00119   {
00120     z0 = zvertex ;
00121   }
00122   else
00123   {
00124     z0 = 0.*mm ;
00125   }
00126 
00127 
00128   //Set the initial particle momentum
00129 
00130   G4double pxangle0,pyangle0 ;
00131 
00132   if(pvertexdefined)
00133   {
00134     pxangle0 = pxanglevertex ;
00135     pyangle0 = pyanglevertex ;
00136   }
00137   else
00138   {
00139     pxangle0 = 0.*deg ;
00140     pyangle0 = 0.*deg ;
00141   }
00142 
00143   G4double myMomentum;
00144 
00145   if(pMomentumdefined)
00146     {
00147     myMomentum=pMomentum;      
00148     }
00149   else
00150     {
00151       myMomentum=0.0;
00152     }
00153 
00154 
00155   particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
00156 
00157 
00158 
00159     G4double xpitch = sin(pxangle0);
00160     G4double ypitch = sin(pyangle0);
00161     G4double zpitch = sqrt(1-(sin(pxangle0)*sin(pxangle0)
00162                            +sin(pyangle0)*sin(pyangle0)));
00163 
00164     // Then orient the spin relative to the beam pitch
00165 
00166 
00167   //longitudinal
00168     particleGun->SetParticlePolarization(G4ThreeVector(xpitch,ypitch,-zpitch));
00169 
00170   //transverse
00171   //     particleGun->SetParticlePolarization(G4ThreeVector(zpitch,0,-xpitch));
00172 
00173 
00174   G4double energy = sqrt(1e6*myMomentum*myMomentum+11163.82428)-105.659; 
00175   particleGun->SetParticleEnergy(energy*MeV);
00176   particleGun->SetParticleMomentumDirection(G4ThreeVector(xpitch,ypitch,zpitch));  particleGun->GeneratePrimaryVertex(anEvent);
00177 
00178 
00179 
00180 }

static G4String musrPrimaryGeneratorAction::GetPrimaryName  )  [static]
 

void musrPrimaryGeneratorAction::SetBeamWidth G4double  w  ) 
 

Definition at line 228 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00229 {
00230   Widthdefined = true;
00231   TheSetWidth=w;
00232 G4cout<< "FWHM beam width set to "<< TheSetWidth <<"mm" <<G4endl;
00233 
00234 }

void musrPrimaryGeneratorAction::SetMomentum G4double  p  ) 
 

Definition at line 220 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00221 {
00222   pMomentumdefined = true ;
00223   pMomentum = p ;
00224 
00225 }

void musrPrimaryGeneratorAction::Setpxanglevertex G4double  px  ) 
 

Definition at line 207 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00208 {
00209   pvertexdefined = true ;
00210   pxanglevertex = px ;
00211 
00212 }

void musrPrimaryGeneratorAction::Setpyanglevertex G4double  py  ) 
 

Definition at line 214 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00215 {
00216   pvertexdefined = true ;
00217   pyanglevertex = py ;
00218 
00219 }

void musrPrimaryGeneratorAction::SetRndmFlag G4String  val  )  [inline]
 

Definition at line 24 of file musrPrimaryGeneratorAction.hh.

00024 { rndmFlag = val;}

void musrPrimaryGeneratorAction::Setxvertex G4double  x  ) 
 

Definition at line 187 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00188 {
00189   xyvertexdefined = true ;
00190   xvertex = x ;
00191 
00192 }

void musrPrimaryGeneratorAction::Setyvertex G4double  y  ) 
 

Definition at line 194 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00195 {
00196   xyvertexdefined = true ;
00197   yvertex = y ;
00198 
00199 }

void musrPrimaryGeneratorAction::Setzvertex G4double  z  ) 
 

Definition at line 200 of file musrPrimaryGeneratorAction.cc.

Referenced by musrPrimaryGeneratorMessenger::SetNewValue().

00201 {
00202   zvertexdefined = true ;
00203   zvertex = z ;
00204 
00205 }


Member Data Documentation

G4double musrPrimaryGeneratorAction::decaytime
 

Definition at line 55 of file musrPrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries().

HepRandomEngine* musrPrimaryGeneratorAction::theEngine
 

Definition at line 56 of file musrPrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries().


The documentation for this class was generated from the following files:
Generated on Mon Mar 27 12:19:54 2006 for MUSR by  doxygen 1.4.6