]> git.uio.no Git - u/mrichter/AliRoot.git/blob - LHC/AliLHC.cxx
LHC related code. First commit.
[u/mrichter/AliRoot.git] / LHC / AliLHC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /*
17 $Log$
18 */
19 #include "AliLHC.h"
20 #include "AliLhcIRegion.h"
21 #include "AliLhcProcess.h"
22 #include "AliLhcBeam.h"
23
24 ClassImp(AliLHC)
25
26 AliLHC::AliLHC()
27 {
28 // Constructor
29     fIRegions   = new TList;
30     fProcesses  = new TList;
31     fNRegions   = 0;
32     fNProcesses = 0;
33     fBeams = new TObjArray(2);
34     (*fBeams)[0] = 0;
35     (*fBeams)[1] = 0;    
36     fTime = 0;
37     fTimeMax = 0;
38 }
39
40 AliLHC::AliLHC(const AliLHC& lhc)
41 {
42 // copy constructor
43 }
44
45 AliLHC::~AliLHC()
46 {
47 // Destructor
48     delete fIRegions;
49     delete fProcesses;
50     delete fBeams;
51 }
52
53 void AliLHC::AddIRegion(AliLhcIRegion *region)
54 {
55 //
56 //  Add region to list   
57      fIRegions->Add(region);
58      fNRegions++;
59  }
60
61 void AliLHC::AddProcess(AliLhcProcess *process)
62 {
63 //
64 //  Add process to list   
65      fProcesses->Add(process);
66      fNProcesses++;
67  }
68
69 void AliLHC::SetBeams(AliLhcBeam *beam1, AliLhcBeam *beam2 )
70 {
71
72 //
73 //  Set the beams   
74
75     (*fBeams)[0] = beam1;
76     (*fBeams)[1] = beam2;
77 }
78
79   void AliLHC::Init()
80 {
81 // Initialisation
82     fNt    = 0;
83     fNmax  = Int_t(fTimeMax/fTimeStep); 
84     fTimeA = new Float_t[fNmax];
85     //
86     Beam(0)->Init();
87     Beam(1)->Init();
88   
89     TIter next(fIRegions);
90     AliLhcIRegion *region;
91     //
92     // Loop over generators and initialize
93     while((region = (AliLhcIRegion*)next())) {
94         region->Init();
95         region->SetMonitor(fNmax);
96     }
97     
98     Beam(0)->SetMonitor(fNmax);
99     Beam(1)->SetMonitor(fNmax);
100
101     TIter nextp(fProcesses);
102     AliLhcProcess *process;
103     //
104     // Loop over generators and initialize
105     while((process = (AliLhcProcess*)nextp())) {
106         process->Init();
107         process->SetMonitor(fNmax);
108     }  
109 }
110
111  void AliLHC::EvolveTime()
112 {
113 //
114 // Simulate Time Evolution
115 //
116     while (fTime <= fTimeMax) {
117         printf("\n Time: %f %f", fTime, fTimeStep);
118         //
119         //  Processes
120         //      
121         TIter next(fProcesses);
122         AliLhcProcess *process;
123         //
124         // Evolve for each process
125         while((process = (AliLhcProcess*)next())) {
126             process->Evolve(fTimeStep);
127             process->Record();
128         }  
129         //
130         // Update and Monitoring
131         //
132         TIter nextregion(fIRegions);
133         AliLhcIRegion *region;
134         //
135         while((region = (AliLhcIRegion*)nextregion())) {
136           printf("\n Region: %s, Luminosity %10.3e", 
137                  region->GetName(), region->Luminosity());
138           region->Update();
139           region->Record();
140         }
141         Beam(0)->Record();
142         fTimeA[fNt] = fTime/3600.;
143         fTime+=fTimeStep;
144         fNt++;
145     }
146 }
147
148 void AliLHC::Evaluate()
149 {
150   // Evaluation of the results
151   TIter nextregion(fIRegions);
152   AliLhcIRegion *region;
153   //
154   // Loop over generators and initialize
155   while((region = (AliLhcIRegion*)nextregion())) {
156     region->Draw();
157   }
158   
159   TIter next(fProcesses);
160   AliLhcProcess *process;
161   //
162   // Evolve for each process
163   while((process = (AliLhcProcess*)next())) {
164     process->Draw();
165   }
166   
167   Beam(0)->Draw();
168 }
169    
170 AliLHC& AliLHC::operator=(const  AliLHC & rhs)
171 {
172 // Assignment operator
173     return *this;
174 }
175
176