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()
53 fName = "HaloProtvino";
54 fTitle = "Halo from LHC Tunnel";
61 AliGenHaloProtvino::AliGenHaloProtvino(Int_t npart)
77 fTitle= "Halo from LHC Tunnel";
84 //____________________________________________________________
85 AliGenHaloProtvino::~AliGenHaloProtvino()
90 //____________________________________________________________
91 void AliGenHaloProtvino::Init()
94 fFile = fopen(fFileName,"r");
96 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
98 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
103 // Read file with gas pressure values
105 if (fRunPeriod < 5) {
106 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
108 fG1 = new Float_t[fGPASize];
109 fG2 = new Float_t[fGPASize];
110 fZ1 = new Float_t[fGPASize];
111 fZ2 = new Float_t[fGPASize];
112 } else if (fRunPeriod == 5) {
113 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
115 fG1 = new Float_t[fGPASize];
116 fZ1 = new Float_t[fGPASize];
117 } else if (fRunPeriod ==6) {
118 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
120 fG1 = new Float_t[fGPASize];
121 fZ1 = new Float_t[fGPASize];
123 Fatal("Init()", "No gas pressure file for given run period !");
127 FILE* file = fopen(name, "r");
132 const Float_t kCrossSection = 0.094e-28; // m^2
133 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
134 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
136 if (fRunPeriod < 5) {
141 for (i = 0; i < fGPASize; i++)
143 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
144 fG1[i] = p[fRunPeriod];
147 fZ1[i] = fZ1[i-1] + z;
155 for (i = 0; i < fGPASize; i++)
157 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
158 fG2[i] = p[fRunPeriod];
160 fZ2[i] = fZ2[i-1] + z;
168 for (i = 0; i < fGPASize; i++)
170 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
171 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
175 for (i = 0; i < fGPASize; i++)
177 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
179 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
180 // 1/3 of nominal intensity at startup
181 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
190 // Transform into interaction rates
199 for (Int_t i = 0; i < 300; i++) {
200 Float_t z = 20.+i*1.;
202 Float_t wgt1 = GasPressureWeight(z);
203 Float_t wgt2 = GasPressureWeight(-z);
204 // printf("weight: %f %f %f %f %f \n", z, wgt1, wgt2, fZ1[20], fZ2[20]);
210 printf("\n %f %f \n \n", sum1, sum2);
213 //____________________________________________________________
214 void AliGenHaloProtvino::Generate()
216 // Generate from input file
218 Float_t polar[3]= {0,0,0};
225 static Int_t nskip = 0;
228 Float_t* zPrimary = new Float_t [fNpart];
229 Int_t * inuc = new Int_t [fNpart];
230 Int_t * ipart = new Int_t [fNpart];
231 Float_t* wgt = new Float_t [fNpart];
232 Float_t* ekin = new Float_t [fNpart];
233 Float_t* vx = new Float_t [fNpart];
234 Float_t* vy = new Float_t [fNpart];
235 Float_t* tx = new Float_t [fNpart];
236 Float_t* ty = new Float_t [fNpart];
238 Float_t zVertexOld = -1.e10;
239 Int_t nInt = 0; // Counts number of interactions
244 // Load event into array
246 ncols = fscanf(fFile,"%f %d %d %f %f %f %f %f %f",
247 &zPrimary[nread], &inuc[nread], &ipart[nread], &wgt[nread],
248 &ekin[nread], &vx[nread], &vy[nread],
249 &tx[nread], &ty[nread]);
251 if (ncols < 0) break;
252 // Skip fNskip events
254 if (fNpart !=-1 && nskip <= fNskip) continue;
255 // Count interactions
256 if (zPrimary[nread] != zVertexOld) {
258 zVertexOld = zPrimary[nread];
262 if (fNpart !=-1 && nread > fNpart) break;
265 // Mean time between interactions
267 Float_t dT = fTimePerEvent/nInt; // sec
268 Float_t t = 0; // sec
271 // Loop over primaries
276 for (Int_t nprim = 0; nprim < fNpart; nprim++)
278 amass = TDatabasePDG::Instance()->GetParticle(ipart[nprim])->Mass();
283 p0=sqrt(ekin[nprim]*ekin[nprim] + 2.*amass*ekin[nprim]);
285 txy=TMath::Sqrt(tx[nprim]*tx[nprim]+ty[nprim]*ty[nprim]);
289 tz=-TMath::Sqrt(1.-txy);
296 origin[0] = vx[nprim];
297 origin[1] = vy[nprim];
304 Float_t originP[3] = {0., 0., 0.};
305 originP[2] = zPrimary[nprim];
307 Float_t pP[3] = {0., 0., 0.};
311 originP[2] = -zPrimary[nprim];
312 origin[2] = -origin[2];
319 if (zPrimary[nprim] != zVertexOld) {
320 while(arg==0.) arg = gRandom->Rndm();
321 t -= dT*TMath::Log(arg); // (sec)
322 zVertexOld = zPrimary[nprim];
325 // Get statistical weight according to local gas-pressure
327 fParentWeight=wgt[nprim]*GasPressureWeight(zPrimary[nprim]);
329 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
330 // Pass parent particle
332 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
334 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
337 // Both sides are considered
341 fParentWeight=wgt[nprim]*GasPressureWeight(-zPrimary[nprim]);
342 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
343 origin[2] = -origin[2];
344 originP[2] = -originP[2];
346 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
348 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
351 wwgt += fParentWeight;
353 SetHighWaterMark(nt);
364 printf("Total weight %f\n\n", wwgt);
369 Float_t AliGenHaloProtvino::GasPressureWeight(Float_t zPrimary)
372 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
375 zPrimary /= 100.; // m
376 if (fRunPeriod < 5) {
377 Float_t zAbs = TMath::Abs(zPrimary);
380 if (zAbs > fZ1[20]) {
383 for (Int_t i = 1; i < 21; i++) {
391 if (zAbs > fZ2[20]) {
394 for (Int_t i = 1; i < 21; i++) {
403 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
409 void AliGenHaloProtvino::Draw(Option_t *)
411 // Draws the gas pressure distribution
415 for (Int_t i = 0; i < 400; i++)
417 z[i] = -20000. + Float_t(i) * 100;
418 p[i] = GasPressureWeight(z[i]);
421 TGraph* gr = new TGraph(400, z, p);
422 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
429 # Title: README file for the sources of IR8 machine induced background
430 # Author: Vadim Talanov <Vadim.Talanov@cern.ch>
431 # Modified: 12-12-2000
435 There are three files, named ring.one.beta.[01,10,50].m, which
436 contain the lists of background particles, induced by proton losses
437 upstream of IP8 in the LHC ring one, for the beta* values of 1, 10
438 and 50 m, respectively.
442 Each line in the files contains the coordinates of particle track
443 crossing with the infinite plane, positioned at z=-1m, together with
444 the physical properties of corresponding particle, namely:
446 S - S coordinate of the primary interaction vertex, cm;
447 N - type of the gas nuclei at interaction, 1 is H, 2 - C and 3 - O;
448 I - particle ID in PDG particle numbering scheme;
450 E - particle kinetic energy, GeV;
451 X - x coordinate of the crossing point, cm;
452 Y - y coordinate of the crossing point, cm;
453 Dx - x direction cosine;
454 Dy - y direction cosine.
458 Each file is given per unity of linear density of proton inelastic
459 interactions with the gas nuclei, [1 inelastic interaction/m].
461 # ~/vtalanov/public/README.mib: the end.