Type of fFileName changed to TString, fp has been !-ed.
[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$
bd1cece1 18Revision 1.6 2000/06/09 20:36:01 morsch
19All coding rule violations except RS3 corrected
20
f87cfe57 21Revision 1.5 1999/11/03 17:43:20 fca
22New version from G.Martinez & A.Morsch
23
886b6f73 24Revision 1.4 1999/09/29 09:24:14 fca
25Introduction of the Copyright and cvs Log
26
4c039060 27*/
28
fe4da5cc 29#include "AliGenHalo.h"
fe4da5cc 30#include "AliRun.h"
c5970876 31#include "AliPDG.h"
32
1578254f 33#include <TDatabasePDG.h>
fe4da5cc 34#include <stdlib.h>
f87cfe57 35
fe4da5cc 36 ClassImp(AliGenHalo)
37 AliGenHalo::AliGenHalo()
38 :AliGenerator(-1)
39{
f87cfe57 40// Constructor
fe4da5cc 41 fName="Halo";
42 fTitle="Halo from LHC Tunnel";
43 // Set the default file
bd1cece1 44 fFileName=TString("~/marsip/marsip5.mu");
fe4da5cc 45//
46// Read all particles
47 fNpart=-1;
48 fp=0;
49}
50
51AliGenHalo::AliGenHalo(Int_t npart)
52 :AliGenerator(npart)
53{
f87cfe57 54// Constructor
fe4da5cc 55 fName="Halo";
56 fTitle="Halo from LHC Tunnel";
57 // Set the default file
bd1cece1 58 fFileName=TString("~/marsip/marsip5.mu");
fe4da5cc 59//
60// Read all particles
61 fNpart=-1;
62 fp=0;
63}
64
f87cfe57 65AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
66{
67// copy constructor
68}
69
70
fe4da5cc 71//____________________________________________________________
72AliGenHalo::~AliGenHalo()
73{
f87cfe57 74// Destructor
fe4da5cc 75}
76
77//____________________________________________________________
78void AliGenHalo::Init()
f87cfe57 79{
80// Initialisation
81}
fe4da5cc 82
83//____________________________________________________________
84void AliGenHalo::Generate()
85{
f87cfe57 86// Generate from input file
fe4da5cc 87 FILE *fp = fopen(fFileName,"r");
88 if (fp) {
bd1cece1 89 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
fe4da5cc 90 } else {
bd1cece1 91 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
fe4da5cc 92 }
93//
94// MARS particle codes
f87cfe57 95 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
1578254f 96 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
fe4da5cc 97
98 Float_t polar[3]= {0,0,0};
99 Float_t origin[3];
100 Float_t p[3], p0;
101 Float_t ekin, wgt, tx, ty, tz, txy;
1578254f 102 Float_t amass;
fe4da5cc 103 //
1578254f 104 Int_t ipart, ncols, nt;
fe4da5cc 105
106 Int_t nread=0;
107 origin[2]=2650;
108
109 while(1) {
110 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
111 &ipart, &ekin, &wgt,
112 &origin[0], &origin[1],
113 &tx, &ty);
114 if (ncols < 0) break;
115 nread++;
116 if (fNpart !=-1 && nread > fNpart) break;
f87cfe57 117 ipart = kmars[ipart];
1578254f 118 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
fe4da5cc 119 p0=sqrt(ekin*ekin + 2.*amass);
120
121 txy=TMath::Sqrt(tx*tx+ty*ty);
122 if (txy == 1.) {
123 tz=0;
124 } else {
125 tz=-TMath::Sqrt(1.-txy);
126 }
127 p[0]=p0*tx;
128 p[1]=p0*ty;
129 p[2]=p0*tz;
130 fParentWeight=wgt;
886b6f73 131 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
fe4da5cc 132 origin[2]=-origin[2];
133 p[2]=-p[2];
886b6f73 134 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
fe4da5cc 135 origin[2]=-origin[2];
136 p[2]=-p[2];
137 }
138}
139
140
f87cfe57 141AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
142{
143// Assignment operator
144 return *this;
145}
146
fe4da5cc 147
148
149
150
151
152
153