17#include "HepMC/GenEvent.h"
18#include "HepMC/GenVertex.h"
19#include "HepMC/GenParticle.h"
20#include "CLHEP/Vector/LorentzVector.h"
22#include "GaudiKernel/MsgStream.h"
23#include "GaudiKernel/ISvcLocator.h"
24#include "GaudiKernel/AlgFactory.h"
25#include "GaudiKernel/DataSvc.h"
26#include "GaudiKernel/SmartDataPtr.h"
31#include "cfortran/cfortran.h"
48#define MOMSET COMMON_BLOCK(MOMSET_DEF, momset)
55#define GLIMIT(LENMX) CCALLSFSUB1(GLIMIT,glimit,INT,LENMX)
58#define DUMPS(NOUT) CCALLSFSUB1(DUMPS,dumps,INT,NOUT)
61#define BHLUMI(MODE,XPAR,NPAR) CCALLSFSUB3(BHLUMI,bhlumi,INT,DOUBLEV,INTV,MODE,XPAR,NPAR)
64#define MARINI(IJKLIN, NTOTIN, NTOT2N) CCALLSFSUB3(MARINI, marini, INT, INT, INT, IJKLIN, NTOTIN, NTOT2N)
68 extern void marran_(
float* rvec,
int* nma);
69 extern void ecuran_(
double* rvec,
int* nma);
70 extern void carran_(
double* rvec,
int* nma);
84 for(
int i=0; i<nmax; i++) rvec[i]=rvecd[i];
93 for(
int i=0; i<nmax; i++) rvec[i]=rvecd[i];
102 for(
int i=0; i<nmax; i++) rvec[i]=rvecd[i];
106Bhlumi::Bhlumi(
const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
108 declareProperty(
"CMEnergy", m_cmEnergy = 3.097);
109 declareProperty(
"AngleMode", m_angleMode = 0);
111 declareProperty(
"MinThetaAngle", m_minThetaAngle = 0.24);
112 declareProperty(
"MaxThetaAngle", m_maxThetaAngle = 0.58);
113 declareProperty(
"SoftPhotonCut", m_infraredCut = 1E-4);
121 MsgStream log(messageService(), name());
123 log << MSG::INFO <<
"Bhlumi initialize" << endreq;
125 static const bool CREATEIFNOTTHERE(
true);
126 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
127 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
129 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
132 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Bhlumi");
133 engine->showStatus();
158 int KeyOpt =1000*KeyGen +100*KeyRem +10*KeyWgt +KeyRnd;
166 int KeyRad =1000*KeyZet +10*KeyMod +KeyPia;
170 double CmsEne = m_cmEnergy;
172 double th1,th2,thmin,thmax;
174 th1 = m_minThetaAngle;
175 th2 = m_maxThetaAngle;
178 if(thmin<0.||thmax>3.1415926) {
179 log << MSG::WARNING <<
"input angles exceed range (0~pi), so effect will be unprospectable" << endreq;
180 return StatusCode::FAILURE;
183 else if(m_angleMode==1){
184 th1 = m_minThetaAngle*3.1415926/180.;
185 th2 = m_maxThetaAngle*3.1415926/180.;
190 else if(m_angleMode==2){
191 th1 = acos(max(m_minThetaAngle,m_maxThetaAngle));
192 th2 = acos(min(m_minThetaAngle,m_maxThetaAngle));
198 log << MSG::FATAL <<
"unknown angle mode!" << endreq;
199 return StatusCode::FAILURE;
201 if(thmin<0.||thmax>3.1415926) {
202 log << MSG::FATAL <<
"input angles exceed range (0~pi), unprospectable" << endreq;
203 return StatusCode::FAILURE;
205 else if(thmin>thmax) {
206 log << MSG::FATAL <<
"thmin>thmax, unprospectable" << endreq;
207 return StatusCode::FAILURE;
209 if(KeyWgt == 2) thmin=th1;
210 xpar[1]= CmsEne*CmsEne*(1-
cos(thmin))/2;
211 xpar[2]= CmsEne*CmsEne*(1-
cos(thmax))/2;
212 xpar[3]= m_infraredCut;
218 return StatusCode::SUCCESS;
223 MsgStream log(messageService(), name());
224 log << MSG::INFO <<
"Bhlumi executing" << endreq;
229 if( log.level() < MSG::INFO )
239 GenEvent* evt =
new GenEvent(1,1);
241 GenVertex* prod_vtx =
new GenVertex();
243 evt->add_vertex( prod_vtx );
246 GenParticle* p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p1[0],
MOMSET.p1[1],
249 p->suggest_barcode( ++npart );
250 prod_vtx->add_particle_in(p);
255 p->suggest_barcode( ++npart );
256 prod_vtx->add_particle_in(p);
259 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.p2[0],
MOMSET.p2[1],
262 p->suggest_barcode( ++npart );
263 prod_vtx->add_particle_out(p);
268 p->suggest_barcode( ++npart );
269 prod_vtx->add_particle_out(p);
272 for (iphot=0; iphot<
MOMSET.nphot; iphot++)
275 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.phot[0][iphot],
MOMSET.phot[1][iphot],
278 p->suggest_barcode( ++npart );
279 prod_vtx->add_particle_out(p);
282 if( log.level() < MSG::INFO )
288 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
292 MsgStream log(messageService(), name());
293 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
295 anMcCol->push_back(mcEvent);
302 mcColl->push_back(mcEvent);
303 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
304 if (sc != StatusCode::SUCCESS)
306 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
310 return StatusCode::FAILURE;
314 log << MSG::INFO <<
"McGenEventCol created and " << npart <<
" particles stored in McGenEvent" << endreq;
336 return StatusCode::SUCCESS;
341 MsgStream log(messageService(), name());
345 log << MSG::INFO <<
"Bhlumi finalized" << endreq;
347 return StatusCode::SUCCESS;
double cos(const BesAngle a)
void marran_(float *rvec, int *nma)
#define BHLUMI(MODE, XPAR, NPAR)
void carran_(double *rvec, int *nma)
#define MARINI(IJKLIN, NTOTIN, NTOT2N)
void ecuran_(double *rvec, int *nma)
ObjectVector< McGenEvent > McGenEventCol
#define PROTOCCALLSFSUB3(UN, LN, T1, T2, T3)
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
static void FlatArray(double *vect, const int size)
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Bhlumi(const std::string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.