/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSBunchEShell.cc

00001 #include "BDSBunchEShell.hh"
00002 #include "BDSDebug.hh"
00003 
00004 BDSBunchEShell::BDSBunchEShell() : 
00005   BDSBunchInterface(), shellX(0.0), shellXp(0.0), shellY(0.0), shellYp(0.0), 
00006   shellXWidth(0.0), shellXpWidth(0.0), shellYWidth(0.0), shellYpWidth(0.0) 
00007 {
00008 #ifdef BDSDEBUG 
00009   G4cout << __METHOD_NAME__ << G4endl;
00010 #endif
00011   FlatGen  = new CLHEP::RandFlat(*CLHEP::HepRandom::getTheEngine()); 
00012 }
00013 
00014 BDSBunchEShell::BDSBunchEShell(G4double shellXIn, G4double shellXpIn,
00015                                G4double shellYIn, G4double shellYpIn,
00016                                G4double shellXWidthIn, G4double shellXpWidthIn,
00017                                G4double shellYWidthIn, G4double shellYpWidthIn,
00018                                G4double X0In,     G4double Y0In,       G4double Z0In,   G4double T0In, 
00019                                G4double Xp0In,    G4double Yp0In,      G4double Zp0In,                       
00020                                G4double sigmaTIn, G4double sigmaEIn) :
00021   BDSBunchInterface(X0In,Y0In,Z0In,T0In,Xp0In,Yp0In,Zp0In,sigmaTIn,sigmaEIn), 
00022   shellX(shellXIn), shellXp(shellXpIn), shellY(shellYIn), shellYp(shellYpIn),
00023   shellXWidth(shellXWidthIn), shellXpWidth(shellXpWidthIn), 
00024   shellYWidth(shellYWidthIn), shellYpWidth(shellYpWidthIn)
00025 {
00026 #ifdef BDSDEBUG 
00027   G4cout << __METHOD_NAME__ << G4endl;
00028 #endif
00029   FlatGen  = new CLHEP::RandFlat(*CLHEP::HepRandom::getTheEngine()); 
00030 }
00031 
00032 BDSBunchEShell::~BDSBunchEShell() 
00033 {
00034 #ifdef BDSDEBUG 
00035   G4cout << __METHOD_NAME__ << G4endl;
00036 #endif
00037   delete FlatGen;
00038 }
00039 
00040 void BDSBunchEShell::SetOptions(struct Options& opt) {
00041 #ifdef BDSDEBUG 
00042   G4cout << __METHOD_NAME__ << G4endl;
00043 #endif
00044   BDSBunchInterface::SetOptions(opt);
00045   SetShellX (opt.shellX);
00046   SetShellY (opt.shellY);
00047   SetShellXp(opt.shellXp);
00048   SetShellYp(opt.shellYp);
00049   SetShellXWidth (opt.shellXWidth );
00050   SetShellXpWidth(opt.shellXpWidth);
00051   SetShellYWidth (opt.shellYWidth );
00052   SetShellYpWidth(opt.shellYpWidth);
00053 }
00054 
00055 void BDSBunchEShell::GetNextParticle(G4double& x0, G4double& y0, G4double& z0, 
00056                                     G4double& xp, G4double& yp, G4double& zp,
00057                                     G4double& t , G4double&  E, G4double& weight) {
00058 #ifdef BDSDEBUG 
00059   G4cout << __METHOD_NAME__ << G4endl;
00060 #endif
00061   G4double phi = 2 * CLHEP::pi * FlatGen->shoot();
00062   G4double xamp  = 0.5 - FlatGen->shoot();
00063   G4double yamp  = 0.5 - FlatGen->shoot();
00064   G4double xpamp = 0.5 - FlatGen->shoot();
00065   G4double ypamp = 0.5 - FlatGen->shoot();
00066   
00067   x0 = (X0 +  (sin(phi) * shellX)  + xamp * shellXWidth) * CLHEP::m;
00068   xp = (Xp0 + (cos(phi) * shellXp) + xpamp * shellXpWidth);
00069   
00070   phi = 2 * CLHEP::pi * FlatGen->shoot();
00071   
00072   y0 = (Y0 +  (sin(phi) * shellY)  + yamp * shellYWidth) * CLHEP::m;
00073   yp = (Yp0 + (cos(phi) * shellYp) + ypamp * shellYpWidth);
00074   
00075   z0 = Z0 * CLHEP::m;
00076   zp = CalculateZp(xp,yp,Zp0);
00077  
00078   t = T0 * CLHEP::s;
00079   E = BDSGlobalConstants::Instance()->GetParticleKineticEnergy()* (1 + sigmaE/2. * (1. -2. * FlatGen->shoot()));
00080   weight = 1.0;
00081 
00082   return;
00083 }
00084                     

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7