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");
128 printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile);
130 printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile);
135 // Skip the first fNskip events
141 // Read file with gas pressure values
143 if (fRunPeriod < 5) {
144 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/gasPressure.dat" );
146 fG1 = new Float_t[fGPASize];
147 fG2 = new Float_t[fGPASize];
148 fZ1 = new Float_t[fGPASize];
149 fZ2 = new Float_t[fGPASize];
150 } else if (fRunPeriod == 5) {
151 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_startup.dat");
153 fG1 = new Float_t[fGPASize];
154 fZ1 = new Float_t[fGPASize];
155 } else if (fRunPeriod ==6) {
156 name = gSystem->ExpandPathName("$(ALICE_ROOT)/LHC/pressure_2003_conditioned.dat");
158 fG1 = new Float_t[fGPASize];
159 fZ1 = new Float_t[fGPASize];
161 Fatal("Init()", "No gas pressure file for given run period !");
166 if (name) file = fopen(name, "r");
168 AliError("No gas pressure file");
176 const Float_t kCrossSection = 0.094e-28; // m^2
177 const Float_t kFlux = 1.e11 / 25.e-9; // protons/s
178 Float_t pFlux[5] = {0.2, 0.2, 0.3, 0.3, 1.0};
180 if (fRunPeriod < 5) {
185 for (i = 0; i < fGPASize; i++)
187 ir = fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
190 fG1[i] = p[fRunPeriod];
193 fZ1[i] = fZ1[i-1] + z;
201 for (i = 0; i < fGPASize; i++)
203 ir = fscanf(file, "%f %f %f %f %f %f", &z, &p[0], &p[1], &p[2] , &p[3], &p[4]);
206 fG2[i] = p[fRunPeriod];
208 fZ2[i] = fZ2[i-1] + z;
216 for (i = 0; i < fGPASize; i++)
218 fG1[i] = fG1[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
219 fG2[i] = fG2[i] * kCrossSection * pFlux[fRunPeriod] * kFlux; // 1/m/s
223 for (i = 0; i < fGPASize; i++)
225 ir = fscanf(file, "%f %e %e %e %e %e", &z, &p[0], &p[1], &p[2], &p[3], &p[4]);
228 fG1[i] = p[4] * kCrossSection * kFlux; // 1/m/s
229 // 1/3 of nominal intensity at startup
230 if (fRunPeriod == kLHCPR674Startup) fG1[i] /= 3.;
239 // Transform into interaction rates
248 for (Int_t iz = 0; iz < 300; iz++) {
249 Float_t zpos = 20. + iz * 1.;
251 Float_t wgt1 = GasPressureWeight( zpos);
252 Float_t wgt2 = GasPressureWeight(-zpos);
258 printf("\n %f %f \n \n", sum1, sum2);
262 //____________________________________________________________
263 void AliGenHalo::Generate()
265 // Generate by reading particles from input file
267 Float_t polar[3]= {0., 0., 0.};
274 static Bool_t first = kTRUE;
275 static Int_t oldID = -1;
278 if (first && (fNskip == 0)) ReadNextParticle();
283 // Push particle to stack
284 mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
285 p0 = TMath::Sqrt(fEkin * fEkin + 2. * mass * fEkin);
286 txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
290 tz = - TMath::Sqrt(1. - txy);
301 PushTrack(fTrackIt , -1, fPdg , p, origin, polar, fTS - 1950./2.9979e10, kPNoProcess, nt, fWS);
303 Int_t nc = ReadNextParticle();
305 if (fLossID != oldID || nc == 0) {
310 SetHighWaterMark(nt);
314 Float_t AliGenHalo::GasPressureWeight(Float_t zPrimary)
317 // Return z-dependent gasspressure weight = interaction rate [1/m/s].
320 zPrimary /= 100.; // m
321 if (fRunPeriod < 5) {
322 Float_t zAbs = TMath::Abs(zPrimary);
325 if (zAbs > fZ1[20]) {
328 for (Int_t i = 1; i < 21; i++) {
336 if (zAbs > fZ2[20]) {
339 for (Int_t i = 1; i < 21; i++) {
348 Int_t index = TMath::BinarySearch(fGPASize, fZ1, zPrimary);
354 void AliGenHalo::Draw(Option_t *)
356 // Draws the gas pressure distribution
360 for (Int_t i = 0; i < 400; i++)
362 z[i] = -20000. + Float_t(i) * 100;
363 p[i] = GasPressureWeight(z[i]);
366 TGraph* gr = new TGraph(400, z, p);
367 TCanvas* c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
372 Int_t AliGenHalo::ReadNextParticle()
374 // Read the next particle from the file
375 Int_t ncols = fscanf(fFile,"%d %f %f %d %f %d %f %f %f %f %f %f %f %f",
376 &fLossID, &fLossT0, &fLossZ, &fLossA, &fLossW, &fPdg, &fXS, &fYS, &fZS, &fDX, &fDY, &fEkin, &fTS, &fWS);
385 void AliGenHalo::SkipEvents()
388 // Skip the first fNskip events
395 if (oldID != fLossID) {
401 void AliGenHalo::CountEvents()
403 // Count total number of events
409 nc = ReadNextParticle();
410 if (oldID != fLossID) {
413 printf("Number of events %10d %10d \n", nev, oldID);