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.10 2000/12/21 16:24:06 morsch
19 Coding convention clean-up
21 Revision 1.9 2000/11/30 07:12:50 alibrary
22 Introducing new Rndm and QA classes
24 Revision 1.8 2000/10/02 15:20:40 morsch
25 Direct reference to default input file removed.
27 Revision 1.7 2000/06/30 12:19:07 morsch
28 Type of fFileName changed to TString, fp has been !-ed.
30 Revision 1.6 2000/06/09 20:36:01 morsch
31 All coding rule violations except RS3 corrected
33 Revision 1.5 1999/11/03 17:43:20 fca
34 New version from G.Martinez & A.Morsch
36 Revision 1.4 1999/09/29 09:24:14 fca
37 Introduction of the Copyright and cvs Log
41 // Read background particles from a boundary source
42 // Very specialized generator to simulate background from beam halo.
43 // The input file is a text file specially prepared
45 // Author: andreas.morsch@cern.ch
47 #include "AliGenHalo.h"
51 #include <TDatabasePDG.h>
55 AliGenHalo::AliGenHalo()
60 fTitle="Halo from LHC Tunnel";
67 AliGenHalo::AliGenHalo(Int_t npart)
72 fTitle="Halo from LHC Tunnel";
79 AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
85 //____________________________________________________________
86 AliGenHalo::~AliGenHalo()
91 //____________________________________________________________
92 void AliGenHalo::Init()
97 //____________________________________________________________
98 void AliGenHalo::Generate()
100 // Generate from input file
101 FILE *fp = fopen(fFileName,"r");
103 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
105 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
108 // MARS particle codes
109 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
110 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
112 Float_t polar[3]= {0,0,0};
115 Float_t ekin, wgt, tx, ty, tz, txy;
118 Int_t ipart, ncols, nt;
124 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
126 &origin[0], &origin[1],
128 if (ncols < 0) break;
130 if (fNpart !=-1 && nread > fNpart) break;
131 ipart = kmars[ipart];
132 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
133 p0=sqrt(ekin*ekin + 2.*amass);
135 txy=TMath::Sqrt(tx*tx+ty*ty);
139 tz=-TMath::Sqrt(1.-txy);
145 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
146 // SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
147 origin[2]=-origin[2];
149 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
150 // SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
151 origin[2]=-origin[2];
157 AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
159 // Assignment operator