37 EvtPhotosEngine::EvtPhotosEngine( std::string photonType,
bool useEvtGenRandom )
39 _photonType = photonType;
40 _gammaId =
EvtId( -1, -1 );
46 if ( useEvtGenRandom ==
true ) {
48 <<
"Using EvtGen random number engine also for Photos++" << endl;
53 Photospp::Photos::initialize();
56 Photospp::Photos::maxWtInterference(
58 Photospp::Photos::setInterference(
true );
59 Photospp::Photos::setExponentiation(
true );
63 Photospp::Photos::setInfraredCutOff( 1.0e-7 );
68 void EvtPhotosEngine::initialise()
70 if ( _initialised ==
false ) {
73 if ( _gammaId ==
EvtId( -1, -1 ) ) {
75 <<
"Error in EvtPhotosEngine. Do not recognise the photon type " 76 << _photonType <<
". Setting this to \"gamma\". " << endl;
87 bool EvtPhotosEngine::doDecay(
EvtParticle* theMother )
89 if ( _initialised ==
false ) {
93 if ( theMother == 0 ) {
108 if ( nDaug == 0 || nDaug >= 10 ) {
113 auto theEvent = std::make_unique<GenEvent>( Units::GEV, Units::MM );
117 theEvent->add_vertex( theVertex );
120 GenParticlePtr hepMCMother = this->createGenParticle( theMother,
true );
121 theVertex->add_particle_in( hepMCMother );
125 int iDaug( 0 ), nGamma( 0 );
126 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
128 GenParticlePtr hepMCDaughter = this->createGenParticle( theDaughter,
130 theVertex->add_particle_out( hepMCDaughter );
133 int daugId = theDaughter->
getPDGId();
134 if ( daugId == _gammaPDG ) {
143 Photospp::PhotosHepMC3Event photosEvent( theEvent.get() );
145 Photospp::PhotosHepMCEvent photosEvent( theEvent.get() );
149 photosEvent.process();
152 int nPhotons = this->getNumberOfPhotons( theVertex );
155 int nDiffPhotons = nPhotons - nGamma;
158 if ( nDiffPhotons > 0 ) {
164 for (
auto outParticle : theVertex->particles_out() ) {
166 HepMC::GenVertex::particles_out_const_iterator outIter;
167 for ( outIter = theVertex->particles_out_const_begin();
168 outIter != theVertex->particles_out_const_end(); ++outIter ) {
170 HepMC::GenParticle* outParticle = *outIter;
174 double px( 0.0 ), py( 0.0 ), pz( 0.0 );
177 if ( outParticle != 0 ) {
182 pdgId = outParticle->pdg_id();
188 if ( iLoop < nDaug ) {
191 if ( daugParticle != 0 ) {
195 double mass = daugParticle->
mass();
196 double energy = sqrt( mass * mass + px * px + py * py +
198 newP4.
set( energy, px, py, pz );
203 }
else if ( pdgId == _gammaPDG ) {
205 double energy = sqrt( _mPhoton * _mPhoton + px * px + py * py +
207 newP4.
set( energy, px, py, pz );
211 gamma->
init( _gammaId, newP4 );
236 if ( theParticle == 0 ) {
243 if ( incoming ==
true ) {
246 p4 = theParticle->
getP4();
250 double E = p4.
get( 0 );
251 double px = p4.get( 1 );
252 double py = p4.get( 2 );
253 double pz = p4.get( 3 );
261 int status = Photospp::PhotosParticle::HISTORY;
262 if ( incoming ==
false ) {
263 status = Photospp::PhotosParticle::STABLE;
271 int EvtPhotosEngine::getNumberOfPhotons(
const GenVertexPtr theVertex )
const 283 for (
auto outParticle : theVertex->particles_out() ) {
285 HepMC::GenVertex::particles_out_const_iterator outIter;
286 for ( outIter = theVertex->particles_out_const_begin();
287 outIter != theVertex->particles_out_const_end(); ++outIter ) {
289 HepMC::GenParticle* outParticle = *outIter;
294 if ( outParticle != 0 ) {
295 pdgId = outParticle->pdg_id();
299 if ( pdgId == _gammaPDG ) {
void setAttribute(std::string attName, int attValue)
HepMC::GenParticle * GenParticlePtr
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
static double getMeanMass(EvtId i)
void set(int i, double d)
HepMC::FourVector FourVector
GenVertexPtr newGenVertexPtr(const FourVector &pos=FourVector(0.0, 0.0, 0.0, 0.0))
void init(EvtId part_n, double e, double px, double py, double pz)
void addDaug(EvtParticle *node)
static EvtId getId(const std::string &name)
void setP4WithFSR(const EvtVector4R &p4)
const EvtVector4R & getP4() const
HepMC::GenVertex * GenVertexPtr
EvtParticle * getDaug(int i)
EvtVector4R getP4Restframe() const
GenParticlePtr newGenParticlePtr(const FourVector &mom=FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
static int getStdHep(EvtId id)