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)
66#define DIGAM COMMON_BLOCK(DIGAM_DEF, digam)
73#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
80#define FORMFACTOR COMMON_BLOCK(FORMFACTOR_DEF, formfactor)
102#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
105Eepipi::Eepipi(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
107 declareProperty(
"Ecms", m_Ecms = 3.65);
108 declareProperty(
"OnlyDigam", m_onlyDigam = 0);
109 declareProperty(
"ExcludeDigam", m_excludeDigam = 0);
110 declareProperty(
"WriteMC", m_mctruth = 0);
115 MsgStream log(messageService(), name());
117 log << MSG::INFO <<
"Eepipi initialize" << endreq;
120 static const bool CREATEIFNOTTHERE(
true);
121 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
122 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
124 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
127 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Eepipi");
128 std::cout<<
"==============================="<<engine<<endl;
133 COSEE.setcos=m_cosee;
135 DIGAM.onlyDigam =m_onlyDigam;
136 DIGAM.excludeDigam=m_excludeDigam;
138 std::string locvp=getenv(
"EEPIPIROOT");
139 locvp +=
"/share/fitpipi.dat";
141 std::cout<<
"myfile :"<<
FORMFACTOR.myfile<<std::endl;
142 system(
"cat $EEPIPIROOT/share/fitpipi.dat>fitpipi.dat");
145 std::cout<<
"m_evtMax = "<<m_evtMax<<std::endl;
149 return StatusCode::SUCCESS;
155 MsgStream log(messageService(), name());
159 int pid1,pid2,pid3,pid4,pst1,pst2;
170 GenEvent* evt =
new GenEvent(1,1);
172 GenVertex* prod_vtx =
new GenVertex();
174 evt->add_vertex( prod_vtx );
177 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[1][evtgen],
MOMSET.p1[2][evtgen],
180 p->suggest_barcode( ++npart );
181 prod_vtx->add_particle_in(p);
185 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q1[1][evtgen],
MOMSET.q1[2][evtgen],
189 p->suggest_barcode( ++npart );
190 prod_vtx->add_particle_in(p);
193 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[1][evtgen],
MOMSET.p2[2][evtgen],
196 p->suggest_barcode( ++npart );
197 prod_vtx->add_particle_out(p);
200 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q2[1][evtgen],
MOMSET.q2[2][evtgen],
203 p->suggest_barcode( ++npart );
204 prod_vtx->add_particle_out(p);
207 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p3[1][evtgen],
MOMSET.p3[2][evtgen],
210 p->suggest_barcode( ++npart );
211 prod_vtx->add_particle_out(p);
214 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.q3[1][evtgen],
MOMSET.q3[2][evtgen],
217 p->suggest_barcode( ++npart );
218 prod_vtx->add_particle_out(p);
224 if( log.level() < MSG::INFO )
230 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
234 MsgStream log(messageService(), name());
235 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
237 anMcCol->push_back(mcEvent);
244 mcColl->push_back(mcEvent);
245 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
246 if (sc != StatusCode::SUCCESS)
248 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
252 return StatusCode::FAILURE;
260 return StatusCode::SUCCESS;
265 MsgStream log(messageService(), name());
267 strcpy(delcmd,
"cat ");
268 strcat(delcmd,
"fresult.dat");
271 std::cout<<
"Eepipi finalized" << endl;
272 return StatusCode::SUCCESS;
276 IProperty* appPropMgr=0;
278 serviceLocator()->getService(
"ApplicationMgr", IProperty::interfaceID(),
279 reinterpret_cast<IInterface*&
>( appPropMgr ));
280 if( status.isFailure() )
return status;
282 IntegerProperty evtMax(
"EvtMax",0);
283 status = appPropMgr->getProperty( &evtMax );
284 if (status.isFailure())
return status;
286 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.