32 #include "Tauola/Log.h" 33 #include "Tauola/Tauola.h" 43 EvtTauolaEngine::EvtTauolaEngine(
bool useEvtGenRandom )
54 Tauolapp::Tauola::setDecayingParticle( _tauPDG );
55 Tauolapp::Tauola::setSameParticleDecayMode(
56 Tauolapp::Tauola::All );
57 Tauolapp::Tauola::setOppositeParticleDecayMode(
58 Tauolapp::Tauola::All );
61 Tauolapp::Log::SetWarningLimit( 1 );
64 if ( useEvtGenRandom ==
true ) {
66 <<
"Using EvtGen random number engine also for Tauola++" << endl;
73 Tauolapp::Tauola::setNewCurrents( 1 );
75 Tauolapp::Tauola::initialize();
87 void EvtTauolaEngine::initialise()
95 if ( _initialised ==
false ) {
96 this->setUpPossibleTauModes();
97 this->setOtherParameters();
103 void EvtTauolaEngine::setUpPossibleTauModes()
117 bool gotAnyTauolaModes(
false );
119 for ( iPDL = 0; iPDL < nPDL; iPDL++ ) {
123 if (
abs( PDGId ) == _tauPDG && gotAnyTauolaModes ==
false ) {
124 int aliasInt = particleId.
getAlias();
128 int iMode( 0 ), iTauMode( 0 );
133 std::vector<double> tauolaModeBFs( _nTauolaModes );
135 for ( iTauMode = 0; iTauMode < _nTauolaModes; iTauMode++ ) {
136 tauolaModeBFs[iTauMode] = 0.0;
139 double totalTauModeBF( 0.0 );
141 int nNonTauolaModes( 0 );
144 for ( iMode = 0; iMode < nModes; iMode++ ) {
150 std::string modelName = decayModel->
getName();
151 if ( modelName ==
"TAUOLA" ) {
152 if ( gotAnyTauolaModes ==
false ) {
153 gotAnyTauolaModes =
true;
158 int modeArrayInt = this->getModeInt( decayModel ) - 1;
160 if ( modeArrayInt >= 0 && modeArrayInt < _nTauolaModes ) {
161 tauolaModeBFs[modeArrayInt] = BF;
162 totalTauModeBF += BF;
173 if ( gotAnyTauolaModes ==
true && nNonTauolaModes > 0 ) {
175 <<
"Please remove all non-TAUOLA decay modes for particle " 182 if ( totalTauModeBF > 0.0 ) {
184 <<
"Setting TAUOLA BF modes using the definitions for the particle " 187 for ( iTauMode = 0; iTauMode < _nTauolaModes; iTauMode++ ) {
188 tauolaModeBFs[iTauMode] /= totalTauModeBF;
189 double modeBF = tauolaModeBFs[iTauMode];
191 <<
"Setting TAUOLA BF for mode " << iTauMode + 1
192 <<
" = " << modeBF << endl;
193 Tauolapp::Tauola::setTauBr( iTauMode + 1, modeBF );
197 <<
"Any other TAUOLA BF modes for other tau particle decay mode definitions will be ignored!" 206 int EvtTauolaEngine::getModeInt(
EvtDecayBase* decayModel )
211 int nVars = decayModel->
getNArg();
214 modeInt = static_cast<int>( decayModel->
getArg( 0 ) );
221 void EvtTauolaEngine::setOtherParameters()
230 if ( neutPropName ==
"Z0" || neutPropName ==
"Z" ) {
231 _neutPropType = Tauolapp::TauolaParticle::Z0;
232 }
else if ( neutPropName ==
"Gamma" ) {
233 _neutPropType = Tauolapp::TauolaParticle::GAMMA;
234 }
else if ( neutPropName ==
"Higgs" ) {
235 _neutPropType = Tauolapp::TauolaParticle::HIGGS;
236 }
else if ( neutPropName ==
"PseudoHiggs" ) {
237 _neutPropType = Tauolapp::TauolaParticle::HIGGS_A;
238 }
else if ( neutPropName ==
"MixedHiggs" ) {
239 _neutPropType = Tauolapp::Tauola::getHiggsScalarPseudoscalarPDG();
242 if ( _neutPropType != 0 ) {
244 <<
"TAUOLA neutral spin propagator PDG id set to " << _neutPropType
250 std::string chargedPropName =
EvtSymTable::get(
"TauolaChargedProp", iErr );
251 if ( chargedPropName ==
"W" ) {
252 _negPropType = Tauolapp::TauolaParticle::W_MINUS;
253 _posPropType = Tauolapp::TauolaParticle::W_PLUS;
254 }
else if ( chargedPropName ==
"Higgs" ) {
255 _negPropType = Tauolapp::TauolaParticle::HIGGS_MINUS;
256 _posPropType = Tauolapp::TauolaParticle::HIGGS_PLUS;
259 if ( _negPropType != 0 ) {
261 <<
"TAUOLA negative charge spin propagator PDG id set to " 262 << _negPropType << endl;
265 if ( _posPropType != 0 ) {
267 <<
"TAUOLA positive charge spin propagator PDG id set to " 268 << _posPropType << endl;
275 if ( mixString !=
"TauolaHiggsMixingAngle" ) {
276 double mixAngle = std::atof( mixString.c_str() );
278 <<
"TAUOLA Higgs mixing angle set to " << mixAngle <<
" radians" 280 Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle( mixAngle );
286 std::vector<double> BRVect;
287 BRVect.push_back( 0.5 );
288 BRVect.push_back( 0.5 );
289 BRVect.push_back( 0.5 );
290 BRVect.push_back( 0.6667 );
292 for ( j = 1; j < 5; j++ ) {
293 std::ostringstream o;
295 std::string BRName =
"TauolaBR" + o.str();
299 if ( stringBR != BRName ) {
300 BRVect[j - 1] = std::atof( stringBR.c_str() );
305 <<
"TAUOLA::setTaukle values are " << BRVect[0] <<
", " << BRVect[1]
306 <<
", " << BRVect[2] <<
", " << BRVect[3] << endl;
308 Tauolapp::Tauola::setTaukle( BRVect[0], BRVect[1], BRVect[2], BRVect[3] );
312 std::string currentOption =
EvtSymTable::get(
"TauolaCurrentOption", iErr );
314 if ( currentOption !=
"TauolaCurrentOption" ) {
315 int currentOpt = std::atoi( currentOption.c_str() );
317 <<
"TAUOLA current option = " << currentOpt << endl;
319 Tauolapp::Tauola::setNewCurrents( currentOpt );
323 bool EvtTauolaEngine::doDecay(
EvtParticle* tauParticle )
325 if ( _initialised ==
false ) {
329 if ( tauParticle == 0 ) {
339 int nTauDaug = tauParticle->
getNDaug();
343 if ( nTauDaug > 0 ) {
347 this->decayTauEvent( tauParticle );
352 void EvtTauolaEngine::decayTauEvent(
EvtParticle* tauParticle )
364 auto theEvent = std::make_unique<GenEvent>( Units::GEV, Units::MM );
368 theEvent->add_vertex( theVertex );
376 hepMCParent = this->createGenParticle( theParent );
377 theVertex->add_particle_in( hepMCParent );
381 GenParticlePtr tauGenInit = this->createGenParticle( tauParticle );
382 theVertex->add_particle_in( tauGenInit );
399 std::map<GenParticlePtr, EvtParticle*> tauMap;
403 EvtId origParentId( -1, -1 );
415 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
421 theVertex->add_particle_out( hepMCDaughter );
426 if (
abs( PDGInt ) == _tauPDG ) {
428 if ( theDaughter->
getNDaug() > 0 ) {
431 tauMap[hepMCDaughter] = theDaughter;
435 hepMCDaughter->set_status( Tauolapp::TauolaParticle::STABLE );
444 if ( nTaus > 0 && hepMCParent ) {
447 if ( parCharge == 0 && _neutPropType != 0 ) {
448 hepMCParent->set_pdg_id( _neutPropType );
449 }
else if ( parCharge == -1 && _negPropType != 0 ) {
450 hepMCParent->set_pdg_id( _negPropType );
451 }
else if ( parCharge == 1 && _posPropType != 0 ) {
452 hepMCParent->set_pdg_id( _posPropType );
458 GenParticlePtr singleTau = this->createGenParticle( tauParticle );
459 theVertex->add_particle_out( singleTau );
460 tauMap[singleTau] = tauParticle;
466 Tauolapp::TauolaHepMC3Event tauolaEvent( theEvent.get() );
468 Tauolapp::TauolaHepMCEvent tauolaEvent( theEvent.get() );
472 tauolaEvent.decayTaus();
483 for (
auto aParticle : theEvent->particles() ) {
485 HepMC::GenEvent::particle_iterator eventIter;
486 for ( eventIter = theEvent->particles_begin();
487 eventIter != theEvent->particles_end(); ++eventIter ) {
489 HepMC::GenParticle* aParticle = ( *eventIter );
492 if ( aParticle &&
abs( aParticle->pdg_id() ) == _tauPDG ) {
497 if ( tauEvtParticle ) {
501 tauP4CM.
set( tauP4CM.
get( 0 ), -tauP4CM.
get( 1 ),
502 -tauP4CM.
get( 2 ), -tauP4CM.
get( 3 ) );
507 std::vector<EvtId> daugIdVect;
508 std::vector<EvtVector4R> daugP4Vect;
513 HepMC3::Relatives::DESCENDANTS( endVertex ) ) {
515 HepMC::GenVertex::particle_iterator tauIter;
517 for ( tauIter = endVertex->particles_begin( HepMC::descendants );
518 tauIter != endVertex->particles_end( HepMC::descendants );
520 HepMC::GenParticle* tauDaug = ( *tauIter );
526 if ( daugDecayVtx ) {
531 int tauDaugPDG = tauDaug->pdg_id();
533 daugIdVect.push_back( daugId );
536 double tauDaug_px = tauDaugP4.px();
537 double tauDaug_py = tauDaugP4.py();
538 double tauDaug_pz = tauDaugP4.pz();
539 double tauDaug_E = tauDaugP4.e();
541 EvtVector4R daugP4( tauDaug_E, tauDaug_px, tauDaug_py,
543 daugP4Vect.push_back( daugP4 );
548 int nDaug = daugIdVect.size();
553 for ( iDaug = 0; iDaug < nDaug; iDaug++ ) {
557 EvtId theDaugId = daugIdVect[iDaug];
561 theDaugPart->
init( theDaugId, theDaugP4 );
576 if ( theParticle == 0 ) {
584 double E = p4.
get( 0 );
585 double px = p4.
get( 1 );
586 double py = p4.
get( 2 );
587 double pz = p4.
get( 3 );
594 int status = Tauolapp::TauolaParticle::HISTORY;
static std::string name(EvtId i)
static EvtDecayTable * getInstance()
EvtParticle * getParent() const
HepMC::GenParticle * GenParticlePtr
static EvtId getEntry(int i)
double getArg(unsigned int j)
EvtVector4R getP4Lab() const
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void makeDaughters(unsigned int ndaug, EvtId *id)
void set(int i, double d)
static std::string get(const std::string &name, int &ierr)
HepMC::FourVector FourVector
GenVertexPtr newGenVertexPtr(const FourVector &pos=FourVector(0.0, 0.0, 0.0, 0.0))
double getBranchingFraction() const
int getNModes(int aliasInt)
void deleteDaughters(bool keepChannel=false)
EvtDecayBase * findDecayModel(int aliasInt, int modeInt)
double abs(const EvtComplex &c)
static EvtId evtIdFromStdHep(int stdhep)
static EvtId getId(const std::string &name)
HepMC::GenVertex * GenVertexPtr
virtual std::string getName()=0
void applyBoostTo(const EvtVector4R &p4, bool inverse=false)
EvtParticle * getDaug(int i)
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)