17#include "CLHEP/Vector/LorentzVector.h"
18#include "HepMC/GenEvent.h"
19#include "HepMC/GenParticle.h"
20#include "HepMC/GenVertex.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/MsgStream.h"
24#include "GaudiKernel/SmartDataPtr.h"
26#include "BesRndmGenSvc/IBesRndmGenSvc.h"
27#include "GeneratorObject/McGenEvent.h"
29#include "cfortran/cfortran.h"
45#define MOMSET COMMON_BLOCK( MOMSET_DEF, momset )
52#define GLIMIT( LENMX ) CCALLSFSUB1( GLIMIT, glimit, INT, LENMX )
55#define DUMPS( NOUT ) CCALLSFSUB1( DUMPS, dumps, INT, NOUT )
58#define BHLUMI( MODE, XPAR, NPAR ) \
59 CCALLSFSUB3( BHLUMI, bhlumi, INT, DOUBLEV, INTV, MODE, XPAR, NPAR )
62#define MARINI( IJKLIN, NTOTIN, NTOT2N ) \
63 CCALLSFSUB3( MARINI, marini, INT, INT, INT, IJKLIN, NTOTIN, NTOT2N )
67extern void marran_(
float* rvec,
int* nma );
68extern void ecuran_(
double* rvec,
int* nma );
69extern void carran_(
double* rvec,
int* nma );
79 for (
int i = 0; i < nmax; i++ ) rvec[i] = rvecd[i];
87 for (
int i = 0; i < nmax; i++ ) rvec[i] = rvecd[i];
95 for (
int i = 0; i < nmax; i++ ) rvec[i] = rvecd[i];
100 : Algorithm( name, pSvcLocator ) {
101 declareProperty(
"CMEnergy", m_cmEnergy = 3.097 );
102 declareProperty(
"AngleMode",
105 declareProperty(
"MinThetaAngle", m_minThetaAngle = 0.24 );
106 declareProperty(
"MaxThetaAngle", m_maxThetaAngle = 0.58 );
107 declareProperty(
"SoftPhotonCut",
108 m_infraredCut = 1E-4 );
116 MsgStream log(
msgSvc(), name() );
118 log << MSG::INFO <<
"Bhlumi initialize" << endmsg;
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" << endmsg;
127 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine(
"Bhlumi" );
128 engine->showStatus();
153 int KeyOpt = 1000 * KeyGen + 100 * KeyRem + 10 * KeyWgt + KeyRnd;
161 int KeyRad = 1000 * KeyZet + 10 * KeyMod + KeyPia;
165 double CmsEne = m_cmEnergy;
167 double th1, th2, thmin, thmax;
168 if ( m_angleMode == 0 )
170 th1 = m_minThetaAngle;
171 th2 = m_maxThetaAngle;
174 if ( thmin < 0. || thmax > 3.1415926 )
177 <<
"input angles exceed range (0~pi), so effect will be unprospectable" << endmsg;
178 return StatusCode::FAILURE;
181 else if ( m_angleMode == 1 )
183 th1 = m_minThetaAngle * 3.1415926 / 180.;
184 th2 = m_maxThetaAngle * 3.1415926 / 180.;
189 else if ( m_angleMode == 2 )
191 th1 = acos(
max( m_minThetaAngle, m_maxThetaAngle ) );
192 th2 = acos(
min( m_minThetaAngle, m_maxThetaAngle ) );
199 log << MSG::FATAL <<
"unknown angle mode!" << endmsg;
200 return StatusCode::FAILURE;
202 if ( thmin < 0. || thmax > 3.1415926 )
204 log << MSG::FATAL <<
"input angles exceed range (0~pi), unprospectable" << endmsg;
205 return StatusCode::FAILURE;
207 else if ( thmin > thmax )
209 log << MSG::FATAL <<
"thmin>thmax, unprospectable" << endmsg;
210 return StatusCode::FAILURE;
212 if ( KeyWgt == 2 ) thmin = th1;
213 xpar[1] = CmsEne * CmsEne * ( 1 -
cos( thmin ) ) / 2;
214 xpar[2] = CmsEne * CmsEne * ( 1 -
cos( thmax ) ) / 2;
215 xpar[3] = m_infraredCut;
221 return StatusCode::SUCCESS;
225 MsgStream log(
msgSvc(), name() );
226 log << MSG::INFO <<
"Bhlumi executing" << endmsg;
230 if ( log.level() < MSG::INFO )
240 GenEvent* evt =
new GenEvent( 1, 1 );
242 GenVertex* prod_vtx =
new GenVertex();
244 evt->add_vertex( prod_vtx );
247 GenParticle* p =
new GenParticle(
250 p->suggest_barcode( ++npart );
251 prod_vtx->add_particle_in( p );
257 p->suggest_barcode( ++npart );
258 prod_vtx->add_particle_in( p );
264 p->suggest_barcode( ++npart );
265 prod_vtx->add_particle_out( p );
271 p->suggest_barcode( ++npart );
272 prod_vtx->add_particle_out( p );
275 for ( iphot = 0; iphot <
MOMSET.nphot; iphot++ )
278 p =
new GenParticle( CLHEP::HepLorentzVector(
MOMSET.phot[0][iphot],
MOMSET.phot[1][iphot],
282 p->suggest_barcode( ++npart );
283 prod_vtx->add_particle_out( p );
286 if ( log.level() < MSG::INFO ) { evt->print(); }
289 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(),
"/Event/Gen" );
293 MsgStream log(
msgSvc(), name() );
294 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endmsg;
296 anMcCol->push_back( mcEvent );
303 mcColl->push_back( mcEvent );
304 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen", mcColl );
305 if ( sc != StatusCode::SUCCESS )
307 log << MSG::ERROR <<
"Could not register McGenEvent" << endmsg;
311 return StatusCode::FAILURE;
315 log << MSG::INFO <<
"McGenEventCol created and " << npart
316 <<
" particles stored in McGenEvent" << endmsg;
338 return StatusCode::SUCCESS;
342 MsgStream log(
msgSvc(), name() );
346 log << MSG::INFO <<
"Bhlumi finalized" << endmsg;
348 return StatusCode::SUCCESS;
DECLARE_COMPONENT(BesBdkRc)
void marran_(float *rvec, int *nma)
#define BHLUMI(MODE, XPAR, NPAR)
void carran_(double *rvec, int *nma)
#define MARINI(IJKLIN, NTOTIN, NTOT2N)
COMMON_BLOCK_DEF(MOMSET_DEF, MOMSET)
void ecuran_(double *rvec, int *nma)
ObjectVector< McGenEvent > McGenEventCol
double cos(const BesAngle a)
static void FlatArray(double *vect, const int size)
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Bhlumi(const std::string &name, ISvcLocator *pSvcLocator)
PROTOCCALLSFSUB3(INPUT, input, PLONG, PINT, PSTRING)
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)