12#include "../EeTo4e/EeTo4e.h"
13#include "../EeTo4e/EeTo4eRandom.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)
59#define COSEE COMMON_BLOCK(COSEE_DEF, cosee)
66#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
88#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
91EeTo4e::EeTo4e(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
93 declareProperty(
"Ecms", m_Ecms = 3.65);
94 declareProperty(
"cosee", m_cosee = 0.93);
95 declareProperty(
"WriteMC", m_mctruth = 0);
100 MsgStream log(messageService(), name());
102 log << MSG::INFO <<
"EeTo4e initialize" << endreq;
105 static const bool CREATEIFNOTTHERE(
true);
106 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
107 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
109 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
112 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"EeTo4e");
113 std::cout<<
"==============================="<<engine<<endl;
117 COSEE.setcos=m_cosee;
122 std::cout<<
"m_evtMax = "<<m_evtMax<<std::endl;
126 return StatusCode::SUCCESS;
132 MsgStream log(messageService(), name());
136 int pid1,pid2,pid3,pid4,pst1,pst2;
147 GenEvent* evt =
new GenEvent(1,1);
149 GenVertex* prod_vtx =
new GenVertex();
151 evt->add_vertex( prod_vtx );
154 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
157 p->suggest_barcode( ++npart );
158 prod_vtx->add_particle_in(p);
162 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
166 p->suggest_barcode( ++npart );
167 prod_vtx->add_particle_in(p);
170 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
173 p->suggest_barcode( ++npart );
174 prod_vtx->add_particle_out(p);
177 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
180 p->suggest_barcode( ++npart );
181 prod_vtx->add_particle_out(p);
184 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p3[1][evtgen],
MOMSET.p3[2][evtgen],
187 p->suggest_barcode( ++npart );
188 prod_vtx->add_particle_out(p);
191 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
194 p->suggest_barcode( ++npart );
195 prod_vtx->add_particle_out(p);
201 if( log.level() < MSG::INFO )
207 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
211 MsgStream log(messageService(), name());
212 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
214 anMcCol->push_back(mcEvent);
221 mcColl->push_back(mcEvent);
222 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
223 if (sc != StatusCode::SUCCESS)
225 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
229 return StatusCode::FAILURE;
237 return StatusCode::SUCCESS;
242 MsgStream log(messageService(), name());
244 strcpy(delcmd,
"cat ");
245 strcat(delcmd,
"fresult.dat");
248 std::cout<<
"EeTo4e finalized" << endl;
249 return StatusCode::SUCCESS;
253 IProperty* appPropMgr=0;
255 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
256 reinterpret_cast<IInterface*&
>( appPropMgr ));
257 if( status.isFailure() )
return status;
259 IntegerProperty evtMax(
"EvtMax",0);
260 status = appPropMgr->getProperty( &evtMax );
261 if (status.isFailure())
return status;
263 m_evtMax = evtMax.value();
ObjectVector< McGenEvent > McGenEventCol
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
EeTo4e(const string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.