12#include "../Eepipi/Eepipi.h"
13#include "../Eepipi/EepipiRandom.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"
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)
58#define COSEE COMMON_BLOCK(COSEE_DEF, cosee)
65#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
87#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
90Eepipi::Eepipi(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
92 declareProperty(
"Ecms", m_Ecms = 3.65);
94 declareProperty(
"WriteMC", m_mctruth = 0);
99 MsgStream log(messageService(), name());
101 log << MSG::INFO <<
"Eepipi initialize" << endreq;
104 static const bool CREATEIFNOTTHERE(
true);
105 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
106 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
108 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
111 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Eepipi");
112 std::cout<<
"==============================="<<engine<<endl;
117 COSEE.setcos=m_cosee;
121 std::cout<<
"m_evtMax = "<<m_evtMax<<std::endl;
125 return StatusCode::SUCCESS;
131 MsgStream log(messageService(), name());
135 int pid1,pid2,pid3,pid4,pst1,pst2;
146 GenEvent* evt =
new GenEvent(1,1);
148 GenVertex* prod_vtx =
new GenVertex();
150 evt->add_vertex( prod_vtx );
153 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
156 p->suggest_barcode( ++npart );
157 prod_vtx->add_particle_in(p);
161 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
165 p->suggest_barcode( ++npart );
166 prod_vtx->add_particle_in(p);
169 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
172 p->suggest_barcode( ++npart );
173 prod_vtx->add_particle_out(p);
176 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
179 p->suggest_barcode( ++npart );
180 prod_vtx->add_particle_out(p);
183 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p3[1][evtgen],
MOMSET.p3[2][evtgen],
186 p->suggest_barcode( ++npart );
187 prod_vtx->add_particle_out(p);
190 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
193 p->suggest_barcode( ++npart );
194 prod_vtx->add_particle_out(p);
200 if( log.level() < MSG::INFO )
206 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
210 MsgStream log(messageService(), name());
211 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
213 anMcCol->push_back(mcEvent);
220 mcColl->push_back(mcEvent);
221 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
222 if (sc != StatusCode::SUCCESS)
224 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
228 return StatusCode::FAILURE;
236 return StatusCode::SUCCESS;
241 MsgStream log(messageService(), name());
243 strcpy(delcmd,
"cat ");
244 strcat(delcmd,
"fresult.dat");
247 std::cout<<
"Eepipi finalized" << endl;
248 return StatusCode::SUCCESS;
252 IProperty* appPropMgr=0;
254 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
255 reinterpret_cast<IInterface*&
>( appPropMgr ));
256 if( status.isFailure() )
return status;
258 IntegerProperty evtMax(
"EvtMax",0);
259 status = appPropMgr->getProperty( &evtMax );
260 if (status.isFailure())
return status;
262 m_evtMax = evtMax.value();
ObjectVector< McGenEvent > McGenEventCol
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
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.