CMS 3D CMS Logo

Pythia6Random.cc

Go to the documentation of this file.
00001 #include "FastSimulation/ParticleDecay/interface/Pythia6Random.h"
00002 
00003 #include <string>
00004 #include <iostream>
00005 
00006 #define PYDATR pydatr_
00007 extern "C" void *getAddr(void *item)
00008 {
00009         return item;
00010 }
00011 
00012 extern 
00013 struct {
00014         int mrpy[6];
00015         double rrpy[100];
00016 } PYDATR;
00017 
00018 struct Pythia6Random::_pythia6random * Pythia6Random::__pythia6random = 0;
00019 
00020 double Pythia6Random::dDummy = 0.0;
00021 int Pythia6Random::nDummy = 0;
00022 
00023 Pythia6Random::Pythia6Random(int seed) {
00024 
00025   myPythia6Random[0] = new _pythia6random;
00026   myPythia6Random[1] = new _pythia6random;
00027 
00028   // Initialize current state of the decay random generation
00029   myPythia6Random[1]->mrpy[0] = seed;
00030   myPythia6Random[1]->mrpy[1] = 0;
00031   myPythia6Random[1]->mrpy[2] = 0;
00032   myPythia6Random[1]->mrpy[3] = 0;
00033   myPythia6Random[1]->mrpy[4] = 0;
00034   myPythia6Random[1]->mrpy[5] = 0;
00035   for ( int j=0; j<100; ++j ) myPythia6Random[1]->rrpy[j] = 0.;
00036 
00037 }
00038 
00039 Pythia6Random::~Pythia6Random(void) {
00040 
00041   delete myPythia6Random[0];
00042   delete myPythia6Random[1];
00043 
00044 }
00045 
00046 void 
00047 Pythia6Random::init(void)
00048 {
00049   __pythia6random = 
00050     static_cast<struct Pythia6Random::_pythia6random *>(getAddr(&PYDATR.mrpy[0]));
00051 }
00052 
00053 int&
00054 Pythia6Random::mrpy(int i)
00055 {
00056   if (__pythia6random == 0) init();
00057   if ( i<1 || i>m_length ) {
00058     nDummy = -999;
00059     return nDummy;
00060   }
00061   return __pythia6random->mrpy[i-1];
00062 }
00063 
00064 double&
00065 Pythia6Random::rrpy(int i)
00066 {
00067   if (__pythia6random == 0) init();
00068   if ( i<1 || i>r_length ) {
00069     dDummy = -999.0;
00070     return dDummy;
00071   }
00072   return __pythia6random->rrpy[i-1];
00073 }
00074 
00075 void
00076 Pythia6Random::save(int i) {
00077 
00078   for ( int j=1; j<7; ++j ) {
00079     myPythia6Random[i]->mrpy[j-1] =  mrpy(j);
00080     //    std::cout << "Save " << i << " mrpy(" << j << ") = " << mrpy(j) << std::endl;
00081   }
00082   for ( int j=1; j<101; ++j ) {
00083     myPythia6Random[i]->rrpy[j-1] =  rrpy(j);
00084     //    std::cout << "Save " << i << " rrpy(" << j << ") = " << rrpy(j) << std::endl;
00085   }
00086 
00087 }
00088 
00089 void
00090 Pythia6Random::get(int i) {
00091 
00092   for ( int j=1; j<7; ++j ) {
00093     mrpy(j) = myPythia6Random[i]->mrpy[j-1];
00094     //    std::cout << "Get " << i << " mrpy(" << j << ") = " << mrpy(j) << std::endl;
00095   }
00096   for ( int j=1; j<101; ++j ) { 
00097     rrpy(j) = myPythia6Random[i]->rrpy[j-1];
00098     //    std::cout << "Get " << i << " rrpy(" << j << ") = " << rrpy(j) << std::endl;
00099   }
00100 
00101 }

Generated on Tue Jun 9 17:35:13 2009 for CMSSW by  doxygen 1.5.4