00001
00002 #include "HepMC/PythiaWrapper6_2.h"
00003
00004
00005 #include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h"
00006 #include "FastSimulation/ParticleDecay/interface/Pythia6Decays.h"
00007 #include "FastSimulation/ParticleDecay/interface/Pythia6jets.h"
00008 #include "FastSimulation/ParticleDecay/interface/Pythia6Random.h"
00009
00010 #define PYTHIA6PYDECY pythia6pydecy_
00011
00012 extern "C" {
00013 void PYTHIA6PYDECY(int *ip);
00014 }
00015
00016 Pythia6Decays::Pythia6Decays(int seed,double comE)
00017 {
00018
00019 pyjets = new Pythia6jets();
00020
00021 pyrand = new Pythia6Random(seed);
00022
00023 if(pyint1.vint[289]==0)
00024 {
00025 std::cout << " It seems that pythia has not been initialized. Since Pythia is needed";
00026 std::cout << " to simulate the particle decays. FAMOS will call PYINIT " << std::endl;
00027 std::cout << " Note that the centre-of-mass energy does not overwrite the generator settings " << std::endl;
00028 call_pyinit( "CMS", "p", "p", comE );
00029 }
00030
00031 }
00032
00033 Pythia6Decays::~Pythia6Decays() {
00034 delete pyjets;
00035 delete pyrand;
00036 }
00037
00038 const void
00039 Pythia6Decays::getRandom() {
00040 pyrand->save(0);
00041 pyrand->get(1);
00042 }
00043
00044 const void
00045 Pythia6Decays::saveRandom() {
00046 pyrand->save(1);
00047 pyrand->get(0);
00048 }
00049
00050 const DaughterParticleList&
00051 Pythia6Decays::particleDaughters(ParticlePropagator& particle)
00052 {
00053
00054 int ip;
00055
00056 pyjets->k(1,1) = 1;
00057 pyjets->k(1,2) = particle.pid();
00058 pyjets->p(1,1) = particle.Px();
00059 pyjets->p(1,2) = particle.Py();
00060 pyjets->p(1,3) = particle.Pz();
00061 pyjets->p(1,4) = std::max(particle.mass(),particle.e());
00062 pyjets->p(1,5) = particle.mass();
00063 pyjets->v(1,1) = particle.X();
00064 pyjets->v(1,2) = particle.Y();
00065 pyjets->v(1,3) = particle.Z();
00066 pyjets->v(1,4) = particle.T();
00067 pyjets->n() = 1;
00068
00069 ip = 1;
00070 PYTHIA6PYDECY(&ip);
00071
00072
00073 theList.clear();
00074 if ( pyjets->n()==1 ) return theList;
00075
00076 theList.resize(pyjets->n()-1,RawParticle());
00077
00078 for (int i=2;i<=pyjets->n();++i) {
00079
00080 theList[i-2].SetXYZT(pyjets->p(i,1),pyjets->p(i,2),
00081 pyjets->p(i,3),pyjets->p(i,4));
00082 theList[i-2].setVertex(pyjets->v(i,1),pyjets->v(i,2),
00083 pyjets->v(i,3),pyjets->v(i,4));
00084 theList[i-2].setID(pyjets->k(i,2));
00085 theList[i-2].setMass(pyjets->p(i,5));
00086
00087 }
00088
00089 return theList;
00090
00091 }