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"
37 AliGenHalo::AliGenHalo()
68 fTitle = "Halo from LHC Beam";
75 AliGenHalo::AliGenHalo(Int_t npart)
105 fTitle= "Halo from LHC Beam";
112 //____________________________________________________________
113 AliGenHalo::~AliGenHalo()
118 //____________________________________________________________
119 void AliGenHalo::Init()
122 fFile = fopen(fFileName,"r");
124 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
126 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
130 // Skip the first fNskip events
136 // Read file with gas pressure values
138 if (fRunPeriod < 5) {
139 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
141 fG1 = new Float_t[fGPASize];
142 fG2 = new Float_t[fGPASize];
143 fZ1 = new Float_t[fGPASize];
144 fZ2 = new Float_t[fGPASize];
145 } else if (fRunPeriod == 5) {
146 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
148 fG1 = new Float_t[fGPASize];
149 fZ1 = new Float_t[fGPASize];
150 } else if (fRunPeriod ==6) {
151 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
153 fG1 = new Float_t[fGPASize];
154 fZ1 = new Float_t[fGPASize];
156 Fatal("Init()", "No gas pressure file for given run period !");
160 FILE* file = fopen(name, "r");
165 const Float_t kCrossSection = 0.094e-28; // m^2
166 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
167 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
169 if (fRunPeriod < 5) {
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 fG1[i] = p[fRunPeriod];
180 fZ1[i] = fZ1[i-1] + z;
188 for (i = 0; i < fGPASize; i++)
190 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
191 fG2[i] = p[fRunPeriod];
193 fZ2[i] = fZ2[i-1] + z;
201 for (i = 0; i < fGPASize; i++)
203 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
204 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
208 for (i = 0; i < fGPASize; i++)
210 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
212 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
213 // 1/3 of nominal intensity at startup
214 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
223 // Transform into interaction rates
232 for (Int_t iz = 0; iz < 300; iz++) {
233 Float_t zpos = 20. + iz * 1.;
235 Float_t wgt1 = GasPressureWeight( zpos);
236 Float_t wgt2 = GasPressureWeight(-zpos);
242 printf("\n %f %f \n \n", sum1, sum2);
245 //____________________________________________________________
246 void AliGenHalo::Generate()
248 // Generate by reading particles from input file
250 Float_t polar[3]= {0., 0., 0.};
257 static Bool_t first = kTRUE;
258 static Int_t oldID = -1;
261 if (first && (fNskip == 0)) ReadNextParticle();
266 // Push particle to stack
267 mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
268 p0 = TMath::Sqrt(fEkin * fEkin + 2. * mass * fEkin);
269 txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
273 tz = - TMath::Sqrt(1. - txy);
284 PushTrack(fTrackIt , -1, fPdg , p, origin, polar, fTS - 1950./2.9979e10, kPNoProcess, nt, fWS);
286 Int_t nc = ReadNextParticle();
288 if (fLossID != oldID || nc == 0) {
293 SetHighWaterMark(nt);
297 Float_t AliGenHalo::GasPressureWeight(Float_t zPrimary)
300 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
303 zPrimary /= 100.; // m
304 if (fRunPeriod < 5) {
305 Float_t zAbs = TMath::Abs(zPrimary);
308 if (zAbs > fZ1[20]) {
311 for (Int_t i = 1; i < 21; i++) {
319 if (zAbs > fZ2[20]) {
322 for (Int_t i = 1; i < 21; i++) {
331 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
337 void AliGenHalo::Draw(Option_t *)
339 // Draws the gas pressure distribution
343 for (Int_t i = 0; i < 400; i++)
345 z[i] = -20000. + Float_t(i) * 100;
346 p[i] = GasPressureWeight(z[i]);
349 TGraph* gr = new TGraph(400, z, p);
350 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
355 Int_t AliGenHalo::ReadNextParticle()
357 // Read the next particle from the file
358 Int_t ncols = fscanf(fFile,"%d %f %f %d %f %d %f %f %f %f %f %f %f %f",
359 &fLossID, &fLossT0, &fLossZ, &fLossA, &fLossW, &fPdg, &fXS, &fYS, &fZS, &fDX, &fDY, &fEkin, &fTS, &fWS);
368 void AliGenHalo::SkipEvents()
371 // Skip the first fNskip events
378 if (oldID != fLossID) {