7 #include "Tauola/Tauola.h" 8 #include "Tauola/TauolaHepMCEvent.h" 9 #include "Tauola/Log.h" 10 #include "Tauola/TauolaHepMCParticle.h" 11 #include "Tauola/TauolaParticle.h" 17 #include "CLHEP/Random/RandomEngine.h" 19 #include "HepMC/GenEvent.h" 20 #include "HepMC/IO_HEPEVT.h" 21 #include "HepMC/HEPEVT_Wrapper.h" 42 for (
int i = 0;
i < *lenv;
i++)
51 : fPolarization(
false),
54 fIsInitialized(
false),
56 fSelectDecayByEvent(
false),
60 dolheBosonCorr(
false),
74 throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to initialize Tauola with an empty ParameterSet\n" 81 Tauolapp::Tauola::setDecayingParticle(15);
97 fMDTAU = cards.getParameter<
int>(
"mdtau");
100 Tauolapp::Tauola::setSameParticleDecayMode(cards.getParameter<
int>(
"pjak1"));
101 Tauolapp::Tauola::setOppositeParticleDecayMode(cards.getParameter<
int>(
"pjak2"));
112 double lifetime = PData->lifetime().value();
113 Tauolapp::Tauola::setTauLifetime(
lifetime);
115 fPDGs.push_back(Tauolapp::Tauola::getDecayingParticle());
120 std::vector<std::string> par =
fPSet->
getParameter<std::vector<std::string> >(
"parameterSets");
121 for (
unsigned int ip = 0; ip < par.size(); ++ip) {
123 if (curSet ==
"setNewCurrents")
130 Tauolapp::Tauola::spin_correlation.setAll(
134 std::vector<std::string> par =
fPSet->
getParameter<std::vector<std::string> >(
"parameterSets");
135 for (
unsigned int ip = 0; ip < par.size(); ++ip) {
137 if (curSet ==
"spinCorrelationSetAll")
139 if (curSet ==
"spinCorrelationGAMMA")
141 if (curSet ==
"spinCorrelationZ0")
143 if (curSet ==
"spinCorrelationHIGGS")
145 if (curSet ==
"spinCorrelationHIGGSH")
147 if (curSet ==
"spinCorrelationHIGGSA")
149 if (curSet ==
"spinCorrelationHIGGSPLUS")
150 Tauolapp::Tauola::spin_correlation.HIGGS_PLUS =
fPSet->
getParameter<
bool>(curSet);
151 if (curSet ==
"spinCorrelationHIGGSMINUS")
152 Tauolapp::Tauola::spin_correlation.HIGGS_MINUS =
fPSet->
getParameter<
bool>(curSet);
153 if (curSet ==
"spinCorrelationWPLUS")
155 if (curSet ==
"spinCorrelationWMINUS")
158 if (curSet ==
"setHiggsScalarPseudoscalarPDG")
159 Tauolapp::Tauola::setHiggsScalarPseudoscalarPDG(
fPSet->
getParameter<
int>(curSet));
160 if (curSet ==
"setHiggsScalarPseudoscalarMixingAngle")
161 Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle(
fPSet->
getParameter<
double>(curSet));
163 if (curSet ==
"setRadiation")
165 if (curSet ==
"setRadiationCutOff")
168 if (curSet ==
"setEtaK0sPi") {
170 if (vpar.size() == 3)
171 Tauolapp::Tauola::setEtaK0sPi(vpar[0], vpar[1], vpar[2]);
173 std::cout <<
"WARNING invalid size for setEtaK0sPi: " << vpar.size() <<
" Require 3 elements " << std::endl;
177 if (curSet ==
"setTaukle") {
179 if (vpar.size() == 4)
180 Tauolapp::Tauola::setTaukle(vpar[0], vpar[1], vpar[2], vpar[3]);
182 std::cout <<
"WARNING invalid size for setTaukle: " << vpar.size() <<
" Require 4 elements " << std::endl;
186 if (curSet ==
"setTauBr") {
188 std::vector<int> vJAK =
cfg.getParameter<std::vector<int> >(
"JAK");
189 std::vector<double> vBR =
cfg.getParameter<std::vector<double> >(
"BR");
190 if (vJAK.size() == vBR.size()) {
191 for (
unsigned int i = 0;
i < vJAK.size();
i++)
192 Tauolapp::Tauola::setTauBr(vJAK[
i], vBR[
i]);
194 std::cout <<
"WARNING invalid size for setTauBr - JAK: " << vJAK.size() <<
" BR: " << vBR.size() << std::endl;
209 Tauolapp::Log::IgnoreRedirection(
true);
217 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n" 218 <<
"This might mean that the code was modified to generate a random number outside the\n" 219 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
227 Tauolapp::Tauola::setRandomGenerator(
229 int NPartBefore = evt->particles_size();
230 int NVtxBefore = evt->vertices_size();
241 std::vector<HepMC::GenParticle>
particles;
242 std::vector<int> m_idx;
245 for (
unsigned int i = 0;
i < spinup.size();
i++) {
258 std::vector<HepMC::GenParticle*> match;
259 for (HepMC::GenEvent::particle_const_iterator iter = evt->particles_begin(); iter != evt->particles_end(); iter++) {
260 if (
abs((*iter)->pdg_id()) == 15) {
264 for (HepMC::GenVertex::particle_iterator mother = (*iter)->production_vertex()->particles_begin(
HepMC::parents);
265 mother != (*iter)->production_vertex()->particles_end(
HepMC::parents);
267 mother_pid = (*mother)->pdg_id();
268 if (mother_pid != (*iter)->pdg_id()) {
270 if (
abs(mother_pid) == 24 ||
271 abs(mother_pid) == 37 ||
272 abs(mother_pid) == 23 ||
273 abs(mother_pid) == 22 ||
274 abs(mother_pid) == 25 ||
275 abs(mother_pid) == 35 ||
276 abs(mother_pid) == 36
278 bool isfound =
false;
279 for (
unsigned int k = 0;
k < match.size();
k++) {
280 if ((*mother) == match.at(
k))
284 match.push_back(*mother);
295 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
296 t_event->undecayTaus();
297 t_event->decayTaus();
299 for (
unsigned int j = 0;
j < spinup.size();
j++) {
301 double diffhelminus = (-1.0 * (double)Tauolapp::Tauola::getHelMinus() -
303 double diffhelplus = ((double)Tauolapp::Tauola::getHelPlus() - spinup.at(
j));
304 if (
pdg.at(
j) == 15 && diffhelminus > 0.5)
306 if (
pdg.at(
j) == -15 && diffhelplus > 0.5)
317 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
318 t_event->undecayTaus();
321 for (HepMC::GenEvent::particle_const_iterator iter = evt->particles_begin(); iter != evt->particles_end();
325 (*iter)->momentum().px(), (*iter)->momentum().py(), (*iter)->momentum().pz(), (*iter)->momentum().e());
327 TLorentzVector mother(
m->momentum().px(),
m->momentum().py(),
m->momentum().pz(),
m->momentum().e());
328 TVector3
boost = -1.0 * mother.BoostVector();
329 TLorentzVector ltau_lab = ltau;
334 Tauolapp::TauolaParticle*
tp =
new Tauolapp::TauolaHepMCParticle(
p);
336 if ((*iter)->pdg_id() == 15)
340 Tauolapp::Tauola::decayOne(
tp,
true, 0, 0, ((
double)helicity) * 0.999999);
353 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
355 t_event->decayTaus();
359 for (
int iv = NVtxBefore + 1;
iv <= evt->vertices_size();
iv++) {
360 HepMC::GenVertex*
GenVtx = evt->barcode_to_vertex(-
iv);
366 std::vector<int> BCodes;
371 if ((*pitr)->barcode() > 10000) {
372 BCodes.push_back((*pitr)->barcode());
375 if (!BCodes.empty()) {
376 for (
size_t ibc = 0; ibc < BCodes.size(); ibc++) {
378 int nbc =
p1->barcode() - 10000 + NPartBefore;
379 p1->suggest_barcode(nbc);
384 for (HepMC::GenEvent::particle_const_iterator
p = evt->particles_begin();
p != evt->particles_end(); ++
p) {
385 if ((*p)->end_vertex() && (*p)->status() == 1)
387 if ((*p)->end_vertex() && (*p)->end_vertex()->particles_out_size() == 0)
418 Tauolapp::jaki_.jak1 = 1;
419 Tauolapp::jaki_.jak2 = 1;
420 Tauolapp::Tauola::setSameParticleDecayMode(1);
421 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
428 Tauolapp::jaki_.jak1 = 2;
429 Tauolapp::jaki_.jak2 = 2;
430 Tauolapp::Tauola::setSameParticleDecayMode(2);
431 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
439 Tauolapp::jaki_.jak1 = 1;
440 Tauolapp::jaki_.jak2 = 0;
441 Tauolapp::Tauola::setSameParticleDecayMode(1);
442 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
450 Tauolapp::jaki_.jak1 = 2;
451 Tauolapp::jaki_.jak2 = 0;
452 Tauolapp::Tauola::setSameParticleDecayMode(2);
453 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
461 Tauolapp::jaki_.jak1 = 0;
462 Tauolapp::jaki_.jak2 = 1;
463 Tauolapp::Tauola::setSameParticleDecayMode(0);
464 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
472 Tauolapp::jaki_.jak1 = 0;
473 Tauolapp::jaki_.jak2 = 2;
474 Tauolapp::Tauola::setSameParticleDecayMode(0);
475 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
482 Tauolapp::jaki_.jak1 = 3;
483 Tauolapp::jaki_.jak2 = 3;
484 Tauolapp::Tauola::setSameParticleDecayMode(3);
485 Tauolapp::Tauola::setOppositeParticleDecayMode(3);
493 Tauolapp::jaki_.jak1 = 3;
494 Tauolapp::jaki_.jak2 = 0;
495 Tauolapp::Tauola::setSameParticleDecayMode(3);
496 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
504 Tauolapp::jaki_.jak1 = 0;
505 Tauolapp::jaki_.jak2 = 3;
506 Tauolapp::Tauola::setSameParticleDecayMode(0);
507 Tauolapp::Tauola::setOppositeParticleDecayMode(3);
524 for (
int i = 0;
i < 22;
i++) {
525 sumBra += Tauolapp::taubra_.gamprt[
i];
529 for (
int i = 0;
i < 22;
i++) {
530 double newBra = Tauolapp::taubra_.gamprt[
i] / sumBra;
531 Tauolapp::Tauola::setTauBr(
i + 1, newBra);
535 double sumLeptonBra = Tauolapp::taubra_.gamprt[0] + Tauolapp::taubra_.gamprt[1];
536 double sumHadronBra = sumBra - sumLeptonBra;
538 for (
int i = 0;
i < 2;
i++) {
542 for (
int i = 2;
i < 22;
i++) {
554 Tauolapp::jaki_.jak1 =
mode;
555 Tauolapp::Tauola::setSameParticleDecayMode(
mode);
557 Tauolapp::jaki_.jak2 =
mode;
558 Tauolapp::Tauola::setOppositeParticleDecayMode(
mode);
566 Tauolapp::jaki_.jak1 = modeL;
567 Tauolapp::jaki_.jak2 = 0;
568 Tauolapp::Tauola::setSameParticleDecayMode(modeL);
569 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
574 Tauolapp::jaki_.jak1 = 0;
575 Tauolapp::jaki_.jak2 = modeL;
576 Tauolapp::Tauola::setSameParticleDecayMode(0);
577 Tauolapp::Tauola::setOppositeParticleDecayMode(modeL);
582 Tauolapp::jaki_.jak1 = modeL;
583 Tauolapp::jaki_.jak2 = modeH;
584 Tauolapp::Tauola::setSameParticleDecayMode(modeL);
585 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
590 Tauolapp::jaki_.jak1 = modeH;
591 Tauolapp::jaki_.jak2 = modeL;
592 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
593 Tauolapp::Tauola::setOppositeParticleDecayMode(modeL);
598 Tauolapp::jaki_.jak1 = 1;
599 Tauolapp::jaki_.jak2 = modeH;
600 Tauolapp::Tauola::setSameParticleDecayMode(1);
601 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
606 Tauolapp::jaki_.jak1 = modeH;
607 Tauolapp::jaki_.jak2 = 1;
608 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
609 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
614 Tauolapp::jaki_.jak1 = 2;
615 Tauolapp::jaki_.jak2 = modeH;
616 Tauolapp::Tauola::setSameParticleDecayMode(2);
617 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
622 Tauolapp::jaki_.jak1 = modeH;
623 Tauolapp::jaki_.jak2 = 2;
624 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
625 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
630 Tauolapp::jaki_.jak1 = modeH;
632 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
633 Tauolapp::Tauola::setOppositeParticleDecayMode(Tauolapp::jaki_.jak2);
638 Tauolapp::jaki_.jak1 = modeH;
639 Tauolapp::jaki_.jak2 = 0;
640 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
641 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
646 Tauolapp::jaki_.jak1 = 0;
647 Tauolapp::jaki_.jak2 = modeH;
648 Tauolapp::Tauola::setSameParticleDecayMode(0);
649 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
658 Tauolapp::Tauola::setSameParticleDecayMode(0);
659 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
686 for (
int i = 1;
i <
NN;
i++) {
700 HepMC::FourVector momentum_tau1(
l.Px(),
l.Py(),
l.Pz(),
l.E());
704 HepMC::GenVertex*
vertex =
new HepMC::GenVertex();
706 event->add_vertex(
vertex);
714 partHep->set_status(
p->status());
715 if (
p->end_vertex()) {
716 if (!partHep->end_vertex()) {
717 HepMC::GenVertex*
vtx =
new HepMC::GenVertex(
p->end_vertex()->position());
718 theEvent->add_vertex(
vtx);
719 vtx->add_particle_in(partHep);
721 if (
p->end_vertex()->particles_out_size() != 0) {
722 for (HepMC::GenVertex::particles_out_const_iterator
d =
p->end_vertex()->particles_out_const_begin();
723 d !=
p->end_vertex()->particles_out_const_end();
726 TLorentzVector
l((*d)->momentum().px(), (*d)->momentum().py(), (*d)->momentum().pz(), (*d)->momentum().e());
728 HepMC::FourVector momentum(
l.Px(),
l.Py(),
l.Pz(),
l.E());
730 daughter->suggest_barcode(theEvent->particles_size() + 1);
731 partHep->end_vertex()->add_particle_out(daughter);
732 if ((*d)->end_vertex())
740 if (
tau->end_vertex()) {
741 HepMC::GenVertex::particle_iterator dau;
745 int dau_pid = (*dau)->pdg_id();
746 if (dau_pid ==
tau->pdg_id())
754 std::vector<HepMC::GenParticle>&
p,
755 std::vector<double>& spinup,
756 std::vector<int>& m_idx) {
759 TLorentzVector
t(
tau->momentum().px(),
tau->momentum().py(),
tau->momentum().pz(),
tau->momentum().e());
760 TLorentzVector
m(mother->momentum().px(), mother->momentum().py(), mother->momentum().pz(), mother->momentum().e());
761 for (
unsigned int i = 0;
i <
p.size();
i++) {
762 if (
tau->pdg_id() ==
p.at(
i).pdg_id()) {
763 if (mother->pdg_id() ==
p.at(m_idx.at(
i)).
pdg_id()) {
764 TLorentzVector pm(
p.at(m_idx.at(
i)).momentum().px(),
765 p.at(m_idx.at(
i)).momentum().py(),
766 p.at(m_idx.at(
i)).momentum().pz(),
767 p.at(m_idx.at(
i)).momentum().e());
777 if (
tau->production_vertex()) {
778 HepMC::GenVertex::particle_iterator mother;
782 if ((*mother)->pdg_id() ==
tau->pdg_id())
790 if (
tau->production_vertex()) {
791 HepMC::GenVertex::particle_iterator mother;
795 if ((*mother)->pdg_id() ==
tau->pdg_id())
805 TLorentzVector&
prod) {
806 if (
p->end_vertex() &&
p->production_vertex()) {
807 HepMC::GenVertex* PGenVtx =
p->production_vertex();
808 HepMC::GenVertex* EGenVtx =
p->end_vertex();
809 double VxDec = PGenVtx->position().x() + lab.Px() /
prod.Px() * (EGenVtx->position().x() - PGenVtx->position().x());
810 double VyDec = PGenVtx->position().y() + lab.Py() /
prod.Py() * (EGenVtx->position().y() - PGenVtx->position().y());
811 double VzDec = PGenVtx->position().z() + lab.Pz() /
prod.Pz() * (EGenVtx->position().z() - PGenVtx->position().z());
812 double VtDec = PGenVtx->position().t() + lab.Pt() /
prod.Pt() * (EGenVtx->position().t() - PGenVtx->position().t());
813 EGenVtx->set_position(HepMC::FourVector(VxDec, VyDec, VzDec, VtDec));
814 for (HepMC::GenVertex::particle_iterator dau =
p->end_vertex()->particles_begin(
HepMC::children);
static AlgebraicMatrix initialize()
void statistics() override
edm::ParameterSet * fPSet
T getParameter(std::string const &) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
HepMC::GenEvent * decay(HepMC::GenEvent *) override
std::vector< double > fScaledHadronBrRatios
HepMC::GenEvent * make_simple_tau_event(const TLorentzVector &l, int pdgid, int status)
TauolappInterface(const edm::ParameterSet &, edm::ConsumesCollector)
void init(const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
void BoostProdToLabLifeTimeInDecays(HepMC::GenParticle *p, TLorentzVector &lab, TLorentzVector &prod)
std::vector< int > fLeptonModes
~TauolappInterface() override
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > fPDGTableToken
std::vector< FiveVector > PUP
constexpr Matriplex::idx_t NN
std::vector< double > SPINUP
Abs< T >::type abs(const T &t)
void rmarin_(int *, int *, int *)
std::vector< std::pair< int, int > > MOTHUP
HepPDT::ParticleData ParticleData
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void update_particles(HepMC::GenParticle *partHep, HepMC::GenEvent *theEvent, HepMC::GenParticle *p, TVector3 &boost)
const HEPEUP * getHEPEUP() const
HepMC::GenParticle * FirstTauInChain(HepMC::GenParticle *tau)
bool isLastTauInChain(const HepMC::GenParticle *tau)
std::vector< double > fScaledLeptonBrRatios
static CLHEP::HepRandomEngine * fRandomEngine
std::vector< int > fHadronModes
void ranmar_(float *rvec, int *lenv)
HepMC::GenParticle * GetMother(HepMC::GenParticle *tau)
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
Log< level::Warning, false > LogWarning
double MatchedLHESpinUp(HepMC::GenParticle *tau, std::vector< HepMC::GenParticle > &p, std::vector< double > &spinup, std::vector< int > &m_idx)
void selectDecayByMDTAU()