22 #include "EvtGen_i/EvtGenExternal/EvtTauolaEngine.hh"
24 #include "EvtGenBase/EvtDecayTable.hh"
25 #include "EvtGenBase/EvtPDL.hh"
26 #include "EvtGenBase/EvtRandom.hh"
27 #include "EvtGenBase/EvtReport.hh"
28 #include "EvtGenBase/EvtSymTable.hh"
29 #include "EvtGenBase/EvtVector4R.hh"
31 #include "Tauola/Log.h"
32 #include "Tauola/Tauola.h"
42 EvtTauolaEngine::EvtTauolaEngine(
bool useEvtGenRandom )
49 EvtGenReport( EVTGEN_INFO,
"EvtGen" ) <<
"Setting up TAUOLA." << endl;
53 Tauolapp::Tauola::setDecayingParticle( m_tauPDG );
54 Tauolapp::Tauola::setSameParticleDecayMode(
56 Tauolapp::Tauola::setOppositeParticleDecayMode(
60 Tauolapp::Log::SetWarningLimit( 1 );
63 if ( useEvtGenRandom ==
true ) {
64 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
65 <<
"Using EvtGen random number engine also for Tauola++" << endl;
67 Tauolapp::Tauola::setRandomGenerator( EvtRandom::Flat );
72 Tauolapp::Tauola::setNewCurrents( 1 );
83 m_initialised =
false;
86 void EvtTauolaEngine::initialise()
94 if ( m_initialised ==
false ) {
95 this->setUpPossibleTauModes();
96 this->setOtherParameters();
102 void EvtTauolaEngine::setUpPossibleTauModes()
116 bool gotAnyTauolaModes(
false );
118 for ( iPDL = 0; iPDL < nPDL; iPDL++ ) {
119 EvtId particleId = EvtPDL::getEntry( iPDL );
120 int PDGId = EvtPDL::getStdHep( particleId );
122 if ( abs( PDGId ) == m_tauPDG && gotAnyTauolaModes ==
false ) {
123 int aliasInt = particleId.getAlias();
126 int nModes = EvtDecayTable::getInstance()->getNModes( aliasInt );
127 int iMode( 0 ), iTauMode( 0 );
132 std::vector<double> tauolaModeBFs( m_nTauolaModes );
134 for ( iTauMode = 0; iTauMode < m_nTauolaModes; iTauMode++ ) {
135 tauolaModeBFs[iTauMode] = 0.0;
138 double totalTauModeBF( 0.0 );
140 int nNonTauolaModes( 0 );
143 for ( iMode = 0; iMode < nModes; iMode++ ) {
144 EvtDecayBase* decayModel =
145 EvtDecayTable::getInstance()->findDecayModel( aliasInt,
149 std::string modelName = decayModel->getName();
150 if ( modelName ==
"TAUOLA" ) {
151 if ( gotAnyTauolaModes ==
false ) {
152 gotAnyTauolaModes =
true;
156 double BF = decayModel->getBranchingFraction();
157 int modeArrayInt = this->getModeInt( decayModel ) - 1;
159 if ( modeArrayInt >= 0 && modeArrayInt < m_nTauolaModes ) {
160 tauolaModeBFs[modeArrayInt] = BF;
161 totalTauModeBF += BF;
172 if ( gotAnyTauolaModes ==
true && nNonTauolaModes > 0 ) {
173 EvtGenReport( EVTGEN_ERROR,
"EvtGen" )
174 <<
"Please remove all non-TAUOLA decay modes for particle "
181 if ( totalTauModeBF > 0.0 ) {
182 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
183 <<
"Setting TAUOLA BF modes using the definitions for the particle "
186 for ( iTauMode = 0; iTauMode < m_nTauolaModes; iTauMode++ ) {
187 tauolaModeBFs[iTauMode] /= totalTauModeBF;
188 double modeBF = tauolaModeBFs[iTauMode];
189 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
190 <<
"Setting TAUOLA BF for mode " << iTauMode + 1
191 <<
" = " << modeBF << endl;
192 Tauolapp::Tauola::setTauBr( iTauMode + 1, modeBF );
195 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
196 <<
"Any other TAUOLA BF modes for other tau particle decay mode definitions will be ignored!"
205 int EvtTauolaEngine::getModeInt( EvtDecayBase* decayModel )
210 int nVars = decayModel->getNArg();
213 modeInt =
static_cast<int>( decayModel->getArg( 0 ) );
220 void EvtTauolaEngine::setOtherParameters()
229 if ( neutPropName ==
"Z0" || neutPropName ==
"Z" ) {
231 }
else if ( neutPropName ==
"Gamma" ) {
232 m_neutPropType = Tauolapp::TauolaParticle::GAMMA;
233 }
else if ( neutPropName ==
"Higgs" ) {
234 m_neutPropType = Tauolapp::TauolaParticle::HIGGS;
235 }
else if ( neutPropName ==
"PseudoHiggs" ) {
236 m_neutPropType = Tauolapp::TauolaParticle::HIGGS_A;
237 }
else if ( neutPropName ==
"MixedHiggs" ) {
238 m_neutPropType = Tauolapp::Tauola::getHiggsScalarPseudoscalarPDG();
241 if ( m_neutPropType != 0 ) {
242 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
243 <<
"TAUOLA neutral spin propagator PDG id set to " << m_neutPropType
249 std::string chargedPropName =
EvtSymTable::get(
"TauolaChargedProp", iErr );
250 if ( chargedPropName ==
"W" ) {
251 m_negPropType = Tauolapp::TauolaParticle::W_MINUS;
252 m_posPropType = Tauolapp::TauolaParticle::W_PLUS;
253 }
else if ( chargedPropName ==
"Higgs" ) {
254 m_negPropType = Tauolapp::TauolaParticle::HIGGS_MINUS;
255 m_posPropType = Tauolapp::TauolaParticle::HIGGS_PLUS;
258 if ( m_negPropType != 0 ) {
259 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
260 <<
"TAUOLA negative charge spin propagator PDG id set to "
261 << m_negPropType << endl;
264 if ( m_posPropType != 0 ) {
265 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
266 <<
"TAUOLA positive charge spin propagator PDG id set to "
267 << m_posPropType << endl;
274 if ( mixString !=
"TauolaHiggsMixingAngle" ) {
275 double mixAngle =
std::atof( mixString.c_str() );
276 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
277 <<
"TAUOLA Higgs mixing angle set to " << mixAngle <<
" radians"
279 Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle( mixAngle );
285 std::vector<double> BRVect;
286 BRVect.push_back( 0.5 );
287 BRVect.push_back( 0.5 );
288 BRVect.push_back( 0.5 );
289 BRVect.push_back( 0.6667 );
291 for ( j = 1; j < 5; j++ ) {
292 std::ostringstream o;
294 std::string BRName =
"TauolaBR" + o.str();
298 if ( stringBR != BRName ) {
299 BRVect[j - 1] =
std::atof( stringBR.c_str() );
303 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
304 <<
"TAUOLA::setTaukle values are " << BRVect[0] <<
", " << BRVect[1]
305 <<
", " << BRVect[2] <<
", " << BRVect[3] << endl;
307 Tauolapp::Tauola::setTaukle( BRVect[0], BRVect[1], BRVect[2], BRVect[3] );
311 std::string currentOption =
EvtSymTable::get(
"TauolaCurrentOption", iErr );
313 if ( currentOption !=
"TauolaCurrentOption" ) {
314 int currentOpt =
std::atoi( currentOption.c_str() );
315 EvtGenReport( EVTGEN_INFO,
"EvtGen" )
316 <<
"TAUOLA current option = " << currentOpt << endl;
318 Tauolapp::Tauola::setNewCurrents( currentOpt );
322 bool EvtTauolaEngine::doDecay( EvtParticle* tauParticle )
324 if ( m_initialised ==
false ) {
328 if ( tauParticle == 0 ) {
333 EvtId partId = tauParticle->getId();
334 if ( abs( EvtPDL::getStdHep( partId ) ) != m_tauPDG ) {
338 int nTauDaug = tauParticle->getNDaug();
342 if ( nTauDaug > 0 ) {
346 this->decayTauEvent( tauParticle );
351 void EvtTauolaEngine::decayTauEvent( EvtParticle* tauParticle )
367 theEvent->add_vertex( theVertex );
370 EvtParticle* theParent = tauParticle->getParent();
375 hepMCParent = this->createGenParticle( theParent );
376 theVertex->add_particle_in( hepMCParent );
380 GenParticlePtr tauGenInit = this->createGenParticle( tauParticle );
381 theVertex->add_particle_in( tauGenInit );
398 std::map<GenParticlePtr, EvtParticle*> tauMap;
402 EvtId origParentId( -1, -1 );
406 origParentId = EvtPDL::getId( theParent->getName() );
411 int nDaug( theParent->getNDaug() );
414 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
415 EvtParticle* theDaughter = theParent->getDaug( iDaug );
420 theVertex->add_particle_out( hepMCDaughter );
422 EvtId theId = theDaughter->getId();
423 int PDGInt = EvtPDL::getStdHep( theId );
425 if ( abs( PDGInt ) == m_tauPDG ) {
427 if ( theDaughter->getNDaug() > 0 ) {
428 theDaughter->deleteDaughters(
false );
430 tauMap[hepMCDaughter] = theDaughter;
434 hepMCDaughter->set_status( Tauolapp::TauolaParticle::STABLE );
443 if ( nTaus > 0 && hepMCParent ) {
444 int parCharge = EvtPDL::chg3( origParentId ) /
446 if ( parCharge == 0 && m_neutPropType != 0 ) {
447 hepMCParent->set_pdg_id( m_neutPropType );
448 }
else if ( parCharge == -1 && m_negPropType != 0 ) {
449 hepMCParent->set_pdg_id( m_negPropType );
450 }
else if ( parCharge == 1 && m_posPropType != 0 ) {
451 hepMCParent->set_pdg_id( m_posPropType );
457 GenParticlePtr singleTau = this->createGenParticle( tauParticle );
458 theVertex->add_particle_out( singleTau );
459 tauMap[singleTau] = tauParticle;
465 Tauolapp::TauolaHepMC3Event tauolaEvent( theEvent.get() );
467 Tauolapp::TauolaHepMCEvent tauolaEvent( theEvent.get() );
471 tauolaEvent.decayTaus();
482 for (
auto aParticle : theEvent->particles() ) {
484 HepMC::GenEvent::particle_iterator eventIter;
485 for ( eventIter = theEvent->particles_begin();
486 eventIter != theEvent->particles_end(); ++eventIter ) {
491 if ( aParticle && abs( aParticle->pdg_id() ) == m_tauPDG ) {
494 EvtParticle* tauEvtParticle = tauMap[aParticle];
496 if ( tauEvtParticle ) {
499 EvtVector4R tauP4CM = tauEvtParticle->getP4Lab();
500 tauP4CM.set( tauP4CM.get( 0 ), -tauP4CM.get( 1 ),
501 -tauP4CM.get( 2 ), -tauP4CM.get( 3 ) );
506 std::vector<EvtId> daugIdVect;
507 std::vector<EvtVector4R> daugP4Vect;
512 HepMC3::Relatives::DESCENDANTS( endVertex ) ) {
514 HepMC::GenVertex::particle_iterator tauIter;
516 for ( tauIter = endVertex->particles_begin( HepMC::descendants );
517 tauIter != endVertex->particles_end( HepMC::descendants );
525 if ( daugDecayVtx ) {
530 int tauDaugPDG = tauDaug->pdg_id();
531 EvtId daugId = EvtPDL::evtIdFromStdHep( tauDaugPDG );
532 daugIdVect.push_back( daugId );
534 FourVector tauDaugP4 = tauDaug->momentum();
535 double tauDaug_px = tauDaugP4.px();
536 double tauDaug_py = tauDaugP4.py();
537 double tauDaug_pz = tauDaugP4.pz();
538 double tauDaug_E = tauDaugP4.e();
540 EvtVector4R daugP4( tauDaug_E, tauDaug_px, tauDaug_py,
542 daugP4Vect.push_back( daugP4 );
547 int nDaug = daugIdVect.size();
549 tauEvtParticle->makeDaughters( nDaug, daugIdVect );
552 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
553 EvtParticle* theDaugPart = tauEvtParticle->getDaug( iDaug );
556 EvtId theDaugId = daugIdVect[iDaug];
557 EvtVector4R theDaugP4 = daugP4Vect[iDaug];
558 theDaugP4.applyBoostTo(
560 theDaugPart->init( theDaugId, theDaugP4 );
572 GenParticlePtr EvtTauolaEngine::createGenParticle( EvtParticle* theParticle )
575 if ( theParticle == 0 ) {
580 EvtVector4R p4 = theParticle->getP4Lab();
583 double E = p4.get( 0 );
584 double px = p4.get( 1 );
585 double py = p4.get( 2 );
586 double pz = p4.get( 3 );
588 FourVector hepMC_p4(
px,
py,
pz,
E );
590 int PDGInt = EvtPDL::getStdHep( theParticle->getId() );
593 int status = Tauolapp::TauolaParticle::HISTORY;