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