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