4 #include "Tauola/Tauola.h"
5 #include "Tauola/TauolaHepMCEvent.h"
6 #include "Tauola/Log.h"
10 #include "CLHEP/Random/RandomEngine.h"
11 #include "HepMC/GenEvent.h"
12 #include "HepMC/IO_HEPEVT.h"
13 #include "HepMC/HEPEVT_Wrapper.h"
22 for(
int i = 0;
i < *lenv;
i++)
34 fIsInitialized(
false),
36 fSelectDecayByEvent(
false)
38 if (
fPSet != 0 )
throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to override Tauola an existing ParameterSet\n" << std::endl;
44 if (
fPSet == 0 )
throw cms::Exception(
"TauolappInterfaceError") <<
"Attempt to initialize Tauola with an empty ParameterSet\n" << std::endl;
47 Tauolapp::Tauola::setDecayingParticle(15);
56 fMDTAU = cards.getParameter<
int >(
"mdtau" );
57 if ( fMDTAU == 0 || fMDTAU == 1 )
59 Tauolapp::Tauola::setSameParticleDecayMode( cards.getParameter<
int >(
"pjak1" ) ) ;
60 Tauolapp::Tauola::setOppositeParticleDecayMode( cards.getParameter<
int >(
"pjak2" ) ) ;
67 double lifetime = PData->lifetime().value();
68 Tauolapp::Tauola::setTauLifetime( lifetime );
70 fPDGs.push_back( Tauolapp::Tauola::getDecayingParticle() );
75 std::vector<std::string> par =
fPSet->
getParameter< std::vector<std::string> >(
"parameterSets");
76 for (
unsigned int ip=0; ip<par.size(); ++ip ){
78 if(curSet==
"setNewCurrents") Tauolapp::Tauola::setNewCurrents(
fPSet->
getParameter<
int>(curSet));
79 if(curSet==
"spinCorrelationSetAll") Tauolapp::Tauola::spin_correlation.setAll(
fPSet->
getParameter<
bool>(curSet));
80 if(curSet==
"spinCorrelationGAMMA") Tauolapp::Tauola::spin_correlation.GAMMA=
fPSet->
getParameter<
bool>(curSet);
81 if(curSet==
"spinCorrelationZ0") Tauolapp::Tauola::spin_correlation.Z0=
fPSet->
getParameter<
bool>(curSet);
82 if(curSet==
"spinCorrelationHIGGS") Tauolapp::Tauola::spin_correlation.HIGGS=
fPSet->
getParameter<
bool>(curSet);
83 if(curSet==
"spinCorrelationHIGGSH") Tauolapp::Tauola::spin_correlation.HIGGS_H=
fPSet->
getParameter<
bool>(curSet);
84 if(curSet==
"spinCorrelationHIGGSA") Tauolapp::Tauola::spin_correlation.HIGGS_A=
fPSet->
getParameter<
bool>(curSet);
85 if(curSet==
"spinCorrelationHIGGSPLUS") Tauolapp::Tauola::spin_correlation.HIGGS_PLUS=
fPSet->
getParameter<
bool>(curSet);
86 if(curSet==
"spinCorrelationHIGGSMINUS") Tauolapp::Tauola::spin_correlation.HIGGS_MINUS=
fPSet->
getParameter<
bool>(curSet);
87 if(curSet==
"spinCorrelationWPLUS") Tauolapp::Tauola::spin_correlation.W_PLUS=
fPSet->
getParameter<
bool>(curSet);
88 if(curSet==
"spinCorrelationWMINUS") Tauolapp::Tauola::spin_correlation.W_MINUS=
fPSet->
getParameter<
bool>(curSet);
89 if(curSet==
"setHiggsScalarPseudoscalarPDG") Tauolapp::Tauola::setHiggsScalarPseudoscalarPDG(
fPSet->
getParameter<
int>(curSet));
90 if(curSet==
"setHiggsScalarPseudoscalarMixingAngle") Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle(
fPSet->
getParameter<
double>(curSet));
91 if(curSet==
"setRadiation") Tauolapp::Tauola::setRadiation(
fPSet->
getParameter<
bool>(curSet));
92 if(curSet==
"setRadiationCutOff") Tauolapp::Tauola::setRadiationCutOff(
fPSet->
getParameter<
double>(curSet));
93 if(curSet==
"setEtaK0sPi"){
95 if(vpar.size()==3) Tauolapp::Tauola::setEtaK0sPi(vpar[0],vpar[1],vpar[2]);
96 else {
std::cout <<
"WARNING invalid size for setEtaK0sPi: " << vpar.size() <<
" Require 3 elements " << std::endl;}
98 if(curSet==
"setTaukle"){
100 if(vpar.size()==4) Tauolapp::Tauola::setTaukle(vpar[0], vpar[1], vpar[2], vpar[3]);
101 else {
std::cout <<
"WARNING invalid size for setTaukle: " << vpar.size() <<
" Require 4 elements " << std::endl;}
103 if(curSet==
"setTauBr"){
105 std::vector<int> vJAK = cfg.
getParameter<std::vector<int> >(
"JAK");
106 std::vector<double> vBR = cfg.
getParameter<std::vector<double> >(
"BR");
107 if(vJAK.size() == vBR.size()){
108 for(
unsigned int i=0;
i<vJAK.size();
i++) Tauolapp::Tauola::setTauBr(vJAK[
i],vBR[i]);
110 else {
std::cout <<
"WARNING invalid size for setTauBr - JAK: " << vJAK.size() <<
" BR: " << vBR.size() << std::endl;}
118 if ( fMDTAU != 0 && fMDTAU != 1 )
122 Tauolapp::Log::LogWarning(
false);
129 <<
"TauolaInterface::flat: Attempt to generate random number when engine pointer is null\n"
130 <<
"This might mean that the code was modified to generate a random number outside the\n"
131 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
138 int NPartBefore = evt->particles_size();
139 int NVtxBefore = evt->vertices_size();
153 auto * t_event =
new Tauolapp::TauolaHepMCEvent(evt);
159 t_event->decayTaus();
169 for (
int iv=NVtxBefore+1; iv<=evt->vertices_size(); iv++ )
171 HepMC::GenVertex* GenVtx = evt->barcode_to_vertex(-iv);
177 std::vector<int> BCodes;
179 for (HepMC::GenVertex::particle_iterator pitr= GenVtx->particles_begin(HepMC::children);
180 pitr != GenVtx->particles_end(HepMC::children); ++pitr)
182 if ( (*pitr)->barcode() > 10000 )
184 BCodes.push_back( (*pitr)->barcode() );
187 if ( BCodes.size() > 0 )
189 for (
size_t ibc=0; ibc<BCodes.size(); ibc++ )
192 int nbc = p1->barcode() - 10000 + NPartBefore;
193 p1->suggest_barcode( nbc );
221 if ( mdtau == 101 || mdtau == 201 )
225 Tauolapp::jaki_.jak1 = 1;
226 Tauolapp::jaki_.jak2 = 1;
227 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
228 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
231 if ( mdtau == 102 || mdtau == 202 )
235 Tauolapp::jaki_.jak1 = 2;
236 Tauolapp::jaki_.jak2 = 2;
237 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
238 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
241 if ( mdtau == 111 || mdtau == 211 )
246 Tauolapp::jaki_.jak1 = 1;
247 Tauolapp::jaki_.jak2 = 0;
248 Tauolapp::Tauola::setSameParticleDecayMode( 1 ) ;
249 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
252 if ( mdtau == 112 || mdtau == 212 )
257 Tauolapp::jaki_.jak1 = 2;
258 Tauolapp::jaki_.jak2 = 0;
259 Tauolapp::Tauola::setSameParticleDecayMode( 2 ) ;
260 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
263 if ( mdtau == 121 || mdtau == 221 )
268 Tauolapp::jaki_.jak1 = 0;
269 Tauolapp::jaki_.jak2 = 1;
270 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
271 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 ) ;
274 if ( mdtau == 122 || mdtau == 222 )
279 Tauolapp::jaki_.jak1 = 0;
280 Tauolapp::jaki_.jak2 = 2;
281 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
282 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 ) ;
285 if ( mdtau == 140 || mdtau == 240 )
289 Tauolapp::jaki_.jak1 = 3;
290 Tauolapp::jaki_.jak2 = 3;
291 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
292 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
295 if ( mdtau == 141 || mdtau == 241 )
300 Tauolapp::jaki_.jak1 = 3;
301 Tauolapp::jaki_.jak2 = 0;
302 Tauolapp::Tauola::setSameParticleDecayMode( 3 ) ;
303 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 ) ;
306 if ( mdtau == 142 || mdtau == 242 )
311 Tauolapp::jaki_.jak1 = 0;
312 Tauolapp::jaki_.jak2 = 3;
313 Tauolapp::Tauola::setSameParticleDecayMode( 0 ) ;
314 Tauolapp::Tauola::setOppositeParticleDecayMode( 3 ) ;
327 for (
int i=0;
i<22;
i++ )
331 if ( sumBra == 0. )
return ;
332 for (
int i=0;
i<22;
i++ )
335 Tauolapp::Tauola::setTauBr(
i+1, newBra );
339 double sumHadronBra = sumBra - sumLeptonBra;
340 for (
int i=0;
i<2;
i++ )
345 for (
int i=2;
i<22;
i++ )
358 Tauolapp::jaki_.jak1 =
mode;
359 Tauolapp::Tauola::setSameParticleDecayMode( mode );
361 Tauolapp::jaki_.jak2 =
mode;
362 Tauolapp::Tauola::setOppositeParticleDecayMode( mode );
369 Tauolapp::jaki_.jak1 = modeL;
370 Tauolapp::jaki_.jak2 = 0;
371 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
372 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
377 Tauolapp::jaki_.jak1 = 0;
378 Tauolapp::jaki_.jak2 = modeL;
379 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
380 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
385 Tauolapp::jaki_.jak1 = modeL;
386 Tauolapp::jaki_.jak2 = modeH;
387 Tauolapp::Tauola::setSameParticleDecayMode( modeL );
388 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
393 Tauolapp::jaki_.jak1 = modeH;
394 Tauolapp::jaki_.jak2 = modeL;
395 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
396 Tauolapp::Tauola::setOppositeParticleDecayMode( modeL );
401 Tauolapp::jaki_.jak1 = 1;
402 Tauolapp::jaki_.jak2 = modeH;
403 Tauolapp::Tauola::setSameParticleDecayMode( 1 );
404 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
409 Tauolapp::jaki_.jak1 = modeH;
410 Tauolapp::jaki_.jak2 = 1;
411 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
412 Tauolapp::Tauola::setOppositeParticleDecayMode( 1 );
417 Tauolapp::jaki_.jak1 = 2;
418 Tauolapp::jaki_.jak2 = modeH;
419 Tauolapp::Tauola::setSameParticleDecayMode( 2 );
420 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
425 Tauolapp::jaki_.jak1 = modeH;
426 Tauolapp::jaki_.jak2 = 2;
427 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
428 Tauolapp::Tauola::setOppositeParticleDecayMode( 2 );
433 Tauolapp::jaki_.jak1 = modeH;
435 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
436 Tauolapp::Tauola::setOppositeParticleDecayMode( Tauolapp::jaki_.
jak2 );
441 Tauolapp::jaki_.jak1 = modeH;
442 Tauolapp::jaki_.jak2 = 0;
443 Tauolapp::Tauola::setSameParticleDecayMode( modeH );
444 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
449 Tauolapp::jaki_.jak1 = 0;
450 Tauolapp::jaki_.jak2 = modeH;
451 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
452 Tauolapp::Tauola::setOppositeParticleDecayMode( modeH );
460 Tauolapp::Tauola::setSameParticleDecayMode( 0 );
461 Tauolapp::Tauola::setOppositeParticleDecayMode( 0 );
483 if ( prob > 0. && prob <= sumBra )
490 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
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 *)
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()