7 #include "Tauola/Tauola.h"
8 #include "Tauola/TauolaHepMCEvent.h"
9 #include "Tauola/Log.h"
15 #include "CLHEP/Random/RandomEngine.h"
17 #include "HepMC/GenEvent.h"
18 #include "HepMC/IO_HEPEVT.h"
19 #include "HepMC/HEPEVT_Wrapper.h"
34 for(
int i = 0;
i < *lenv;
i++)
49 fIsInitialized(
false),
51 fSelectDecayByEvent(
false)
53 if (
fPSet != 0 )
throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to override Tauola an existing ParameterSet\n" << std::endl;
61 if (
fPSet == 0 )
throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to initialize Tauola with an empty ParameterSet\n" << std::endl;
67 Tauolapp::Tauola::setDecayingParticle(15);
79 fMDTAU = cards.getParameter<
int >(
"mdtau" );
81 if ( fMDTAU == 0 || fMDTAU == 1 )
83 Tauolapp::Tauola::setSameParticleDecayMode( cards.getParameter<
int >(
"pjak1" ) ) ;
84 Tauolapp::Tauola::setOppositeParticleDecayMode( cards.getParameter<
int >(
"pjak2" ) ) ;
92 Tauolapp::Tauola::setTauLifetime(0.0);
94 lifetime = PData->lifetime().value();
97 fPDGs.push_back( Tauolapp::Tauola::getDecayingParticle() );
105 std::vector<std::string> par =
fPSet->
getParameter< std::vector<std::string> >(
"parameterSets");
106 for (
unsigned int ip=0; ip<par.size(); ++ip ){
109 if(curSet==
"setNewCurrents") Tauolapp::Tauola::setNewCurrents(
fPSet->
getParameter<
int>(curSet));
110 if(curSet==
"spinCorrelationSetAll") Tauolapp::Tauola::spin_correlation.setAll(
fPSet->
getParameter<
bool>(curSet));
111 if(curSet==
"spinCorrelationGAMMA") Tauolapp::Tauola::spin_correlation.GAMMA=
fPSet->
getParameter<
bool>(curSet);
112 if(curSet==
"spinCorrelationZ0") Tauolapp::Tauola::spin_correlation.Z0=
fPSet->
getParameter<
bool>(curSet);
113 if(curSet==
"spinCorrelationHIGGS") Tauolapp::Tauola::spin_correlation.HIGGS=
fPSet->
getParameter<
bool>(curSet);
114 if(curSet==
"spinCorrelationHIGGSH") Tauolapp::Tauola::spin_correlation.HIGGS_H=
fPSet->
getParameter<
bool>(curSet);
115 if(curSet==
"spinCorrelationHIGGSA") Tauolapp::Tauola::spin_correlation.HIGGS_A=
fPSet->
getParameter<
bool>(curSet);
116 if(curSet==
"spinCorrelationHIGGSPLUS") Tauolapp::Tauola::spin_correlation.HIGGS_PLUS=
fPSet->
getParameter<
bool>(curSet);
117 if(curSet==
"spinCorrelationHIGGSMINUS") Tauolapp::Tauola::spin_correlation.HIGGS_MINUS=
fPSet->
getParameter<
bool>(curSet);
118 if(curSet==
"spinCorrelationWPLUS") Tauolapp::Tauola::spin_correlation.W_PLUS=
fPSet->
getParameter<
bool>(curSet);
119 if(curSet==
"spinCorrelationWMINUS") Tauolapp::Tauola::spin_correlation.W_MINUS=
fPSet->
getParameter<
bool>(curSet);
121 if(curSet==
"setHiggsScalarPseudoscalarPDG") Tauolapp::Tauola::setHiggsScalarPseudoscalarPDG(
fPSet->
getParameter<
int>(curSet));
122 if(curSet==
"setHiggsScalarPseudoscalarMixingAngle") Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle(
fPSet->
getParameter<
double>(curSet));
124 if(curSet==
"setRadiation") Tauolapp::Tauola::setRadiation(
fPSet->
getParameter<
bool>(curSet));
125 if(curSet==
"setRadiationCutOff") Tauolapp::Tauola::setRadiationCutOff(
fPSet->
getParameter<
double>(curSet));
127 if(curSet==
"setEtaK0sPi"){
129 if(vpar.size()==3) Tauolapp::Tauola::setEtaK0sPi(vpar[0],vpar[1],vpar[2]);
130 else {
std::cout <<
"WARNING invalid size for setEtaK0sPi: " << vpar.size() <<
" Require 3 elements " << std::endl;}
133 if(curSet==
"setTaukle"){
135 if(vpar.size()==4) Tauolapp::Tauola::setTaukle(vpar[0], vpar[1], vpar[2], vpar[3]);
136 else {
std::cout <<
"WARNING invalid size for setTaukle: " << vpar.size() <<
" Require 4 elements " << std::endl;}
139 if(curSet==
"setTauBr"){
141 std::vector<int> vJAK = cfg.
getParameter<std::vector<int> >(
"JAK");
142 std::vector<double> vBR = cfg.
getParameter<std::vector<double> >(
"BR");
143 if(vJAK.size() == vBR.size()){
144 for(
unsigned int i=0;
i<vJAK.size();
i++) Tauolapp::Tauola::setTauBr(vJAK[
i],vBR[i]);
146 else {
std::cout <<
"WARNING invalid size for setTauBr - JAK: " << vJAK.size() <<
" BR: " << vBR.size() << std::endl;}
155 if ( fMDTAU != 0 && fMDTAU != 1 )
160 Tauolapp::Log::LogWarning(
false);
169 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n"
170 <<
"This might mean that the code was modified to generate a random number outside the\n"
171 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
179 int NPartBefore = evt->particles_size();
180 int NVtxBefore = evt->vertices_size();
197 auto * t_event =
new Tauolapp::TauolaHepMCEvent(evt);
205 t_event->decayTaus();
218 for(HepMC::GenEvent::particle_const_iterator
iter = evt->particles_begin();
iter != evt->particles_end();
iter++){
220 HepMC::FourVector PMom = (*iter)->momentum();
221 double mass = (*iter)->generated_mass();
230 for (
int iv=NVtxBefore+1; iv<=evt->vertices_size(); iv++ ){
231 HepMC::GenVertex* GenVtx = evt->barcode_to_vertex(-iv);
237 std::vector<int> BCodes;
239 for (HepMC::GenVertex::particle_iterator pitr= GenVtx->particles_begin(HepMC::children);
240 pitr != GenVtx->particles_end(HepMC::children); ++pitr)
242 if ( (*pitr)->barcode() > 10000 )
244 BCodes.push_back( (*pitr)->barcode() );
247 if ( BCodes.size() > 0 )
249 for (
size_t ibc=0; ibc<BCodes.size(); ibc++ )
252 int nbc = p1->barcode() - 10000 + NPartBefore;
253 p1->suggest_barcode( nbc );
288 if ( mdtau == 101 || mdtau == 201 )
292 Tauolapp::jaki_.jak1 = 1;
293 Tauolapp::jaki_.jak2 = 1;
294 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
295 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
299 if ( mdtau == 102 || mdtau == 202 )
303 Tauolapp::jaki_.jak1 = 2;
304 Tauolapp::jaki_.jak2 = 2;
305 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
306 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
310 if ( mdtau == 111 || mdtau == 211 )
315 Tauolapp::jaki_.jak1 = 1;
316 Tauolapp::jaki_.jak2 = 0;
317 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
318 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
322 if ( mdtau == 112 || mdtau == 212 )
327 Tauolapp::jaki_.jak1 = 2;
328 Tauolapp::jaki_.jak2 = 0;
329 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
330 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
334 if ( mdtau == 121 || mdtau == 221 )
339 Tauolapp::jaki_.jak1 = 0;
340 Tauolapp::jaki_.jak2 = 1;
341 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
342 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
346 if ( mdtau == 122 || mdtau == 222 )
351 Tauolapp::jaki_.jak1 = 0;
352 Tauolapp::jaki_.jak2 = 2;
353 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
354 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
358 if ( mdtau == 140 || mdtau == 240 )
362 Tauolapp::jaki_.jak1 = 3;
363 Tauolapp::jaki_.jak2 = 3;
364 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
365 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
369 if ( mdtau == 141 || mdtau == 241 )
374 Tauolapp::jaki_.jak1 = 3;
375 Tauolapp::jaki_.jak2 = 0;
376 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
377 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
381 if ( mdtau == 142 || mdtau == 242 )
386 Tauolapp::jaki_.jak1 = 0;
387 Tauolapp::jaki_.jak2 = 3;
388 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
389 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
406 for (
int i=0;
i<22;
i++ )
410 if ( sumBra == 0. )
return ;
411 for (
int i=0;
i<22;
i++ )
414 Tauolapp::Tauola::setTauBr(
i+1, newBra );
419 double sumHadronBra = sumBra - sumLeptonBra;
421 for (
int i=0;
i<2;
i++ )
426 for (
int i=2;
i<22;
i++ )
444 Tauolapp::jaki_.jak1 =
mode;
445 Tauolapp::Tauola::setSameParticleDecayMode( mode );
447 Tauolapp::jaki_.jak2 =
mode;
448 Tauolapp::Tauola::setOppositeParticleDecayMode( mode );
457 Tauolapp::jaki_.jak1 = modeL;
458 Tauolapp::jaki_.jak2 = 0;
459 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
460 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
466 Tauolapp::jaki_.jak1 = 0;
467 Tauolapp::jaki_.jak2 = modeL;
468 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
469 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
475 Tauolapp::jaki_.jak1 = modeL;
476 Tauolapp::jaki_.jak2 = modeH;
477 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
478 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
484 Tauolapp::jaki_.jak1 = modeH;
485 Tauolapp::jaki_.jak2 = modeL;
486 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
487 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
493 Tauolapp::jaki_.jak1 = 1;
494 Tauolapp::jaki_.jak2 = modeH;
495 Tauolapp::Tauola::setSameParticleDecayMode( 1 );
496 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
502 Tauolapp::jaki_.jak1 = modeH;
503 Tauolapp::jaki_.jak2 = 1;
504 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
505 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 );
511 Tauolapp::jaki_.jak1 = 2;
512 Tauolapp::jaki_.jak2 = modeH;
513 Tauolapp::Tauola::setSameParticleDecayMode( 2 );
514 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
520 Tauolapp::jaki_.jak1 = modeH;
521 Tauolapp::jaki_.jak2 = 2;
522 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
523 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 );
529 Tauolapp::jaki_.jak1 = modeH;
531 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
532 Tauolapp::Tauola::setOppositeParticleDecayMode( Tauolapp::jaki_.
jak2 );
538 Tauolapp::jaki_.jak1 = modeH;
539 Tauolapp::jaki_.jak2 = 0;
540 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
541 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
547 Tauolapp::jaki_.jak1 = 0;
548 Tauolapp::jaki_.jak2 = modeH;
549 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
550 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
559 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
560 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
592 if ( prob > 0. && prob <= sumBra )
599 for (
int i=1;
i<NN;
i++ )
614 if ( tau->end_vertex() ) {
615 HepMC::GenVertex::particle_iterator dau;
616 for (dau = tau->end_vertex()->particles_begin(HepMC::children); dau!= tau->end_vertex()->particles_end(HepMC::children); dau++ ) {
617 int dau_pid = (*dau)->pdg_id();
618 if(dau_pid == tau->pdg_id())
return false;
626 HepMC::GenVertex* GenVtx=p->end_vertex();
627 double VxDec = GenVtx->position().x();
629 double VyDec = GenVtx->position().y();
631 double VzDec = GenVtx->position().z();
633 double VtDec = GenVtx->position().t();
635 GenVtx->set_position( HepMC::FourVector(VxDec,VyDec,VzDec,VtDec) );
636 for(HepMC::GenVertex::particle_iterator dau=p->end_vertex()->particles_begin(HepMC::children); dau!=p->end_vertex()->particles_end(HepMC::children); dau++){
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
TauolappInterface(const edm::ParameterSet &)
edm::ParameterSet * fPSet
std::vector< double > fScaledHadronBrRatios
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void rmarin_(int *, int *, int *)
void getData(T &iHolder) const
std::vector< int > fLeptonModes
Abs< T >::type abs(const T &t)
void ranmar_(float *rvec, int *lenv)
HepPDT::ParticleData ParticleData
void init(const edm::EventSetup &)
HepMC::GenEvent * decay(HepMC::GenEvent *)
bool isLastTauInChain(const HepMC::GenParticle *tau)
std::vector< double > fScaledLeptonBrRatios
static CLHEP::HepRandomEngine * fRandomEngine
return(e1-e2)*(e1-e2)+dp *dp
void setLifeTimeInDecays(HepMC::GenParticle *p, double vx, double vy, double vz, double vt)
std::vector< int > fHadronModes
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
volatile std::atomic< bool > shutdown_flag false
void selectDecayByMDTAU()