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);
131 // Read file with gas pressure values
133 if (fRunPeriod < 5) {
134 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
136 fG1 = new Float_t[fGPASize];
137 fG2 = new Float_t[fGPASize];
138 fZ1 = new Float_t[fGPASize];
139 fZ2 = new Float_t[fGPASize];
140 } else if (fRunPeriod == 5) {
141 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
143 fG1 = new Float_t[fGPASize];
144 fZ1 = new Float_t[fGPASize];
145 } else if (fRunPeriod ==6) {
146 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
148 fG1 = new Float_t[fGPASize];
149 fZ1 = new Float_t[fGPASize];
151 Fatal("Init()", "No gas pressure file for given run period !");
155 FILE* file = fopen(name, "r");
160 const Float_t kCrossSection = 0.094e-28; // m^2
161 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
162 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
164 if (fRunPeriod < 5) {
169 for (i = 0; i < fGPASize; i++)
171 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
172 fG1[i] = p[fRunPeriod];
175 fZ1[i] = fZ1[i-1] + z;
183 for (i = 0; i < fGPASize; i++)
185 fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
186 fG2[i] = p[fRunPeriod];
188 fZ2[i] = fZ2[i-1] + z;
196 for (i = 0; i < fGPASize; i++)
198 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
199 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
203 for (i = 0; i < fGPASize; i++)
205 fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
207 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
208 // 1/3 of nominal intensity at startup
209 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
218 // Transform into interaction rates
227 for (Int_t iz = 0; iz < 300; iz++) {
228 Float_t zpos = 20. + iz * 1.;
230 Float_t wgt1 = GasPressureWeight( zpos);
231 Float_t wgt2 = GasPressureWeight(-zpos);
237 printf("\n %f %f \n \n", sum1, sum2);
240 //____________________________________________________________
241 void AliGenHalo::Generate()
243 // Generate by reading particles from input file
245 Float_t polar[3]= {0., 0., 0.};
252 static Bool_t first = kTRUE;
253 static Int_t oldID = -1;
264 // Push particle to stack
265 mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
266 p0 = TMath::Sqrt(fEkin * fEkin + 2.* mass * fEkin);
267 txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
271 tz = - TMath::Sqrt(1. - txy);
281 PushTrack(fTrackIt , -1, fPdg , p, origin, polar, fTS, kPNoProcess, nt, fWS);
283 Int_t nc = ReadNextParticle();
285 if (fLossID != oldID || nc == 0) {
290 SetHighWaterMark(nt);
294 Float_t AliGenHalo::GasPressureWeight(Float_t zPrimary)
297 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
300 zPrimary /= 100.; // m
301 if (fRunPeriod < 5) {
302 Float_t zAbs = TMath::Abs(zPrimary);
305 if (zAbs > fZ1[20]) {
308 for (Int_t i = 1; i < 21; i++) {
316 if (zAbs > fZ2[20]) {
319 for (Int_t i = 1; i < 21; i++) {
328 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
334 void AliGenHalo::Draw(Option_t *)
336 // Draws the gas pressure distribution
340 for (Int_t i = 0; i < 400; i++)
342 z[i] = -20000. + Float_t(i) * 100;
343 p[i] = GasPressureWeight(z[i]);
346 TGraph* gr = new TGraph(400, z, p);
347 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
352 Int_t AliGenHalo::ReadNextParticle()
354 // Read the next particle from the file
355 Int_t ncols = fscanf(fFile,"%d %f %f %d %f %d %f %f %f %f %f %f %f %f",
356 &fLossID, &fLossT0, &fLossZ, &fLossA, &fLossW, &fPdg, &fXS, &fYS, &fZS, &fDX, &fDY, &fEkin, &fTS, &fWS);