]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFlukaIon.cxx
Class for user defined primary ions.
[u/mrichter/AliRoot.git] / TFluka / TFlukaIon.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$*/
17
18 //
19 // Stores user defined ion properties. 
20 // Fluka allows only one user defined ion which can be used as a beam particle.
21 // Author:
22 // A. Morsch 
23 // andreas.morsch@cern.ch
24 //
25
26 #include "TFlukaIon.h"
27 #include <TDatabasePDG.h>
28    
29 ClassImp(TFlukaIon)
30
31
32 TFlukaIon::TFlukaIon() : 
33     TNamed("", "Ion"),
34     fZ(0), 
35     fA(0),
36     fQ(0),
37     fExEnergy(0.),
38     fMass(0.)
39 {
40 // Default constructor
41 }
42
43
44 TFlukaIon::TFlukaIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t exE, Double_t mass) :
45     TNamed(name, "Ion"),
46     fZ(z), 
47     fA(a),
48     fQ(q),
49     fExEnergy(exE),
50     fMass(mass)
51
52 {
53 // Constructor
54     AddIon(a, z);
55 }
56
57 Int_t TFlukaIon::GetIonPdg(Int_t z, Int_t a, Int_t i)
58 {
59 // Acording to
60 // http://cepa.fnal.gov/psm/stdhep/pdg/montecarlorpp-2006.pdf
61
62   return 1000000000 + 10*1000*z + 10*a + i;
63 }  
64
65 void TFlukaIon::AddIon(Int_t a, Int_t z)
66 {
67
68     // Add a new ion
69     TDatabasePDG *pdgDB = TDatabasePDG::Instance();
70     const Double_t kAu2Gev   = 0.9314943228;
71     Int_t pdg =  GetIonPdg(z, a);
72     if (pdgDB->GetParticle(pdg)) return;
73     
74     pdgDB->AddParticle(Form("Iion A  = %5d Z = %5d", a, z),"Ion", Float_t(a) * kAu2Gev + 8.071e-3, kTRUE,
75                        0, 3 * z, "Ion", pdg);
76 }
77
78 void TFlukaIon::WriteUserInputCard(FILE* pFlukaVmcInp) const
79 {
80     // Write the user input card
81     
82     fprintf(pFlukaVmcInp,"HI-PROPE  %10.1f%10.1f%10.3f\n", (Float_t)GetZ(), (Float_t)GetA(), GetExcitationEnergy());
83 }