#include <BesPrimaryGeneratorAction.hh>
Public Member Functions | |
BesPrimaryGeneratorAction () | |
BesPrimaryGeneratorAction () | |
void | GeneratePrimaries (G4Event *anEvent) |
void | GeneratePrimaries (G4Event *anEvent) |
G4String | GetGenbesName () |
G4String | GetGenbesName () |
G4String | GetGeneratorName () |
G4String | GetGeneratorName () |
void | SetDeltaP (G4double dp) |
void | SetDeltaP (G4double dp) |
void | SetGenbesName (G4String genbesNew) |
void | SetGenbesName (G4String genbesNew) |
void | SetGeneratorName (G4String genNew) |
void | SetGeneratorName (G4String genNew) |
void | SetMaxCos (G4double max1) |
void | SetMaxCos (G4double max1) |
void | SetMinCos (G4double min1) |
void | SetMinCos (G4double min1) |
void | SetMomentum (G4double pm) |
void | SetMomentum (G4double pm) |
void | SetNParticle (G4int np) |
void | SetNParticle (G4int np) |
void | SetParticleName (G4String pname) |
void | SetParticleName (G4String pname) |
void | SetPhiEnd (G4double pe) |
void | SetPhiEnd (G4double pe) |
void | SetPhiStart (G4double ps) |
void | SetPhiStart (G4double ps) |
void | SetPosX (G4double x) |
void | SetPosX (G4double x) |
void | SetPosY (G4double y) |
void | SetPosY (G4double y) |
void | SetPosZ (G4double z) |
void | SetPosZ (G4double z) |
~BesPrimaryGeneratorAction () | |
~BesPrimaryGeneratorAction () | |
Private Attributes | |
G4double | deltaP |
G4String | genbesName |
G4String | generatorName |
TH1F * | h1 |
TH1F * | h1 |
TH1F * | h2 |
TH1F * | h2 |
TH1F * | h3 |
TH1F * | h3 |
G4VPrimaryGenerator * | HEPEvt |
G4VPrimaryGenerator * | HEPEvt |
G4bool | isGenbes |
G4double | maxCos |
BesPrimaryGeneratorMessenger * | messenger |
BesPrimaryGeneratorMessenger * | messenger |
G4double | minCos |
G4int | nParticle |
G4ParticleGun * | particleGun |
G4ParticleGun * | particleGun |
G4String | particleName |
G4double | phiEnd |
G4double | phiStart |
G4double | pMomentum |
G4double | posX |
G4double | posY |
G4double | posZ |
|
00025 { 00026 nParticle = 1; 00027 particleName = "pi-"; 00028 minCos = -0.8; 00029 maxCos = 0.8; 00030 phiStart = 0.; 00031 phiEnd = 360.; 00032 pMomentum = 1.; 00033 deltaP = 0.; 00034 posX=0; 00035 posY=0; 00036 posZ=0; 00037 00038 particleGun = new G4ParticleGun(1); 00039 isGenbes = true; 00040 HEPEvt = 0; 00041 generatorName = "tester"; 00042 //TESTER parameters passed by this messenger 00043 messenger = new BesPrimaryGeneratorMessenger(this); 00044 00045 if(generatorName == "cosmic") 00046 { 00047 std::string path = getenv("GENSIMROOT"); 00048 G4cout<<"path: "<<path<<G4endl; 00049 00050 path += "/root/"; 00051 std::string pFile = path + "ppdc.root"; 00052 std::string thetaFile = path + "theta.root"; 00053 std::string phiFile = path +"phi.root"; 00054 00055 TFile* f1 = new TFile(pFile.c_str()); 00056 h1 = (TH1F*)f1->Get("htemp"); 00057 00058 TFile* f2 = new TFile(thetaFile.c_str()); 00059 h2 = (TH1F*)f2->Get("htemp"); 00060 00061 TFile* f3 = new TFile(phiFile.c_str()); 00062 h3 = (TH1F*)f3->Get("htemp"); 00063 00064 //ftest = new TFile("ftest.root","recreate"); 00065 //tuple = new TNtuple("test","test","p:theta:phi"); 00066 //counter = 0; 00067 } 00068 }
|
|
00071 { 00072 delete particleGun; 00073 if(messenger) delete messenger; 00074 if(generatorName=="genbes")delete HEPEvt; 00075 }
|
|
|
|
|
|
|
|
00078 { 00079 if(generatorName=="tester") 00080 { 00081 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 00082 G4ParticleDefinition* particle 00083 = particleTable->FindParticle(particleName); 00084 particleGun->SetParticleDefinition(particle); 00085 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ)); 00086 00087 //set TESTER parameters 00088 for(G4int i=0; i<nParticle; i++) 00089 { 00090 G4double pMag = pMomentum; 00091 //randomize p 00092 if(deltaP>0.)pMag = pMomentum - deltaP*(1.0 - 2.0*G4UniformRand()); 00093 pMag = pMag*GeV; 00094 //randomize cos(theta) 00095 G4double costheta = minCos +(maxCos - minCos)*G4UniformRand(); 00096 //randomize phi 00097 G4double phi = phiStart+(phiEnd-phiStart)*G4UniformRand(); 00098 phi = phi*degree; 00099 G4double sintheta = sqrt(1.-costheta*costheta); 00100 //computer 3-vector momentum 00101 G4ParticleMomentum aMomentum; 00102 aMomentum[0] = pMag*sintheta*cos(phi); 00103 aMomentum[1] = pMag*sintheta*sin(phi); 00104 aMomentum[2] = pMag*costheta; 00105 //use ParticleGun to generate event 00106 particleGun->SetParticleMomentum(aMomentum); 00107 particleGun->GeneratePrimaryVertex(anEvent); 00108 } 00109 } 00110 else if(generatorName=="cosmic") 00111 { 00112 G4cout<<"generatorName: "<<generatorName<<G4endl; 00113 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 00114 G4ParticleDefinition* particle 00115 = particleTable->FindParticle(particleName); 00116 G4cout<<"particleName: "<<particleName<<G4endl; 00117 00118 particleGun->SetParticleDefinition(particle); 00119 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ)); 00120 00121 /*std::string path = getenv("GENSIMROOT"); 00122 G4cout<<"path: "<<path<<G4endl; 00123 00124 path += "/root/"; 00125 std::string pFile = path + "ppdc.root"; 00126 std::string thetaFile = path + "theta.root"; 00127 std::string phiFile = path +"phi.root";*/ 00128 00129 //TFile* f1 = new TFile(pFile.c_str()); 00130 //H1F* h1 = (TH1F*)f1->Get("htemp"); 00131 G4double pMag = h1->GetRandom()*GeV; 00132 G4cout<<"pMag: "<<pMag<<G4endl; 00133 //f1->Close(); 00134 00135 //TFile* f2 = new TFile(thetaFile.c_str()); 00136 //TH1F* h2 = (TH1F*)f2->Get("htemp"); 00137 //randomize cos(theta) 00138 G4double theta =(Double_t)h2->GetRandom(); 00139 G4cout<<"theta: "<<theta<<G4endl; 00140 G4double costheta = cos(theta); 00141 //f2->Close(); 00142 00143 //TFile* f3 = new TFile(phiFile.c_str()); 00144 //TH1F* h3 = (TH1F*)f3->Get("htemp"); 00145 //randomize phi 00146 G4double phi = (Double_t)h3->GetRandom(); 00147 G4cout<<"phi: "<<phi<<G4endl; 00148 //f3->Close(); 00149 00150 //f1->Close(); 00151 //f2->Close(); 00152 //f3->Close(); 00153 //ftest->ReOpen("update"); 00154 //tuple->Fill(pMag,theta,phi); 00155 //counter++; 00156 //if(counter==2000) 00157 // tuple->Write(); 00158 00159 G4double sintheta = sqrt(1.-costheta*costheta); 00160 //computer 3-vector momentum 00161 G4ParticleMomentum aMomentum; 00162 aMomentum[0] = pMag*sintheta*cos(phi); 00163 aMomentum[1] = pMag*sintheta*sin(phi); 00164 aMomentum[2] = pMag*costheta; 00165 //use ParticleGun to generate event 00166 particleGun->SetParticleMomentum(aMomentum); 00167 particleGun->GeneratePrimaryVertex(anEvent); 00168 } 00169 00170 else if(generatorName=="genbes") 00171 { 00172 G4cout<<"genbes called"<<G4endl; 00173 if(isGenbes) 00174 { 00175 isGenbes=false; 00176 HEPEvt=new G4HEPEvtInterface(genbesName); 00177 } 00178 HEPEvt->GeneratePrimaryVertex(anEvent); 00179 } 00180 }
|
|
00039 {return genbesName;}
|
|
00039 {return genbesName;}
|
|
00037 {return generatorName;}
|
|
00037 {return generatorName;}
|
|
00048 {deltaP = dp;}
|
|
00048 {deltaP = dp;}
|
|
00040 {genbesName=genbesNew;}
|
|
00040 {genbesName=genbesNew;}
|
|
00038 {generatorName=genNew;}
|
|
00038 {generatorName=genNew;}
|
|
00044 {maxCos = max1;}
|
|
00044 {maxCos = max1;}
|
|
00043 {minCos = min1;}
|
|
00043 {minCos = min1;}
|
|
00047 {pMomentum = pm;}
|
|
00047 {pMomentum = pm;}
|
|
00041 {nParticle = np;}
|
|
00041 {nParticle = np;}
|
|
00042 {particleName = pname;}
|
|
00042 {particleName = pname;}
|
|
00046 {phiEnd = pe;}
|
|
00046 {phiEnd = pe;}
|
|
00045 {phiStart =ps;}
|
|
00045 {phiStart =ps;}
|
|
00049 {posX = x;}
|
|
00049 {posX = x;}
|
|
00050 {posY = y;}
|
|
00050 {posY = y;}
|
|
00051 {posZ = z;}
|
|
00051 {posZ = z;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|