TPythia8.cxx

Go to the documentation of this file.
00001 // @(#)root/pythia8:$Name$:$Id: TPythia8.cxx 34928 2010-08-22 05:59:15Z brun $
00002 // Author: Andreas Morsch   27/10/2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 
00013 ////////////////////////////////////////////////////////////////////////////////
00014 //                                                                            //
00015 // TPythia8                                                                   //
00016 //                                                                            //
00017 // TPythia is an interface class to C++ version of Pythia 8.1                 //
00018 // event generators, written by T.Sjostrand.                                  //
00019 //                                                                            //
00020 // The user is assumed to be familiar with the Pythia package.                //
00021 // This class includes only a basic interface to Pythia8. Because Pythia8 is  //
00022 // also written in C++, its functions/classes can be called directly from a   //
00023 // compiled C++ script.                                                       //
00024 // To call Pythia functions not available in this interface a dictionary must //
00025 // be generated.                                                              //
00026 // see $ROOTSYS/tutorials/pythia/pythia8.C for an example of use from CINT.   //
00027 //                                                                            //
00028 ////////////////////////////////////////////////////////////////////////////////
00029 /*
00030 *------------------------------------------------------------------------------------*
00031  |                                                                                    |
00032  |  *------------------------------------------------------------------------------*  |
00033  |  |                                                                              |  |
00034  |  |                                                                              |  |
00035  |  |   PPP   Y   Y  TTTTT  H   H  III    A      Welcome to the Lund Monte Carlo!  |  |
00036  |  |   P  P   Y Y     T    H   H   I    A A     This is PYTHIA version 8.100      |  |
00037  |  |   PPP     Y      T    HHHHH   I   AAAAA    Last date of change: 20 Oct 2007  |  |
00038  |  |   P       Y      T    H   H   I   A   A                                      |  |
00039  |  |   P       Y      T    H   H  III  A   A    Now is 27 Oct 2007 at 18:26:53    |  |
00040  |  |                                                                              |  |
00041  |  |   Main author: Torbjorn Sjostrand; CERN/PH, CH-1211 Geneva, Switzerland,     |  |
00042  |  |     and Department of Theoretical Physics, Lund University, Lund, Sweden;    |  |
00043  |  |     phone: + 41 - 22 - 767 82 27; e-mail: torbjorn@thep.lu.se                |  |
00044  |  |   Author: Stephen Mrenna; Computing Division, Simulations Group,             |  |
00045  |  |     Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA;   |  |
00046  |  |     phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov                   |  |
00047  |  |   Author: Peter Skands; CERN/PH, CH-1211 Geneva, Switzerland,                |  |
00048  |  |     and Theoretical Physics Department,                                      |  |
00049  |  |     Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA;   |  |
00050  |  |     phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov                    |  |
00051  |  |                                                                              |  |
00052  |  |   The main program reference is the 'Brief Introduction to PYTHIA 8.1',      |  |
00053  |  |   T. Sjostrand, S. Mrenna and P. Skands, arXiv:0710.3820                     |  |
00054  |  |                                                                              |  |
00055  |  |   The main physics reference is the 'PYTHIA 6.4 Physics and Manual',         |  |
00056  |  |   T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 [hep-ph/0603175]. |  |
00057  |  |                                                                              |  |
00058  |  |   An archive of program versions and documentation is found on the web:      |  |
00059  |  |   http://www.thep.lu.se/~torbjorn/Pythia.html                                |  |
00060  |  |                                                                              |  |
00061  |  |   This program is released under the GNU General Public Licence version 2.   |  |
00062  |  |   Please respect the MCnet Guidelines for Event Generator Authors and Users. |  |
00063  |  |                                                                              |  |
00064  |  |   Disclaimer: this program comes without any guarantees.                     |  |
00065  |  |   Beware of errors and use common sense when interpreting results.           |  |
00066  |  |                                                                              |  |
00067  |  |   Copyright (C) 2007 Torbjorn Sjostrand                                      |  |
00068  |  |                                                                              |  |
00069  |  |                                                                              |  |
00070  |  *------------------------------------------------------------------------------*  |
00071  |                                                                                    |
00072  *------------------------------------------------------------------------------------*
00073 */
00074 
00075 #include "TPythia8.h"
00076 
00077 #include "TClonesArray.h"
00078 #include "TParticle.h"
00079 #include "TDatabasePDG.h"
00080 #include "TLorentzVector.h"
00081 
00082 ClassImp(TPythia8)
00083 
00084 TPythia8*  TPythia8::fgInstance = 0;
00085 
00086 //___________________________________________________________________________
00087 TPythia8::TPythia8():
00088     TGenerator("TPythia8", "TPythia8"),
00089     fPythia(0),
00090     fNumberOfParticles(0)
00091 {
00092    // Constructor
00093    if (fgInstance) 
00094       Fatal("TPythia8", "There's already an instance of TPythia8");
00095   
00096    delete fParticles; // was allocated as TObjArray in TGenerator
00097     
00098    fParticles = new TClonesArray("TParticle",50);
00099    fPythia    = new Pythia8::Pythia();
00100 }
00101 
00102 //___________________________________________________________________________
00103 TPythia8::TPythia8(const char *xmlDir):
00104     TGenerator("TPythia8", "TPythia8"),
00105     fPythia(0),
00106     fNumberOfParticles(0)
00107 {
00108    // Constructor with an xmlDir (eg "../xmldoc"
00109    if (fgInstance) 
00110       Fatal("TPythia8", "There's already an instance of TPythia8");
00111   
00112    delete fParticles; // was allocated as TObjArray in TGenerator
00113     
00114    fParticles = new TClonesArray("TParticle",50);
00115    fPythia    = new Pythia8::Pythia(xmlDir);
00116 }
00117 
00118 //___________________________________________________________________________
00119 TPythia8::~TPythia8()
00120 {
00121    // Destructor
00122    if (fParticles) {
00123       fParticles->Delete();
00124       delete fParticles;
00125       fParticles = 0;
00126    }
00127    delete fPythia;
00128 }
00129 
00130 //___________________________________________________________________________
00131 TPythia8* TPythia8::Instance()
00132 {
00133    // Return an instance of TPythia8
00134    return fgInstance ? fgInstance : (fgInstance = new TPythia8()) ;
00135 }
00136 
00137 //___________________________________________________________________________
00138 Bool_t TPythia8::Initialize(Int_t idAin, Int_t idBin, Double_t ecms)
00139 {
00140    // Initialization
00141    AddParticlesToPdgDataBase();
00142    return fPythia->init(idAin, idBin, ecms);
00143 }
00144 
00145 //___________________________________________________________________________
00146 void TPythia8::GenerateEvent()
00147 {
00148    // Generate the next event
00149    fPythia->next();
00150    fNumberOfParticles  = fPythia->event.size() - 1;
00151    ImportParticles();
00152 }
00153 
00154 //___________________________________________________________________________
00155 Int_t TPythia8::ImportParticles(TClonesArray *particles, Option_t *option)
00156 {
00157    // Import particles from Pythia stack
00158    if (particles == 0) return 0;
00159    TClonesArray &clonesParticles = *particles;
00160    clonesParticles.Clear();
00161    Int_t nparts=0;
00162    Int_t i;
00163    fNumberOfParticles  = fPythia->event.size() - 1;
00164 
00165    if (!strcmp(option,"") || !strcmp(option,"Final")) {
00166       for (i = 0; i <= fNumberOfParticles; i++) {
00167         if (fPythia->event[i].id() == 90) continue;
00168          if (fPythia->event[i].isFinal()) {
00169             new(clonesParticles[nparts]) TParticle(
00170                 fPythia->event[i].id(),
00171                 fPythia->event[i].status(),
00172                 fPythia->event[i].mother1() - 1,
00173                 fPythia->event[i].mother2() - 1,
00174                 fPythia->event[i].daughter1() - 1, 
00175                 fPythia->event[i].daughter2() - 1,
00176                 fPythia->event[i].px(),     // [GeV/c]
00177                 fPythia->event[i].py(),     // [GeV/c]
00178                 fPythia->event[i].pz(),     // [GeV/c]
00179                 fPythia->event[i].e(),      // [GeV]
00180                 fPythia->event[i].xProd(),  // [mm]
00181                 fPythia->event[i].yProd(),  // [mm]
00182                 fPythia->event[i].zProd(),  // [mm]
00183                 fPythia->event[i].tProd()); // [mm/c] 
00184                 nparts++;
00185             } // final state partice
00186         } // particle loop
00187     } else if (!strcmp(option,"All")) {
00188         for (i = 0; i <= fNumberOfParticles; i++) {
00189           if (fPythia->event[i].id() == 90) continue;
00190             new(clonesParticles[nparts]) TParticle(
00191                 fPythia->event[i].id(),
00192                 fPythia->event[i].status(),
00193                 fPythia->event[i].mother1() - 1,
00194                 fPythia->event[i].mother2() - 1,
00195                 fPythia->event[i].daughter1() - 1,
00196                 fPythia->event[i].daughter2() - 1,
00197                 fPythia->event[i].px(),       // [GeV/c]
00198                 fPythia->event[i].py(),       // [GeV/c]
00199                 fPythia->event[i].pz(),       // [GeV/c]
00200                 fPythia->event[i].e(),        // [GeV]
00201                 fPythia->event[i].xProd(),    // [mm]
00202                 fPythia->event[i].yProd(),    // [mm]
00203                 fPythia->event[i].zProd(),    // [mm]
00204                 fPythia->event[i].tProd());   // [mm/c]
00205             nparts++;
00206         } // particle loop      
00207     }
00208     return nparts;
00209 }
00210 
00211 //___________________________________________________________________________
00212 TObjArray* TPythia8::ImportParticles(Option_t* /* option */)
00213 {
00214    // Import particles from Pythia stack
00215    fParticles->Clear();
00216    Int_t numpart   = fPythia->event.size() - 1;
00217    TClonesArray &a = *((TClonesArray*)fParticles);
00218    for (Int_t i = 1; i <= numpart; i++) {
00219       new(a[i]) TParticle(
00220          fPythia->event[i].id(),
00221          fPythia->event[i].status(),
00222          fPythia->event[i].mother1()  - 1,
00223          fPythia->event[i].mother2()  - 1,
00224          fPythia->event[i].daughter1() - 1,
00225          fPythia->event[i].daughter2() - 1,
00226          fPythia->event[i].px(),       // [GeV/c]
00227          fPythia->event[i].py(),       // [GeV/c]
00228          fPythia->event[i].pz(),       // [GeV/c]
00229          fPythia->event[i].e(),        // [GeV]
00230          fPythia->event[i].xProd(),    // [mm]
00231          fPythia->event[i].yProd(),    // [mm]
00232          fPythia->event[i].zProd(),    // [mm]
00233          fPythia->event[i].tProd());   // [mm/c]
00234    }
00235    return fParticles;
00236 }
00237 
00238 //___________________________________________________________________________
00239 Int_t TPythia8::GetN() const
00240 {
00241    // Initialization
00242    return (fPythia->event.size() - 1);
00243 }
00244 
00245 //___________________________________________________________________________
00246 void TPythia8::ReadString(const char* string) const
00247 {
00248    // Configuration
00249    fPythia->readString(string);
00250 }
00251 
00252 //___________________________________________________________________________
00253 void  TPythia8::ReadConfigFile(const char* string) const
00254 {
00255   // Configuration
00256   fPythia->readFile(string);
00257 }
00258 
00259 //___________________________________________________________________________
00260 void TPythia8::PrintStatistics() const
00261 {
00262    // Print end of run statistics
00263    fPythia->statistics();
00264 }
00265 
00266 //___________________________________________________________________________
00267 void TPythia8::EventListing() const
00268 {
00269    // Event listing
00270    fPythia->event.list();
00271 }
00272 
00273 //___________________________________________________________________________
00274 void TPythia8::AddParticlesToPdgDataBase()
00275 {
00276    // Add some pythia specific particle code to the data base    
00277 
00278    TDatabasePDG *pdgDB = TDatabasePDG::Instance();
00279    pdgDB->AddParticle("string","string", 0, kTRUE,
00280                       0, 0, "QCD string", 90);
00281    pdgDB->AddParticle("rho_diff0", "rho_diff0", 0, kTRUE,
00282                       0, 0, "QCD diffr. state", 9900110);
00283    pdgDB->AddParticle("pi_diffr+", "pi_diffr+", 0, kTRUE,
00284                       0, 1, "QCD diffr. state", 9900210);
00285    pdgDB->AddParticle("omega_di", "omega_di", 0, kTRUE,
00286                       0, 0, "QCD diffr. state", 9900220);
00287    pdgDB->AddParticle("phi_diff","phi_diff", 0, kTRUE,
00288                       0, 0, "QCD diffr. state", 9900330);
00289    pdgDB->AddParticle("J/psi_di", "J/psi_di", 0, kTRUE,
00290                       0, 0, "QCD diffr. state", 9900440);
00291    pdgDB->AddParticle("n_diffr0","n_diffr0",0,kTRUE,
00292                       0, 0, "QCD diffr. state", 9902110);
00293    pdgDB->AddParticle("p_diffr+","p_diffr+", 0, kTRUE,
00294                       0, 1, "QCD diffr. state", 9902210);
00295 }
00296 

Generated on Tue Jul 5 14:45:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1