1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include "AliGenHalo.h"
21 #include "AliGenMUONlib.h"
26 #include <TDirectory.h>
27 #include <TDatabasePDG.h>
32 AliGenHalo::AliGenHalo()
36 fTitle="Halo from LHC Tunnel";
37 // Set the default file
38 fFileName="~/marsip/marsip5.mu";
45 AliGenHalo::AliGenHalo(Int_t npart)
49 fTitle="Halo from LHC Tunnel";
50 // Set the default file
51 fFileName="~/marsip/marsip5.mu";
58 //____________________________________________________________
59 AliGenHalo::~AliGenHalo()
63 //____________________________________________________________
64 void AliGenHalo::Init()
67 //____________________________________________________________
68 void AliGenHalo::Generate()
70 FILE *fp = fopen(fFileName,"r");
72 printf("\n File %s opened for reading ! \n ", fFileName);
74 printf("\n Opening of file %s failed ! \n ", fFileName);
77 // MARS particle codes
78 // const Int_t imars[12]={0,14, 13, 8, 9, 11, 12, 5, 6, 1, 3, 2};
79 const Int_t imars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
80 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
82 Float_t polar[3]= {0,0,0};
85 Float_t ekin, wgt, tx, ty, tz, txy;
88 Int_t ipart, ncols, nt;
94 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
96 &origin[0], &origin[1],
100 if (fNpart !=-1 && nread > fNpart) break;
101 ipart = imars[ipart];
102 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
103 p0=sqrt(ekin*ekin + 2.*amass);
105 txy=TMath::Sqrt(tx*tx+ty*ty);
109 tz=-TMath::Sqrt(1.-txy);
115 gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
116 origin[2]=-origin[2];
118 gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
119 origin[2]=-origin[2];