tags T/AliGeant4-4-01__ar-v3-06-Rev-02__g4-3-2-ref07 commented
[u/mrichter/AliRoot.git] / EVGEN / AliGenHaloProtvino.cxx
CommitLineData
14ab5373 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
16/*
17$Log$
a99cf51f 18Revision 1.2 2001/06/14 12:15:27 morsch
19Bugs corrected. SetSide() method added.
20
154d524b 21Revision 1.1 2001/01/23 15:04:33 morsch
22Generator to read beam halo file from Protvino group.
23
14ab5373 24*/
25
26// Read background particles from a boundary source
27// Very specialized generator to simulate background from beam halo.
28// The input file is a text file specially prepared
29// for this purpose.
30// Author: andreas.morsch@cern.ch
31
32#include "AliGenHaloProtvino.h"
33#include "AliRun.h"
34#include "AliMC.h"
35#include "AliPDG.h"
36
37#include <TDatabasePDG.h>
38#include <stdlib.h>
39
40 ClassImp(AliGenHaloProtvino)
41 AliGenHaloProtvino::AliGenHaloProtvino()
42 :AliGenerator(-1)
43{
44// Constructor
154d524b 45 printf("\n Calling Default Constructor");
46
47 fName = "HaloProtvino";
48 fTitle = "Halo from LHC Tunnel";
14ab5373 49//
50// Read all particles
154d524b 51 fNpart = -1;
52 fFile = 0;
53 fSide = 1;
14ab5373 54}
55
56AliGenHaloProtvino::AliGenHaloProtvino(Int_t npart)
57 :AliGenerator(npart)
58{
59// Constructor
154d524b 60 printf("\n Calling Constructor");
61 fName = "Halo";
62 fTitle= "Halo from LHC Tunnel";
14ab5373 63//
154d524b 64 fNpart = npart;
65 fFile = 0;
66 fSide = 1;
14ab5373 67}
68
69AliGenHaloProtvino::AliGenHaloProtvino(const AliGenHaloProtvino & HaloProtvino)
70{
71// copy constructor
72}
73
74
75//____________________________________________________________
76AliGenHaloProtvino::~AliGenHaloProtvino()
77{
78// Destructor
79}
80
81//____________________________________________________________
82void AliGenHaloProtvino::Init()
83{
84// Initialisation
154d524b 85 fFile = fopen(fFileName,"r");
86 if (fFile) {
87 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), fFile);
88 } else {
89 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), fFile);
90 }
14ab5373 91}
92
93//____________________________________________________________
94void AliGenHaloProtvino::Generate()
95{
96// Generate from input file
14ab5373 97
98 Float_t polar[3]= {0,0,0};
99 Float_t origin[3];
100 Float_t p[3], p0;
101 Float_t ekin, wgt, tx, ty, tz, txy;
102 Float_t zPrimary;
103 Float_t amass;
104 Int_t inuc;
105 //
106 Int_t ipart, ncols, nt;
154d524b 107 Int_t nread = 0;
14ab5373 108 while(1) {
154d524b 109 ncols = fscanf(fFile,"%f %d %d %f %f %f %f %f %f",
14ab5373 110 &zPrimary, &inuc, &ipart, &wgt,
111 &ekin, &origin[0], &origin[1],
112 &tx, &ty);
154d524b 113/*
14ab5373 114 printf(" \n %f %d %d %f %f %f %f %f %f",
115 zPrimary, inuc, ipart, wgt,
116 ekin, origin[0], origin[1],
117 tx, ty);
154d524b 118*/
14ab5373 119 if (ncols < 0) break;
120 nread++;
154d524b 121
14ab5373 122 if (fNpart !=-1 && nread > fNpart) break;
123
124
125
126 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
127
128 //
129 // Momentum vector
130 //
131 p0=sqrt(ekin*ekin + 2.*amass);
132
133 txy=TMath::Sqrt(tx*tx+ty*ty);
134 if (txy == 1.) {
135 tz=0;
136 } else {
137 tz=-TMath::Sqrt(1.-txy);
138 }
139
140 p[0]=p0*tx;
141 p[1]=p0*ty;
154d524b 142 p[2]=-p0*tz;
143
144 origin[2] = 21.965;
14ab5373 145
146 //
147 //
148 // Particle weight
149
154d524b 150 Float_t originP[3] = {0., 0., 0.};
151 originP[2] = zPrimary;
152
153 Float_t pP[3] = {0., 0., 0.};
154 Int_t ntP;
155
156 if (fSide == -1) {
157 originP[2] = -zPrimary;
158 origin[2] = -origin[2];
159 p[2] = -p[2];
160 }
161
a99cf51f 162 SetTrack(0,-1,kProton,pP,originP,polar,0,kPNoProcess,ntP);
163 KeepTrack(ntP);
14ab5373 164 fParentWeight=wgt*GassPressureWeight(zPrimary);
a99cf51f 165 SetTrack(fTrackIt,ntP,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
166 SetHighWaterMark(nt);
154d524b 167
14ab5373 168 //
169 // Assume particles come from two directions with same probability
154d524b 170
14ab5373 171 origin[2]=-origin[2];
172 p[2]=-p[2];
173 fParentWeight=wgt*GassPressureWeight(-zPrimary);
a99cf51f 174 SetTrack(fTrackIt,ntP,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
14ab5373 175 origin[2]=-origin[2];
176 p[2]=-p[2];
154d524b 177 origin[2]=-origin[2];
14ab5373 178 }
179}
180
181
182AliGenHaloProtvino& AliGenHaloProtvino::operator=(const AliGenHaloProtvino& rhs)
183{
184// Assignment operator
185 return *this;
186}
187
188
189Float_t AliGenHaloProtvino::GassPressureWeight(Float_t zPrimary)
190{
191 // Return z-dependent gasspressure weight
192 //
154d524b 193 Float_t weight = 500.;
194
195 if (zPrimary > 45000.) weight = 2.e4;
196
197 return weight;
14ab5373 198}
199
200/*
201# Title: README file for the sources of IR8 machine induced background
202# Author: Vadim Talanov <Vadim.Talanov@cern.ch>
203# Modified: 12-12-2000
204
2050. Overview
206
207 There are three files, named ring.one.beta.[01,10,50].m, which
208 contain the lists of background particles, induced by proton losses
209 upstream of IP8 in the LHC ring one, for the beta* values of 1, 10
210 and 50 m, respectively.
211
2121. File contents
213
214 Each line in the files contains the coordinates of particle track
215 crossing with the infinite plane, positioned at z=-1m, together with
216 the physical properties of corresponding particle, namely:
217
218 S - S coordinate of the primary interaction vertex, cm;
219 N - type of the gas nuclei at interaction, 1 is H, 2 - C and 3 - O;
220 I - particle ID in PDG particle numbering scheme;
221 W - particle weight;
222 E - particle kinetic energy, GeV;
223 X - x coordinate of the crossing point, cm;
224 Y - y coordinate of the crossing point, cm;
225 Dx - x direction cosine;
226 Dy - y direction cosine.
227
2282. Normalisation
229
230 Each file is given per unity of linear density of proton inelastic
231 interactions with the gas nuclei, [1 inelastic interaction/m].
232
233# ~/vtalanov/public/README.mib: the end.
234
235*/
236
237
238
239