CGEM BOSS 6.6.5.h
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)
 

Detailed Description

Definition at line 26 of file BesPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ BesPrimaryGeneratorAction()

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

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}

Member Function Documentation

◆ GeneratePrimaries()

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)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213

◆ GetGenbesName()

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

Definition at line 39 of file BesPrimaryGeneratorAction.hh.

39{return genbesName;}

Referenced by BesPrimaryGeneratorMessenger::GetCurrentValue().

◆ GetGeneratorName()

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

Definition at line 37 of file BesPrimaryGeneratorAction.hh.

37{return generatorName;}

Referenced by BesPrimaryGeneratorMessenger::GetCurrentValue().

◆ SetDeltaP()

void BesPrimaryGeneratorAction::SetDeltaP ( G4double dp)
inline

Definition at line 48 of file BesPrimaryGeneratorAction.hh.

48{deltaP = dp;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetGenbesName()

void BesPrimaryGeneratorAction::SetGenbesName ( G4String genbesNew)
inline

Definition at line 40 of file BesPrimaryGeneratorAction.hh.

40{genbesName=genbesNew;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetGeneratorName()

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String genNew)
inline

Definition at line 38 of file BesPrimaryGeneratorAction.hh.

38{generatorName=genNew;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetMaxCos()

void BesPrimaryGeneratorAction::SetMaxCos ( G4double max1)
inline

Definition at line 44 of file BesPrimaryGeneratorAction.hh.

44{maxCos = max1;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetMinCos()

void BesPrimaryGeneratorAction::SetMinCos ( G4double min1)
inline

Definition at line 43 of file BesPrimaryGeneratorAction.hh.

43{minCos = min1;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetMomentum()

void BesPrimaryGeneratorAction::SetMomentum ( G4double pm)
inline

Definition at line 47 of file BesPrimaryGeneratorAction.hh.

47{pMomentum = pm;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetNParticle()

void BesPrimaryGeneratorAction::SetNParticle ( G4int np)
inline

Definition at line 41 of file BesPrimaryGeneratorAction.hh.

41{nParticle = np;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetParticleName()

void BesPrimaryGeneratorAction::SetParticleName ( G4String pname)
inline

Definition at line 42 of file BesPrimaryGeneratorAction.hh.

42{particleName = pname;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetPhiEnd()

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double pe)
inline

Definition at line 46 of file BesPrimaryGeneratorAction.hh.

46{phiEnd = pe;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetPhiStart()

void BesPrimaryGeneratorAction::SetPhiStart ( G4double ps)
inline

Definition at line 45 of file BesPrimaryGeneratorAction.hh.

45{phiStart =ps;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetPosX()

void BesPrimaryGeneratorAction::SetPosX ( G4double x)
inline

Definition at line 49 of file BesPrimaryGeneratorAction.hh.

49{posX = x;}
Double_t x[10]

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetPosY()

void BesPrimaryGeneratorAction::SetPosY ( G4double y)
inline

Definition at line 50 of file BesPrimaryGeneratorAction.hh.

50{posY = y;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().

◆ SetPosZ()

void BesPrimaryGeneratorAction::SetPosZ ( G4double z)
inline

Definition at line 51 of file BesPrimaryGeneratorAction.hh.

51{posZ = z;}

Referenced by BesPrimaryGeneratorMessenger::SetNewValue().


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