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>
33 #include "AliGenHaloProtvino.h"
36 ClassImp(AliGenHaloProtvino)
38 AliGenHaloProtvino::AliGenHaloProtvino()
54 fName = "HaloProtvino";
55 fTitle = "Halo from LHC Tunnel";
62 AliGenHaloProtvino::AliGenHaloProtvino(Int_t npart)
78 fTitle= "Halo from LHC Tunnel";
85 //____________________________________________________________
86 AliGenHaloProtvino::~AliGenHaloProtvino()
91 //____________________________________________________________
92 void AliGenHaloProtvino::Init()
95 fFile = fopen(fFileName,"r");
97 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
99 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
104 // Read file with gas pressure values
106 if (fRunPeriod < 5) {
107 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
109 fG1 = new Float_t[fGPASize];
110 fG2 = new Float_t[fGPASize];
111 fZ1 = new Float_t[fGPASize];
112 fZ2 = new Float_t[fGPASize];
113 } else if (fRunPeriod == 5) {
114 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
116 fG1 = new Float_t[fGPASize];
117 fZ1 = new Float_t[fGPASize];
118 } else if (fRunPeriod ==6) {
119 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
121 fG1 = new Float_t[fGPASize];
122 fZ1 = new Float_t[fGPASize];
124 Fatal("Init()", "No gas pressure file for given run period !");
128 if (name) file = fopen(name, "r");
130 AliError("No gas pressure file");
138 const Float_t kCrossSection = 0.094e-28; // m^2
139 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
140 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
143 if (fRunPeriod < 5) {
148 for (i = 0; i < fGPASize; i++)
150 ncols = fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
153 fG1[i] = p[fRunPeriod];
156 fZ1[i] = fZ1[i-1] + z;
164 for (i = 0; i < fGPASize; i++)
166 ncols = fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
169 fG2[i] = p[fRunPeriod];
171 fZ2[i] = fZ2[i-1] + z;
179 for (i = 0; i < fGPASize; i++)
181 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
182 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
186 for (i = 0; i < fGPASize; i++)
188 ncols = fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
192 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
193 // 1/3 of nominal intensity at startup
194 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
203 // Transform into interaction rates
212 for (Int_t iz = 0; iz < 300; iz++) {
213 Float_t zpos = 20. + iz * 1.;
215 Float_t wgt1 = GasPressureWeight( zpos);
216 Float_t wgt2 = GasPressureWeight(-zpos);
222 printf("\n %f %f \n \n", sum1, sum2);
226 //____________________________________________________________
227 void AliGenHaloProtvino::Generate()
229 // Generate from input file
231 Float_t polar[3]= {0,0,0};
238 static Int_t nskip = 0;
241 Float_t* zPrimary = new Float_t [fNpart];
242 Int_t * inuc = new Int_t [fNpart];
243 Int_t * ipart = new Int_t [fNpart];
244 Float_t* wgt = new Float_t [fNpart];
245 Float_t* ekin = new Float_t [fNpart];
246 Float_t* vx = new Float_t [fNpart];
247 Float_t* vy = new Float_t [fNpart];
248 Float_t* tx = new Float_t [fNpart];
249 Float_t* ty = new Float_t [fNpart];
251 Float_t zVertexOld = -1.e10;
252 Int_t nInt = 0; // Counts number of interactions
257 // Load event into array
259 ncols = fscanf(fFile,"%f %d %d %f %f %f %f %f %f",
260 &zPrimary[nread], &inuc[nread], &ipart[nread], &wgt[nread],
261 &ekin[nread], &vx[nread], &vy[nread],
262 &tx[nread], &ty[nread]);
264 if (ncols < 0) break;
265 // Skip fNskip events
267 if (fNpart !=-1 && nskip <= fNskip) continue;
268 // Count interactions
269 if (zPrimary[nread] != zVertexOld) {
271 zVertexOld = zPrimary[nread];
275 if (fNpart !=-1 && nread >= fNpart) break;
278 // Mean time between interactions
281 Float_t dT = 0.; // sec
283 dT = fTimePerEvent/nInt;
284 Float_t t = 0; // sec
287 // Loop over primaries
292 for (Int_t nprim = 0; nprim < fNpart; nprim++)
294 amass = TDatabasePDG::Instance()->GetParticle(ipart[nprim])->Mass();
299 p0=sqrt(ekin[nprim]*ekin[nprim] + 2.*amass*ekin[nprim]);
301 txy=TMath::Sqrt(tx[nprim]*tx[nprim]+ty[nprim]*ty[nprim]);
305 tz=-TMath::Sqrt(1.-txy);
312 origin[0] = vx[nprim];
313 origin[1] = vy[nprim];
320 Float_t originP[3] = {0., 0., 0.};
321 originP[2] = zPrimary[nprim];
323 Float_t pP[3] = {0., 0., 0.};
327 originP[2] = -zPrimary[nprim];
328 origin[2] = -origin[2];
335 if (zPrimary[nprim] != zVertexOld) {
336 while(arg==0.) arg = gRandom->Rndm();
337 t -= dT*TMath::Log(arg); // (sec)
338 zVertexOld = zPrimary[nprim];
341 // Get statistical weight according to local gas-pressure
343 fParentWeight=wgt[nprim]*GasPressureWeight(zPrimary[nprim]);
345 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
346 // Pass parent particle
348 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
350 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
353 // Both sides are considered
357 fParentWeight=wgt[nprim]*GasPressureWeight(-zPrimary[nprim]);
358 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
359 origin[2] = -origin[2];
360 originP[2] = -originP[2];
362 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
364 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
367 wwgt += fParentWeight;
369 SetHighWaterMark(nt);
380 printf("Total weight %f\n\n", wwgt);
385 Float_t AliGenHaloProtvino::GasPressureWeight(Float_t zPrimary)
388 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
391 zPrimary /= 100.; // m
392 if (fRunPeriod < 5) {
393 Float_t zAbs = TMath::Abs(zPrimary);
396 if (zAbs > fZ1[20]) {
399 for (Int_t i = 1; i < 21; i++) {
407 if (zAbs > fZ2[20]) {
410 for (Int_t i = 1; i < 21; i++) {
419 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
425 void AliGenHaloProtvino::Draw(Option_t *)
427 // Draws the gas pressure distribution
431 for (Int_t i = 0; i < 400; i++)
433 z[i] = -20000. + Float_t(i) * 100;
434 p[i] = GasPressureWeight(z[i]);
437 TGraph* gr = new TGraph(400, z, p);
438 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
445 # Title: README file for the sources of IR8 machine induced background
446 # Author: Vadim Talanov <Vadim.Talanov@cern.ch>
447 # Modified: 12-12-2000
451 There are three files, named ring.one.beta.[01,10,50].m, which
452 contain the lists of background particles, induced by proton losses
453 upstream of IP8 in the LHC ring one, for the beta* values of 1, 10
454 and 50 m, respectively.
458 Each line in the files contains the coordinates of particle track
459 crossing with the infinite plane, positioned at z=-1m, together with
460 the physical properties of corresponding particle, namely:
462 S - S coordinate of the primary interaction vertex, cm;
463 N - type of the gas nuclei at interaction, 1 is H, 2 - C and 3 - O;
464 I - particle ID in PDG particle numbering scheme;
466 E - particle kinetic energy, GeV;
467 X - x coordinate of the crossing point, cm;
468 Y - y coordinate of the crossing point, cm;
469 Dx - x direction cosine;
470 Dy - y direction cosine.
474 Each file is given per unity of linear density of proton inelastic
475 interactions with the gas nuclei, [1 inelastic interaction/m].
477 # ~/vtalanov/public/README.mib: the end.