]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
803d1ab0 | 16 | /* $Id$ */ |
4c039060 | 17 | |
675e9664 | 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 | |
21 | // for this purpose. | |
22 | // Author: andreas.morsch@cern.ch | |
23 | ||
116cbefd | 24 | #include <stdlib.h> |
c5970876 | 25 | |
1578254f | 26 | #include <TDatabasePDG.h> |
116cbefd | 27 | #include <TPDGCode.h> |
28 | ||
29 | #include "AliGenHalo.h" | |
30 | #include "AliRun.h" | |
f87cfe57 | 31 | |
198bb1c7 | 32 | ClassImp(AliGenHalo) |
33 | ||
34 | AliGenHalo::AliGenHalo() | |
1c56e311 | 35 | :AliGenerator(-1), |
36 | fp(0), | |
37 | fFileName(0) | |
fe4da5cc | 38 | { |
f87cfe57 | 39 | // Constructor |
fe4da5cc | 40 | fName="Halo"; |
41 | fTitle="Halo from LHC Tunnel"; | |
fe4da5cc | 42 | // |
43 | // Read all particles | |
44 | fNpart=-1; | |
fe4da5cc | 45 | } |
46 | ||
47 | AliGenHalo::AliGenHalo(Int_t npart) | |
1c56e311 | 48 | :AliGenerator(npart), |
49 | fp(0), | |
50 | fFileName(0) | |
fe4da5cc | 51 | { |
f87cfe57 | 52 | // Constructor |
fe4da5cc | 53 | fName="Halo"; |
54 | fTitle="Halo from LHC Tunnel"; | |
fe4da5cc | 55 | // |
56 | // Read all particles | |
57 | fNpart=-1; | |
fe4da5cc | 58 | } |
59 | ||
60 | //____________________________________________________________ | |
61 | AliGenHalo::~AliGenHalo() | |
62 | { | |
f87cfe57 | 63 | // Destructor |
fe4da5cc | 64 | } |
65 | ||
66 | //____________________________________________________________ | |
67 | void AliGenHalo::Init() | |
f87cfe57 | 68 | { |
69 | // Initialisation | |
70 | } | |
fe4da5cc | 71 | |
72 | //____________________________________________________________ | |
73 | void AliGenHalo::Generate() | |
74 | { | |
f87cfe57 | 75 | // Generate from input file |
dc1d768c | 76 | fp = fopen(fFileName,"r"); |
fe4da5cc | 77 | if (fp) { |
bd1cece1 | 78 | printf("\n File %s opened for reading ! \n ", (char*) &fFileName); |
fe4da5cc | 79 | } else { |
bd1cece1 | 80 | printf("\n Opening of file %s failed ! \n ", (char*) &fFileName); |
fe4da5cc | 81 | } |
82 | // | |
83 | // MARS particle codes | |
f87cfe57 | 84 | const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus, |
1578254f | 85 | kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron}; |
fe4da5cc | 86 | |
87 | Float_t polar[3]= {0,0,0}; | |
88 | Float_t origin[3]; | |
89 | Float_t p[3], p0; | |
90 | Float_t ekin, wgt, tx, ty, tz, txy; | |
1578254f | 91 | Float_t amass; |
fe4da5cc | 92 | // |
1578254f | 93 | Int_t ipart, ncols, nt; |
fe4da5cc | 94 | |
95 | Int_t nread=0; | |
96 | origin[2]=2650; | |
97 | ||
98 | while(1) { | |
99 | ncols = fscanf(fp,"%i %f %f %f %f %f %f", | |
100 | &ipart, &ekin, &wgt, | |
101 | &origin[0], &origin[1], | |
102 | &tx, &ty); | |
103 | if (ncols < 0) break; | |
104 | nread++; | |
105 | if (fNpart !=-1 && nread > fNpart) break; | |
f87cfe57 | 106 | ipart = kmars[ipart]; |
1578254f | 107 | amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass(); |
fe4da5cc | 108 | p0=sqrt(ekin*ekin + 2.*amass); |
109 | ||
110 | txy=TMath::Sqrt(tx*tx+ty*ty); | |
111 | if (txy == 1.) { | |
112 | tz=0; | |
113 | } else { | |
114 | tz=-TMath::Sqrt(1.-txy); | |
115 | } | |
116 | p[0]=p0*tx; | |
117 | p[1]=p0*ty; | |
118 | p[2]=p0*tz; | |
119 | fParentWeight=wgt; | |
642f15cf | 120 | PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight); |
121 | // PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight); | |
fe4da5cc | 122 | origin[2]=-origin[2]; |
123 | p[2]=-p[2]; | |
642f15cf | 124 | PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight); |
125 | // PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight); | |
fe4da5cc | 126 | origin[2]=-origin[2]; |
127 | p[2]=-p[2]; | |
128 | } | |
129 | } | |
130 | ||
131 | ||
fe4da5cc | 132 | |
133 | ||
134 | ||
135 | ||
136 | ||
137 |