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>
32 #include "AliGenHaloProtvino.h"
35 ClassImp(AliGenHaloProtvino)
37 AliGenHaloProtvino::AliGenHaloProtvino()
42 fName = "HaloProtvino";
43 fTitle = "Halo from LHC Tunnel";
55 AliGenHaloProtvino::AliGenHaloProtvino(Int_t npart)
60 fTitle= "Halo from LHC Tunnel";
71 AliGenHaloProtvino::AliGenHaloProtvino(const AliGenHaloProtvino & HaloProtvino):
72 AliGenerator(HaloProtvino)
75 HaloProtvino.Copy(*this);
79 //____________________________________________________________
80 AliGenHaloProtvino::~AliGenHaloProtvino()
85 //____________________________________________________________
86 void AliGenHaloProtvino::Init()
89 fFile = fopen(fFileName,"r");
91 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), fFile);
93 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), fFile);
98 // Read file with gas pressure values
100 if (fRunPeriod < 5) {
101 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
103 fG1 = new Float_t[fGPASize];
104 fG2 = new Float_t[fGPASize];
105 fZ1 = new Float_t[fGPASize];
106 fZ2 = new Float_t[fGPASize];
107 } else if (fRunPeriod == 5) {
108 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
110 fG1 = new Float_t[fGPASize];
111 fZ1 = new Float_t[fGPASize];
112 } else if (fRunPeriod ==6) {
113 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
115 fG1 = new Float_t[fGPASize];
116 fZ1 = new Float_t[fGPASize];
118 Fatal("Init()", "No gas pressure file for given run period !");
122 FILE* file = fopen(name, "r");
127 const Float_t kCrossSection = 0.094e-28; // m^2
128 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
129 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
131 if (fRunPeriod < 5) {
136 for (i = 0; i < fGPASize; i++)
138 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
139 fG1[i] = p[fRunPeriod];
142 fZ1[i] = fZ1[i-1] + z;
150 for (i = 0; i < fGPASize; i++)
152 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
153 fG2[i] = p[fRunPeriod];
155 fZ2[i] = fZ2[i-1] + z;
163 for (i = 0; i < fGPASize; i++)
165 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
166 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
170 for (i = 0; i < fGPASize; i++)
172 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
174 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
175 // 1/3 of nominal intensity at startup
176 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
185 // Transform into interaction rates
194 for (Int_t i = 0; i < 300; i++) {
195 Float_t z = 20.+i*1.;
197 Float_t wgt1 = GasPressureWeight(z);
198 Float_t wgt2 = GasPressureWeight(-z);
199 // printf("weight: %f %f %f %f %f \n", z, wgt1, wgt2, fZ1[20], fZ2[20]);
205 printf("\n %f %f \n \n", sum1, sum2);
208 //____________________________________________________________
209 void AliGenHaloProtvino::Generate()
211 // Generate from input file
213 Float_t polar[3]= {0,0,0};
223 Float_t* zPrimary = new Float_t [fNpart];
224 Int_t * inuc = new Int_t [fNpart];
225 Int_t * ipart = new Int_t [fNpart];
226 Float_t* wgt = new Float_t [fNpart];
227 Float_t* ekin = new Float_t [fNpart];
228 Float_t* vx = new Float_t [fNpart];
229 Float_t* vy = new Float_t [fNpart];
230 Float_t* tx = new Float_t [fNpart];
231 Float_t* ty = new Float_t [fNpart];
233 Float_t zVertexOld = -1.e10;
234 Int_t nInt = 0; // Counts number of interactions
239 // Load event into array
241 ncols = fscanf(fFile,"%f %d %d %f %f %f %f %f %f",
242 &zPrimary[nread], &inuc[nread], &ipart[nread], &wgt[nread],
243 &ekin[nread], &vx[nread], &vy[nread],
244 &tx[nread], &ty[nread]);
246 if (ncols < 0) break;
247 // Skip fNskip events
249 if (fNpart !=-1 && nskip <= fNskip) continue;
250 // Count interactions
251 if (zPrimary[nread] != zVertexOld) {
253 zVertexOld = zPrimary[nread];
257 if (fNpart !=-1 && nread > fNpart) break;
260 // Mean time between interactions
262 Float_t dT = fTimePerEvent/nInt; // sec
263 Float_t t = 0; // sec
266 // Loop over primaries
271 for (Int_t nprim = 0; nprim < fNpart; nprim++)
273 amass = TDatabasePDG::Instance()->GetParticle(ipart[nprim])->Mass();
278 p0=sqrt(ekin[nprim]*ekin[nprim] + 2.*amass*ekin[nprim]);
280 txy=TMath::Sqrt(tx[nprim]*tx[nprim]+ty[nprim]*ty[nprim]);
284 tz=-TMath::Sqrt(1.-txy);
291 origin[0] = vx[nprim];
292 origin[1] = vy[nprim];
299 Float_t originP[3] = {0., 0., 0.};
300 originP[2] = zPrimary[nprim];
302 Float_t pP[3] = {0., 0., 0.};
306 originP[2] = -zPrimary[nprim];
307 origin[2] = -origin[2];
314 if (zPrimary[nprim] != zVertexOld) {
315 while(arg==0.) arg = gRandom->Rndm();
316 t -= dT*TMath::Log(arg); // (sec)
317 zVertexOld = zPrimary[nprim];
320 // Get statistical weight according to local gas-pressure
322 fParentWeight=wgt[nprim]*GasPressureWeight(zPrimary[nprim]);
324 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
325 // Pass parent particle
327 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
329 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
332 // Both sides are considered
336 fParentWeight=wgt[nprim]*GasPressureWeight(-zPrimary[nprim]);
337 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
338 origin[2] = -origin[2];
339 originP[2] = -originP[2];
341 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
343 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
346 Wgt += fParentWeight;
348 SetHighWaterMark(nt);
359 printf("Total weight %f\n\n", Wgt);
364 AliGenHaloProtvino& AliGenHaloProtvino::operator=(const AliGenHaloProtvino& rhs)
366 // Assignment operator
373 Float_t AliGenHaloProtvino::GasPressureWeight(Float_t zPrimary)
376 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
379 zPrimary /= 100.; // m
380 if (fRunPeriod < 5) {
381 Float_t zAbs = TMath::Abs(zPrimary);
384 if (zAbs > fZ1[20]) {
387 for (Int_t i = 1; i < 21; i++) {
395 if (zAbs > fZ2[20]) {
398 for (Int_t i = 1; i < 21; i++) {
407 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
413 void AliGenHaloProtvino::Draw()
415 // Draws the gas pressure distribution
419 for (Int_t i = 0; i < 400; i++)
421 z[i] = -20000. + Float_t(i) * 100;
422 p[i] = GasPressureWeight(z[i]);
425 TGraph* gr = new TGraph(400, z, p);
426 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
432 void AliGenHaloProtvino::Copy(TObject&) const
437 Fatal("Copy","Not implemented!\n");
442 # Title: README file for the sources of IR8 machine induced background
443 # Author: Vadim Talanov <Vadim.Talanov@cern.ch>
444 # Modified: 12-12-2000
448 There are three files, named ring.one.beta.[01,10,50].m, which
449 contain the lists of background particles, induced by proton losses
450 upstream of IP8 in the LHC ring one, for the beta* values of 1, 10
451 and 50 m, respectively.
455 Each line in the files contains the coordinates of particle track
456 crossing with the infinite plane, positioned at z=-1m, together with
457 the physical properties of corresponding particle, namely:
459 S - S coordinate of the primary interaction vertex, cm;
460 N - type of the gas nuclei at interaction, 1 is H, 2 - C and 3 - O;
461 I - particle ID in PDG particle numbering scheme;
463 E - particle kinetic energy, GeV;
464 X - x coordinate of the crossing point, cm;
465 Y - y coordinate of the crossing point, cm;
466 Dx - x direction cosine;
467 Dy - y direction cosine.
471 Each file is given per unity of linear density of proton inelastic
472 interactions with the gas nuclei, [1 inelastic interaction/m].
474 # ~/vtalanov/public/README.mib: the end.