BOSS 8.0.0
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)
 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/3]

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction ( )

Definition at line 26 of file BesPrimaryGeneratorAction.cc.

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

◆ ~BesPrimaryGeneratorAction() [1/3]

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction ( )

Definition at line 71 of file BesPrimaryGeneratorAction.cc.

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

◆ BesPrimaryGeneratorAction() [2/3]

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction ( )

◆ ~BesPrimaryGeneratorAction() [2/3]

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction ( )

◆ BesPrimaryGeneratorAction() [3/3]

BesPrimaryGeneratorAction::BesPrimaryGeneratorAction ( )

◆ ~BesPrimaryGeneratorAction() [3/3]

BesPrimaryGeneratorAction::~BesPrimaryGeneratorAction ( )

Member Function Documentation

◆ GeneratePrimaries() [1/3]

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event * anEvent)

Definition at line 77 of file BesPrimaryGeneratorAction.cc.

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

◆ GeneratePrimaries() [2/3]

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event * anEvent)

◆ GeneratePrimaries() [3/3]

void BesPrimaryGeneratorAction::GeneratePrimaries ( G4Event * anEvent)

◆ GetGenbesName() [1/3]

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

Definition at line 36 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

36{ return genbesName; }

◆ GetGenbesName() [2/3]

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

Definition at line 36 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

36{ return genbesName; }

◆ GetGenbesName() [3/3]

G4String BesPrimaryGeneratorAction::GetGenbesName ( )
inline

Definition at line 36 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

36{ return genbesName; }

◆ GetGeneratorName() [1/3]

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

Definition at line 34 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

34{ return generatorName; }

◆ GetGeneratorName() [2/3]

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

Definition at line 34 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

34{ return generatorName; }

◆ GetGeneratorName() [3/3]

G4String BesPrimaryGeneratorAction::GetGeneratorName ( )
inline

Definition at line 34 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

34{ return generatorName; }

◆ SetDeltaP() [1/3]

void BesPrimaryGeneratorAction::SetDeltaP ( G4double dp)
inline

◆ SetDeltaP() [2/3]

void BesPrimaryGeneratorAction::SetDeltaP ( G4double dp)
inline

◆ SetDeltaP() [3/3]

void BesPrimaryGeneratorAction::SetDeltaP ( G4double dp)
inline

Definition at line 45 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

45{ deltaP = dp; }

◆ SetGenbesName() [1/3]

void BesPrimaryGeneratorAction::SetGenbesName ( G4String genbesNew)
inline

Definition at line 37 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

37{ genbesName = genbesNew; }

◆ SetGenbesName() [2/3]

void BesPrimaryGeneratorAction::SetGenbesName ( G4String genbesNew)
inline

Definition at line 37 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

37{ genbesName = genbesNew; }

◆ SetGenbesName() [3/3]

void BesPrimaryGeneratorAction::SetGenbesName ( G4String genbesNew)
inline

Definition at line 37 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

37{ genbesName = genbesNew; }

◆ SetGeneratorName() [1/3]

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String genNew)
inline

Definition at line 35 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

35{ generatorName = genNew; }

◆ SetGeneratorName() [2/3]

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String genNew)
inline

Definition at line 35 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

35{ generatorName = genNew; }

◆ SetGeneratorName() [3/3]

void BesPrimaryGeneratorAction::SetGeneratorName ( G4String genNew)
inline

Definition at line 35 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

35{ generatorName = genNew; }

◆ SetMaxCos() [1/3]

void BesPrimaryGeneratorAction::SetMaxCos ( G4double max1)
inline

Definition at line 41 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

41{ maxCos = max1; }

◆ SetMaxCos() [2/3]

void BesPrimaryGeneratorAction::SetMaxCos ( G4double max1)
inline

Definition at line 41 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

41{ maxCos = max1; }

◆ SetMaxCos() [3/3]

void BesPrimaryGeneratorAction::SetMaxCos ( G4double max1)
inline

Definition at line 41 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

41{ maxCos = max1; }

◆ SetMinCos() [1/3]

void BesPrimaryGeneratorAction::SetMinCos ( G4double min1)
inline

Definition at line 40 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

40{ minCos = min1; }

◆ SetMinCos() [2/3]

void BesPrimaryGeneratorAction::SetMinCos ( G4double min1)
inline

Definition at line 40 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

40{ minCos = min1; }

◆ SetMinCos() [3/3]

void BesPrimaryGeneratorAction::SetMinCos ( G4double min1)
inline

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

40{ minCos = min1; }

◆ SetMomentum() [1/3]

void BesPrimaryGeneratorAction::SetMomentum ( G4double pm)
inline

Definition at line 44 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

44{ pMomentum = pm; }

◆ SetMomentum() [2/3]

void BesPrimaryGeneratorAction::SetMomentum ( G4double pm)
inline

Definition at line 44 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

44{ pMomentum = pm; }

◆ SetMomentum() [3/3]

void BesPrimaryGeneratorAction::SetMomentum ( G4double pm)
inline

Definition at line 44 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

44{ pMomentum = pm; }

◆ SetNParticle() [1/3]

void BesPrimaryGeneratorAction::SetNParticle ( G4int np)
inline

Definition at line 38 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

38{ nParticle = np; }

◆ SetNParticle() [2/3]

void BesPrimaryGeneratorAction::SetNParticle ( G4int np)
inline

Definition at line 38 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

38{ nParticle = np; }

◆ SetNParticle() [3/3]

void BesPrimaryGeneratorAction::SetNParticle ( G4int np)
inline

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

38{ nParticle = np; }

◆ SetParticleName() [1/3]

void BesPrimaryGeneratorAction::SetParticleName ( G4String pname)
inline

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

39{ particleName = pname; }

◆ SetParticleName() [2/3]

void BesPrimaryGeneratorAction::SetParticleName ( G4String pname)
inline

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

39{ particleName = pname; }

◆ SetParticleName() [3/3]

void BesPrimaryGeneratorAction::SetParticleName ( G4String pname)
inline

Definition at line 39 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

39{ particleName = pname; }

◆ SetPhiEnd() [1/3]

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double pe)
inline

◆ SetPhiEnd() [2/3]

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double pe)
inline

◆ SetPhiEnd() [3/3]

void BesPrimaryGeneratorAction::SetPhiEnd ( G4double pe)
inline

Definition at line 43 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

43{ phiEnd = pe; }

◆ SetPhiStart() [1/3]

void BesPrimaryGeneratorAction::SetPhiStart ( G4double ps)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

42{ phiStart = ps; }

◆ SetPhiStart() [2/3]

void BesPrimaryGeneratorAction::SetPhiStart ( G4double ps)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-opt/include/GenSim/BesPrimaryGeneratorAction.hh.

42{ phiStart = ps; }

◆ SetPhiStart() [3/3]

void BesPrimaryGeneratorAction::SetPhiStart ( G4double ps)
inline

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

42{ phiStart = ps; }

◆ SetPosX() [1/3]

void BesPrimaryGeneratorAction::SetPosX ( G4double x)
inline

Definition at line 46 of file InstallArea/x86_64-el9-gcc13-dbg/include/GenSim/BesPrimaryGeneratorAction.hh.

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

◆ SetPosX() [2/3]

void BesPrimaryGeneratorAction::SetPosX ( G4double x)
inline

◆ SetPosX() [3/3]

void BesPrimaryGeneratorAction::SetPosX ( G4double x)
inline

◆ SetPosY() [1/3]

void BesPrimaryGeneratorAction::SetPosY ( G4double y)
inline

◆ SetPosY() [2/3]

void BesPrimaryGeneratorAction::SetPosY ( G4double y)
inline

◆ SetPosY() [3/3]

void BesPrimaryGeneratorAction::SetPosY ( G4double y)
inline

Definition at line 47 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

47{ posY = y; }

◆ SetPosZ() [1/3]

void BesPrimaryGeneratorAction::SetPosZ ( G4double z)
inline

◆ SetPosZ() [2/3]

void BesPrimaryGeneratorAction::SetPosZ ( G4double z)
inline

◆ SetPosZ() [3/3]

void BesPrimaryGeneratorAction::SetPosZ ( G4double z)
inline

Definition at line 48 of file Simulation/BOOST/GenSim/include/GenSim/BesPrimaryGeneratorAction.hh.

48{ posZ = z; }

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