This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / EVGEN / AliGenHalo.cxx
CommitLineData
fe4da5cc 1#include "AliGenHalo.h"
2#include "AliGenMUONlib.h"
3#include "AliMC.h"
4#include "AliRun.h"
5#include <TDirectory.h>
6#include <TFile.h>
7#include <TTree.h>
8#include <stdlib.h>
9 ClassImp(AliGenHalo)
10 AliGenHalo::AliGenHalo()
11 :AliGenerator(-1)
12{
13 fName="Halo";
14 fTitle="Halo from LHC Tunnel";
15 // Set the default file
16 fFileName="~/marsip/marsip5.mu";
17//
18// Read all particles
19 fNpart=-1;
20 fp=0;
21}
22
23AliGenHalo::AliGenHalo(Int_t npart)
24 :AliGenerator(npart)
25{
26 fName="Halo";
27 fTitle="Halo from LHC Tunnel";
28 // Set the default file
29 fFileName="~/marsip/marsip5.mu";
30//
31// Read all particles
32 fNpart=-1;
33 fp=0;
34}
35
36//____________________________________________________________
37AliGenHalo::~AliGenHalo()
38{
39}
40
41//____________________________________________________________
42void AliGenHalo::Init()
43{}
44
45//____________________________________________________________
46void AliGenHalo::Generate()
47{
48 AliMC* pMC = AliMC::GetMC();
49 FILE *fp = fopen(fFileName,"r");
50 if (fp) {
51 printf("\n File %s opened for reading ! \n ", fFileName);
52 } else {
53 printf("\n Opening of file %s failed ! \n ", fFileName);
54 }
55//
56// MARS particle codes
57 const Int_t imars[12]={0,14, 13, 8, 9, 11, 12, 5, 6, 1, 3, 2};
58
59 Float_t polar[3]= {0,0,0};
60 Float_t origin[3];
61 Float_t p[3], p0;
62 Float_t ekin, wgt, tx, ty, tz, txy;
63 Float_t amass, charge, tlife;
64 char name[100];
65 //
66 Int_t ipart, itrtyp, ncols, nt;
67
68 Int_t nread=0;
69 origin[2]=2650;
70
71 while(1) {
72 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
73 &ipart, &ekin, &wgt,
74 &origin[0], &origin[1],
75 &tx, &ty);
76 if (ncols < 0) break;
77 nread++;
78 if (fNpart !=-1 && nread > fNpart) break;
79 ipart = imars[ipart];
80 pMC->Gfpart(ipart, name, itrtyp,
81 amass, charge, tlife);
82 p0=sqrt(ekin*ekin + 2.*amass);
83
84 txy=TMath::Sqrt(tx*tx+ty*ty);
85 if (txy == 1.) {
86 tz=0;
87 } else {
88 tz=-TMath::Sqrt(1.-txy);
89 }
90 p[0]=p0*tx;
91 p[1]=p0*ty;
92 p[2]=p0*tz;
93 fParentWeight=wgt;
94 gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
95 origin[2]=-origin[2];
96 p[2]=-p[2];
97 gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
98 origin[2]=-origin[2];
99 p[2]=-p[2];
100 }
101}
102
103
104
105
106
107
108
109
110