Variable number of modules introduced
[u/mrichter/AliRoot.git] / STEER / AliModule.cxx
CommitLineData
8494b010 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Base class for ALICE modules. Both sensitive modules (Modules) and //
4// non-sensitive ones are described by this base class. This class //
5// supports the hit and digit trees produced by the simulation and also //
6// the objects produced by the reconstruction. //
7// //
8// This class is also responsible for building the geometry of the //
9// Modules. //
10// //
11//Begin_Html
12/*
1439f98e 13<img src="picts/AliModuleClass.gif">
8494b010 14*/
15//End_Html
16// //
17///////////////////////////////////////////////////////////////////////////////
18#include "AliModule.h"
19#include "AliRun.h"
20#include "AliHit.h"
21#include "AliPoints.h"
22#include <TClass.h>
23#include <TNode.h>
24#include <TRandom.h>
25
26ClassImp(AliModule)
27
28//_____________________________________________________________________________
29AliModule::AliModule()
30{
31 //
32 // Default constructor for the AliModule class
33 //
34 fHistograms = 0;
35 fNodes = 0;
36}
37
38//_____________________________________________________________________________
39AliModule::AliModule(const char* name,const char *title):TNamed(name,title)
40{
41 //
42 // Normal constructor invoked by all Modules.
43 // Create the list for Module specific histograms
44 // Add this Module to the global list of Modules in Run.
45 //
46 //
47 // Initialises the histogram list
48 fHistograms = new TList();
49 //
50 // Initialises the list of ROOT TNodes
51 fNodes = new TList();
52 //
53 // Get the Module numeric ID
54 Int_t id = gAlice->GetModuleID(name);
02ca2762 55 if (id>=0) {
56 // Module already added !
57 Warning("Ctor","Module: %s already present at %d\n",name,id);
8494b010 58 return;
59 }
60 //
61 // Add this Module to the list of Modules
02ca2762 62 gAlice->Modules()->Add(this);
8494b010 63 //
64 //
65 SetMarkerColor(3);
66 //
67 // Allocate space for tracking media and material indexes
68 fIdtmed = new TArrayI(100);
69 fIdmate = new TArrayI(100);
70 for(Int_t i=0;i<100;i++) (*fIdmate)[i]=(*fIdtmed)[i]=0;
71 //
72 // Prepare to find the tracking media range
73 fLoMedium = 65536;
74 fHiMedium = 0;
75}
76
77//_____________________________________________________________________________
78AliModule::~AliModule()
79{
80 //
81 // Destructor
82 //
83 fHistograms = 0;
84 //
85 // Delete ROOT geometry
86 fNodes->Clear();
87 delete fNodes;
88 //
89 // Delete TArray objects
90 delete fIdtmed;
91 delete fIdmate;
92}
93
94//_____________________________________________________________________________
95void AliModule::Disable()
96{
97 //
98 // Disable Module on viewer
99 //
100 fActive = kFALSE;
101 TIter next(fNodes);
102 TNode *node;
103 //
104 // Loop through geometry to disable all
105 // nodes for this Module
106 while((node = (TNode*)next())) {
107 node->SetVisibility(0);
108 }
109}
110
111//_____________________________________________________________________________
112Int_t AliModule::DistancetoPrimitive(Int_t, Int_t)
113{
114 //
115 // Return distance from mouse pointer to object
116 // Dummy routine for the moment
117 //
118 return 9999;
119}
120
121//_____________________________________________________________________________
122void AliModule::Enable()
123{
124 //
125 // Enable Module on the viewver
126 //
127 fActive = kTRUE;
128 TIter next(fNodes);
129 TNode *node;
130 //
131 // Loop through geometry to enable all
132 // nodes for this Module
133 while((node = (TNode*)next())) {
134 node->SetVisibility(1);
135 }
136}
137
138//_____________________________________________________________________________
139void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a,
140 Float_t z, Float_t dens, Float_t radl,
141 Float_t absl, Float_t *buf, Int_t nwbuf) const
142{
143 //
144 // Store the parameters for a material
145 //
146 // imat the material index will be stored in (*fIdmate)[imat]
147 // name material name
148 // a atomic mass
149 // z atomic number
150 // dens density
151 // radl radiation length
152 // absl absorbtion length
153 // buf adress of an array user words
154 // nwbuf number of user words
155 //
156 Int_t kmat;
157 AliMC::GetMC()->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
158 (*fIdmate)[imat]=kmat;
159}
160
161
162//_____________________________________________________________________________
163void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
164 Float_t *z, Float_t dens, Int_t nlmat,
165 Float_t *wmat) const
166{
167 //
168 // Defines mixture or compound imat as composed by
169 // nlmat materials defined by arrays a, z and wmat
170 //
171 // If nlmat > 0 wmat contains the proportion by
172 // weights of each basic material in the mixture
173 //
174 // If nlmat < 0 wmat contains the number of atoms
175 // of eack kind in the molecule of the compound
176 // In this case, wmat is changed on output to the relative weigths.
177 //
178 // imat the material index will be stored in (*fIdmate)[imat]
179 // name material name
180 // a array of atomic masses
181 // z array of atomic numbers
182 // dens density
183 // nlmat number of components
184 // wmat array of concentrations
185 //
186 Int_t kmat;
187 AliMC::GetMC()->Mixture(kmat, name, a, z, dens, nlmat, wmat);
188 (*fIdmate)[imat]=kmat;
189}
190
191//_____________________________________________________________________________
192void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
193 Int_t isvol, Int_t ifield, Float_t fieldm,
194 Float_t tmaxfd, Float_t stemax, Float_t deemax,
195 Float_t epsil, Float_t stmin, Float_t *ubuf,
196 Int_t nbuf) const
197{
198 //
199 // Store the parameters of a tracking medium
200 //
201 // numed the medium number is stored into (*fIdtmed)[numed-1]
202 // name medium name
203 // nmat the material number is stored into (*fIdmate)[nmat]
204 // isvol sensitive volume if isvol!=0
205 // ifield magnetic field flag (see below)
206 // fieldm maximum magnetic field
207 // tmaxfd maximum deflection angle due to magnetic field
208 // stemax maximum step allowed
209 // deemax maximum fractional energy loss in one step
210 // epsil tracking precision in cm
211 // stmin minimum step due to continuous processes
212 //
213 // ifield = 0 no magnetic field
214 // = -1 user decision in guswim
215 // = 1 tracking performed with Runge Kutta
216 // = 2 tracking performed with helix
217 // = 3 constant magnetic field along z
218 //
219 Int_t kmed;
8494b010 220 AliMC::GetMC()->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm,
221 tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf);
ad51aeb0 222 (*fIdtmed)[numed]=kmed;
8494b010 223}
224
225//_____________________________________________________________________________
226void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1,
227 Float_t theta2, Float_t phi2, Float_t theta3,
228 Float_t phi3) const
229{
230 //
231 // Define a rotation matrix. Angles are in degrees.
232 //
233 // nmat on output contains the number assigned to the rotation matrix
234 // theta1 polar angle for axis I
235 // phi1 azimuthal angle for axis I
236 // theta2 polar angle for axis II
237 // phi2 azimuthal angle for axis II
238 // theta3 polar angle for axis III
239 // phi3 azimuthal angle for axis III
240 //
241 AliMC::GetMC()->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3);
242}
243
244//_____________________________________________________________________________
245void AliModule::SetEuclidFile(char* material, char* geometry)
246{
247 //
248 // Sets the name of the Euclid file
249 //
250 fEuclidMaterial=material;
251 if(geometry) {
252 fEuclidGeometry=geometry;
253 } else {
254 char* name = new char[strlen(material)];
255 strcpy(name,material);
256 strcpy(&name[strlen(name)-4],".euc");
257 fEuclidGeometry=name;
258 delete [] name;
259 }
260}
261
262//_____________________________________________________________________________
263void AliModule::Streamer(TBuffer &R__b)
264{
265 //
266 // Stream an object of class Module.
267 //
268 if (R__b.IsReading()) {
269 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
270 TNamed::Streamer(R__b);
271 TAttLine::Streamer(R__b);
272 TAttMarker::Streamer(R__b);
273 fEuclidMaterial.Streamer(R__b);
274 fEuclidGeometry.Streamer(R__b);
275 R__b >> fActive;
276 R__b >> fHistograms;
277 //
278 // Stream the pointers but not the TClonesArrays
279 R__b >> fNodes; // diff
280 } else {
281 R__b.WriteVersion(AliModule::IsA());
282 TNamed::Streamer(R__b);
283 TAttLine::Streamer(R__b);
284 TAttMarker::Streamer(R__b);
285 fEuclidMaterial.Streamer(R__b);
286 fEuclidGeometry.Streamer(R__b);
287 R__b << fActive;
288 R__b << fHistograms;
289 //
290 // Stream the pointers but not the TClonesArrays
291 R__b << fNodes; // diff
292 }
293}
294