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),
53 fIsInitialized(
false),
55 fSelectDecayByEvent(
false),
59 dolheBosonCorr(
false),
62 throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to override Tauola an existing ParameterSet\n"
76 throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to initialize Tauola with an empty ParameterSet\n"
83 Tauolapp::Tauola::setDecayingParticle(15);
99 fMDTAU = cards.getParameter<
int>(
"mdtau");
102 Tauolapp::Tauola::setSameParticleDecayMode(cards.getParameter<
int>(
"pjak1"));
103 Tauolapp::Tauola::setOppositeParticleDecayMode(cards.getParameter<
int>(
"pjak2"));
114 double lifetime = PData->lifetime().value();
115 Tauolapp::Tauola::setTauLifetime(
lifetime);
117 fPDGs.push_back(Tauolapp::Tauola::getDecayingParticle());
122 std::vector<std::string> par =
fPSet->
getParameter<std::vector<std::string> >(
"parameterSets");
123 for (
unsigned int ip = 0; ip < par.size(); ++ip) {
125 if (curSet ==
"setNewCurrents")
132 Tauolapp::Tauola::spin_correlation.setAll(
136 std::vector<std::string> par =
fPSet->
getParameter<std::vector<std::string> >(
"parameterSets");
137 for (
unsigned int ip = 0; ip < par.size(); ++ip) {
139 if (curSet ==
"spinCorrelationSetAll")
141 if (curSet ==
"spinCorrelationGAMMA")
143 if (curSet ==
"spinCorrelationZ0")
145 if (curSet ==
"spinCorrelationHIGGS")
147 if (curSet ==
"spinCorrelationHIGGSH")
149 if (curSet ==
"spinCorrelationHIGGSA")
151 if (curSet ==
"spinCorrelationHIGGSPLUS")
152 Tauolapp::Tauola::spin_correlation.HIGGS_PLUS =
fPSet->
getParameter<
bool>(curSet);
153 if (curSet ==
"spinCorrelationHIGGSMINUS")
154 Tauolapp::Tauola::spin_correlation.HIGGS_MINUS =
fPSet->
getParameter<
bool>(curSet);
155 if (curSet ==
"spinCorrelationWPLUS")
157 if (curSet ==
"spinCorrelationWMINUS")
160 if (curSet ==
"setHiggsScalarPseudoscalarPDG")
161 Tauolapp::Tauola::setHiggsScalarPseudoscalarPDG(
fPSet->
getParameter<
int>(curSet));
162 if (curSet ==
"setHiggsScalarPseudoscalarMixingAngle")
163 Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle(
fPSet->
getParameter<
double>(curSet));
165 if (curSet ==
"setRadiation")
167 if (curSet ==
"setRadiationCutOff")
170 if (curSet ==
"setEtaK0sPi") {
172 if (vpar.size() == 3)
173 Tauolapp::Tauola::setEtaK0sPi(vpar[0], vpar[1], vpar[2]);
175 std::cout <<
"WARNING invalid size for setEtaK0sPi: " << vpar.size() <<
" Require 3 elements " << std::endl;
179 if (curSet ==
"setTaukle") {
181 if (vpar.size() == 4)
182 Tauolapp::Tauola::setTaukle(vpar[0], vpar[1], vpar[2], vpar[3]);
184 std::cout <<
"WARNING invalid size for setTaukle: " << vpar.size() <<
" Require 4 elements " << std::endl;
188 if (curSet ==
"setTauBr") {
190 std::vector<int> vJAK =
cfg.getParameter<std::vector<int> >(
"JAK");
191 std::vector<double> vBR =
cfg.getParameter<std::vector<double> >(
"BR");
192 if (vJAK.size() == vBR.size()) {
193 for (
unsigned int i = 0;
i < vJAK.size();
i++)
194 Tauolapp::Tauola::setTauBr(vJAK[
i], vBR[
i]);
196 std::cout <<
"WARNING invalid size for setTauBr - JAK: " << vJAK.size() <<
" BR: " << vBR.size() << std::endl;
218 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n"
219 <<
"This might mean that the code was modified to generate a random number outside the\n"
220 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
228 Tauolapp::Tauola::setRandomGenerator(
230 int NPartBefore = evt->particles_size();
231 int NVtxBefore = evt->vertices_size();
242 std::vector<HepMC::GenParticle>
particles;
243 std::vector<int> m_idx;
246 for (
unsigned int i = 0;
i < spinup.size();
i++) {
259 std::vector<HepMC::GenParticle*>
match;
260 for (HepMC::GenEvent::particle_const_iterator iter = evt->particles_begin(); iter != evt->particles_end(); iter++) {
261 if (
abs((*iter)->pdg_id()) == 15) {
265 for (HepMC::GenVertex::particle_iterator mother = (*iter)->production_vertex()->particles_begin(
HepMC::parents);
266 mother != (*iter)->production_vertex()->particles_end(
HepMC::parents);
268 mother_pid = (*mother)->pdg_id();
269 if (mother_pid != (*iter)->pdg_id()) {
271 if (
abs(mother_pid) == 24 ||
272 abs(mother_pid) == 37 ||
273 abs(mother_pid) == 23 ||
274 abs(mother_pid) == 22 ||
275 abs(mother_pid) == 25 ||
276 abs(mother_pid) == 35 ||
277 abs(mother_pid) == 36
279 bool isfound =
false;
280 for (
unsigned int k = 0;
k <
match.size();
k++) {
281 if ((*mother) ==
match.at(
k))
285 match.push_back(*mother);
296 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
297 t_event->undecayTaus();
298 t_event->decayTaus();
300 for (
unsigned int j = 0;
j < spinup.size();
j++) {
302 double diffhelminus = (-1.0 * (double)Tauolapp::Tauola::getHelMinus() -
304 double diffhelplus = ((double)Tauolapp::Tauola::getHelPlus() - spinup.at(
j));
305 if (
pdg.at(
j) == 15 && diffhelminus > 0.5)
307 if (
pdg.at(
j) == -15 && diffhelplus > 0.5)
318 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
319 t_event->undecayTaus();
322 for (HepMC::GenEvent::particle_const_iterator iter = evt->particles_begin(); iter != evt->particles_end();
326 (*iter)->momentum().px(), (*iter)->momentum().py(), (*iter)->momentum().pz(), (*iter)->momentum().e());
328 TLorentzVector mother(
m->momentum().px(),
m->momentum().py(),
m->momentum().pz(),
m->momentum().e());
329 TVector3
boost = -1.0 * mother.BoostVector();
330 TLorentzVector ltau_lab = ltau;
335 Tauolapp::TauolaParticle*
tp =
new Tauolapp::TauolaHepMCParticle(
p);
337 if ((*iter)->pdg_id() == 15)
341 Tauolapp::Tauola::decayOne(
tp,
true, 0, 0, ((
double)helicity) * 0.999999);
354 auto* t_event =
new Tauolapp::TauolaHepMCEvent(evt);
356 t_event->decayTaus();
360 for (
int iv = NVtxBefore + 1;
iv <= evt->vertices_size();
iv++) {
361 HepMC::GenVertex*
GenVtx = evt->barcode_to_vertex(-
iv);
367 std::vector<int> BCodes;
372 if ((*pitr)->barcode() > 10000) {
373 BCodes.push_back((*pitr)->barcode());
376 if (!BCodes.empty()) {
377 for (
size_t ibc = 0; ibc < BCodes.size(); ibc++) {
379 int nbc =
p1->barcode() - 10000 + NPartBefore;
380 p1->suggest_barcode(nbc);
385 for (HepMC::GenEvent::particle_const_iterator
p = evt->particles_begin();
p != evt->particles_end(); ++
p) {
386 if ((*p)->end_vertex() && (*p)->status() == 1)
388 if ((*p)->end_vertex() && (*p)->end_vertex()->particles_out_size() == 0)
419 Tauolapp::jaki_.jak1 = 1;
420 Tauolapp::jaki_.jak2 = 1;
421 Tauolapp::Tauola::setSameParticleDecayMode(1);
422 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
429 Tauolapp::jaki_.jak1 = 2;
430 Tauolapp::jaki_.jak2 = 2;
431 Tauolapp::Tauola::setSameParticleDecayMode(2);
432 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
440 Tauolapp::jaki_.jak1 = 1;
441 Tauolapp::jaki_.jak2 = 0;
442 Tauolapp::Tauola::setSameParticleDecayMode(1);
443 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
451 Tauolapp::jaki_.jak1 = 2;
452 Tauolapp::jaki_.jak2 = 0;
453 Tauolapp::Tauola::setSameParticleDecayMode(2);
454 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
462 Tauolapp::jaki_.jak1 = 0;
463 Tauolapp::jaki_.jak2 = 1;
464 Tauolapp::Tauola::setSameParticleDecayMode(0);
465 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
473 Tauolapp::jaki_.jak1 = 0;
474 Tauolapp::jaki_.jak2 = 2;
475 Tauolapp::Tauola::setSameParticleDecayMode(0);
476 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
483 Tauolapp::jaki_.jak1 = 3;
484 Tauolapp::jaki_.jak2 = 3;
485 Tauolapp::Tauola::setSameParticleDecayMode(3);
486 Tauolapp::Tauola::setOppositeParticleDecayMode(3);
494 Tauolapp::jaki_.jak1 = 3;
495 Tauolapp::jaki_.jak2 = 0;
496 Tauolapp::Tauola::setSameParticleDecayMode(3);
497 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
505 Tauolapp::jaki_.jak1 = 0;
506 Tauolapp::jaki_.jak2 = 3;
507 Tauolapp::Tauola::setSameParticleDecayMode(0);
508 Tauolapp::Tauola::setOppositeParticleDecayMode(3);
525 for (
int i = 0;
i < 22;
i++) {
530 for (
int i = 0;
i < 22;
i++) {
532 Tauolapp::Tauola::setTauBr(
i + 1, newBra);
537 double sumHadronBra = sumBra - sumLeptonBra;
539 for (
int i = 0;
i < 2;
i++) {
543 for (
int i = 2;
i < 22;
i++) {
555 Tauolapp::jaki_.jak1 =
mode;
556 Tauolapp::Tauola::setSameParticleDecayMode(
mode);
558 Tauolapp::jaki_.jak2 =
mode;
559 Tauolapp::Tauola::setOppositeParticleDecayMode(
mode);
567 Tauolapp::jaki_.jak1 = modeL;
568 Tauolapp::jaki_.jak2 = 0;
569 Tauolapp::Tauola::setSameParticleDecayMode(modeL);
570 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
575 Tauolapp::jaki_.jak1 = 0;
576 Tauolapp::jaki_.jak2 = modeL;
577 Tauolapp::Tauola::setSameParticleDecayMode(0);
578 Tauolapp::Tauola::setOppositeParticleDecayMode(modeL);
583 Tauolapp::jaki_.jak1 = modeL;
584 Tauolapp::jaki_.jak2 = modeH;
585 Tauolapp::Tauola::setSameParticleDecayMode(modeL);
586 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
591 Tauolapp::jaki_.jak1 = modeH;
592 Tauolapp::jaki_.jak2 = modeL;
593 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
594 Tauolapp::Tauola::setOppositeParticleDecayMode(modeL);
599 Tauolapp::jaki_.jak1 = 1;
600 Tauolapp::jaki_.jak2 = modeH;
601 Tauolapp::Tauola::setSameParticleDecayMode(1);
602 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
607 Tauolapp::jaki_.jak1 = modeH;
608 Tauolapp::jaki_.jak2 = 1;
609 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
610 Tauolapp::Tauola::setOppositeParticleDecayMode(1);
615 Tauolapp::jaki_.jak1 = 2;
616 Tauolapp::jaki_.jak2 = modeH;
617 Tauolapp::Tauola::setSameParticleDecayMode(2);
618 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
623 Tauolapp::jaki_.jak1 = modeH;
624 Tauolapp::jaki_.jak2 = 2;
625 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
626 Tauolapp::Tauola::setOppositeParticleDecayMode(2);
631 Tauolapp::jaki_.jak1 = modeH;
633 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
634 Tauolapp::Tauola::setOppositeParticleDecayMode(Tauolapp::jaki_.
jak2);
639 Tauolapp::jaki_.jak1 = modeH;
640 Tauolapp::jaki_.jak2 = 0;
641 Tauolapp::Tauola::setSameParticleDecayMode(modeH);
642 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
647 Tauolapp::jaki_.jak1 = 0;
648 Tauolapp::jaki_.jak2 = modeH;
649 Tauolapp::Tauola::setSameParticleDecayMode(0);
650 Tauolapp::Tauola::setOppositeParticleDecayMode(modeH);
659 Tauolapp::Tauola::setSameParticleDecayMode(0);
660 Tauolapp::Tauola::setOppositeParticleDecayMode(0);
687 for (
int i = 1;
i < NN;
i++) {
701 HepMC::FourVector momentum_tau1(
l.Px(),
l.Py(),
l.Pz(),
l.E());
705 HepMC::GenVertex*
vertex =
new HepMC::GenVertex();
707 event->add_vertex(
vertex);
715 partHep->set_status(
p->status());
716 if (
p->end_vertex()) {
717 if (!partHep->end_vertex()) {
718 HepMC::GenVertex*
vtx =
new HepMC::GenVertex(
p->end_vertex()->position());
719 theEvent->add_vertex(
vtx);
720 vtx->add_particle_in(partHep);
722 if (
p->end_vertex()->particles_out_size() != 0) {
723 for (HepMC::GenVertex::particles_out_const_iterator
d =
p->end_vertex()->particles_out_const_begin();
724 d !=
p->end_vertex()->particles_out_const_end();
727 TLorentzVector
l((*d)->momentum().px(), (*d)->momentum().py(), (*d)->momentum().pz(), (*d)->momentum().e());
729 HepMC::FourVector momentum(
l.Px(),
l.Py(),
l.Pz(),
l.E());
731 daughter->suggest_barcode(theEvent->particles_size() + 1);
732 partHep->end_vertex()->add_particle_out(daughter);
733 if ((*d)->end_vertex())
741 if (
tau->end_vertex()) {
742 HepMC::GenVertex::particle_iterator dau;
746 int dau_pid = (*dau)->pdg_id();
747 if (dau_pid ==
tau->pdg_id())
755 std::vector<HepMC::GenParticle>&
p,
756 std::vector<double>& spinup,
757 std::vector<int>& m_idx) {
760 TLorentzVector
t(
tau->momentum().px(),
tau->momentum().py(),
tau->momentum().pz(),
tau->momentum().e());
761 TLorentzVector
m(mother->momentum().px(), mother->momentum().py(), mother->momentum().pz(), mother->momentum().e());
762 for (
unsigned int i = 0;
i <
p.size();
i++) {
763 if (
tau->pdg_id() ==
p.at(
i).pdg_id()) {
764 if (mother->pdg_id() ==
p.at(m_idx.at(
i)).
pdg_id()) {
765 TLorentzVector pm(
p.at(m_idx.at(
i)).momentum().px(),
766 p.at(m_idx.at(
i)).momentum().py(),
767 p.at(m_idx.at(
i)).momentum().pz(),
768 p.at(m_idx.at(
i)).momentum().e());
778 if (
tau->production_vertex()) {
779 HepMC::GenVertex::particle_iterator mother;
783 if ((*mother)->pdg_id() ==
tau->pdg_id())
791 if (
tau->production_vertex()) {
792 HepMC::GenVertex::particle_iterator mother;
796 if ((*mother)->pdg_id() ==
tau->pdg_id())
806 TLorentzVector&
prod) {
807 if (
p->end_vertex() &&
p->production_vertex()) {
808 HepMC::GenVertex* PGenVtx =
p->production_vertex();
809 HepMC::GenVertex* EGenVtx =
p->end_vertex();
810 double VxDec = PGenVtx->position().x() + lab.Px() /
prod.Px() * (EGenVtx->position().x() - PGenVtx->position().x());
811 double VyDec = PGenVtx->position().y() + lab.Py() /
prod.Py() * (EGenVtx->position().y() - PGenVtx->position().y());
812 double VzDec = PGenVtx->position().z() + lab.Pz() /
prod.Pz() * (EGenVtx->position().z() - PGenVtx->position().z());
813 double VtDec = PGenVtx->position().t() + lab.Pt() /
prod.Pt() * (EGenVtx->position().t() - PGenVtx->position().t());
814 EGenVtx->set_position(HepMC::FourVector(VxDec, VyDec, VzDec, VtDec));
815 for (HepMC::GenVertex::particle_iterator dau =
p->end_vertex()->particles_begin(
HepMC::children);