BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
SingleParticleGun Class Reference

#include <SingleParticleGun.h>

+ Inheritance diagram for SingleParticleGun:

Public Member Functions

 SingleParticleGun (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~SingleParticleGun ()
 
virtual StatusCode genInitialize ()
 
virtual StatusCode callGenerator ()
 
virtual StatusCode genFinalize ()
 
virtual StatusCode fillEvt (GenEvent *evt)
 
 SingleParticleGun (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~SingleParticleGun ()
 
virtual StatusCode genInitialize ()
 
virtual StatusCode callGenerator ()
 
virtual StatusCode genFinalize ()
 
virtual StatusCode fillEvt (GenEvent *evt)
 
- Public Member Functions inherited from GenModule
 GenModule (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~GenModule ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
virtual StatusCode genInitialize ()
 
virtual StatusCode genuserInitialize ()
 
virtual StatusCode callGenerator ()
 
virtual StatusCode genFinalize ()
 
virtual StatusCode fillEvt (GenEvent *evt)
 
 GenModule (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~GenModule ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
virtual StatusCode genInitialize ()
 
virtual StatusCode genuserInitialize ()
 
virtual StatusCode callGenerator ()
 
virtual StatusCode genFinalize ()
 
virtual StatusCode fillEvt (GenEvent *evt)
 

Additional Inherited Members

- Protected Member Functions inherited from GenModule
void StripPartonsInit (void)
 
void StripPartons (GenEvent *evt)
 
void StripPartonsInit (void)
 
void StripPartons (GenEvent *evt)
 
- Protected Attributes inherited from GenModule
bool m_fixedMode
 
double m_meanInteractions
 
int m_randomSeed
 
std::vector< int > m_AllPartons
 
std::vector< int > m_StripVector
 
bool m_StripPartonSwitch
 
CLHEP::HepRandomEngine * m_pRandomEngine
 
CLHEP::RandPoisson * m_pPoissonGenerator
 
HepPDT::ParticleDataTable * m_particleTable
 

Detailed Description

Constructor & Destructor Documentation

◆ SingleParticleGun() [1/2]

SingleParticleGun::SingleParticleGun ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 33 of file SingleParticleGun.cxx.

34 : GenModule(name,pSvcLocator)
35{
36//--------------------------------------------------------------------------
37 declareProperty("Mode",m_Emode = SingleEnergyMode::PtMode);
38 // in PtMode user specifies Pt theta and phi
39 // in EMode user specifies E, theta and phi
40 // defaults are set so that something is always generated
41
42 declareProperty("Pt",m_requestedPt = 5.0);
43 declareProperty("E",m_requestedE = 5.0);
44 declareProperty("Phi",m_requestedPhi = 0.0);
45 declareProperty("Theta",m_requestedTheta = 3.14/4.0);
46
47 declareProperty("VertexX",m_requestedX = 0.0);
48 declareProperty("VertexY",m_requestedY = 0.0);
49 declareProperty("VertexZ",m_requestedZ = 0.0);
50 declareProperty("Time",m_requestedT = 0.0);
51
52 declareProperty("MinPt",m_minPt = 1.);
53 declareProperty("MinE",m_minE = 1.);
54 declareProperty("MinTheta",m_minTheta = 0.);
55 declareProperty("MinPhi",m_minPhi = 0.);
56
57 declareProperty("MaxPt",m_maxPt = 100.);
58 declareProperty("MaxE",m_maxE = 100.);
59 declareProperty("MaxTheta",m_maxTheta=CLHEP::pi);
60 declareProperty("MaxPhi",m_maxPhi = CLHEP::twopi);
61
62 declareProperty("SigmaPt",m_sigmaPt = 0.1);
63 declareProperty("SigmaE",m_sigmaE = 0.1);
64
65 declareProperty("SigmaTheta",m_sigmaTheta= 0.1);
66 declareProperty("SigmaPhi",m_sigmaPhi = 0.1);
67
68 declareProperty("ModePt",m_PtGenMode = SingleParticleGunGenMode::FixedMode);
69 declareProperty("ModeE",m_EGenMode = SingleParticleGunGenMode::FixedMode);
70 declareProperty("ModeTheta",m_ThetaGenMode=SingleParticleGunGenMode::FixedMode);
71
72 declareProperty("ModePhi",m_PhiGenMode=SingleParticleGunGenMode::FixedMode);
73 // specifies type of distribution
74
75 declareProperty("PdgCode",m_pdgCode=211);
76}

◆ ~SingleParticleGun() [1/2]

SingleParticleGun::~SingleParticleGun ( )
virtual

Definition at line 79 of file SingleParticleGun.cxx.

79 {
80//--------------------------------------------------------------------------
81// if(m_pFlatGenerator) delete m_pFlatGenerator;
82// if(m_pGaussGenerator) delete m_pGaussGenerator;
83}

◆ SingleParticleGun() [2/2]

SingleParticleGun::SingleParticleGun ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

◆ ~SingleParticleGun() [2/2]

virtual SingleParticleGun::~SingleParticleGun ( )
virtual

Member Function Documentation

◆ callGenerator() [1/2]

StatusCode SingleParticleGun::callGenerator ( )
virtual

Reimplemented from GenModule.

Definition at line 156 of file SingleParticleGun.cxx.

156 {
157//---------------------------------------------------------------------------
158
159 ++m_events;
160 // Save the random number seeds in the event
161 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("SINGLE");
162 const long* s = engine->getSeeds();
163 m_seeds.clear();
164 m_seeds.push_back(s[0]);
165 m_seeds.push_back(s[1]);
166
167 // Generate values for pt, theta and phi
168 //
169 double pt,phi,theta,E,px,py,pz,p;
170 switch(m_Emode){
171
173 pt = generateValue(m_PtGenMode,m_requestedPt, m_sigmaPt,
174 m_minPt, m_maxPt);
175 theta = generateValue(m_ThetaGenMode,m_requestedTheta, m_sigmaTheta,
176 m_minTheta, m_maxTheta);
177 phi = generateValue(m_PhiGenMode,m_requestedPhi, m_sigmaPhi,
178 m_minPhi, m_maxPhi);
179
180 // Transform to x,y,z coordinates
181 //
182 px = pt*cos(phi);
183 py = pt*sin(phi);
184 pz = pt/tan(theta);
185 m_fourMom.setVectM(CLHEP::Hep3Vector(px,py,pz),m_mass);
186 m_fourPos.set(m_requestedX,m_requestedY,m_requestedZ,m_requestedT);
187 return StatusCode::SUCCESS;
188
190 E = generateValue(m_EGenMode,m_requestedE, m_sigmaE,
191 m_minE, m_maxE);
192 theta = generateValue(m_ThetaGenMode,m_requestedTheta, m_sigmaTheta,
193 m_minTheta, m_maxTheta);
194 phi = generateValue(m_PhiGenMode,m_requestedPhi, m_sigmaPhi,
195 m_minPhi, m_maxPhi);
196
197 // Transform to x,y,z coordinates
198 //
199 if(E*E-m_mass*m_mass < 0.){
200 MsgStream log(messageService(), name());
201 log << MSG::ERROR << "You have Generated a Tachyon!! Increase energy or change particle ID" << endreq;
202return StatusCode::FAILURE;
203 }
204 p=sqrt(E*E-m_mass*m_mass);
205 px = p*sin(theta)*cos(phi);
206 py = p*sin(theta)*sin(phi);
207 pz = p*cos(theta);
208
209 m_fourMom.setVectM(CLHEP::Hep3Vector(px,py,pz),m_mass);
210 m_fourPos.set(m_requestedX,m_requestedY,m_requestedZ,m_requestedT);
211 return StatusCode::SUCCESS;
212}
213 return StatusCode::SUCCESS;
214}
XmlRpcServer s
Definition: HelloServer.cpp:11
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.

◆ callGenerator() [2/2]

virtual StatusCode SingleParticleGun::callGenerator ( )
virtual

Reimplemented from GenModule.

◆ fillEvt() [1/2]

StatusCode SingleParticleGun::fillEvt ( GenEvent *  evt)
virtual

Reimplemented from GenModule.

Definition at line 223 of file SingleParticleGun.cxx.

223 {
224//---------------------------------------------------------------------------
225 // Note: The vertex is owned by the event so the event is responsible
226 // for deleting its memory
227 evt->set_event_number(m_events); // Set the event number
228 GenVertex* v1 = new GenVertex(m_fourPos);
229
230 std::cout << " SingleParticleGun::fillEvt --> " <<std::endl;
231 std::cout << " Event number:: " << m_events << std::endl;
232 std::cout << " vertex.x = " << m_fourPos.x()
233 << " vertex.y = " << m_fourPos.y()
234 << " vertex.z = " << m_fourPos.z()
235 << " vertex.t = " << m_fourPos.t() << std::endl;
236
237 std::cout << " momentum.x = " << m_fourMom.x()
238 << " momentum.y = " << m_fourMom.y()
239 << " momentum.z = " << m_fourMom.z()
240 << " momentum.t = " << m_fourMom.t() << std::endl;
241
242 evt->add_vertex( v1 );
243
244
245 v1->add_particle_out( new GenParticle( m_fourMom, m_pdgCode,1) );
246
247 std::cout << " particles_size = " << evt->particles_size()
248 << " vertices_size = " << evt->vertices_size()
249 << std::endl;
250
251 evt->set_signal_process_id(SINGLE);
252 evt->set_random_states(m_seeds);
253
254 return StatusCode::SUCCESS;
255}

◆ fillEvt() [2/2]

virtual StatusCode SingleParticleGun::fillEvt ( GenEvent *  evt)
virtual

Reimplemented from GenModule.

◆ genFinalize() [1/2]

StatusCode SingleParticleGun::genFinalize ( )
virtual

Reimplemented from GenModule.

Definition at line 217 of file SingleParticleGun.cxx.

217 {
218//---------------------------------------------------------------------------
219 return StatusCode::SUCCESS;
220}

◆ genFinalize() [2/2]

virtual StatusCode SingleParticleGun::genFinalize ( )
virtual

Reimplemented from GenModule.

◆ genInitialize() [1/2]

StatusCode SingleParticleGun::genInitialize ( )
virtual

Reimplemented from GenModule.

Definition at line 86 of file SingleParticleGun.cxx.

86 {
87//---------------------------------------------------------------------------
88
89 // Create the flat and gaussian generators
90 //
91
92 MsgStream log(messageService(), name());
93
94 static const bool CREATEIFNOTTHERE(true);
95 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
96 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
97 {
98 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
99 return RndmStatus;
100 }
101
102 // Get the mass of the particle to be generated
103 //
104 const HepPDT::ParticleData* particle = m_particleTable->particle(HepPDT::ParticleID(abs(m_pdgCode)));
105 m_mass = particle->mass().value();
106
107 //
108 // Make sure the parameters are in a sensible range...
109 //
110 switch (m_Emode){
112 if(!m_PtGenMode && (m_minPt > m_requestedPt || m_maxPt < m_requestedPt)
113 || m_maxPt < m_minPt ) {
114 log << MSG:: ERROR << " Pt min and max out of range. \n" <<
115 " Will set Pt mode to Fixed!!!" << endreq;
117 }
118 if(!m_ThetaGenMode && (m_minTheta > m_requestedTheta || m_maxTheta < m_requestedTheta)
119 || m_maxTheta < m_minTheta ) {
120 log << MSG:: ERROR << " Theta min and max out of range. \n" <<
121 " Will set Theta mode to Fixed!!!" << endreq;
123 }
124 if(!m_PhiGenMode && (m_minPhi > m_requestedPhi || m_maxPhi < m_requestedPhi)
125 || m_maxPhi < m_minPhi ) {
126 log << MSG:: ERROR << " Phi min and max out of range. \n" <<
127 " Will set Phi mode to Fixed!!!" << endreq;
129 }
130 break;
132 if(!m_EGenMode && (m_minE > m_requestedE || m_maxE < m_requestedE)
133 || m_maxE < m_minE ) {
134 log << MSG:: ERROR << " E min and max out of range. \n" <<
135 " Will set E mode to Fixed!!!" << endreq;
137 }
138 if(!m_ThetaGenMode && (m_minTheta > m_requestedTheta || m_maxTheta < m_requestedTheta)
139 || m_maxTheta < m_minTheta ) {
140 log << MSG:: ERROR << " Theta min and max out of range. \n" <<
141 " Will set Theta mode to Fixed!!!" << endreq;
143 }
144 if(!m_PhiGenMode && (m_minPhi > m_requestedPhi || m_maxPhi < m_requestedPhi)
145 || m_maxPhi < m_minPhi ) {
146 log << MSG:: ERROR << " Phi min and max out of range. \n" <<
147 " Will set Phi mode to Fixed!!!" << endreq;
149 }break;
150 }
151 m_events = 0;
152 return StatusCode::SUCCESS;
153}

◆ genInitialize() [2/2]

virtual StatusCode SingleParticleGun::genInitialize ( )
virtual

Reimplemented from GenModule.


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