Class moved from AliGenCocktail.h
[u/mrichter/AliRoot.git] / EVGEN / AliGenHalo.cxx
CommitLineData
4c039060 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/*
17$Log$
886b6f73 18Revision 1.4 1999/09/29 09:24:14 fca
19Introduction of the Copyright and cvs Log
20
4c039060 21*/
22
fe4da5cc 23#include "AliGenHalo.h"
24#include "AliGenMUONlib.h"
25#include "AliMC.h"
26#include "AliRun.h"
c5970876 27#include "AliPDG.h"
28
fe4da5cc 29#include <TDirectory.h>
1578254f 30#include <TDatabasePDG.h>
fe4da5cc 31#include <TFile.h>
32#include <TTree.h>
33#include <stdlib.h>
34 ClassImp(AliGenHalo)
35 AliGenHalo::AliGenHalo()
36 :AliGenerator(-1)
37{
38 fName="Halo";
39 fTitle="Halo from LHC Tunnel";
40 // Set the default file
41 fFileName="~/marsip/marsip5.mu";
42//
43// Read all particles
44 fNpart=-1;
45 fp=0;
46}
47
48AliGenHalo::AliGenHalo(Int_t npart)
49 :AliGenerator(npart)
50{
51 fName="Halo";
52 fTitle="Halo from LHC Tunnel";
53 // Set the default file
54 fFileName="~/marsip/marsip5.mu";
55//
56// Read all particles
57 fNpart=-1;
58 fp=0;
59}
60
61//____________________________________________________________
62AliGenHalo::~AliGenHalo()
63{
64}
65
66//____________________________________________________________
67void AliGenHalo::Init()
68{}
69
70//____________________________________________________________
71void AliGenHalo::Generate()
72{
fe4da5cc 73 FILE *fp = fopen(fFileName,"r");
74 if (fp) {
75 printf("\n File %s opened for reading ! \n ", fFileName);
76 } else {
77 printf("\n Opening of file %s failed ! \n ", fFileName);
78 }
79//
80// MARS particle codes
1578254f 81 // const Int_t imars[12]={0,14, 13, 8, 9, 11, 12, 5, 6, 1, 3, 2};
82 const Int_t imars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
83 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
fe4da5cc 84
85 Float_t polar[3]= {0,0,0};
86 Float_t origin[3];
87 Float_t p[3], p0;
88 Float_t ekin, wgt, tx, ty, tz, txy;
1578254f 89 Float_t amass;
fe4da5cc 90 //
1578254f 91 Int_t ipart, ncols, nt;
fe4da5cc 92
93 Int_t nread=0;
94 origin[2]=2650;
95
96 while(1) {
97 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
98 &ipart, &ekin, &wgt,
99 &origin[0], &origin[1],
100 &tx, &ty);
101 if (ncols < 0) break;
102 nread++;
103 if (fNpart !=-1 && nread > fNpart) break;
104 ipart = imars[ipart];
1578254f 105 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
fe4da5cc 106 p0=sqrt(ekin*ekin + 2.*amass);
107
108 txy=TMath::Sqrt(tx*tx+ty*ty);
109 if (txy == 1.) {
110 tz=0;
111 } else {
112 tz=-TMath::Sqrt(1.-txy);
113 }
114 p[0]=p0*tx;
115 p[1]=p0*ty;
116 p[2]=p0*tz;
117 fParentWeight=wgt;
886b6f73 118 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
fe4da5cc 119 origin[2]=-origin[2];
120 p[2]=-p[2];
886b6f73 121 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
fe4da5cc 122 origin[2]=-origin[2];
123 p[2]=-p[2];
124 }
125}
126
127
128
129
130
131
132
133
134