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