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 beam halo background particles from a boundary source
19 // Boundary source is in the LHCb format http://www.hep.manchester.ac.uk/u/robert/LHC_backgrounds/Note-MIBStudies.pdf
20 // and has been provided by Robert Appleby
21 // Author: andreas.morsch@cern.ch
26 #include <TDatabasePDG.h>
32 #include "AliGenHalo.h"
38 AliGenHalo::AliGenHalo()
69 fTitle = "Halo from LHC Beam";
76 AliGenHalo::AliGenHalo(Int_t npart)
106 fTitle= "Halo from LHC Beam";
113 //____________________________________________________________
114 AliGenHalo::~AliGenHalo()
119 //____________________________________________________________
120 void AliGenHalo::Init()
123 fFile = fopen(fFileName,"r");
125 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
127 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
132 // Skip the first fNskip events
138 // Read file with gas pressure values
140 if (fRunPeriod < 5) {
141 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
143 fG1 = new Float_t[fGPASize];
144 fG2 = new Float_t[fGPASize];
145 fZ1 = new Float_t[fGPASize];
146 fZ2 = new Float_t[fGPASize];
147 } else if (fRunPeriod == 5) {
148 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
150 fG1 = new Float_t[fGPASize];
151 fZ1 = new Float_t[fGPASize];
152 } else if (fRunPeriod ==6) {
153 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
155 fG1 = new Float_t[fGPASize];
156 fZ1 = new Float_t[fGPASize];
158 Fatal("Init()", "No gas pressure file for given run period !");
163 if (name) file = fopen(name, "r");
165 AliError("No gas pressure file");
173 const Float_t kCrossSection = 0.094e-28; // m^2
174 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
175 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
177 if (fRunPeriod < 5) {
182 for (i = 0; i < fGPASize; i++)
184 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
185 fG1[i] = p[fRunPeriod];
188 fZ1[i] = fZ1[i-1] + z;
196 for (i = 0; i < fGPASize; i++)
198 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
199 fG2[i] = p[fRunPeriod];
201 fZ2[i] = fZ2[i-1] + z;
209 for (i = 0; i < fGPASize; i++)
211 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
212 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
216 for (i = 0; i < fGPASize; i++)
218 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
220 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
221 // 1/3 of nominal intensity at startup
222 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
231 // Transform into interaction rates
240 for (Int_t iz = 0; iz < 300; iz++) {
241 Float_t zpos = 20. + iz * 1.;
243 Float_t wgt1 = GasPressureWeight( zpos);
244 Float_t wgt2 = GasPressureWeight(-zpos);
250 printf("\n %f %f \n \n", sum1, sum2);
254 //____________________________________________________________
255 void AliGenHalo::Generate()
257 // Generate by reading particles from input file
259 Float_t polar[3]= {0., 0., 0.};
266 static Bool_t first = kTRUE;
267 static Int_t oldID = -1;
270 if (first && (fNskip == 0)) ReadNextParticle();
275 // Push particle to stack
276 mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
277 p0 = TMath::Sqrt(fEkin * fEkin + 2. * mass * fEkin);
278 txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
282 tz = - TMath::Sqrt(1. - txy);
293 PushTrack(fTrackIt , -1, fPdg , p, origin, polar, fTS - 1950./2.9979e10, kPNoProcess, nt, fWS);
295 Int_t nc = ReadNextParticle();
297 if (fLossID != oldID || nc == 0) {
302 SetHighWaterMark(nt);
306 Float_t AliGenHalo::GasPressureWeight(Float_t zPrimary)
309 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
312 zPrimary /= 100.; // m
313 if (fRunPeriod < 5) {
314 Float_t zAbs = TMath::Abs(zPrimary);
317 if (zAbs > fZ1[20]) {
320 for (Int_t i = 1; i < 21; i++) {
328 if (zAbs > fZ2[20]) {
331 for (Int_t i = 1; i < 21; i++) {
340 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
346 void AliGenHalo::Draw(Option_t *)
348 // Draws the gas pressure distribution
352 for (Int_t i = 0; i < 400; i++)
354 z[i] = -20000. + Float_t(i) * 100;
355 p[i] = GasPressureWeight(z[i]);
358 TGraph* gr = new TGraph(400, z, p);
359 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
364 Int_t AliGenHalo::ReadNextParticle()
366 // Read the next particle from the file
367 Int_t ncols = fscanf(fFile,"%d %f %f %d %f %d %f %f %f %f %f %f %f %f",
368 &fLossID, &fLossT0, &fLossZ, &fLossA, &fLossW, &fPdg, &fXS, &fYS, &fZS, &fDX, &fDY, &fEkin, &fTS, &fWS);
377 void AliGenHalo::SkipEvents()
380 // Skip the first fNskip events
387 if (oldID != fLossID) {
393 void AliGenHalo::CountEvents()
400 nc = ReadNextParticle();
401 if (oldID != fLossID) {
404 printf("Number of events %10d %10d \n", nev, oldID);