BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
BesPrimaryGeneratorAction Class Reference

#include <BesPrimaryGeneratorAction.hh>

+ Inheritance diagram for BesPrimaryGeneratorAction:

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)
 
 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)
 

Detailed Description

Constructor & Destructor Documentation

◆ BesPrimaryGeneratorAction() [1/2]

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction ( )

Definition at line 24 of file BesPrimaryGeneratorAction.cc.

25{
26 nParticle = 1;
27 particleName = "pi-";
28 minCos = -0.8;
29 maxCos = 0.8;
30 phiStart = 0.;
31 phiEnd = 360.;
32 pMomentum = 1.;
33 deltaP = 0.;
34 posX=0;
35 posY=0;
36 posZ=0;
37
38 particleGun = new G4ParticleGun(1);
39 isGenbes = true;
40 HEPEvt = 0;
41 generatorName = "tester";
42 //TESTER parameters passed by this messenger
43 messenger = new BesPrimaryGeneratorMessenger(this);
44
45 if(generatorName == "cosmic")
46 {
47 std::string path = getenv("GENSIMROOT");
48 G4cout<<"path: "<<path<<G4endl;
49
50 path += "/root/";
51 std::string pFile = path + "ppdc.root";
52 std::string thetaFile = path + "theta.root";
53 std::string phiFile = path +"phi.root";
54
55 TFile* f1 = new TFile(pFile.c_str());
56 h1 = (TH1F*)f1->Get("htemp");
57
58 TFile* f2 = new TFile(thetaFile.c_str());
59 h2 = (TH1F*)f2->Get("htemp");
60
61 TFile* f3 = new TFile(phiFile.c_str());
62 h3 = (TH1F*)f3->Get("htemp");
63
64 //ftest = new TFile("ftest.root","recreate");
65 //tuple = new TNtuple("test","test","p:theta:phi");
66 //counter = 0;
67 }
68}
TFile * f1

◆ ~BesPrimaryGeneratorAction() [1/2]

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction ( )

Definition at line 70 of file BesPrimaryGeneratorAction.cc.

71{
72 delete particleGun;
73 if(messenger) delete messenger;
74 if(generatorName=="genbes")delete HEPEvt;
75}

◆ BesPrimaryGeneratorAction() [2/2]

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction ( )

◆ ~BesPrimaryGeneratorAction() [2/2]

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction ( )

Member Function Documentation

◆ GeneratePrimaries() [1/2]

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  anEvent)

Definition at line 77 of file BesPrimaryGeneratorAction.cc.

78{
79 if(generatorName=="tester")
80 {
81 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
82 G4ParticleDefinition* particle
83 = particleTable->FindParticle(particleName);
84 particleGun->SetParticleDefinition(particle);
85 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ));
86
87 //set TESTER parameters
88 for(G4int i=0; i<nParticle; i++)
89 {
90 G4double pMag = pMomentum;
91 //randomize p
92 if(deltaP>0.)pMag = pMomentum - deltaP*(1.0 - 2.0*G4UniformRand());
93 pMag = pMag*GeV;
94 //randomize cos(theta)
95 G4double costheta = minCos +(maxCos - minCos)*G4UniformRand();
96 //randomize phi
97 G4double phi = phiStart+(phiEnd-phiStart)*G4UniformRand();
98 phi = phi*degree;
99 G4double sintheta = sqrt(1.-costheta*costheta);
100 //computer 3-vector momentum
101 G4ParticleMomentum aMomentum;
102 aMomentum[0] = pMag*sintheta*cos(phi);
103 aMomentum[1] = pMag*sintheta*sin(phi);
104 aMomentum[2] = pMag*costheta;
105 //use ParticleGun to generate event
106 particleGun->SetParticleMomentum(aMomentum);
107 particleGun->GeneratePrimaryVertex(anEvent);
108 }
109 }
110 else if(generatorName=="cosmic")
111 {
112 G4cout<<"generatorName: "<<generatorName<<G4endl;
113 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
114 G4ParticleDefinition* particle
115 = particleTable->FindParticle(particleName);
116 G4cout<<"particleName: "<<particleName<<G4endl;
117
118 particleGun->SetParticleDefinition(particle);
119 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ));
120
121 /*std::string path = getenv("GENSIMROOT");
122 G4cout<<"path: "<<path<<G4endl;
123
124 path += "/root/";
125 std::string pFile = path + "ppdc.root";
126 std::string thetaFile = path + "theta.root";
127 std::string phiFile = path +"phi.root";*/
128
129 //TFile* f1 = new TFile(pFile.c_str());
130 //H1F* h1 = (TH1F*)f1->Get("htemp");
131 G4double pMag = h1->GetRandom()*GeV;
132 G4cout<<"pMag: "<<pMag<<G4endl;
133 //f1->Close();
134
135 //TFile* f2 = new TFile(thetaFile.c_str());
136 //TH1F* h2 = (TH1F*)f2->Get("htemp");
137 //randomize cos(theta)
138 G4double theta =(Double_t)h2->GetRandom();
139 G4cout<<"theta: "<<theta<<G4endl;
140 G4double costheta = cos(theta);
141 //f2->Close();
142
143 //TFile* f3 = new TFile(phiFile.c_str());
144 //TH1F* h3 = (TH1F*)f3->Get("htemp");
145 //randomize phi
146 G4double phi = (Double_t)h3->GetRandom();
147 G4cout<<"phi: "<<phi<<G4endl;
148 //f3->Close();
149
150 //f1->Close();
151 //f2->Close();
152 //f3->Close();
153 //ftest->ReOpen("update");
154 //tuple->Fill(pMag,theta,phi);
155 //counter++;
156 //if(counter==2000)
157 // tuple->Write();
158
159 G4double sintheta = sqrt(1.-costheta*costheta);
160 //computer 3-vector momentum
161 G4ParticleMomentum aMomentum;
162 aMomentum[0] = pMag*sintheta*cos(phi);
163 aMomentum[1] = pMag*sintheta*sin(phi);
164 aMomentum[2] = pMag*costheta;
165 //use ParticleGun to generate event
166 particleGun->SetParticleMomentum(aMomentum);
167 particleGun->GeneratePrimaryVertex(anEvent);
168 }
169
170 else if(generatorName=="genbes")
171 {
172 G4cout<<"genbes called"<<G4endl;
173 if(isGenbes)
174 {
175 isGenbes=false;
176 HEPEvt=new G4HEPEvtInterface(genbesName);
177 }
178 HEPEvt->GeneratePrimaryVertex(anEvent);
179 }
180}
double sin(const BesAngle a)
double cos(const BesAngle a)

◆ GeneratePrimaries() [2/2]

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  anEvent)

◆ GetGenbesName() [1/2]

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

◆ GetGenbesName() [2/2]

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

Definition at line 39 of file Simulation/BOOST/GenSim/GenSim-00-00-07/GenSim/BesPrimaryGeneratorAction.hh.

39{return genbesName;}

◆ GetGeneratorName() [1/2]

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

◆ GetGeneratorName() [2/2]

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

Definition at line 37 of file Simulation/BOOST/GenSim/GenSim-00-00-07/GenSim/BesPrimaryGeneratorAction.hh.

37{return generatorName;}

◆ SetDeltaP() [1/2]

void BesPrimaryGeneratorAction::SetDeltaP ( G4double  dp)
inline

◆ SetDeltaP() [2/2]

void BesPrimaryGeneratorAction::SetDeltaP ( G4double  dp)
inline

◆ SetGenbesName() [1/2]

void BesPrimaryGeneratorAction::SetGenbesName ( G4String  genbesNew)
inline

Definition at line 40 of file InstallArea/include/GenSim/GenSim/BesPrimaryGeneratorAction.hh.

40{genbesName=genbesNew;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetGenbesName() [2/2]

void BesPrimaryGeneratorAction::SetGenbesName ( G4String  genbesNew)
inline

Definition at line 40 of file Simulation/BOOST/GenSim/GenSim-00-00-07/GenSim/BesPrimaryGeneratorAction.hh.

40{genbesName=genbesNew;}

◆ SetGeneratorName() [1/2]

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String  genNew)
inline

Definition at line 38 of file InstallArea/include/GenSim/GenSim/BesPrimaryGeneratorAction.hh.

38{generatorName=genNew;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetGeneratorName() [2/2]

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String  genNew)
inline

Definition at line 38 of file Simulation/BOOST/GenSim/GenSim-00-00-07/GenSim/BesPrimaryGeneratorAction.hh.

38{generatorName=genNew;}

◆ SetMaxCos() [1/2]

void BesPrimaryGeneratorAction::SetMaxCos ( G4double  max1)
inline

◆ SetMaxCos() [2/2]

void BesPrimaryGeneratorAction::SetMaxCos ( G4double  max1)
inline

◆ SetMinCos() [1/2]

void BesPrimaryGeneratorAction::SetMinCos ( G4double  min1)
inline

◆ SetMinCos() [2/2]

void BesPrimaryGeneratorAction::SetMinCos ( G4double  min1)
inline

◆ SetMomentum() [1/2]

void BesPrimaryGeneratorAction::SetMomentum ( G4double  pm)
inline

◆ SetMomentum() [2/2]

void BesPrimaryGeneratorAction::SetMomentum ( G4double  pm)
inline

◆ SetNParticle() [1/2]

void BesPrimaryGeneratorAction::SetNParticle ( G4int  np)
inline

◆ SetNParticle() [2/2]

void BesPrimaryGeneratorAction::SetNParticle ( G4int  np)
inline

◆ SetParticleName() [1/2]

void BesPrimaryGeneratorAction::SetParticleName ( G4String  pname)
inline

Definition at line 42 of file InstallArea/include/GenSim/GenSim/BesPrimaryGeneratorAction.hh.

42{particleName = pname;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetParticleName() [2/2]

void BesPrimaryGeneratorAction::SetParticleName ( G4String  pname)
inline

Definition at line 42 of file Simulation/BOOST/GenSim/GenSim-00-00-07/GenSim/BesPrimaryGeneratorAction.hh.

42{particleName = pname;}

◆ SetPhiEnd() [1/2]

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double  pe)
inline

◆ SetPhiEnd() [2/2]

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double  pe)
inline

◆ SetPhiStart() [1/2]

void BesPrimaryGeneratorAction::SetPhiStart ( G4double  ps)
inline

◆ SetPhiStart() [2/2]

void BesPrimaryGeneratorAction::SetPhiStart ( G4double  ps)
inline

◆ SetPosX() [1/2]

void BesPrimaryGeneratorAction::SetPosX ( G4double  x)
inline

◆ SetPosX() [2/2]

void BesPrimaryGeneratorAction::SetPosX ( G4double  x)
inline

◆ SetPosY() [1/2]

void BesPrimaryGeneratorAction::SetPosY ( G4double  y)
inline

◆ SetPosY() [2/2]

void BesPrimaryGeneratorAction::SetPosY ( G4double  y)
inline

◆ SetPosZ() [1/2]

void BesPrimaryGeneratorAction::SetPosZ ( G4double  z)
inline

◆ SetPosZ() [2/2]

void BesPrimaryGeneratorAction::SetPosZ ( G4double  z)
inline

The documentation for this class was generated from the following files: