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