22#include "EvtGen_i/EvtGenExternal/EvtPhotosEngine.hh"
24#include "EvtGenBase/EvtPDL.hh"
25#include "EvtGenBase/EvtPhotonParticle.hh"
26#include "EvtGenBase/EvtRandom.hh"
27#include "EvtGenBase/EvtReport.hh"
28#include "EvtGenBase/EvtVector4R.hh"
39EvtPhotosEngine::EvtPhotosEngine(
const std::string& photonType,
bool useEvtGenRandom ) :
40 m_photonType(photonType),
41 m_gammaId(EvtId( -1, -1 )),
46 EvtGenReport( EVTGEN_INFO,
"EvtGen" ) <<
"Setting up PHOTOS." << endl;
48 if ( useEvtGenRandom ==
true ) {
49 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
50 <<
"Using EvtGen random number engine also for Photos++" << endl;
52 Photospp::Photos::setRandomGenerator( EvtRandom::Flat );
55 Photospp::Photos::initialize();
58 Photospp::Photos::maxWtInterference(
60 Photospp::Photos::setInterference(
true );
61 Photospp::Photos::setExponentiation(
true );
65 Photospp::Photos::setInfraredCutOff( 1.0e-7 );
67 m_initialised =
false;
70void EvtPhotosEngine::initialise()
72 if ( m_initialised ==
false ) {
73 m_gammaId = EvtPDL::getId( m_photonType );
75 if ( m_gammaId == EvtId( -1, -1 ) ) {
76 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
77 <<
"Error in EvtPhotosEngine. Do not recognise the photon type "
78 << m_photonType <<
". Setting this to \"gamma\". " << endl;
79 m_gammaId = EvtPDL::getId(
"gamma" );
82 m_gammaPDG = EvtPDL::getStdHep( m_gammaId );
83 m_mPhoton = EvtPDL::getMeanMass( m_gammaId );
89bool EvtPhotosEngine::doDecay( EvtParticle* theMother )
91 if ( m_initialised ==
false ) {
95 if ( theMother == 0 ) {
109 int nDaug( theMother->getNDaug() );
110 if ( nDaug == 0 || nDaug >= 10 ) {
115 auto theEvent = std::make_unique<GenEvent>( Units::GEV, Units::MM );
119 theEvent->add_vertex( theVertex );
122 GenParticlePtr hepMCMother = this->createGenParticle( theMother,
true );
123 theVertex->add_particle_in( std::move(hepMCMother) );
127 int iDaug( 0 ), nGamma( 0 );
128 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
129 EvtParticle* theDaughter = theMother->getDaug( iDaug );
130 GenParticlePtr hepMCDaughter = this->createGenParticle( theDaughter,
132 theVertex->add_particle_out( std::move(hepMCDaughter) );
135 int daugId = theDaughter->getPDGId();
136 if ( daugId == m_gammaPDG ) {
144 Photospp::PhotosHepMC3Event photosEvent( theEvent.get() );
147 photosEvent.process();
150 int nPhotons = this->getNumberOfPhotons( theVertex );
153 int nDiffPhotons = nPhotons - nGamma;
156 if ( nDiffPhotons > 0 ) {
161 for (
auto outParticle : theVertex->particles_out() ) {
164 double px( 0.0 ),
py( 0.0 ),
pz( 0.0 );
167 if ( outParticle != 0 ) {
172 pdgId = outParticle->pdg_id();
178 if ( iLoop < nDaug ) {
180 EvtParticle* daugParticle = theMother->getDaug( iLoop );
181 if ( daugParticle != 0 ) {
185 double mass = daugParticle->mass();
186 double energy = sqrt( mass * mass + px * px + py * py +
188 newP4.set( energy, px, py, pz );
190 daugParticle->setP4WithFSR( newP4 );
193 }
else if ( pdgId == m_gammaPDG ) {
195 double energy = sqrt( m_mPhoton * m_mPhoton + px * px + py * py +
197 newP4.set( energy, px, py, pz );
200 EvtPhotonParticle*
gamma =
new EvtPhotonParticle();
201 gamma->init( m_gammaId, newP4 );
203 gamma->setFSRP4toZero();
205 gamma->addDaug( theMother );
207 gamma->setAttribute(
"FSR", 1 );
208 gamma->setAttribute(
"ISR", 0 );
222GenParticlePtr EvtPhotosEngine::createGenParticle( EvtParticle* theParticle,
226 if ( theParticle == 0 ) {
231 EvtVector4R p4( 0.0, 0.0, 0.0, 0.0 );
233 if ( incoming ==
true ) {
234 p4 = theParticle->getP4Restframe();
236 p4 = theParticle->getP4();
240 double E = p4.get( 0 );
241 double px = p4.get( 1 );
242 double py = p4.get( 2 );
243 double pz = p4.get( 3 );
247 int PDGInt = EvtPDL::getStdHep( theParticle->getId() );
251 int status = Photospp::PhotosParticle::HISTORY;
252 if ( incoming ==
false ) {
253 status = Photospp::PhotosParticle::STABLE;
261int EvtPhotosEngine::getNumberOfPhotons(
const GenVertexPtr theVertex )
const
272 for (
auto outParticle : theVertex->particles_out() ) {
275 if ( outParticle != 0 ) {
276 pdgId = outParticle->pdg_id();
280 if ( pdgId == m_gammaPDG ) {
HepMC3::FourVector FourVector
GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom=HepMC3::FourVector::ZERO_VECTOR(), int pid=0, int status=0)
HepMC3::GenParticlePtr GenParticlePtr
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
HepMC3::GenVertexPtr GenVertexPtr