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" ) ) ;
87 Tauolapp::Tauola::setTauLifetime(0.0);
102 fPDGs.push_back( Tauolapp::Tauola::getDecayingParticle() );
113 if ( fMDTAU != 0 && fMDTAU != 1 )
118 Tauolapp::Log::LogWarning(
false);
127 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n"
128 <<
"This might mean that the code was modified to generate a random number outside the\n"
129 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
137 int NPartBefore = evt->particles_size();
138 int NVtxBefore = evt->vertices_size();
155 auto * t_event =
new Tauolapp::TauolaHepMCEvent(evt);
163 t_event->decayTaus();
175 for (
int iv=NVtxBefore+1; iv<=evt->vertices_size(); iv++ )
177 HepMC::GenVertex* GenVtx = evt->barcode_to_vertex(-iv);
179 HepMC::GenVertex* ProdVtx = GenPart->production_vertex();
180 HepMC::FourVector PMom = GenPart->momentum();
181 double mass = GenPart->generated_mass();
184 double lifetime = PData->lifetime().value();
188 double ct = -lifetime *
std::log(prob);
189 double VxDec = GenVtx->position().x();
190 VxDec += ct * (PMom.px()/mass);
191 VxDec += ProdVtx->position().x();
192 double VyDec = GenVtx->position().y();
193 VyDec += ct * (PMom.py()/mass);
194 VyDec += ProdVtx->position().y();
195 double VzDec = GenVtx->position().z();
196 VzDec += ct * (PMom.pz()/mass);
197 VzDec += ProdVtx->position().z();
198 double VtDec = GenVtx->position().t();
199 VtDec += ct * (PMom.e()/mass);
200 VtDec += ProdVtx->position().t();
201 GenVtx->set_position( HepMC::FourVector(VxDec,VyDec,VzDec,VtDec) );
207 std::vector<int> BCodes;
209 for (HepMC::GenVertex::particle_iterator pitr= GenVtx->particles_begin(HepMC::children);
210 pitr != GenVtx->particles_end(HepMC::children); ++pitr)
212 if ( (*pitr)->barcode() > 10000 )
214 BCodes.push_back( (*pitr)->barcode() );
217 if ( BCodes.size() > 0 )
219 for (
size_t ibc=0; ibc<BCodes.size(); ibc++ )
222 int nbc = p1->barcode() - 10000 + NPartBefore;
223 p1->suggest_barcode( nbc );
258 if ( mdtau == 101 || mdtau == 201 )
262 Tauolapp::jaki_.jak1 = 1;
263 Tauolapp::jaki_.jak2 = 1;
264 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
265 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
269 if ( mdtau == 102 || mdtau == 202 )
273 Tauolapp::jaki_.jak1 = 2;
274 Tauolapp::jaki_.jak2 = 2;
275 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
276 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
280 if ( mdtau == 111 || mdtau == 211 )
285 Tauolapp::jaki_.jak1 = 1;
286 Tauolapp::jaki_.jak2 = 0;
287 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
288 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
292 if ( mdtau == 112 || mdtau == 212 )
297 Tauolapp::jaki_.jak1 = 2;
298 Tauolapp::jaki_.jak2 = 0;
299 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
300 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
304 if ( mdtau == 121 || mdtau == 221 )
309 Tauolapp::jaki_.jak1 = 0;
310 Tauolapp::jaki_.jak2 = 1;
311 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
312 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
316 if ( mdtau == 122 || mdtau == 222 )
321 Tauolapp::jaki_.jak1 = 0;
322 Tauolapp::jaki_.jak2 = 2;
323 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
324 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
328 if ( mdtau == 140 || mdtau == 240 )
332 Tauolapp::jaki_.jak1 = 3;
333 Tauolapp::jaki_.jak2 = 3;
334 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
335 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
339 if ( mdtau == 141 || mdtau == 241 )
344 Tauolapp::jaki_.jak1 = 3;
345 Tauolapp::jaki_.jak2 = 0;
346 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
347 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
351 if ( mdtau == 142 || mdtau == 242 )
356 Tauolapp::jaki_.jak1 = 0;
357 Tauolapp::jaki_.jak2 = 3;
358 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
359 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
376 for (
int i=0;
i<22;
i++ )
380 if ( sumBra == 0. )
return ;
381 for (
int i=0;
i<22;
i++ )
384 Tauolapp::Tauola::setTauBr(
i+1, newBra );
389 double sumHadronBra = sumBra - sumLeptonBra;
391 for (
int i=0;
i<2;
i++ )
396 for (
int i=2;
i<22;
i++ )
414 Tauolapp::jaki_.jak1 =
mode;
415 Tauolapp::Tauola::setSameParticleDecayMode( mode );
417 Tauolapp::jaki_.jak2 =
mode;
418 Tauolapp::Tauola::setOppositeParticleDecayMode( mode );
427 Tauolapp::jaki_.jak1 = modeL;
428 Tauolapp::jaki_.jak2 = 0;
429 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
430 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
436 Tauolapp::jaki_.jak1 = 0;
437 Tauolapp::jaki_.jak2 = modeL;
438 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
439 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
445 Tauolapp::jaki_.jak1 = modeL;
446 Tauolapp::jaki_.jak2 = modeH;
447 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
448 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
454 Tauolapp::jaki_.jak1 = modeH;
455 Tauolapp::jaki_.jak2 = modeL;
456 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
457 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
463 Tauolapp::jaki_.jak1 = 1;
464 Tauolapp::jaki_.jak2 = modeH;
465 Tauolapp::Tauola::setSameParticleDecayMode( 1 );
466 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
472 Tauolapp::jaki_.jak1 = modeH;
473 Tauolapp::jaki_.jak2 = 1;
474 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
475 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 );
481 Tauolapp::jaki_.jak1 = 2;
482 Tauolapp::jaki_.jak2 = modeH;
483 Tauolapp::Tauola::setSameParticleDecayMode( 2 );
484 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
490 Tauolapp::jaki_.jak1 = modeH;
491 Tauolapp::jaki_.jak2 = 2;
492 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
493 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 );
499 Tauolapp::jaki_.jak1 = modeH;
501 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
502 Tauolapp::Tauola::setOppositeParticleDecayMode( Tauolapp::jaki_.
jak2 );
508 Tauolapp::jaki_.jak1 = modeH;
509 Tauolapp::jaki_.jak2 = 0;
510 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
511 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
517 Tauolapp::jaki_.jak1 = 0;
518 Tauolapp::jaki_.jak2 = modeH;
519 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
520 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
529 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
530 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
562 if ( prob > 0. && prob <= sumBra )
569 for (
int i=1;
i<NN;
i++ )
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
TauolappInterface(const edm::ParameterSet &)
edm::ParameterSet * fPSet
std::vector< double > fScaledHadronBrRatios
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 *)
std::vector< double > fScaledLeptonBrRatios
static CLHEP::HepRandomEngine * fRandomEngine
return(e1-e2)*(e1-e2)+dp *dp
std::vector< int > fHadronModes
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
volatile std::atomic< bool > shutdown_flag false
void selectDecayByMDTAU()