279 #include "Tauola/Tauola.h"
280 #include "Tauola/TauolaHepMCEvent.h"
281 #include "Tauola/Log.h"
285 #include "CLHEP/Random/RandomEngine.h"
287 #include "HepMC/GenEvent.h"
288 #include "HepMC/IO_HEPEVT.h"
289 #include "HepMC/HEPEVT_Wrapper.h"
300 for(
int i = 0;
i < *lenv;
i++)
302 *rvec++ = instance->
flat();
321 : fRandomEngine(
nullptr), fPolarization(
false), fPSet(0),
322 fIsInitialized(
false), fMDTAU(-1), fSelectDecayByEvent(
false)
380 <<
"Attempt to override Tauola an existing ParameterSet\n"
399 <<
"Attempt to initialize Tauola with an empty ParameterSet\n"
407 Tauolapp::Tauola::setDecayingParticle(15);
419 fMDTAU = cards.getParameter<
int >(
"mdtau" );
421 if ( fMDTAU == 0 || fMDTAU == 1 )
423 Tauolapp::Tauola::setSameParticleDecayMode( cards.getParameter<
int >(
"pjak1" ) ) ;
424 Tauolapp::Tauola::setOppositeParticleDecayMode( cards.getParameter<
int >(
"pjak2" ) ) ;
427 Tauolapp::Tauola::setTauLifetime(0.0);
442 fPDGs.push_back( Tauolapp::Tauola::getDecayingParticle() );
445 Tauolapp::Tauola::initialize();
453 if ( fMDTAU != 0 && fMDTAU != 1 )
458 Tauolapp::Log::LogWarning(
false);
470 <<
"Attempt to run random number generator of un-initialized Tauola\n"
478 <<
"Attempt to run random number generator of un-initialized Tauola\n"
484 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n"
485 <<
"This might mean that the code was modified to generate a random number outside the\n"
486 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
496 int NPartBefore = evt->particles_size();
497 int NVtxBefore = evt->vertices_size();
514 auto * t_event =
new Tauolapp::TauolaHepMCEvent(evt);
522 t_event->decayTaus();
534 for (
int iv=NVtxBefore+1; iv<=evt->vertices_size(); iv++ )
536 HepMC::GenVertex* GenVtx = evt->barcode_to_vertex(-iv);
538 HepMC::GenVertex* ProdVtx = GenPart->production_vertex();
539 HepMC::FourVector PMom = GenPart->momentum();
540 double mass = GenPart->generated_mass();
543 double lifetime = PData->lifetime().value();
547 double ct = -lifetime *
std::log(prob);
548 double VxDec = GenVtx->position().x();
549 VxDec += ct * (PMom.px()/mass);
550 VxDec += ProdVtx->position().x();
551 double VyDec = GenVtx->position().y();
552 VyDec += ct * (PMom.py()/mass);
553 VyDec += ProdVtx->position().y();
554 double VzDec = GenVtx->position().z();
555 VzDec += ct * (PMom.pz()/mass);
556 VzDec += ProdVtx->position().z();
557 double VtDec = GenVtx->position().t();
558 VtDec += ct * (PMom.e()/mass);
559 VtDec += ProdVtx->position().t();
560 GenVtx->set_position( HepMC::FourVector(VxDec,VyDec,VzDec,VtDec) );
566 std::vector<int> BCodes;
568 for (HepMC::GenVertex::particle_iterator pitr= GenVtx->particles_begin(HepMC::children);
569 pitr != GenVtx->particles_end(HepMC::children); ++pitr)
571 if ( (*pitr)->barcode() > 10000 )
573 BCodes.push_back( (*pitr)->barcode() );
576 if ( BCodes.size() > 0 )
578 for (
size_t ibc=0; ibc<BCodes.size(); ibc++ )
581 int nbc = p1->barcode() - 10000 + NPartBefore;
582 p1->suggest_barcode( nbc );
617 if ( mdtau == 101 || mdtau == 201 )
621 Tauolapp::jaki_.jak1 = 1;
622 Tauolapp::jaki_.jak2 = 1;
623 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
624 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
628 if ( mdtau == 102 || mdtau == 202 )
632 Tauolapp::jaki_.jak1 = 2;
633 Tauolapp::jaki_.jak2 = 2;
634 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
635 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
639 if ( mdtau == 111 || mdtau == 211 )
644 Tauolapp::jaki_.jak1 = 1;
645 Tauolapp::jaki_.jak2 = 0;
646 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
647 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
651 if ( mdtau == 112 || mdtau == 212 )
656 Tauolapp::jaki_.jak1 = 2;
657 Tauolapp::jaki_.jak2 = 0;
658 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
659 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
663 if ( mdtau == 121 || mdtau == 221 )
668 Tauolapp::jaki_.jak1 = 0;
669 Tauolapp::jaki_.jak2 = 1;
670 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
671 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
675 if ( mdtau == 122 || mdtau == 222 )
680 Tauolapp::jaki_.jak1 = 0;
681 Tauolapp::jaki_.jak2 = 2;
682 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
683 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
687 if ( mdtau == 140 || mdtau == 240 )
691 Tauolapp::jaki_.jak1 = 3;
692 Tauolapp::jaki_.jak2 = 3;
693 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
694 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
698 if ( mdtau == 141 || mdtau == 241 )
703 Tauolapp::jaki_.jak1 = 3;
704 Tauolapp::jaki_.jak2 = 0;
705 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
706 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
710 if ( mdtau == 142 || mdtau == 242 )
715 Tauolapp::jaki_.jak1 = 0;
716 Tauolapp::jaki_.jak2 = 3;
717 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
718 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
735 for (
int i=0;
i<22;
i++ )
739 if ( sumBra == 0. )
return ;
740 for (
int i=0;
i<22;
i++ )
743 Tauolapp::Tauola::setTauBr(
i+1, newBra );
748 double sumHadronBra = sumBra - sumLeptonBra;
750 for (
int i=0;
i<2;
i++ )
755 for (
int i=2;
i<22;
i++ )
773 Tauolapp::jaki_.jak1 =
mode;
774 Tauolapp::Tauola::setSameParticleDecayMode( mode );
776 Tauolapp::jaki_.jak2 =
mode;
777 Tauolapp::Tauola::setOppositeParticleDecayMode( mode );
786 Tauolapp::jaki_.jak1 = modeL;
787 Tauolapp::jaki_.jak2 = 0;
788 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
789 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
795 Tauolapp::jaki_.jak1 = 0;
796 Tauolapp::jaki_.jak2 = modeL;
797 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
798 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
804 Tauolapp::jaki_.jak1 = modeL;
805 Tauolapp::jaki_.jak2 = modeH;
806 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
807 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
813 Tauolapp::jaki_.jak1 = modeH;
814 Tauolapp::jaki_.jak2 = modeL;
815 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
816 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
822 Tauolapp::jaki_.jak1 = 1;
823 Tauolapp::jaki_.jak2 = modeH;
824 Tauolapp::Tauola::setSameParticleDecayMode( 1 );
825 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
831 Tauolapp::jaki_.jak1 = modeH;
832 Tauolapp::jaki_.jak2 = 1;
833 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
834 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 );
840 Tauolapp::jaki_.jak1 = 2;
841 Tauolapp::jaki_.jak2 = modeH;
842 Tauolapp::Tauola::setSameParticleDecayMode( 2 );
843 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
849 Tauolapp::jaki_.jak1 = modeH;
850 Tauolapp::jaki_.jak2 = 2;
851 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
852 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 );
858 Tauolapp::jaki_.jak1 = modeH;
860 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
861 Tauolapp::Tauola::setOppositeParticleDecayMode( Tauolapp::jaki_.
jak2 );
867 Tauolapp::jaki_.jak1 = modeH;
868 Tauolapp::jaki_.jak2 = 0;
869 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
870 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
876 Tauolapp::jaki_.jak1 = 0;
877 Tauolapp::jaki_.jak2 = modeH;
878 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
879 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
888 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
889 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
921 if ( prob > 0. && prob <= sumBra )
928 for (
int i=1;
i<NN;
i++ )
944 return (
double)instance->
flat();
T getParameter(std::string const &) const
void selectDecayByMDTAU()
HepMC::GenEvent * decay(HepMC::GenEvent *)
static PFTauRenderPlugin instance
void setPSet(const edm::ParameterSet &)
void rmarin_(int *, int *, int *)
std::vector< double > fScaledLeptonBrRatios
void getData(T &iHolder) const
std::vector< int > fLeptonModes
static TauolaInterface * fInstance
double TauolappInterface_RandGetter()
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
Abs< T >::type abs(const T &t)
void ranmar_(float *rvec, int *lenv)
HepPDT::ParticleData ParticleData
CLHEP::HepRandomEngine * fRandomEngine
edm::ParameterSet * fPSet
static TauolaInterface * getInstance()
return(e1-e2)*(e1-e2)+dp *dp
std::vector< double > fScaledHadronBrRatios
void init(const edm::EventSetup &)
volatile std::atomic< bool > shutdown_flag false
std::vector< int > fHadronModes