12#include "../Eepipi/Eepipi.h"
13#include "../Eepipi/EepipiRandom.h"
14#include "BesKernel/IBesRndmGenSvc.h"
17#include "HepMC/GenEvent.h"
18#include "HepMC/GenParticle.h"
19#include "HepMC/GenVertex.h"
21#include "GaudiKernel/AlgFactory.h"
22#include "GaudiKernel/DataSvc.h"
23#include "GaudiKernel/ISvcLocator.h"
24#include "GaudiKernel/MsgStream.h"
25#include "GaudiKernel/SmartDataPtr.h"
27#include "CLHEP/Vector/LorentzVector.h"
28#include "GeneratorObject/McGenEvent.h"
29#include "cfortran/cfortran.h"
43#define MOMSET COMMON_BLOCK( MOMSET_DEF, momset )
50#define BEAMENERGY COMMON_BLOCK( BEAMENERGY_DEF, beamenergy )
72#define GEVENT( NEVENTS ) CCALLSFSUB1( GEVENT, gevent, INT, NEVENTS )
75 : Algorithm( name, pSvcLocator ) {
76 declareProperty(
"Ecms", m_Ecms = 3.65 );
81 MsgStream log(
msgSvc(), name() );
83 log << MSG::INFO <<
"Eepipi initialize" << endmsg;
86 static const bool CREATEIFNOTTHERE(
true );
87 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
88 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
90 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endmsg;
93 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine(
"Eepipi" );
94 std::cout <<
"===============================" << engine << endl;
102 std::cout <<
"m_evtMax = " << m_evtMax << std::endl;
106 return StatusCode::SUCCESS;
109static int evtgen = 1;
111 MsgStream log(
msgSvc(), name() );
114 int pid1, pid2, pid3, pid4, pst1, pst2;
123 GenEvent* evt =
new GenEvent( 1, 1 );
125 GenVertex* prod_vtx =
new GenVertex();
127 evt->add_vertex( prod_vtx );
131 new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
134 p->suggest_barcode( ++npart );
135 prod_vtx->add_particle_in( p );
139 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
143 p->suggest_barcode( ++npart );
144 prod_vtx->add_particle_in( p );
147 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
150 p->suggest_barcode( ++npart );
151 prod_vtx->add_particle_out( p );
154 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
157 p->suggest_barcode( ++npart );
158 prod_vtx->add_particle_out( p );
161 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p3[1][evtgen],
MOMSET.p3[2][evtgen],
164 p->suggest_barcode( ++npart );
165 prod_vtx->add_particle_out( p );
168 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
171 p->suggest_barcode( ++npart );
172 prod_vtx->add_particle_out( p );
176 if ( log.level() < MSG::INFO ) { evt->print(); }
179 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(),
"/Event/Gen" );
183 MsgStream log(
msgSvc(), name() );
184 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endmsg;
185 McGenEvent* mcEvent =
new McGenEvent( evt );
186 anMcCol->push_back( mcEvent );
192 McGenEvent* mcEvent =
new McGenEvent( evt );
193 mcColl->push_back( mcEvent );
194 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen", mcColl );
195 if ( sc != StatusCode::SUCCESS )
197 log << MSG::ERROR <<
"Could not register McGenEvent" << endmsg;
201 return StatusCode::FAILURE;
210 return StatusCode::SUCCESS;
214 MsgStream log(
msgSvc(), name() );
216 strcpy( delcmd,
"cat " );
217 strcat( delcmd,
"fresult.dat" );
220 std::cout <<
"Eepipi finalized" << endl;
221 return StatusCode::SUCCESS;
225 IProperty* appPropMgr = 0;
227 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
228 reinterpret_cast<IInterface*&
>( appPropMgr ) );
229 if ( status.isFailure() )
return status;
231 IntegerProperty evtMax(
"EvtMax", 0 );
232 status = appPropMgr->getProperty( &evtMax );
233 if ( status.isFailure() )
return status;
235 m_evtMax = evtMax.value();
COMMON_BLOCK_DEF(MOMSET_DEF, MOMSET)
ObjectVector< McGenEvent > McGenEventCol
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Eepipi(const string &name, ISvcLocator *pSvcLocator)
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)