00001 #include "BDSBunchComposite.hh"
00002 #include "BDSBunchFactory.hh"
00003 #include "BDSDebug.hh"
00004
00005 BDSBunchComposite::BDSBunchComposite() {
00006 #ifdef BDSDEBUG
00007 G4cout << __METHOD_NAME__ << G4endl;
00008 #endif
00009 xBunch = NULL;
00010 yBunch = NULL;
00011 zBunch = NULL;
00012 }
00013
00014 BDSBunchComposite::~BDSBunchComposite() {
00015 #ifdef BDSDEBUG
00016 G4cout << __METHOD_NAME__ << G4endl;
00017 #endif
00018 delete xBunch;
00019 delete yBunch;
00020 delete zBunch;
00021 }
00022
00023 void BDSBunchComposite::SetOptions(struct Options& opt) {
00024 #ifdef BDSDEBUG
00025 G4cout << __METHOD_NAME__ << G4endl;
00026 #endif
00027
00028 BDSBunchInterface::SetOptions(opt);
00029
00030 delete xBunch;
00031 delete yBunch;
00032 delete zBunch;
00033
00034 xBunch = BDSBunchFactory::createBunch(opt.xDistribType);
00035 yBunch = BDSBunchFactory::createBunch(opt.yDistribType);
00036 zBunch = BDSBunchFactory::createBunch(opt.zDistribType);
00037
00038 xBunch->SetOptions(opt);
00039 yBunch->SetOptions(opt);
00040 zBunch->SetOptions(opt);
00041 }
00042
00043 void BDSBunchComposite::GetNextParticle(G4double& x0, G4double& y0, G4double& z0,
00044 G4double& xp, G4double& yp, G4double& zp,
00045 G4double& t , G4double& E, G4double& weight) {
00046 #ifdef BDSDEBUG
00047 G4cout << __METHOD_NAME__ << G4endl;
00048 #endif
00049
00050 G4double xx0, xy0, xz0, xxp, xyp, xzp, xt, xE, xWeight;
00051 G4double yx0, yy0, yz0, yxp, yyp, yzp, yt, yE, yWeight;
00052 G4double zx0, zy0, zz0, zxp, zyp, zzp, zt, zE, zWeight;
00053
00054 xBunch->GetNextParticle(xx0, xy0, xz0, xxp, xyp, xzp, xt, xE, xWeight);
00055 yBunch->GetNextParticle(yx0, yy0, yz0, yxp, yyp, yzp, yt, yE, yWeight);
00056 zBunch->GetNextParticle(zx0, zy0, zz0, zxp, zyp, zzp, zt, zE, zWeight);
00057
00058 x0 = xx0;
00059 xp = xxp;
00060 y0 = yy0;
00061 yp = yyp;
00062 z0 = zz0;
00063 zp = zzp;
00064 t = zt;
00065 E = zE;
00066 weight = xWeight;
00067
00068 return;
00069 }