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 // Read background particles from a boundary source
19 // Very specialized generator to simulate background from beam halo.
20 // The input file is a text file specially prepared
22 // Author: andreas.morsch@cern.ch
26 #include <TDatabasePDG.h>
29 #include "AliGenHalo.h"
33 AliGenHalo::AliGenHalo()
38 fTitle="Halo from LHC Tunnel";
45 AliGenHalo::AliGenHalo(Int_t npart)
50 fTitle="Halo from LHC Tunnel";
57 AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
63 //____________________________________________________________
64 AliGenHalo::~AliGenHalo()
69 //____________________________________________________________
70 void AliGenHalo::Init()
75 //____________________________________________________________
76 void AliGenHalo::Generate()
78 // Generate from input file
79 FILE *fp = fopen(fFileName,"r");
81 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
83 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
86 // MARS particle codes
87 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
88 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
90 Float_t polar[3]= {0,0,0};
93 Float_t ekin, wgt, tx, ty, tz, txy;
96 Int_t ipart, ncols, nt;
102 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
104 &origin[0], &origin[1],
106 if (ncols < 0) break;
108 if (fNpart !=-1 && nread > fNpart) break;
109 ipart = kmars[ipart];
110 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
111 p0=sqrt(ekin*ekin + 2.*amass);
113 txy=TMath::Sqrt(tx*tx+ty*ty);
117 tz=-TMath::Sqrt(1.-txy);
123 PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
124 // PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
125 origin[2]=-origin[2];
127 PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
128 // PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
129 origin[2]=-origin[2];
135 AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
137 // Assignment operator