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.9 2000/11/30 07:12:50 alibrary
19 Introducing new Rndm and QA classes
21 Revision 1.8 2000/10/02 15:20:40 morsch
22 Direct reference to default input file removed.
24 Revision 1.7 2000/06/30 12:19:07 morsch
25 Type of fFileName changed to TString, fp has been !-ed.
27 Revision 1.6 2000/06/09 20:36:01 morsch
28 All coding rule violations except RS3 corrected
30 Revision 1.5 1999/11/03 17:43:20 fca
31 New version from G.Martinez & A.Morsch
33 Revision 1.4 1999/09/29 09:24:14 fca
34 Introduction of the Copyright and cvs Log
38 // Read background particles from a boundary source
39 // Very specialized generator to simulate background from beam halo.
40 // The input file is a text file specially prepared
42 // Author: andreas.morsch@cern.ch
44 #include "AliGenHalo.h"
48 #include <TDatabasePDG.h>
52 AliGenHalo::AliGenHalo()
57 fTitle="Halo from LHC Tunnel";
64 AliGenHalo::AliGenHalo(Int_t npart)
69 fTitle="Halo from LHC Tunnel";
76 AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
82 //____________________________________________________________
83 AliGenHalo::~AliGenHalo()
88 //____________________________________________________________
89 void AliGenHalo::Init()
94 //____________________________________________________________
95 void AliGenHalo::Generate()
97 // Generate from input file
98 FILE *fp = fopen(fFileName,"r");
100 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
102 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
105 // MARS particle codes
106 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
107 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
109 Float_t polar[3]= {0,0,0};
112 Float_t ekin, wgt, tx, ty, tz, txy;
115 Int_t ipart, ncols, nt;
121 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
123 &origin[0], &origin[1],
125 if (ncols < 0) break;
127 if (fNpart !=-1 && nread > fNpart) break;
128 ipart = kmars[ipart];
129 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
130 p0=sqrt(ekin*ekin + 2.*amass);
132 txy=TMath::Sqrt(tx*tx+ty*ty);
136 tz=-TMath::Sqrt(1.-txy);
142 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
143 // gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
144 origin[2]=-origin[2];
146 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
147 // gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
148 origin[2]=-origin[2];
154 AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
156 // Assignment operator