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 **************************************************************************/
18 Revision 1.11 2001/07/27 17:09:36 morsch
19 Use local SetTrack, KeepTrack and SetHighWaterMark methods
20 to delegate either to local stack or to stack owned by AliRun.
21 (Piotr Skowronski, A.M.)
23 Revision 1.10 2000/12/21 16:24:06 morsch
24 Coding convention clean-up
26 Revision 1.9 2000/11/30 07:12:50 alibrary
27 Introducing new Rndm and QA classes
29 Revision 1.8 2000/10/02 15:20:40 morsch
30 Direct reference to default input file removed.
32 Revision 1.7 2000/06/30 12:19:07 morsch
33 Type of fFileName changed to TString, fp has been !-ed.
35 Revision 1.6 2000/06/09 20:36:01 morsch
36 All coding rule violations except RS3 corrected
38 Revision 1.5 1999/11/03 17:43:20 fca
39 New version from G.Martinez & A.Morsch
41 Revision 1.4 1999/09/29 09:24:14 fca
42 Introduction of the Copyright and cvs Log
46 // Read background particles from a boundary source
47 // Very specialized generator to simulate background from beam halo.
48 // The input file is a text file specially prepared
50 // Author: andreas.morsch@cern.ch
54 #include <TDatabasePDG.h>
57 #include "AliGenHalo.h"
61 AliGenHalo::AliGenHalo()
66 fTitle="Halo from LHC Tunnel";
73 AliGenHalo::AliGenHalo(Int_t npart)
78 fTitle="Halo from LHC Tunnel";
85 AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
91 //____________________________________________________________
92 AliGenHalo::~AliGenHalo()
97 //____________________________________________________________
98 void AliGenHalo::Init()
103 //____________________________________________________________
104 void AliGenHalo::Generate()
106 // Generate from input file
107 FILE *fp = fopen(fFileName,"r");
109 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
111 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
114 // MARS particle codes
115 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
116 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
118 Float_t polar[3]= {0,0,0};
121 Float_t ekin, wgt, tx, ty, tz, txy;
124 Int_t ipart, ncols, nt;
130 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
132 &origin[0], &origin[1],
134 if (ncols < 0) break;
136 if (fNpart !=-1 && nread > fNpart) break;
137 ipart = kmars[ipart];
138 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
139 p0=sqrt(ekin*ekin + 2.*amass);
141 txy=TMath::Sqrt(tx*tx+ty*ty);
145 tz=-TMath::Sqrt(1.-txy);
151 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
152 // SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
153 origin[2]=-origin[2];
155 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
156 // SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
157 origin[2]=-origin[2];
163 AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
165 // Assignment operator