12#include "../EeToeeV/EeToeeV.h"
13#include "../EeToeeV/EeToeeVRandom.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"
42#define MOMSET COMMON_BLOCK(MOMSET_DEF, momset)
49#define BEAMENERGY COMMON_BLOCK(BEAMENERGY_DEF, beamenergy)
57#define VECTOR COMMON_BLOCK(VECTOR_DEF, vector)
64#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
87#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
90EeToeeV::EeToeeV(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
92 declareProperty(
"Ecms", m_Ecms = 3.65);
93 declareProperty(
"Vector", m_vect =
"phi");
94 declareProperty(
"WriteMC", m_mctruth = 0);
102 MsgStream log(messageService(), name());
104 log << MSG::INFO <<
"EeToeeV initialize" << endreq;
107 static const bool CREATEIFNOTTHERE(
true);
108 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
109 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
111 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
114 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"EeToeeV");
115 std::cout<<
"==============================="<<engine<<endl;
124 }
else if(m_vect==
"phi"){
127 }
else if(m_vect==
"J/psi"){
130 }
else if(m_vect==
"psi(2S)"){
133 }
else if(m_vect==
"psi(3770)"){
136 }
else if(m_vect==
"psi(4040)"){
139 }
else if(m_vect==
"psi(4160)"){
142 }
else if(m_vect==
"psi(4415)"){
146 std::cout<<
"EeToeeV::initialize() Bad vector "<<std::endl; abort();
148 if(m_Ecms<mpar){std::cout<<
"EeToeeV:initialize: the Ecms less than the vector mass"<<std::endl;abort();}
152 std::cout<<
"m_evtMax = "<<m_evtMax<<std::endl;
156 return StatusCode::SUCCESS;
162 MsgStream log(messageService(), name());
166 int pid1,pid2,pid3,pid4,pst1,pst2;
174 }
else if(m_vect==
"phi"){
176 }
else if(m_vect==
"J/psi"){
178 }
else if(m_vect==
"psi(2S)"){
180 }
else if(m_vect==
"psi(3770)"){
182 }
else if(m_vect==
"psi(4040)"){
184 }
else if(m_vect==
"psi(4160)"){
186 }
else if(m_vect==
"psi(4415)"){
191 GenEvent* evt =
new GenEvent(1,1);
193 GenVertex* prod_vtx =
new GenVertex();
195 evt->add_vertex( prod_vtx );
198 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
201 p->suggest_barcode( ++npart );
202 prod_vtx->add_particle_in(p);
206 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
210 p->suggest_barcode( ++npart );
211 prod_vtx->add_particle_in(p);
214 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
217 p->suggest_barcode( ++npart );
218 prod_vtx->add_particle_out(p);
221 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
224 p->suggest_barcode( ++npart );
225 prod_vtx->add_particle_out(p);
228 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
231 p->suggest_barcode( ++npart );
232 prod_vtx->add_particle_out(p);
236 if( log.level() < MSG::INFO )
242 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
246 MsgStream log(messageService(), name());
247 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
249 anMcCol->push_back(mcEvent);
257 mcColl->push_back(mcEvent);
258 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
259 if (sc != StatusCode::SUCCESS)
261 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
265 return StatusCode::FAILURE;
273 return StatusCode::SUCCESS;
278 MsgStream log(messageService(), name());
280 strcpy(delcmd,
"cat ");
281 strcat(delcmd,
"fresult.dat");
284 std::cout<<
"EeToeeV finalized" << endl;
285 return StatusCode::SUCCESS;
289 IProperty* appPropMgr=0;
291 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
292 reinterpret_cast<IInterface*&
>( appPropMgr ));
293 if( status.isFailure() )
return status;
295 IntegerProperty evtMax(
"EvtMax",0);
296 status = appPropMgr->getProperty( &evtMax );
297 if (status.isFailure())
return status;
299 m_evtMax = evtMax.value();
ObjectVector< McGenEvent > McGenEventCol
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
EeToeeV(const string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.