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

00001 #include "BDSBunchRing.hh"
00002 #include "BDSDebug.hh"
00003 
00004 BDSBunchRing::BDSBunchRing() : 
00005   BDSBunchInterface(), rMin(0), rMax(0) {
00006 #ifdef BDSDEBUG 
00007   G4cout << __METHOD_NAME__ << G4endl;
00008 #endif
00009   FlatGen  = new CLHEP::RandFlat(*CLHEP::HepRandom::getTheEngine());  
00010 }
00011 
00012 BDSBunchRing::BDSBunchRing(G4double rMinIn,   G4double rMaxIn,
00013                            G4double X0In,     G4double Y0In,       G4double Z0In,   G4double T0In, 
00014                            G4double Xp0In,    G4double Yp0In,      G4double Zp0In,                           
00015                            G4double sigmaTIn, G4double sigmaEIn) :
00016   BDSBunchInterface(X0In,Y0In,Z0In,T0In,Xp0In,Yp0In,Zp0In,sigmaTIn,sigmaEIn), rMin(rMinIn), rMax(rMaxIn) {
00017 #ifdef BDSDEBUG 
00018   G4cout << __METHOD_NAME__ << G4endl;
00019 #endif
00020   FlatGen  = new CLHEP::RandFlat(*CLHEP::HepRandom::getTheEngine());  
00021 }
00022 
00023 BDSBunchRing::~BDSBunchRing() {
00024 #ifdef BDSDEBUG 
00025   G4cout << __METHOD_NAME__ << G4endl;
00026 #endif
00027   delete FlatGen;
00028 }
00029 
00030 void BDSBunchRing::SetOptions(struct Options& opt) {
00031 #ifdef BDSDEBUG 
00032   G4cout << __METHOD_NAME__ << G4endl;
00033 #endif
00034 
00035   BDSBunchInterface::SetOptions(opt);
00036   SetRMin(opt.Rmin);  
00037   SetRMax(opt.Rmax);  
00038 }
00039 
00040 void BDSBunchRing::GetNextParticle(G4double& x0, G4double& y0, G4double& z0, 
00041                                        G4double& xp, G4double& yp, G4double& zp,
00042                                        G4double& t , G4double&  E, G4double& weight) {
00043 #ifdef BDSDEBUG 
00044   G4cout << __METHOD_NAME__ << G4endl;
00045 #endif
00046   double r = ( rMin + (rMax - rMin) *  rand() / RAND_MAX );
00047   double phi = 2 * CLHEP::pi * rand() / RAND_MAX;
00048      
00049   x0 = ( X0 + r * sin(phi) ) * CLHEP::m;
00050   y0 = ( Y0 + r * cos(phi) ) * CLHEP::m;
00051   z0 = Z0  * CLHEP::m;
00052   xp = Xp0 * CLHEP::rad;
00053   yp = Yp0 * CLHEP::rad;
00054   zp = CalculateZp(xp,yp,Zp0);
00055   t  = T0 * CLHEP::s;
00056   E  = BDSGlobalConstants::Instance()->GetParticleKineticEnergy()* (1 + sigmaE/2. * (1. -2. * FlatGen->shoot()));  
00057   weight = 1.0;
00058 }
00059 

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7