BesPrimaryGeneratorAction Class Reference

#include <BesPrimaryGeneratorAction.hh>

List of all members.

Public Member Functions

 BesPrimaryGeneratorAction ()
 ~BesPrimaryGeneratorAction ()
void GeneratePrimaries (G4Event *anEvent)
G4String GetGeneratorName ()
void SetGeneratorName (G4String genNew)
G4String GetGenbesName ()
void SetGenbesName (G4String genbesNew)
void SetNParticle (G4int np)
void SetParticleName (G4String pname)
void SetMinCos (G4double min1)
void SetMaxCos (G4double max1)
void SetPhiStart (G4double ps)
void SetPhiEnd (G4double pe)
void SetMomentum (G4double pm)
void SetDeltaP (G4double dp)
void SetPosX (G4double x)
void SetPosY (G4double y)
void SetPosZ (G4double z)

Private Attributes

G4ParticleGun * particleGun
BesPrimaryGeneratorMessengermessenger
G4VPrimaryGenerator * HEPEvt
G4String generatorName
G4String genbesName
G4bool isGenbes
G4int nParticle
G4String particleName
G4double minCos
G4double maxCos
G4double phiStart
G4double phiEnd
G4double pMomentum
G4double deltaP
G4double posX
G4double posY
G4double posZ
TH1F * h1
TH1F * h2
TH1F * h3


Detailed Description

Definition at line 26 of file BesPrimaryGeneratorAction.hh.


Constructor & Destructor Documentation

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction (  ) 

Definition at line 24 of file BesPrimaryGeneratorAction.cc.

References deltaP, f1, f2, generatorName, h1, h2, h3, HEPEvt, isGenbes, maxCos, messenger, minCos, nParticle, particleGun, particleName, phiEnd, phiStart, pMomentum, posX, posY, posZ, and deljobs::string.

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 }

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction (  ) 

Definition at line 70 of file BesPrimaryGeneratorAction.cc.

References generatorName, HEPEvt, messenger, and particleGun.

00071 {
00072   delete particleGun;
00073   if(messenger) delete messenger; 
00074   if(generatorName=="genbes")delete HEPEvt; 
00075 }


Member Function Documentation

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  anEvent  ) 

Definition at line 77 of file BesPrimaryGeneratorAction.cc.

References cos(), deltaP, genbesName, generatorName, h1, h2, h3, HEPEvt, genRecEmupikp::i, isGenbes, maxCos, minCos, nParticle, particleGun, particleName, phiEnd, phiStart, pMomentum, posX, posY, posZ, and sin().

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 }

G4String BesPrimaryGeneratorAction::GetGenbesName (  )  [inline]

Definition at line 39 of file BesPrimaryGeneratorAction.hh.

References genbesName.

Referenced by BesPrimaryGeneratorMessenger::GetCurrentValue().

00039 {return genbesName;}

G4String BesPrimaryGeneratorAction::GetGeneratorName (  )  [inline]

Definition at line 37 of file BesPrimaryGeneratorAction.hh.

References generatorName.

Referenced by BesPrimaryGeneratorMessenger::GetCurrentValue().

00037 {return generatorName;}

void BesPrimaryGeneratorAction::SetDeltaP ( G4double  dp  )  [inline]

Definition at line 48 of file BesPrimaryGeneratorAction.hh.

References deltaP.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00048 {deltaP = dp;}

void BesPrimaryGeneratorAction::SetGenbesName ( G4String  genbesNew  )  [inline]

Definition at line 40 of file BesPrimaryGeneratorAction.hh.

References genbesName.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00040 {genbesName=genbesNew;} 

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String  genNew  )  [inline]

Definition at line 38 of file BesPrimaryGeneratorAction.hh.

References generatorName.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00038 {generatorName=genNew;}

void BesPrimaryGeneratorAction::SetMaxCos ( G4double  max1  )  [inline]

Definition at line 44 of file BesPrimaryGeneratorAction.hh.

References maxCos.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00044 {maxCos = max1;}

void BesPrimaryGeneratorAction::SetMinCos ( G4double  min1  )  [inline]

Definition at line 43 of file BesPrimaryGeneratorAction.hh.

References minCos.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00043 {minCos = min1;}

void BesPrimaryGeneratorAction::SetMomentum ( G4double  pm  )  [inline]

Definition at line 47 of file BesPrimaryGeneratorAction.hh.

References pMomentum.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00047 {pMomentum = pm;}

void BesPrimaryGeneratorAction::SetNParticle ( G4int  np  )  [inline]

Definition at line 41 of file BesPrimaryGeneratorAction.hh.

References nParticle.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00041 {nParticle = np;}

void BesPrimaryGeneratorAction::SetParticleName ( G4String  pname  )  [inline]

Definition at line 42 of file BesPrimaryGeneratorAction.hh.

References particleName.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00042 {particleName = pname;}

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double  pe  )  [inline]

Definition at line 46 of file BesPrimaryGeneratorAction.hh.

References phiEnd.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00046 {phiEnd = pe;}

void BesPrimaryGeneratorAction::SetPhiStart ( G4double  ps  )  [inline]

Definition at line 45 of file BesPrimaryGeneratorAction.hh.

References phiStart.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00045 {phiStart =ps;}

void BesPrimaryGeneratorAction::SetPosX ( G4double  x  )  [inline]

Definition at line 49 of file BesPrimaryGeneratorAction.hh.

References posX.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00049 {posX = x;}

void BesPrimaryGeneratorAction::SetPosY ( G4double  y  )  [inline]

Definition at line 50 of file BesPrimaryGeneratorAction.hh.

References posY.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00050 {posY = y;}

void BesPrimaryGeneratorAction::SetPosZ ( G4double  z  )  [inline]

Definition at line 51 of file BesPrimaryGeneratorAction.hh.

References posZ.

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

00051 {posZ = z;}


Member Data Documentation

G4double BesPrimaryGeneratorAction::deltaP [private]

Definition at line 69 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetDeltaP().

G4String BesPrimaryGeneratorAction::genbesName [private]

Definition at line 59 of file BesPrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), GetGenbesName(), and SetGenbesName().

G4String BesPrimaryGeneratorAction::generatorName [private]

Definition at line 58 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), GetGeneratorName(), SetGeneratorName(), and ~BesPrimaryGeneratorAction().

TH1F* BesPrimaryGeneratorAction::h1 [private]

Definition at line 76 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), and GeneratePrimaries().

TH1F* BesPrimaryGeneratorAction::h2 [private]

Definition at line 77 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), and GeneratePrimaries().

TH1F* BesPrimaryGeneratorAction::h3 [private]

Definition at line 78 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), and GeneratePrimaries().

G4VPrimaryGenerator* BesPrimaryGeneratorAction::HEPEvt [private]

Definition at line 57 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and ~BesPrimaryGeneratorAction().

G4bool BesPrimaryGeneratorAction::isGenbes [private]

Definition at line 60 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), and GeneratePrimaries().

G4double BesPrimaryGeneratorAction::maxCos [private]

Definition at line 65 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetMaxCos().

BesPrimaryGeneratorMessenger* BesPrimaryGeneratorAction::messenger [private]

Definition at line 56 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), and ~BesPrimaryGeneratorAction().

G4double BesPrimaryGeneratorAction::minCos [private]

Definition at line 64 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetMinCos().

G4int BesPrimaryGeneratorAction::nParticle [private]

Definition at line 62 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetNParticle().

G4ParticleGun* BesPrimaryGeneratorAction::particleGun [private]

Definition at line 55 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and ~BesPrimaryGeneratorAction().

G4String BesPrimaryGeneratorAction::particleName [private]

Definition at line 63 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetParticleName().

G4double BesPrimaryGeneratorAction::phiEnd [private]

Definition at line 67 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetPhiEnd().

G4double BesPrimaryGeneratorAction::phiStart [private]

Definition at line 66 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetPhiStart().

G4double BesPrimaryGeneratorAction::pMomentum [private]

Definition at line 68 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetMomentum().

G4double BesPrimaryGeneratorAction::posX [private]

Definition at line 70 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetPosX().

G4double BesPrimaryGeneratorAction::posY [private]

Definition at line 71 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetPosY().

G4double BesPrimaryGeneratorAction::posZ [private]

Definition at line 72 of file BesPrimaryGeneratorAction.hh.

Referenced by BesPrimaryGeneratorAction(), GeneratePrimaries(), and SetPosZ().


Generated on Tue Nov 29 23:17:34 2016 for BOSS_7.0.2 by  doxygen 1.4.7