CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/FastSimulation/ParticleDecay/src/Pythia6Decays.cc

Go to the documentation of this file.
00001 // HepMC Headers
00002 #include "HepMC/PythiaWrapper6_2.h"
00003 
00004 // Pythia6 framework integration service Headers
00005 #include "GeneratorInterface/Pythia6Interface/interface/Pythia6Service.h"
00006 
00007 // FAMOS Headers
00008 #include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h"
00009 #include "FastSimulation/ParticleDecay/interface/Pythia6Decays.h"
00010 #include "FastSimulation/ParticleDecay/interface/Pythia6jets.h"
00011 
00012 #define PYTHIA6PYDECY pythia6pydecy_
00013 
00014 extern "C" {
00015   void PYTHIA6PYDECY(int *ip);
00016 }
00017 
00018 Pythia6Decays::Pythia6Decays()
00019 {
00020   // Create a new Pythia6jets
00021   pyjets = new Pythia6jets();
00022   // Create a new Pythia6Service helper
00023   pyservice = new gen::Pythia6Service();
00024   // The PYTHIA decay tables will be initialized later 
00025 }
00026 
00027 Pythia6Decays::~Pythia6Decays() {
00028   delete pyjets;
00029   delete pyservice;
00030 }
00031 
00032 const DaughterParticleList&
00033 Pythia6Decays::particleDaughters(ParticlePropagator& particle)
00034 {
00035   gen::Pythia6Service::InstanceWrapper guard(pyservice); // grab Py6 context
00036 
00037   //  Pythia6jets pyjets;
00038   int ip;
00039 
00040   pyjets->k(1,1) = 1;
00041   pyjets->k(1,2) = particle.pid();
00042   pyjets->p(1,1) = particle.Px();
00043   pyjets->p(1,2) = particle.Py();
00044   pyjets->p(1,3) = particle.Pz();
00045   pyjets->p(1,4) = std::max(particle.mass(),particle.e());
00046   pyjets->p(1,5) = particle.mass();
00047   pyjets->v(1,1) = particle.X();
00048   pyjets->v(1,2) = particle.Y();
00049   pyjets->v(1,3) = particle.Z();
00050   pyjets->v(1,4) = particle.T();
00051   pyjets->n() = 1;
00052   
00053   ip = 1;
00054   PYTHIA6PYDECY(&ip);
00055 
00056   // Fill the list of daughters
00057   theList.clear();
00058   if ( pyjets->n()==1 ) return theList; 
00059 
00060   theList.resize(pyjets->n()-1,RawParticle());
00061 
00062   for (int i=2;i<=pyjets->n();++i) {
00063     
00064     theList[i-2].SetXYZT(pyjets->p(i,1),pyjets->p(i,2),
00065                          pyjets->p(i,3),pyjets->p(i,4)); 
00066     theList[i-2].setVertex(pyjets->v(i,1),pyjets->v(i,2),
00067                            pyjets->v(i,3),pyjets->v(i,4));
00068     theList[i-2].setID(pyjets->k(i,2));
00069     theList[i-2].setMass(pyjets->p(i,5));
00070 
00071   }
00072 
00073   return theList;
00074   
00075 }