25 {
26 info() << "Initializing DummyParticleGun" << endmsg;
27
28 StatusCode sc = Transformer::initialize();
29 if ( !sc.isSuccess() ) return sc;
30
31
32 if ( m_parts.size() == 0 )
33 {
34 error() <<
"No PDG codes specified" << endmsg;
35 return StatusCode::FAILURE;
36 }
37
38 if ( m_p_range.size() != 2 )
39 {
40 error() <<
"Momentum range must be of size 2" << endmsg;
41 return StatusCode::FAILURE;
42 }
43
44 if ( m_costheta_range.size() != 2 )
45 {
46 error() <<
"Cos(theta) range must be of size 2" << endmsg;
47 return StatusCode::FAILURE;
48 }
49
50 if ( m_phi_range.size() != 2 )
51 {
52 error() <<
"Phi range must be of size 2" << endmsg;
53 return StatusCode::FAILURE;
54 }
55
56
57 m_p1 = m_p_range[0];
58 m_p2 = m_p_range[1];
59 m_costheta1 = m_costheta_range[0];
60 m_costheta2 = m_costheta_range[1];
61 m_phi1 = m_phi_range[0];
62 m_phi2 = m_phi_range[1];
63
64 if ( m_p2 <= m_p1 ) m_p2 = m_p1;
65 if ( m_costheta2 <= m_costheta1 ) m_costheta2 = m_costheta1;
66 if ( m_phi2 <= m_phi1 ) m_phi2 = m_phi1;
67
68
69 m_rndm_svc = service<IBesRndmGenSvc>( "BesRndmGenSvc" );
70 if ( !m_rndm_svc )
71 {
72 error() <<
"Could not get random number service" << endmsg;
73 return StatusCode::FAILURE;
74 }
75
76 m_rndm_engine = m_rndm_svc->GetEngine( "DummyParticleGun" );
77 if ( !m_rndm_engine )
78 {
79 error() <<
"Could not get random engine" << endmsg;
80 return StatusCode::FAILURE;
81 }
82
83
84 auto part_prop_svc = service<IPartPropSvc>( "PartPropSvc" );
85 if ( !part_prop_svc )
86 {
87 error() <<
"Could not get Particle Properties Service" << endmsg;
88 return StatusCode::FAILURE;
89 }
90
91 m_particle_table = part_prop_svc->PDT();
92 if ( !m_particle_table )
93 {
94 error() <<
"Could not get Particle Data Table" << endmsg;
95 return StatusCode::FAILURE;
96 }
97
98 return StatusCode::SUCCESS;
99 }