]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliModule.cxx
56e1bb12db39e889c4a9260d47581541eacc03b8
[u/mrichter/AliRoot.git] / STEER / AliModule.cxx
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 /*
13 <img src="picts/AliModuleClass.gif">
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
26 ClassImp(AliModule)
27  
28 //_____________________________________________________________________________
29 AliModule::AliModule()
30 {
31   //
32   // Default constructor for the AliModule class
33   //
34   fHistograms = 0;
35   fNodes      = 0;
36 }
37  
38 //_____________________________________________________________________________
39 AliModule::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);
55   if (id>=0) {
56     // Module already added !
57      Warning("Ctor","Module: %s already present at %d\n",name,id);
58      return;
59   }
60   //
61   // Add this Module to the list of Modules
62   gAlice->Modules()->Add(this);
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 //_____________________________________________________________________________
78 AliModule::~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 //_____________________________________________________________________________
95 void 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 //_____________________________________________________________________________
112 Int_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 //_____________________________________________________________________________
122 void 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 //_____________________________________________________________________________
139 void 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   gMC->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
158   (*fIdmate)[imat]=kmat;
159 }
160   
161 //_____________________________________________________________________________
162 void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, 
163                               Float_t &z, Float_t &dens, Float_t &radl,
164                               Float_t &absl)
165 {
166   //
167   // Store the parameters for a material
168   //
169   // imat        the material index will be stored in (*fIdmate)[imat]
170   // name        material name
171   // a           atomic mass
172   // z           atomic number
173   // dens        density
174   // radl        radiation length
175   // absl        absorbtion length
176   // buf         adress of an array user words
177   // nwbuf       number of user words
178   //
179
180   Float_t buf[10];
181   Int_t nwbuf, kmat;
182   kmat=(*fIdmate)[imat];
183   gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
184 }
185   
186
187 //_____________________________________________________________________________
188 void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
189                              Float_t *z, Float_t dens, Int_t nlmat,
190                              Float_t *wmat) const
191
192   //
193   // Defines mixture or compound imat as composed by 
194   // nlmat materials defined by arrays a, z and wmat
195   // 
196   // If nlmat > 0 wmat contains the proportion by
197   // weights of each basic material in the mixture  
198   // 
199   // If nlmat < 0 wmat contains the number of atoms 
200   // of eack kind in the molecule of the compound
201   // In this case, wmat is changed on output to the relative weigths.
202   //
203   // imat        the material index will be stored in (*fIdmate)[imat]
204   // name        material name
205   // a           array of atomic masses
206   // z           array of atomic numbers
207   // dens        density
208   // nlmat       number of components
209   // wmat        array of concentrations
210   //
211   Int_t kmat;
212   gMC->Mixture(kmat, name, a, z, dens, nlmat, wmat);
213   (*fIdmate)[imat]=kmat;
214
215  
216 //_____________________________________________________________________________
217 void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
218                             Int_t isvol, Int_t ifield, Float_t fieldm,
219                             Float_t tmaxfd, Float_t stemax, Float_t deemax,
220                             Float_t epsil, Float_t stmin, Float_t *ubuf,
221                             Int_t nbuf) const
222
223   //
224   // Store the parameters of a tracking medium
225   //
226   // numed       the medium number is stored into (*fIdtmed)[numed-1]
227   // name        medium name
228   // nmat        the material number is stored into (*fIdmate)[nmat]
229   // isvol       sensitive volume if isvol!=0
230   // ifield      magnetic field flag (see below)
231   // fieldm      maximum magnetic field
232   // tmaxfd      maximum deflection angle due to magnetic field
233   // stemax      maximum step allowed
234   // deemax      maximum fractional energy loss in one step
235   // epsil       tracking precision in cm
236   // stmin       minimum step due to continuous processes
237   //
238   // ifield =  0       no magnetic field
239   //        = -1       user decision in guswim
240   //        =  1       tracking performed with Runge Kutta
241   //        =  2       tracking performed with helix
242   //        =  3       constant magnetic field along z
243   //  
244   Int_t kmed;
245   gMC->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm,
246                          tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); 
247   (*fIdtmed)[numed]=kmed;
248
249  
250 //_____________________________________________________________________________
251 void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1,
252                             Float_t theta2, Float_t phi2, Float_t theta3,
253                             Float_t phi3) const
254 {
255   // 
256   // Define a rotation matrix. Angles are in degrees.
257   //
258   // nmat        on output contains the number assigned to the rotation matrix
259   // theta1      polar angle for axis I
260   // phi1        azimuthal angle for axis I
261   // theta2      polar angle for axis II
262   // phi2        azimuthal angle for axis II
263   // theta3      polar angle for axis III
264   // phi3        azimuthal angle for axis III
265   //
266   gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); 
267
268
269 //_____________________________________________________________________________
270 void AliModule::SetEuclidFile(char* material, char* geometry)
271 {
272   //
273   // Sets the name of the Euclid file
274   //
275   fEuclidMaterial=material;
276   if(geometry) {
277     fEuclidGeometry=geometry;
278   } else {
279     char* name = new char[strlen(material)];
280     strcpy(name,material);
281     strcpy(&name[strlen(name)-4],".euc");
282     fEuclidGeometry=name;
283     delete [] name;
284   }
285 }
286  
287 //_____________________________________________________________________________
288 void AliModule::Streamer(TBuffer &R__b)
289 {
290   //
291   // Stream an object of class Module.
292   //
293   if (R__b.IsReading()) {
294     Version_t R__v = R__b.ReadVersion(); if (R__v) { }
295     TNamed::Streamer(R__b);
296     TAttLine::Streamer(R__b);
297     TAttMarker::Streamer(R__b);
298     fEuclidMaterial.Streamer(R__b);
299     fEuclidGeometry.Streamer(R__b);
300     R__b >> fActive;
301     R__b >> fHistograms;
302     //
303     // Stream the pointers but not the TClonesArrays
304     R__b >> fNodes; // diff
305   } else {
306     R__b.WriteVersion(AliModule::IsA());
307     TNamed::Streamer(R__b);
308     TAttLine::Streamer(R__b);
309     TAttMarker::Streamer(R__b);
310     fEuclidMaterial.Streamer(R__b);
311     fEuclidGeometry.Streamer(R__b);
312     R__b << fActive;
313     R__b << fHistograms;
314     //
315     // Stream the pointers but not the TClonesArrays
316     R__b << fNodes; // diff
317   }
318 }
319