52 bStopAtPhaseSpace=
true;
63 accTargetZPosition=ZPos;
64 max_N_particles_in_PhSp_File=maxPartFile;
65 nMaxParticlesInRamPhaseSpace = nMaxPart;
67 primaryParticleData=pData;
71 bSavePhaseSpace=bSave;
72 bStopAtPhaseSpace=bStop;
77 sprintf(a,
"%d", seed);
80 fullOutFileData=PhaseSpaceOutFile+
"_"+seedName+
".txt";
81 fullOutFileData=PhaseSpaceOutFile+
"_"+seedName+
".txt";
90 void CML2SDWithParticle::saveHeaderParticles()
93 out.open(fullOutFileData, std::ios::out);
94 out <<
"Sensitive Detector-Particles"<<
G4endl;
95 out <<
"n Total Events,\t x [mm],\t y [mm],\t z [mm],\t dirX,\t dirY,\t dirZ,\t KinEnergy [MeV],\t part Type,\t primary part type,\t nPrimaryPart" <<
G4endl;
98 void CML2SDWithParticle::saveDataParticles(
G4int nPart)
102 static G4int nTotParticles=0;
103 for (
int i=0; i< nPart; i++)
105 out << nTotParticles++ <<
'\t';
107 out << particles[i].
pos.
getX()/
mm <<
'\t';
108 out << particles[i].
pos.
getY()/
mm <<
'\t';
109 out << (accTargetZPosition + particles[i].
pos.
getZ())/
mm <<
'\t';
110 out << particles[i].
dir.
getX() <<
'\t';
111 out << particles[i].
dir.
getY() <<
'\t';
112 out << particles[i].
dir.
getZ() <<
'\t';
114 out << particles[i].
partPDGE<<
'\t';
126 static bool bFirstTime=
true;
139 particles[nParticle].
kinEnergy=energyKin;
145 if (nTotalParticles==max_N_particles_in_PhSp_File)
150 saveHeaderParticles();
152 saveDataParticles(nParticle);
156 if (nParticle==nMaxParticlesInRamPhaseSpace)
161 saveHeaderParticles();
163 saveDataParticles(nParticle);
177 if (bStopAtPhaseSpace)
183 if (bStopAtPhaseSpace)
193 {saveDataParticles(nParticle);nParticle=0;}
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4ParticleDefinition * GetDefinition() const
static CML2AcceleratorConstruction * GetInstance(void)
G4int GetPDGEncoding() const
G4StepPoint * GetPreStepPoint() const
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROHist)
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
~CML2SDWithParticle(void)
G4int primaryParticlePDGE
const G4ThreeVector & GetPosition() const
G4Track * GetTrack() const