12#include "../Eepipi/Eepipi.h"
13#include "../Eepipi/EepipiRandom.h"
14#include "BesKernel/IBesRndmGenSvc.h"
17#include "HepMC/GenEvent.h"
18#include "HepMC/GenVertex.h"
19#include "HepMC/GenParticle.h"
21#include "GaudiKernel/MsgStream.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/AlgFactory.h"
24#include "GaudiKernel/DataSvc.h"
25#include "GaudiKernel/SmartDataPtr.h"
27#include "GeneratorObject/McGenEvent.h"
28#include "CLHEP/Vector/LorentzVector.h"
29#include "cfortran/cfortran.h"
43#define MOMSET COMMON_BLOCK(MOMSET_DEF, momset)
50#define BEAMENERGY COMMON_BLOCK(BEAMENERGY_DEF, beamenergy)
74#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
77Eepipi::Eepipi(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
79 declareProperty(
"Ecms", m_Ecms = 3.65);
84 MsgStream log(messageService(), name());
86 log << MSG::INFO <<
"Eepipi initialize" << endreq;
89 static const bool CREATEIFNOTTHERE(
true);
90 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
91 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
93 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
96 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Eepipi");
97 std::cout<<
"==============================="<<engine<<endl;
105 std::cout<<
"m_evtMax = "<<m_evtMax<<std::endl;
109 return StatusCode::SUCCESS;
115 MsgStream log(messageService(), name());
119 int pid1,pid2,pid3,pid4,pst1,pst2;
130 GenEvent* evt =
new GenEvent(1,1);
132 GenVertex* prod_vtx =
new GenVertex();
134 evt->add_vertex( prod_vtx );
137 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
140 p->suggest_barcode( ++npart );
141 prod_vtx->add_particle_in(p);
145 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
149 p->suggest_barcode( ++npart );
150 prod_vtx->add_particle_in(p);
153 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
156 p->suggest_barcode( ++npart );
157 prod_vtx->add_particle_out(p);
160 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
163 p->suggest_barcode( ++npart );
164 prod_vtx->add_particle_out(p);
167 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p3[1][evtgen],
MOMSET.p3[2][evtgen],
170 p->suggest_barcode( ++npart );
171 prod_vtx->add_particle_out(p);
174 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
177 p->suggest_barcode( ++npart );
178 prod_vtx->add_particle_out(p);
184 if( log.level() < MSG::INFO )
190 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
194 MsgStream log(messageService(), name());
195 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
197 anMcCol->push_back(mcEvent);
204 mcColl->push_back(mcEvent);
205 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
206 if (sc != StatusCode::SUCCESS)
208 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
212 return StatusCode::FAILURE;
220 return StatusCode::SUCCESS;
225 MsgStream log(messageService(), name());
227 strcpy(delcmd,
"cat ");
228 strcat(delcmd,
"fresult.dat");
231 std::cout<<
"Eepipi finalized" << endl;
232 return StatusCode::SUCCESS;
236 IProperty* appPropMgr=0;
238 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
239 reinterpret_cast<IInterface*&
>( appPropMgr ));
240 if( status.isFailure() )
return status;
242 IntegerProperty evtMax(
"EvtMax",0);
243 status = appPropMgr->getProperty( &evtMax );
244 if (status.isFailure())
return status;
246 m_evtMax = evtMax.value();
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
ObjectVector< McGenEvent > McGenEventCol
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Eepipi(const string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.