#include "G4VUserPrimaryGeneratorAction.hh" #include "G4ParticleGun.hh" #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" #include "Randomize.hh" #include using namespace std; extern float P_GENERATED; // GeV extern float THETA_GENERATED; // radians extern float PHI_GENERATED; // radians extern float MASS_GENERATED; // GeV class PiMuG4PrimaryGeneratorAction:public G4VUserPrimaryGeneratorAction{ public: PiMuG4PrimaryGeneratorAction(const char *ptype="pi+"){ double E = G4RandFlat::shoot(0.5,5.0)*GeV; E = 2.0*GeV; // z=-220 is just upstream of FCAL // z=-843 is at nominal CPP target position G4ThreeVector position(0.0, 0.0, -220.0*cm); //G4ThreeVector position(0.0, 0.0, -843.0*cm); G4ThreeVector momentumDirection(0.0, 0.0, 1.0); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle(ptype); fParticleGun = new G4ParticleGun(1); fParticleGun->SetParticleDefinition(particle); fParticleGun->SetParticleEnergy(E); fParticleGun->SetParticlePosition(position); fParticleGun->SetParticleMomentumDirection(momentumDirection); MASS_GENERATED = particle->GetPDGMass()/GeV; Nevents=0; ifs = new ifstream("pb_pol70_10days_pi+.ascii"); if(!ifs->is_open()){ G4cout<<"Unable to open input file \"pb_pol70_10days_pi+.ascii\"!"<> id >> pname >> m >> charge >> px >> py >> pz >> E; // if(ifs->eof()){ // G4cout<<"NO MORE EVENTS IN INPUT FILE!"<SetParticleEnergy(E*GeV); // fParticleGun->SetParticleMomentumDirection(dir); fParticleGun->GeneratePrimaryVertex(anEvent); if(++Nevents%100 == 0){ G4cout<<" "<