13#include "Mcgpj/Mcgpj.h"
16#include "HepMC/GenEvent.h"
17#include "HepMC/GenVertex.h"
18#include "HepMC/GenParticle.h"
20#include "CLHEP/Vector/LorentzVector.h"
21#include "BesKernel/IBesRndmGenSvc.h"
23#include "GaudiKernel/SmartDataPtr.h"
25#include "GeneratorObject/McGenEvent.h"
54Mcgpj::Mcgpj(
const std::string& name, ISvcLocator* pSvcLocator):Algorithm(name, pSvcLocator){
55 declareProperty(
"Data", m_datapath =
"${MCGPJROOT}/data");
56 declareProperty(
"VpolFname", m_vpolfname =
"vpol.dat");
57 declareProperty(
"CMEnergy", cmE = 3.097);
58 declareProperty(
"Process", proc = 0);
59 declareProperty(
"NRad", NRad = 20000);
60 declareProperty(
"HardPhoton", IsHardPhoton = 1);
61 declareProperty(
"NoVacPol", IsNoVacPol = 0);
62 declareProperty(
"FSR", IsFSR = 1);
63 declareProperty(
"AcolAngle", pc = 0.);
64 declareProperty(
"DeltaE", de = -1.);
65 declareProperty(
"NTheta0", nt0 = -1.);
66 declareProperty(
"DeltaTheta", dt = 0.5);
67 declareProperty(
"DeltaPhi", dp = 0.3);
68 declareProperty(
"AverageTheta", at = 1.1);
69 declareProperty(
"ThetaDetector", td = 1.1 - 0.5/2);
70 declareProperty(
"AverageMomentum", am = 0.090);
71 declareProperty(
"CrossMomentum", cm = 0.090);
72 declareProperty(
"MinimumEnergy", em = 0.050);
73 declareProperty(
"ThetaIntermediate", ti = 0.473);
74 declareProperty(
"AlphaScale", al = 1.);
75 declareProperty(
"ThetaMinus", thm = -1.);
76 declareProperty(
"ThetaPlus", thp = -1.);
77 declareProperty(
"AbsoluteError", te = 0.05);
78 declareProperty(
"RelativeError", re = 0.05);
80 declareProperty(
"BeamSpread", spread = -1);
82 declareProperty(
"Mode5pi", m_fmode5pi = 0);
86 MsgStream log(messageService(), name());
88 log << MSG::INFO <<
"Mcgpj initialize" << endreq;
90 static const bool CREATEIFNOTTHERE(
true);
91 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
92 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
94 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
97 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Mcgpj");
107 if(gRandom)
delete gRandom;
108 gRandom =
new TRandom3();
109 gRandom->SetSeed(engine->getSeed());
126 const int MaxList = 20;
127 bool InList[MaxList];
128 for(
int j = 0; j<MaxList; j++) InList[j] =
true;
130 double EBeam = 0.5*cmE;
132 if( ( EBeam < 100 || EBeam > 2500 ) && !IsNoVacPol ){
133 log<<MSG::ERROR<<
"Invalid value of beam energy:"<<
EBeam<<endreq;
134 return StatusCode::FAILURE;
197 }
catch(std::logic_error lge){
198 log<<MSG::ERROR<<lge.what()<<endreq;
199 return StatusCode::FAILURE;
211 log<<MSG::INFO<<
"Cross-section statistical precision will be better than "
216 log<<MSG::INFO<<
"Hard photon on big angle is not included!"<<endreq;
219 log<<MSG::INFO<<
"Vacuum polarization is not included!"<<endreq;
222 log<<MSG::INFO<<
"Final state radiation is not included!"<<endreq;
225 log<<MSG::INFO<<
"Alpha order generation only!"<<endreq;
233 else if(proc==1 || proc==5)
245 for(
int j = 0; j<MaxList; j++) InList[j] =
false;
251 return StatusCode::FAILURE;
269 fpid[0] = 11; fpid[1] = -11; fM = 0.51099891;
272 fpid[0] = 13; fpid[1] = -13; fM = 105.658367;
275 fpid[0] = 211; fpid[1] = -211; fM = 139.57018;
278 fpid[0] = 130; fpid[1] = 310; fM = 497.614;
281 fpid[0] = 321; fpid[1] = -321; fM = 493.677;
284 fpid[0] = 15; fpid[1] = -15; fM = 1776.84;
287 fpid[0] = 22; fpid[1] = 22; fM = 0;
290 double EBeam = 0.5*cmE;
291 if(0>de) de = 0.005*
EBeam;
313 log << MSG::INFO <<
"Mcgpj initialize finished" << endreq;
315 return StatusCode::SUCCESS;
319 MsgStream log(messageService(), name());
320 log << MSG::INFO <<
"Mcgpj executing" << endreq;
321 log<<MSG::WARNING<<
"execute start"<<endreq;
324 GenEvent* evt =
new GenEvent(1,1);
326 GenVertex* prod_vtx =
new GenVertex();
328 evt->add_vertex( prod_vtx );
332 new GenParticle(HepLorentzVector(0,0,0.5*cmE*1e-3,0.5*cmE*1e-3),-11, 3);
333 p->suggest_barcode(1);
334 prod_vtx->add_particle_in(p);
338 new GenParticle(HepLorentzVector(0,0,0.5*cmE*1e-3, 0.5*cmE*1e-3), 11, 3);
339 p->suggest_barcode(2);
340 prod_vtx->add_particle_in(p);
349 for(
int i=0; i<np;i++){
350 double ptot = mom[i*4+3];
351 double px = ptot*mom[i*4+0];
352 double py = ptot*mom[i*4+1];
353 double pz = ptot*mom[i*4+2];
361 p =
new GenParticle( HepLorentzVector(px,py,pz,
etot), pid, 1);
362 p->suggest_barcode(i+3);
363 prod_vtx->add_particle_out(p);
369 for(
size_t i=0;i<nmax;i++){
373 new GenParticle( HepLorentzVector(
q.X()*1e-3,
q.Y()*1e-3,
q.Z()*1e-3,
q.T()*1e-3), pid, 1);
374 p->suggest_barcode(i+3);
375 prod_vtx->add_particle_out(p);
380 if( log.level() < MSG::INFO ){
385 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
388 log<<MSG::WARNING<<
"add event"<<endreq;
389 MsgStream log(messageService(), name());
390 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
392 anMcCol->push_back(mcEvent);
395 log<<MSG::WARNING<<
"create collection"<<endreq;
398 mcColl->push_back(mcEvent);
399 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
400 if (sc != StatusCode::SUCCESS) {
401 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
405 return StatusCode::FAILURE;
407 log << MSG::INFO <<
"McGenEventCol created and " << npart
408 <<
" particles stored in McGenEvent" << endreq;
412 log<<MSG::WARNING<<
"execute end"<<endreq;
413 return StatusCode::SUCCESS;
417 MsgStream log(messageService(), name());
426 log << MSG::INFO <<
"Mcgpj finalized" << endreq;
428 return StatusCode::SUCCESS;
ObjectVector< McGenEvent > McGenEventCol
double cos(const BesAngle a)
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
TVCrossPart * MatrixElements
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.
Mcgpj(const std::string &name, ISvcLocator *pSvcLocator)
void SetAlphaScale(const double &x)
void MakeParts(double err)
size_t GenUnWeightedEvent()
TLorentzVector ** GetParticles()
void SetBeamSpread(double x=1)
void AverageTheta(const double &x)
void SetNEvents(const unsigned int &n)
void SetPartList(const bool *InList)
void SetDatadir(std::string dir)
void Set_ThetaMin(const double &x)
void Set_Type(const int x)
void Set_ThetaInt(const double &x)
void Set_dE_Abs(const double &x)
double Get_RelativeError()
void Set_RelativeError(const double &x)
void SetVpolFname(std::string fname)
void Set_Theta0_Rel(const double &x)
void Set_E(const double &x)
void Set_TotalError(const double &x)
virtual void SetHardPhoton(const bool &x)