--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+#include "AliLHC.h"
+#include "AliLhcIRegion.h"
+#include "AliLhcProcess.h"
+#include "AliLhcBeam.h"
+
+ClassImp(AliLHC)
+
+AliLHC::AliLHC()
+{
+// Constructor
+ fIRegions = new TList;
+ fProcesses = new TList;
+ fNRegions = 0;
+ fNProcesses = 0;
+ fBeams = new TObjArray(2);
+ (*fBeams)[0] = 0;
+ (*fBeams)[1] = 0;
+ fTime = 0;
+ fTimeMax = 0;
+}
+
+AliLHC::AliLHC(const AliLHC& lhc)
+{
+// copy constructor
+}
+
+AliLHC::~AliLHC()
+{
+// Destructor
+ delete fIRegions;
+ delete fProcesses;
+ delete fBeams;
+}
+
+void AliLHC::AddIRegion(AliLhcIRegion *region)
+{
+//
+// Add region to list
+ fIRegions->Add(region);
+ fNRegions++;
+ }
+
+void AliLHC::AddProcess(AliLhcProcess *process)
+{
+//
+// Add process to list
+ fProcesses->Add(process);
+ fNProcesses++;
+ }
+
+void AliLHC::SetBeams(AliLhcBeam *beam1, AliLhcBeam *beam2 )
+{
+
+//
+// Set the beams
+
+ (*fBeams)[0] = beam1;
+ (*fBeams)[1] = beam2;
+}
+
+ void AliLHC::Init()
+{
+// Initialisation
+ fNt = 0;
+ fNmax = Int_t(fTimeMax/fTimeStep);
+ fTimeA = new Float_t[fNmax];
+ //
+ Beam(0)->Init();
+ Beam(1)->Init();
+
+ TIter next(fIRegions);
+ AliLhcIRegion *region;
+ //
+ // Loop over generators and initialize
+ while((region = (AliLhcIRegion*)next())) {
+ region->Init();
+ region->SetMonitor(fNmax);
+ }
+
+ Beam(0)->SetMonitor(fNmax);
+ Beam(1)->SetMonitor(fNmax);
+
+ TIter nextp(fProcesses);
+ AliLhcProcess *process;
+ //
+ // Loop over generators and initialize
+ while((process = (AliLhcProcess*)nextp())) {
+ process->Init();
+ process->SetMonitor(fNmax);
+ }
+}
+
+ void AliLHC::EvolveTime()
+{
+//
+// Simulate Time Evolution
+//
+ while (fTime <= fTimeMax) {
+ printf("\n Time: %f %f", fTime, fTimeStep);
+ //
+ // Processes
+ //
+ TIter next(fProcesses);
+ AliLhcProcess *process;
+ //
+ // Evolve for each process
+ while((process = (AliLhcProcess*)next())) {
+ process->Evolve(fTimeStep);
+ process->Record();
+ }
+ //
+ // Update and Monitoring
+ //
+ TIter nextregion(fIRegions);
+ AliLhcIRegion *region;
+ //
+ while((region = (AliLhcIRegion*)nextregion())) {
+ printf("\n Region: %s, Luminosity %10.3e",
+ region->GetName(), region->Luminosity());
+ region->Update();
+ region->Record();
+ }
+ Beam(0)->Record();
+ fTimeA[fNt] = fTime/3600.;
+ fTime+=fTimeStep;
+ fNt++;
+ }
+}
+
+void AliLHC::Evaluate()
+{
+ // Evaluation of the results
+ TIter nextregion(fIRegions);
+ AliLhcIRegion *region;
+ //
+ // Loop over generators and initialize
+ while((region = (AliLhcIRegion*)nextregion())) {
+ region->Draw();
+ }
+
+ TIter next(fProcesses);
+ AliLhcProcess *process;
+ //
+ // Evolve for each process
+ while((process = (AliLhcProcess*)next())) {
+ process->Draw();
+ }
+
+ Beam(0)->Draw();
+}
+
+AliLHC& AliLHC::operator=(const AliLHC & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+
--- /dev/null
+#ifndef ALILHC_H
+#define ALILHC_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include <TObject.h>
+#include <TList.h>
+#include <TObjArray.h>
+
+class AliLhcIRegion;
+class AliLhcProcess;
+class AliLhcBeam;
+
+
+class AliLHC : public TObject
+{
+ public:
+ AliLHC();
+ AliLHC(const AliLHC &lhc);
+ virtual ~AliLHC();
+
+ virtual void AddIRegion(AliLhcIRegion *region);
+ virtual void AddProcess(AliLhcProcess *process);
+ virtual void SetBeams(AliLhcBeam* beam1, AliLhcBeam* beam2);
+ virtual void SetTime(Float_t dt, Float_t tmax)
+ {fTimeStep = dt; fTimeMax = tmax;}
+ virtual void SetFillingTime(Float_t t) {fFillingTime = t;}
+ virtual void SetSetUpTime(Float_t t) {fSetUpTime = t;}
+
+ virtual void SetRadius(Float_t r) {fRadius = r;}
+ virtual void SetAverageBeta(Float_t b) {fAverageBeta = b;}
+ virtual void SetAverageDisp(Float_t b) {fAverageDisp = b;}
+
+ virtual Float_t Radius() {return fRadius;}
+ virtual Float_t AverageBeta() {return fAverageBeta;}
+ virtual Float_t AverageDisp() {return fAverageDisp;}
+ virtual Float_t SetUpTime() {return fSetUpTime;}
+ virtual Float_t FillingTime() {return fFillingTime;}
+
+
+ virtual AliLhcBeam* Beam(Int_t i)
+ {return (AliLhcBeam*) (*fBeams)[i];}
+ virtual TList* IRegions(){return fIRegions;}
+ virtual void Init();
+ virtual void EvolveTime();
+ virtual void Evaluate();
+ virtual Float_t Time() {return fTime;}
+ virtual Float_t TimeStep() {return fTimeStep;}
+ virtual Float_t* TimeA() {return fTimeA;}
+ virtual Int_t Nt() {return fNt;}
+
+ AliLHC & operator=(const AliLHC & rhs);
+
+ protected:
+ Int_t fNRegions; // Number of IR
+ Int_t fNProcesses; // Number of processes
+ TList* fIRegions; // List of intercation regions
+ TList* fProcesses; // Beam processes
+ TObjArray* fBeams; // Lhc beams
+ Float_t fRadius; // Radius (cm)
+ Float_t fAverageBeta; // Average beta (cm)
+ Float_t fAverageDisp; // Average dispersion (cm)
+
+ Int_t fNt; // Number of time steps
+ Int_t fNmax; // Max. Number of time steps
+
+ Float_t fTime; // Current time
+ Float_t* fTimeA; // [fNmax] Current time
+ Float_t fTimeStep; // Current time step
+ Float_t fTimeMax; // Maximal time
+ //
+ Float_t fFillingTime; // Filling Time
+ Float_t fSetUpTime; // Set-up time
+//
+ ClassDef(AliLHC,1) // LHC manager class
+};
+
+#endif
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcBeam.h"
+#include "AliLHC.h"
+#include <TMath.h>
+#include <TCanvas.h>
+#include <TGraph.h>
+#include <TMultiGraph.h>
+
+ClassImp(AliLhcBeam)
+
+AliLhcBeam::AliLhcBeam(AliLHC* lhc)
+{
+// Constructor
+ fAccelerator = lhc;
+}
+
+AliLhcBeam::AliLhcBeam(const AliLhcBeam& beam)
+{
+// copy constructor
+}
+
+AliLhcBeam::~AliLhcBeam()
+{
+// Destructor
+
+}
+
+void AliLhcBeam::Init()
+{
+ // Initialization
+ printf("\n Initializing Beam");
+ printf("\n ^^^^^^^^^^^^^^^^^");
+ // Scale energy with regidity
+ fEnergy *= fZ/fA;
+ fGamma = fEnergy/0.938272;
+ fEmittance = fNEmittance/fGamma;
+ fEmittance0 = fEmittance;
+ fEmittanceL *= fZ;
+ fEmittanceL0 = fEmittanceL;
+ fN0=fN;
+
+ printf("\n Beam Energy :%10.3e GeV", fEnergy);
+ printf("\n Beam Normalized Emittance :%10.3e cm ", fNEmittance);
+ printf("\n Beam Particles per Bunch :%10.3e ", fN);
+}
+
+void AliLhcBeam::RemoveParticles(Float_t loss)
+{
+ fN-=loss;
+}
+
+void AliLhcBeam::IncreaseEmittance(Float_t de, Float_t del)
+{
+ fEmittance *= (1.+de);
+ fEmittanceL *= (1.+del);
+ fEnergySpread *= (1.+del);
+}
+
+AliLhcBeam& AliLhcBeam::operator=(const AliLhcBeam & rhs)
+{
+// Assignment operator
+ return *this;
+}
+void AliLhcBeam::SetMonitor(Int_t n)
+{
+ fNmax = n;
+ if (fEmittanceArray) delete fEmittanceArray;
+ if (fEmittanceLArray) delete fEmittanceLArray;
+
+
+ fEmittanceArray = new Float_t[n];
+ fEmittanceLArray = new Float_t[n];
+}
+
+void AliLhcBeam::Record()
+{
+ fEmittanceArray [fAccelerator->Nt()] = fEmittance/fEmittance0;
+ fEmittanceLArray[fAccelerator->Nt()] = fEmittanceL/fEmittanceL0;
+}
+
+
+void AliLhcBeam::DrawPlots()
+{
+ // Draw monitor plots
+ Float_t* t = fAccelerator->TimeA();
+
+ TH1 *e1 = new TH1F("e1","Hor. Emittance",fNmax,0,t[fNmax]);
+ e1->SetMinimum(1);
+ e1->SetMaximum(fEmittanceArray[fNmax]*1.1);
+ e1->SetStats(0);
+ e1->GetXaxis()->SetTitle("t (h)");
+ e1->GetYaxis()->SetTitle("rel. Emittance (t)");
+
+ TH1 *e2 = new TH1F("e2","Long. Emittance",fNmax,0,t[fNmax]);
+ e2->SetMinimum(1);
+ e2->SetMaximum(fEmittanceLArray[fNmax]*1.1);
+ e2->SetStats(0);
+ e2->GetXaxis()->SetTitle("t (h)");
+ e2->GetYaxis()->SetTitle("rel. Emittance (t)");
+
+
+ TGraph* grE = new TGraph(fNmax, t, fEmittanceArray);
+ grE->SetHistogram(e1);
+ TGraph* grEl = new TGraph(fNmax, t, fEmittanceLArray);
+ grEl->SetHistogram(e2);
+ grEl->SetLineStyle(2);
+
+ TMultiGraph* mg = new TMultiGraph();
+ mg->Add(grE);
+ mg->Add(grEl);
+
+ TCanvas *c2 = new TCanvas("c2","Emittance Increase", 200, 10, 700, 500);
+ c2->SetGrid();
+ mg->Draw("AC");
+ mg->GetXaxis()->SetTitle("t (h)");
+ mg->GetYaxis()->SetTitle("rel. Emittance(t)");
+ mg->Draw("AC");
+}
+
+
+
+
--- /dev/null
+#ifndef ALILHCBEAM_H
+#define ALILHCBAEM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include <TNamed.h>
+#include "AliLhcMonitor.h"
+
+class AliLHC;
+
+class AliLhcBeam : public TNamed, public AliLhcMonitor
+{
+ public:
+ AliLhcBeam(AliLHC* lhc);
+ AliLhcBeam(const AliLhcBeam &beam);
+ virtual ~AliLhcBeam();
+
+ virtual void Init();
+
+ virtual Float_t N() {return fN;}
+ virtual Float_t A() {return fA;}
+ virtual Float_t Z() {return fZ;}
+ virtual Float_t Emittance() {return fEmittance;}
+ virtual Float_t Energy() {return fEnergy;}
+ virtual Float_t Gamma() {return fGamma;}
+ virtual Float_t LongEmittance() {return fEmittanceL;}
+ virtual Float_t EnergySpread() {return fEnergySpread;}
+
+ virtual void SetParticle(Float_t a, Float_t z) {fA = a; fZ = z;}
+ virtual void SetN(Float_t n) {fN = n;}
+ virtual void SetAccelerator(AliLHC* acc) {fAccelerator = acc;}
+ virtual void SetEnergy(Float_t e) {fEnergy = e;}
+ virtual void SetNEmittance(Float_t e) {fNEmittance = e;}
+ virtual void SetLongEmittance(Float_t e) {fEmittanceL = e;}
+ virtual void SetEnergySpread(Float_t b) {fEnergySpread = b;}
+
+ virtual void RemoveParticles(Float_t loss);
+ virtual void IncreaseEmittance(Float_t de, Float_t del);
+ virtual void SetMonitor(Int_t n);
+ virtual void Record();
+ virtual void DrawPlots();
+
+
+ AliLhcBeam & operator=(const AliLhcBeam & rhs);
+
+ protected:
+ AliLHC* fAccelerator; // Accelerator
+ Float_t fN; // Number of Particles
+ Float_t fN0; // Initial Number of Particles
+ Float_t fNEmittance; // Normalized Emittance
+ Float_t fEmittance; // Emittance
+ Float_t fEmittance0; // Initial Emittance
+ Float_t fEmittanceL; // Longitudinal Emittance
+ Float_t fEmittanceL0; // Longitudinal Emittance
+ Float_t fEnergySpread; // Energy Spread
+
+ Float_t fA; // Atomic Number
+ Float_t fZ; // Charge Number
+ Float_t fEnergy; // Energy
+ Float_t fGamma; // relativistic gamma
+ //
+ Float_t* fTimeArray; // [fNmax] Time array
+ Float_t* fEmittanceArray; // [fNmax] Emittance array
+ Float_t* fEmittanceLArray; // [fNmax] Long. Emittance array
+//
+ ClassDef(AliLhcBeam,1) // LHC Beam
+};
+
+#endif
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcIRegion.h"
+#include "AliLhcBeam.h"
+#include "AliLHC.h"
+
+#include <TMath.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TGraph.h>
+#include <TMultiGraph.h>
+#include <TH1.h>
+
+ClassImp(AliLhcIRegion)
+
+AliLhcIRegion::AliLhcIRegion(AliLHC* lhc, const char* name, const char* title)
+ :TNamed(name,title)
+{
+// Constructor
+ fAccelerator=lhc;
+ fLumiArray = 0;
+ fAverageLumiArray = 0;
+ fBetaStarArray = 0;
+}
+
+AliLhcIRegion::AliLhcIRegion(const AliLhcIRegion& region)
+{
+// copy constructor
+}
+
+AliLhcIRegion::~AliLhcIRegion()
+{
+// Destructor
+
+ if (fLumiArray) delete fLumiArray;
+ if (fAverageLumiArray) delete fAverageLumiArray;
+ if (fBetaStarArray) delete fBetaStarArray;
+}
+
+
+AliLhcIRegion& AliLhcIRegion::operator=(const AliLhcIRegion & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+void AliLhcIRegion::Init()
+{
+ // Initialization
+ printf("\n Initializing Interaction Region %s", GetName());
+ printf("\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+ // Initial Luminosity
+ fBeam1 = fAccelerator->Beam(0);
+ fBeam2 = fAccelerator->Beam(1);
+ fFrequency = 3.e10/(2.*TMath::Pi()*fAccelerator->Radius());
+
+ Luminosity();
+
+ fLuminosity0 = fLuminosity;
+ fAverageLumi=0.;
+ fBetaStar0 = fBetaStar;
+ printf("\n IR Beta* :%10.3e cm ", fBetaStar);
+ printf("\n IR Initial Luminosity :%10.3e cm^-2s^-1 ", fLuminosity);
+}
+
+Float_t AliLhcIRegion::Luminosity()
+{
+ Float_t sigma1 = TMath::Sqrt(fBeam1->Emittance()*fBetaStar);
+ Float_t sigma2 = TMath::Sqrt(fBeam2->Emittance()*fBetaStar);
+ fLuminosity = fFrequency *
+ fBeam1->N()*fBeam2->N()/(2.*TMath::Pi()*(sigma1*sigma1+sigma2*sigma2));
+ return fLuminosity;
+}
+
+void AliLhcIRegion::Update()
+{
+ Luminosity();
+}
+
+void AliLhcIRegion::SetMonitor(Int_t n)
+{
+ // Initialize monitors
+
+ if (fLumiArray) delete fLumiArray;
+ if (fAverageLumiArray) delete fAverageLumiArray;
+ if (fBetaStarArray) delete fBetaStarArray;
+
+ fLumiArray = new Float_t[n];
+ fAverageLumiArray = new Float_t[n];
+ fBetaStarArray = new Float_t[n];
+
+ fAverageLumiArray[0] = 0.;
+ fNmax = n;
+}
+
+void AliLhcIRegion::Record()
+{
+ // Record some time dependent quantities
+ //
+ Int_t n = fAccelerator->Nt();
+ // Luminosity
+
+ fLumiArray[n] = fLuminosity;
+
+ // Average Luminosity respecting set-up and filling time
+ if (fAccelerator->Time() > fAccelerator->SetUpTime())
+ fAverageLumi+=fLuminosity*fAccelerator->TimeStep();
+
+ fAverageLumiArray[n] = fAverageLumi/
+ (Float_t(n+1)*fAccelerator->TimeStep()+fAccelerator->FillingTime())/
+ fLuminosity0;
+
+ // Beta*
+ fBetaStarArray[n] = fBetaStar;
+}
+
+
+void AliLhcIRegion::DrawPlots()
+{
+ //
+ // Draw the monitor plots
+ //
+ Float_t* t = fAccelerator->TimeA();
+ //
+ char name1[20], name2[20], hname[20];
+ sprintf(name1,"c%s",GetName());
+ sprintf(name2,"b%s",GetName());
+ char title[30];
+ sprintf(title,"Luminosity Lifetime for %s",GetName());
+
+ //
+ sprintf(hname,"%s%d",name1,0);
+ TH1 *g1 = new TH1F(hname,"Luminosity",fNmax,0,t[fNmax]);
+ g1->SetMinimum(0);
+ g1->SetMaximum(fLumiArray[0]*1.1);
+ g1->SetStats(0);
+ g1->GetXaxis()->SetTitle("t (h)");
+ g1->GetYaxis()->SetTitle("L(t) (cm**-2 s**-1)");
+ sprintf(hname,"%s%d",name1,1);
+ TH1 *g2 = new TH1F(hname,"Luminosity",fNmax,0,t[fNmax]);
+ g2->SetMinimum(0);
+ g2->SetMaximum(1.1);
+ g2->SetStats(0);
+ g2->GetXaxis()->SetTitle("t (h)");
+ g2->GetYaxis()->SetTitle("L(t)/L0");
+ sprintf(hname,"%s%d",name1,3);
+
+ TH1 *g3 = new TH1F(hname,"Average Luminosity",fNmax,0,t[fNmax]);
+ g3->SetMinimum(0);
+ g3->SetMaximum(1.1);
+ g3->SetStats(0);
+
+ g3->GetXaxis()->SetTitle("t (h)");
+ g3->GetYaxis()->SetTitle("L(t)/L0");
+ sprintf(hname,"%s%d",name1,3);
+
+ TH1 *g4 = new TH1F(hname,"Beta*",fNmax,0,t[fNmax]);
+ g4->SetMinimum(0);
+ g4->SetMaximum(fBetaStarArray[0]*1.1);
+ g4->SetStats(0);
+ g4->GetXaxis()->SetTitle("t (h)");
+ g4->GetYaxis()->SetTitle("beta* (cm)");
+
+ TGraph* grLumi = new TGraph(fNmax, t, fLumiArray);
+ grLumi->SetHistogram(g1);
+
+ for (Int_t i=0; i<fNmax; i++) {
+ fLumiArray[i]=fLumiArray[i]/fLuminosity0;
+ }
+ TGraph* grLumiN = new TGraph(fNmax, t, fLumiArray);
+ grLumiN->SetHistogram(g2);
+
+ TGraph* grLumiA = new TGraph(fNmax, t, fAverageLumiArray);
+ grLumiA->SetHistogram(g3);
+ grLumiA->SetLineStyle(2);
+
+ TGraph* grLumiB = new TGraph(fNmax, t, fBetaStarArray);
+ grLumiB->SetHistogram(g4);
+
+ TMultiGraph* mg = new TMultiGraph();
+ mg->Add(grLumiN);
+ mg->Add(grLumiA);
+
+
+
+ TCanvas *c1 = new TCanvas(name1,title, 200, 10, 700, 500);
+
+ c1->SetGrid();
+ mg->Draw("AC");
+ mg->GetXaxis()->SetTitle("t (h)");
+ mg->GetYaxis()->SetTitle("L(t)/L0 and <L>/L0");
+ mg->Draw("AC");
+
+ TCanvas *c2 = new TCanvas(name2,title, 200, 10, 700, 500);
+ c1->SetGrid();
+ grLumiB->Draw("AC");
+
+}
+
+
+
+
--- /dev/null
+#ifndef ALILHCIREGION_H
+#define ALILHCIREGION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include <TNamed.h>
+#include "AliLhcMonitor.h"
+
+class AliLHC;
+class AliLhcBeam;
+
+class AliLhcIRegion : public TNamed, public AliLhcMonitor
+{
+ public:
+ AliLhcIRegion(AliLHC* lhc, const char* name, const char* tile);
+ AliLhcIRegion(const AliLhcIRegion ®ion);
+ virtual ~AliLhcIRegion();
+ AliLhcIRegion & operator=(const AliLhcIRegion & rhs);
+
+ virtual void Init();
+ virtual Float_t Luminosity();
+ virtual Float_t InitialLumi() {return fLuminosity0;}
+ virtual Float_t BetaStar() {return fBetaStar;}
+ virtual void SetBetaStar(Float_t beta) {fBetaStar = beta;}
+ virtual void SetCrossingAngle(Float_t angle) {fCrossingAngle = angle;}
+ virtual void SetAccelerator(AliLHC* acc) {fAccelerator = acc;}
+ virtual void Update();
+ virtual void SetMonitor(Int_t n);
+ virtual void Record();
+ virtual void DrawPlots();
+
+ protected:
+ AliLHC* fAccelerator; // Accelerator
+ AliLhcBeam* fBeam1; // Beam1
+ AliLhcBeam* fBeam2; // Beam2
+ Float_t fLuminosity; // Luminosity
+ Float_t fLuminosity0; // Initial Luminosity
+ Float_t fAverageLumi; // Average Initial Luminosity
+ Float_t fBetaStar; // Beta*
+ Float_t fBetaStar0; // Initial Beta*
+ Float_t fCrossingAngle; // Crossing Angle
+ Float_t fFrequency; // Frequency
+ Float_t* fLumiArray; // [fNmax] Luminosity(t)
+ Float_t* fAverageLumiArray; // [fNmax] Average Luminosity(t)
+ Float_t* fBetaStarArray; // [fNmax] Beta*(t)
+//
+ ClassDef(AliLhcIRegion,1) // LHC Interaction Region
+};
+
+#endif
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcMonitor.h"
+#include "AliLHC.h"
+#include <TMath.h>
+#include <TCanvas.h>
+#include <TGraph.h>
+
+ClassImp(AliLhcMonitor)
+
+
+
+
+
+
--- /dev/null
+#ifndef ALILHCMONITOR_H
+#define ALILHCMONITOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include <TObject.h>
+class AliLhcMonitor
+{
+ public:
+ AliLhcMonitor(){;}
+ virtual ~AliLhcMonitor(){;}
+ virtual void SetMonitor(Int_t n) = 0;
+ virtual void Record() = 0;
+ virtual void DrawPlots() = 0;
+
+ protected:
+ int fNmax;
+ ClassDef(AliLhcMonitor,1) // LHC Monitor Base Class
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcProcess.h"
+#include "AliLHC.h"
+
+ClassImp(AliLhcProcess)
+
+AliLhcProcess::AliLhcProcess(AliLHC *lhc, const char* name, const char* title)
+ :TNamed(name,title)
+{
+// Constructor
+ fAccelerator = lhc;
+}
+
+AliLhcProcess::AliLhcProcess(const AliLhcProcess& process)
+{
+// copy constructor
+}
+
+AliLhcProcess::~AliLhcProcess()
+{
+// Destructor
+
+}
+
+void AliLhcProcess::Evolve(Float_t dt)
+{
+ printf("\n Here process %s %f:", GetName(), dt);
+}
+
+AliLhcProcess& AliLhcProcess::operator=(const AliLhcProcess & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+
--- /dev/null
+#ifndef ALILHCPROCESS_H
+#define ALILHCPROCESS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include "AliLhcMonitor.h"
+#include <TNamed.h>
+
+class AliLHC;
+
+class AliLhcProcess : public TNamed, public AliLhcMonitor
+{
+ public:
+ AliLhcProcess(AliLHC* lhc, const char* name, const char* title);
+ virtual void SetAccelerator(AliLHC* acc) {fAccelerator = acc;}
+ AliLhcProcess(const AliLhcProcess &process);
+ virtual ~AliLhcProcess();
+ virtual void Init(){;}
+ virtual void Evolve(Float_t dt);
+ virtual void SetMonitor(Int_t n){;}
+ virtual void Record(){;}
+ virtual void DrawPlots(){;}
+ AliLhcProcess & operator=(const AliLhcProcess & rhs);
+
+ protected:
+ AliLHC* fAccelerator; // Accelerator
+ //
+ ClassDef(AliLhcProcess,1) // LHC Process Base Class
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcProcessBB.h"
+#include "AliLHC.h"
+#include "AliLhcIRegion.h"
+#include "AliLhcBeam.h"
+
+ClassImp(AliLhcProcessBB)
+
+AliLhcProcessBB::AliLhcProcessBB(AliLHC* lhc, const char* name, const char* title)
+ :AliLhcProcess(lhc,name,title)
+{
+// Constructor
+}
+
+
+AliLhcProcessBB::~AliLhcProcessBB()
+{
+// Destructor
+
+}
+
+void AliLhcProcessBB::Init()
+{
+ // Initialization
+ printf("\n Initializing Process %s", GetName());
+ printf("\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+ fIRegions = fAccelerator->IRegions();
+ fBeam1 = fAccelerator->Beam(0);
+ fBeam2 = fAccelerator->Beam(1);
+}
+
+void AliLhcProcessBB::Evolve(Float_t dt)
+{
+ printf("\n Here process %s %f:", GetName(), dt);
+ TIter next(fIRegions);
+ AliLhcIRegion *region;
+ //
+ // Loop over generators and initialize
+ while((region = (AliLhcIRegion*)next())) {
+ Float_t rate = region->Luminosity()*fCrossSection;
+ Float_t loss = rate*dt;
+ fBeam1->RemoveParticles(loss);
+ fBeam2->RemoveParticles(loss);
+ }
+}
+
+
+AliLhcProcessBB& AliLhcProcessBB::operator=(const AliLhcProcessBB & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+
--- /dev/null
+#ifndef ALILHCPROCESSBB_H
+#define ALILHCPROCESSBB_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include "AliLhcProcess.h"
+class TList;
+class AliLhcBeam;
+
+class AliLhcProcessBB : public AliLhcProcess
+{
+ public:
+ AliLhcProcessBB(AliLHC* lhc, const char* name, const char* title);
+ virtual ~AliLhcProcessBB();
+ virtual void SetCrossSection(Float_t sig) {fCrossSection = sig*1.e-24;}
+ virtual void Init();
+ virtual void Evolve(Float_t dt);
+
+ AliLhcProcessBB & operator=(const AliLhcProcessBB & rhs);
+ protected:
+ Float_t fCrossSection; // Interaction cross section
+ TList * fIRegions; // Interaction Regions
+ AliLhcBeam* fBeam1; // Beam1
+ AliLhcBeam* fBeam2; // Beam2
+
+//
+ ClassDef(AliLhcProcessBB,1) // LHC Process: Beam-Beam
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcProcessBT.h"
+#include "AliLHC.h"
+#include "AliLhcIRegion.h"
+#include "AliLhcBeam.h"
+
+ClassImp(AliLhcProcessBT)
+
+AliLhcProcessBT::AliLhcProcessBT(AliLHC* lhc, const char* name, const char* title)
+ :AliLhcProcess(lhc,name,title)
+{
+// Constructor
+}
+
+
+AliLhcProcessBT::~AliLhcProcessBT()
+{
+// Destructor
+}
+
+void AliLhcProcessBT::Init()
+{
+ // Initialization
+ printf("\n Initializing Process %s", GetName());
+ printf("\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+ fIRegions = fAccelerator->IRegions();
+}
+
+void AliLhcProcessBT::Evolve(Float_t dt)
+{
+ printf("\n Here process %s %f:", GetName(), dt);
+ TIter next(fIRegions);
+ AliLhcIRegion *region;
+ //
+ // Loop over generators and initialize
+ while((region = (AliLhcIRegion*)next())) {
+ Float_t betanew =
+ region->Luminosity()/region->InitialLumi()*region->BetaStar();
+ if (betanew > fBetaMin) region->SetBetaStar(betanew);
+ }
+}
+
+
+AliLhcProcessBT& AliLhcProcessBT::operator=(const AliLhcProcessBT & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+
--- /dev/null
+#ifndef ALILHCPROCESSBT_H
+#define ALILHCPROCESSBT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include "AliLhcProcess.h"
+class TList;
+class AliLhcBeam;
+
+class AliLhcProcessBT : public AliLhcProcess
+{
+ public:
+ AliLhcProcessBT(AliLHC* lhc, const char* name, const char* title);
+ virtual ~AliLhcProcessBT();
+ virtual void SetCrossSection(Float_t sig) {fCrossSection = sig*1.e-24;}
+ virtual void Init();
+ virtual void Evolve(Float_t dt);
+ virtual void SetBetaMin(Float_t b) {fBetaMin = b;}
+
+ AliLhcProcessBT & operator=(const AliLhcProcessBT & rhs);
+ protected:
+ Float_t fCrossSection; // Interaction cross section
+ TList * fIRegions; // Interaction Regions
+ Float_t fBetaMin; // Minimal allowed beta*
+//
+ ClassDef(AliLhcProcessBT,1) // LHC Process: Beta Tuning
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log$
+*/
+
+#include "AliLhcProcessIBS.h"
+#include "AliLHC.h"
+#include "AliLhcIRegion.h"
+#include "AliLhcBeam.h"
+
+#include <TF1.h>
+#include <TMath.h>
+#include <TCanvas.h>
+#include <TGraph.h>
+#include <TMultiGraph.h>
+
+ClassImp(AliLhcProcessIBS)
+
+ Double_t func(Double_t *x, Double_t *par);
+
+AliLhcProcessIBS::AliLhcProcessIBS(AliLHC* lhc, const char* name, const char* title)
+ :AliLhcProcess(lhc,name,title)
+{
+// Constructor
+}
+
+
+AliLhcProcessIBS::~AliLhcProcessIBS()
+{
+// Destructor
+
+}
+
+void AliLhcProcessIBS::Init()
+{
+ // Initialization
+ const Float_t r0=1.535e-16;
+
+ printf("\n Initializing Process %s", GetName());
+ printf("\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+
+ fIRegions = fAccelerator->IRegions();
+
+ for (Int_t i = 0; i < 2; i++) {
+ fBeam[i] = fAccelerator->Beam(i);
+ fR[i] = r0*fBeam[i]->Z()*fBeam[i]->Z()/fBeam[i]->A();
+ fE[i] = 0.938*fBeam[i]->A();
+ }
+}
+
+void AliLhcProcessIBS::Evolve(Float_t dt)
+{
+ printf("\n Here process %s %f:", GetName(), dt);
+ for (Int_t i=0; i<2; i++) {
+ // Density
+ Float_t sige = fBeam[i]->EnergySpread();
+ Float_t avbeta = fAccelerator->AverageBeta();
+ Float_t avd = fAccelerator->AverageDisp();
+
+ Float_t gamma = fBeam[i]->Gamma();
+ Float_t epsx = fBeam[i]->Emittance()*gamma;
+ Float_t epsy = epsx;
+ Float_t epse = fBeam[i]->LongEmittance();
+ Float_t sigxb = TMath::Sqrt(epsx/gamma*avbeta);
+ Float_t sigx = TMath::Sqrt(sigxb*sigxb+(avd*avd*sige*sige));
+ Float_t ssigx = TMath::Sqrt(epsx/gamma/avbeta);
+ Float_t sigy = sigx;
+ Float_t ssigy = ssigx;
+
+ Float_t asd = fBeam[i]->N()*fR[i]*fR[i]*fE[i]/
+ (16.*TMath::Pi()*gamma*epsx*epsy*epse);
+
+ // impact parameter
+ Float_t d = sige*avd/sigx;
+ //
+ Float_t at = sige*TMath::Sqrt(1.-d*d)/(gamma*ssigx);
+ Float_t bt = sige*TMath::Sqrt(1.-d*d)/(gamma*ssigy);
+ Float_t ct = sige*TMath::Sqrt(1.-d*d)*TMath::Sqrt(4.*sigy/fR[i]);
+ //
+ Double_t par[3];
+ par[0] = at;
+ par[1] = bt;
+ par[2] = ct;
+ TF1 *fct = new TF1("func",func, 0., 1., 3);
+
+ Float_t f = (Float_t) 8.0*TMath::Pi()*
+ fct->Integral(0., 1., par, 1.e-5);
+ //
+ fTaux = 1./(asd*f*(d*d-at*at/2.));
+ fTaue = 1./(asd*f*(1.-d*d));
+ // printf("\n taux, taue %f %f", taux, taue);
+ // Float_t tauy = -2./at*at/asd/f;
+ fBeam[i]->IncreaseEmittance(dt/fTaux, dt/fTaue);
+ }
+
+}
+
+void AliLhcProcessIBS::SetMonitor(Int_t n)
+{
+ // Initialize Monitor
+ if (fTauxArray) delete fTauxArray;
+ if (fTaueArray) delete fTaueArray;
+ fTauxArray = new Float_t[n];
+ fTaueArray = new Float_t[n];
+ fNmax = n;
+}
+
+void AliLhcProcessIBS::Record()
+{
+ // Record monitor quantities
+ fTauxArray[fAccelerator->Nt()] = fTaux/3600.;
+ fTaueArray[fAccelerator->Nt()] = fTaue/3600.;
+}
+
+
+void AliLhcProcessIBS::DrawPlots()
+{
+ // Draw monitor plots
+ Float_t* t = fAccelerator->TimeA();
+
+ TH1 *t1 = new TH1F("t1","Hor. IBS growth time",fNmax,0,t[fNmax]);
+ t1->SetMinimum(0);
+ t1->SetMaximum(fTauxArray[fNmax]*1.1);
+ t1->SetStats(0);
+ t1->GetXaxis()->SetTitle("t (h)");
+ t1->GetYaxis()->SetTitle("tau_x (t)");
+
+ TH1 *t2 = new TH1F("t2","Long. IBS growth time",fNmax,0,t[fNmax]);
+ t2->SetMinimum(0);
+ t2->SetMaximum(fTaueArray[fNmax]*1.1);
+ t2->SetStats(0);
+ t2->GetXaxis()->SetTitle("t (h)");
+ t2->GetYaxis()->SetTitle("tau_l (t)");
+
+ TGraph* grTaux = new TGraph(fNmax, fAccelerator->TimeA(), fTauxArray);
+ grTaux->SetHistogram(t1);
+
+ TGraph* grTaue = new TGraph(fNmax, fAccelerator->TimeA(), fTaueArray);
+ grTaue->SetHistogram(t2);
+ grTaue->SetLineStyle(2);
+
+ TMultiGraph* mg = new TMultiGraph();
+ mg->Add(grTaux);
+ mg->Add(grTaue);
+
+ TCanvas *c3 = new TCanvas("c3","IBS", 200, 10, 700, 500);
+ c3->SetGrid();
+ mg->Draw("AC");
+ mg->GetXaxis()->SetTitle("t (h)");
+ mg->GetYaxis()->SetTitle("IBS Growth Time (h)");
+ mg->Draw("AC");
+}
+
+
+
+
+
+AliLhcProcessIBS& AliLhcProcessIBS::operator=(const AliLhcProcessIBS & rhs)
+{
+// Assignment operator
+ return *this;
+}
+
+Double_t func(Double_t *x, Double_t *par)
+{
+ Double_t a = par[0];
+ Double_t b = par[1];
+ Double_t cc = par[2];
+
+ const Double_t bc = 0.5772;
+ Double_t xx = x[0];
+ Double_t x2=xx*xx;
+ Double_t x1=1.0-x2;
+ Double_t p=1.0/TMath::Sqrt(x2+a*a*x1);
+ Double_t q=1.0/TMath::Sqrt(x2+b*b*x1);
+ return (1.0-3.0*x2)*p*q*(2.0*TMath::Log(0.5*cc*(p+q))-bc);
+}
+
--- /dev/null
+#ifndef ALILHCPROCESSIBS_H
+#define ALILHCPROCESSIBS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+#include "AliLhcProcess.h"
+class TList;
+class AliLhcBeam;
+
+class AliLhcProcessIBS : public AliLhcProcess
+{
+ public:
+ AliLhcProcessIBS(AliLHC* lhc, const char* name, const char* title);
+ virtual ~AliLhcProcessIBS();
+ virtual void SetCrossSection(Float_t sig) {fCrossSection = sig*1.e-24;}
+ virtual void Init();
+ virtual void Evolve(Float_t dt);
+ virtual void SetMonitor(Int_t n);
+ virtual void Record();
+ virtual void DrawPlots();
+ AliLhcProcessIBS & operator=(const AliLhcProcessIBS & rhs);
+ protected:
+ Float_t fCrossSection; // Interaction cross section
+ TList * fIRegions; // Interaction Regions
+ AliLhcBeam* fBeam[2]; // Beams
+ Float_t fR[2]; // elem. ion radius
+ Float_t fE[2]; // ion radius
+ Float_t fTaux;
+ Float_t fTaue;
+ Float_t* fTauxArray; // [fNmax]
+ Float_t* fTaueArray; // [fNmax]
+
+//
+ ClassDef(AliLhcProcessIBS,1) // LHC Process: Intra Beam Scattering
+};
+
+#endif
--- /dev/null
+#ifdef __CINT__
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliGenLHC+;
+#pragma link C++ class AliLhcIRegion+;
+#pragma link C++ class AliLhcBeam+;
+#pragma link C++ class AliLhcProcess+;
+#pragma link C++ class AliLhcProcessBB+;
+#pragma link C++ class AliLhcProcessIBS+;
+#pragma link C++ class AliLhcProcessBT+;
+#pragma link C++ class AliLhcMonitor+;
+#endif
+
+
+
+
+
+
--- /dev/null
+############################### LHC Makefile ################################
+
+# Include machine specific definitions
+
+include $(ALICE_ROOT)/conf/GeneralDef
+include $(ALICE_ROOT)/conf/MachineDef.$(ALICE_TARGET)
+
+PACKAGE = LHC
+
+# C++ sources
+
+SRCS = AliLHC.cxx AliLhcIRegion.cxx AliLhcBeam.cxx AliLhcProcess.cxx \
+ AliLhcProcessBB.cxx AliLhcProcessIBS.cxx AliLhcMonitor.cxx \
+ AliLhcProcessBT.cxx
+
+# C++ Headers
+
+HDRS = $(SRCS:.cxx=.h)
+
+# Library dictionary
+
+DICT = LHCCint.cxx
+DICTH = $(DICT:.cxx=.h)
+DICTO = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(DICT))
+
+# FORTRAN Objectrs
+
+FOBJS = $(patsubst %.F,tgt_$(ALICE_TARGET)/%.o,$(FSRCS))
+
+# C Objects
+
+COBJS = $(patsubst %.c,tgt_$(ALICE_TARGET)/%.o,$(CSRCS))
+
+# C++ Objects
+
+OBJS = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(SRCS)) $(DICTO)
+
+# C++ compilation flags
+
+CXXFLAGS = $(CXXOPTS) -I$(ROOTSYS)/include -I. -I$(ALICE_ROOT)/include/
+
+# FORTRAN compilation flags
+
+FFLAGS = $(FOPT)
+
+##### TARGETS #####
+
+# Target
+
+SLIBRARY = $(LIBDIR)/libLHC.$(SL)
+ALIBRARY = $(LIBDIR)/libLHC.a
+
+default: $(SLIBRARY)
+
+$(LIBDIR)/libLHC.$(SL): $(OBJS)
+
+$(DICT): $(HDRS)
+
+depend: $(SRCS)
+
+
+TOCLEAN = $(OBJS) *Cint.cxx *Cint.h
+
+CHECKS = $(patsubst %.cxx,check/%.viol,$(SRCS))
+
+############################### General Macros ################################
+
+include $(ALICE_ROOT)/conf/GeneralMacros
+
+############################ Dependencies #####################################
+
+-include tgt_$(ALICE_TARGET)/Make-depend
+
+
+
+
+
+
+