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 AliGenHaloProtvino::AliGenHaloProtvino(const AliGenHaloProtvino & HaloProtvino):
85 AliGenerator(HaloProtvino),
99 HaloProtvino.Copy(*this);
103 //____________________________________________________________
104 AliGenHaloProtvino::~AliGenHaloProtvino()
109 //____________________________________________________________
110 void AliGenHaloProtvino::Init()
113 fFile = fopen(fFileName,"r");
115 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
117 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
122 // Read file with gas pressure values
124 if (fRunPeriod < 5) {
125 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
127 fG1 = new Float_t[fGPASize];
128 fG2 = new Float_t[fGPASize];
129 fZ1 = new Float_t[fGPASize];
130 fZ2 = new Float_t[fGPASize];
131 } else if (fRunPeriod == 5) {
132 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
134 fG1 = new Float_t[fGPASize];
135 fZ1 = new Float_t[fGPASize];
136 } else if (fRunPeriod ==6) {
137 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
139 fG1 = new Float_t[fGPASize];
140 fZ1 = new Float_t[fGPASize];
142 Fatal("Init()", "No gas pressure file for given run period !");
146 FILE* file = fopen(name, "r");
151 const Float_t kCrossSection = 0.094e-28; // m^2
152 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
153 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
155 if (fRunPeriod < 5) {
160 for (i = 0; i < fGPASize; i++)
162 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
163 fG1[i] = p[fRunPeriod];
166 fZ1[i] = fZ1[i-1] + z;
174 for (i = 0; i < fGPASize; i++)
176 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
177 fG2[i] = p[fRunPeriod];
179 fZ2[i] = fZ2[i-1] + z;
187 for (i = 0; i < fGPASize; i++)
189 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
190 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
194 for (i = 0; i < fGPASize; i++)
196 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
198 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
199 // 1/3 of nominal intensity at startup
200 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
209 // Transform into interaction rates
218 for (Int_t i = 0; i < 300; i++) {
219 Float_t z = 20.+i*1.;
221 Float_t wgt1 = GasPressureWeight(z);
222 Float_t wgt2 = GasPressureWeight(-z);
223 // printf("weight: %f %f %f %f %f \n", z, wgt1, wgt2, fZ1[20], fZ2[20]);
229 printf("\n %f %f \n \n", sum1, sum2);
232 //____________________________________________________________
233 void AliGenHaloProtvino::Generate()
235 // Generate from input file
237 Float_t polar[3]= {0,0,0};
244 static Int_t nskip = 0;
247 Float_t* zPrimary = new Float_t [fNpart];
248 Int_t * inuc = new Int_t [fNpart];
249 Int_t * ipart = new Int_t [fNpart];
250 Float_t* wgt = new Float_t [fNpart];
251 Float_t* ekin = new Float_t [fNpart];
252 Float_t* vx = new Float_t [fNpart];
253 Float_t* vy = new Float_t [fNpart];
254 Float_t* tx = new Float_t [fNpart];
255 Float_t* ty = new Float_t [fNpart];
257 Float_t zVertexOld = -1.e10;
258 Int_t nInt = 0; // Counts number of interactions
263 // Load event into array
265 ncols = fscanf(fFile,"%f %d %d %f %f %f %f %f %f",
266 &zPrimary[nread], &inuc[nread], &ipart[nread], &wgt[nread],
267 &ekin[nread], &vx[nread], &vy[nread],
268 &tx[nread], &ty[nread]);
270 if (ncols < 0) break;
271 // Skip fNskip events
273 if (fNpart !=-1 && nskip <= fNskip) continue;
274 // Count interactions
275 if (zPrimary[nread] != zVertexOld) {
277 zVertexOld = zPrimary[nread];
281 if (fNpart !=-1 && nread > fNpart) break;
284 // Mean time between interactions
286 Float_t dT = fTimePerEvent/nInt; // sec
287 Float_t t = 0; // sec
290 // Loop over primaries
295 for (Int_t nprim = 0; nprim < fNpart; nprim++)
297 amass = TDatabasePDG::Instance()->GetParticle(ipart[nprim])->Mass();
302 p0=sqrt(ekin[nprim]*ekin[nprim] + 2.*amass*ekin[nprim]);
304 txy=TMath::Sqrt(tx[nprim]*tx[nprim]+ty[nprim]*ty[nprim]);
308 tz=-TMath::Sqrt(1.-txy);
315 origin[0] = vx[nprim];
316 origin[1] = vy[nprim];
323 Float_t originP[3] = {0., 0., 0.};
324 originP[2] = zPrimary[nprim];
326 Float_t pP[3] = {0., 0., 0.};
330 originP[2] = -zPrimary[nprim];
331 origin[2] = -origin[2];
338 if (zPrimary[nprim] != zVertexOld) {
339 while(arg==0.) arg = gRandom->Rndm();
340 t -= dT*TMath::Log(arg); // (sec)
341 zVertexOld = zPrimary[nprim];
344 // Get statistical weight according to local gas-pressure
346 fParentWeight=wgt[nprim]*GasPressureWeight(zPrimary[nprim]);
348 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
349 // Pass parent particle
351 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
353 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
356 // Both sides are considered
360 fParentWeight=wgt[nprim]*GasPressureWeight(-zPrimary[nprim]);
361 if (!fAnalog || gRandom->Rndm() < fParentWeight) {
362 origin[2] = -origin[2];
363 originP[2] = -originP[2];
365 PushTrack(0,-1,kProton,pP,originP,polar,t,kPNoProcess,ntP, fParentWeight);
367 PushTrack(fTrackIt,ntP,ipart[nprim],p,origin,polar,t,kPNoProcess,nt,fParentWeight);
370 wwgt += fParentWeight;
372 SetHighWaterMark(nt);
383 printf("Total weight %f\n\n", wwgt);
388 AliGenHaloProtvino& AliGenHaloProtvino::operator=(const AliGenHaloProtvino& rhs)
390 // Assignment operator
397 Float_t AliGenHaloProtvino::GasPressureWeight(Float_t zPrimary)
400 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
403 zPrimary /= 100.; // m
404 if (fRunPeriod < 5) {
405 Float_t zAbs = TMath::Abs(zPrimary);
408 if (zAbs > fZ1[20]) {
411 for (Int_t i = 1; i < 21; i++) {
419 if (zAbs > fZ2[20]) {
422 for (Int_t i = 1; i < 21; i++) {
431 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
437 void AliGenHaloProtvino::Draw(Option_t *)
439 // Draws the gas pressure distribution
443 for (Int_t i = 0; i < 400; i++)
445 z[i] = -20000. + Float_t(i) * 100;
446 p[i] = GasPressureWeight(z[i]);
449 TGraph* gr = new TGraph(400, z, p);
450 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
456 void AliGenHaloProtvino::Copy(TObject&) const
461 Fatal("Copy","Not implemented!\n");
466 # Title: README file for the sources of IR8 machine induced background
467 # Author: Vadim Talanov <Vadim.Talanov@cern.ch>
468 # Modified: 12-12-2000
472 There are three files, named ring.one.beta.[01,10,50].m, which
473 contain the lists of background particles, induced by proton losses
474 upstream of IP8 in the LHC ring one, for the beta* values of 1, 10
475 and 50 m, respectively.
479 Each line in the files contains the coordinates of particle track
480 crossing with the infinite plane, positioned at z=-1m, together with
481 the physical properties of corresponding particle, namely:
483 S - S coordinate of the primary interaction vertex, cm;
484 N - type of the gas nuclei at interaction, 1 is H, 2 - C and 3 - O;
485 I - particle ID in PDG particle numbering scheme;
487 E - particle kinetic energy, GeV;
488 X - x coordinate of the crossing point, cm;
489 Y - y coordinate of the crossing point, cm;
490 Dx - x direction cosine;
491 Dy - y direction cosine.
495 Each file is given per unity of linear density of proton inelastic
496 interactions with the gas nuclei, [1 inelastic interaction/m].
498 # ~/vtalanov/public/README.mib: the end.