]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv1.cxx
Avoid warnings on SunOS
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Transition Radiation Detector version 1 -- coarse simulation             //
4 //  This version has two detector arms, leaving the space in front of the    //
5 //  HMPID and PHOS empty                                                     //
6 //                                                                           //
7 //Begin_Html
8 /*
9 <img src="picts/AliTRDv1Class.gif">
10 */
11 //End_Html
12 //                                                                           //
13 //                                                                           //
14 ///////////////////////////////////////////////////////////////////////////////
15
16 #include <TMath.h>
17 #include <TRandom.h>
18 #include <TVector.h>
19
20 #include "AliTRDv1.h"
21 #include "AliRun.h"
22 #include "AliMC.h"
23 #include "AliConst.h"
24  
25 ClassImp(AliTRDv1)
26
27 //_____________________________________________________________________________
28 AliTRDv1::AliTRDv1(const char *name, const char *title) 
29          :AliTRD(name, title) 
30 {
31   //
32   // Standard constructor for the Transition Radiation Detector version 1
33   //
34   fIdSens1 = fIdSens2 = fIdSens3 = 0;
35 }
36  
37 //_____________________________________________________________________________
38 void AliTRDv1::CreateGeometry()
39 {
40   //
41   // Create the geometry for the Transition Radiation Detector version 1
42   // --- The coarse geometry of the TRD, that can be used for background 
43   //     studies. This version leaves the space in front of the PHOS and 
44   //     HMPID empty. 
45   // --- Author :  Christoph Blume (GSI) 18/5/99 
46   //
47   // --- Volume names : 
48   //     TRD       --> Mother TRD volume                                     (Air)
49   //     UTRD      --> The detector arms                                     (Al)
50   //     UTRS      --> Sectors of the sub-detector                           (Al)
51   //     UTRI      --> Inner part of the detector frame                      (Air) 
52   //     UTCI(N,O) --> Frames of the inner, neighbouring and outer chambers  (C) 
53   //     UTII(N,O) --> Inner part of the chambers                            (Air) 
54   //     UTMI(N,O) --> Modules in the chambers                               (Air) 
55   //     UT0I(N,O) --> Radiator seal                                         (G10)
56   //     UT1I(N,O) --> Radiator                                              (CO2)
57   //     UT2I(N,O) --> Polyethylene of radiator                              (PE)
58   //     UT3I(N,O) --> Entrance window                                       (Mylar)
59   //     UT4I(N,O) --> Gas volume (sensitive)                                (Xe/Isobutane)
60   //     UT5I(N,O) --> Pad plane                                             (Cu)
61   //     UT6I(N,O) --> Support structure                                     (G10)
62   //     UT7I(N,O) --> FEE + signal lines                                    (Cu)
63   //     UT8I(N,O) --> Polyethylene of cooling device                        (PE)
64   //     UT9I(N,O) --> Cooling water                                         (Water)
65   //
66   //Begin_Html
67   /*
68     <img src="picts/AliTRDv1.gif">
69   */
70   //End_Html
71   //Begin_Html
72   /*
73     <img src="picts/AliTRDv1Tree.gif">
74   */
75   //End_Html
76
77   Float_t xpos, ypos, zpos, f;
78   Int_t   idmat[5];
79
80   const Int_t nparmo = 10;
81   const Int_t nparar = 10;
82   const Int_t nparfr =  4;
83   const Int_t nparic =  4;
84   const Int_t nparnc =  4;
85   const Int_t nparoc = 11;
86
87   Float_t par_mo[nparmo];
88   Float_t par_ar[nparar];
89   Float_t par_fr[nparfr];
90   Float_t par_ic[nparic];
91   Float_t par_nc[nparnc];
92   Float_t par_oc[nparoc];
93   
94   Int_t *idtmed = fIdtmed->GetArray()-1299;
95   
96   //////////////////////////////////////////////////////////////////////////
97   //     Definition of Volumes   
98   //////////////////////////////////////////////////////////////////////////
99
100   // Definition of the mother volume for the TRD (Air) 
101   par_mo[0] =   0.;
102   par_mo[1] = 360.;
103   par_mo[2] = nsect;
104   par_mo[3] = 2.;
105   par_mo[4] = -zmax1;
106   par_mo[5] = rmin;
107   par_mo[6] = rmax;
108   par_mo[7] =  zmax1;
109   par_mo[8] = rmin;
110   par_mo[9] = rmax;
111   gMC->Gsvolu("TRD ", "PGON", idtmed[1302-1], par_mo, nparmo);
112   
113   Float_t phisec = 360. / nsect;   
114   // Definition of the two detector arms (Al) 
115   par_ar[0] = 120.;
116   par_ar[1] = narmsec * phisec;
117   par_ar[2] = narmsec;
118   par_ar[3] = 2.;
119   par_ar[4] = -zmax1;
120   par_ar[5] = rmin;
121   par_ar[6] = rmax;
122   par_ar[7] =  zmax1;
123   par_ar[8] = rmin;
124   par_ar[9] = rmax;
125   gMC->Gsvolu("UTRD", "PGON", idtmed[1301-1], par_ar, nparar);
126   gMC->Gsdvn("UTRS", "UTRD", narmsec, 2);
127
128   // The minimal width of a sector in rphi-direction
129   Float_t widmi = rmin * TMath::Tan(kPI/nsect);
130   // The maximal width of a sector in rphi-direction
131   Float_t widma = rmax * TMath::Tan(kPI/nsect);
132   // The total thickness of the spaceframe (Al + Air)
133   Float_t frame = widmi - (widpl1 / 2);
134
135   // Definition of the inner part of the detector frame (Air) 
136   par_fr[0] = widmi - alframe / 2;
137   par_fr[1] = widma - alframe / 2;
138   par_fr[2] = zmax1;
139   par_fr[3] = (rmax - rmin) / 2;
140   gMC->Gsvolu("UTRI", "TRD1", idtmed[1302-1], par_fr, nparfr); 
141
142   // 
143   // The outer chambers
144   //
145
146   // Calculate some shape-parameter
147   Float_t tanzr = (zmax1 - zmax2) / (rmax - rmin);
148   Float_t theoc = -kRaddeg * TMath::ATan(tanzr / 2);
149
150   // The carbon frame (C)
151   par_oc[0]  = (rmax - rmin) / 2;
152   par_oc[1]  = theoc;
153   par_oc[2]  = 90.;
154   par_oc[3]  = (zmax2 - zlenn - zleni/2)   / 2;
155   par_oc[4]  = widmi - frame;
156   par_oc[5]  = widmi - frame;
157   par_oc[6]  = 0.;
158   par_oc[7]  = (zmax1 - zlenn - zleni/2)   / 2;
159   par_oc[8]  = widma - frame;
160   par_oc[9]  = widma - frame;
161   par_oc[10] = 0.;
162   gMC->Gsvolu("UTCO", "TRAP", idtmed[1307-1], par_oc, nparoc);
163
164   // The inner part (Air) 
165   par_oc[3] -= ccframe;
166   par_oc[4] -= ccframe;
167   par_oc[5] -= ccframe; 
168   par_oc[7] -= ccframe;
169   par_oc[8] -= ccframe;
170   par_oc[9] -= ccframe;
171   gMC->Gsvolu("UTIO", "TRAP", idtmed[1302-1], par_oc, nparoc);
172
173   // Definition of the six modules within each chamber 
174   gMC->Gsdvn("UTMO", "UTIO", nmodul, 3);
175
176   // Definition of the layers of each chamber 
177   par_oc[1]  =  theoc;
178   par_oc[2]  =  90.;
179   par_oc[3]  = -1.;
180   par_oc[4]  = -1.;
181   par_oc[5]  = -1.;
182   par_oc[6]  =  0.;
183   par_oc[7]  = -1.;
184   par_oc[8]  = -1.;
185   par_oc[9]  = -1.;
186   par_oc[10] =  0.;
187   // G10 layer (radiator layer)
188   par_oc[0] = sethick / 2;
189   gMC->Gsvolu("UT0O", "TRAP", idtmed[1313-1], par_oc, nparoc);
190   // CO2 layer (radiator)
191   par_oc[0] = rathick / 2;
192   gMC->Gsvolu("UT1O", "TRAP", idtmed[1312-1], par_oc, nparoc);
193   // PE layer (radiator)
194   par_oc[0] = pethick / 2;
195   gMC->Gsvolu("UT2O", "TRAP", idtmed[1303-1], par_oc, nparoc);
196   // Mylar layer (entrance window + HV cathode) 
197   par_oc[0] = mythick / 2;
198   gMC->Gsvolu("UT3O", "TRAP", idtmed[1308-1], par_oc, nparoc);
199   // Xe/Isobutane layer (gasvolume)
200   par_oc[0] = xethick / 2;
201   gMC->Gsvolu("UT4O", "TRAP", idtmed[1309-1], par_oc, nparoc);
202   // Cu layer (pad plane)
203   par_oc[0] = cuthick / 2;
204   gMC->Gsvolu("UT5O", "TRAP", idtmed[1305-1], par_oc, nparoc);
205   // G10 layer (support structure)
206   par_oc[0] = suthick / 2;
207   gMC->Gsvolu("UT6O", "TRAP", idtmed[1313-1], par_oc, nparoc);
208   // Cu layer (FEE + signal lines)
209   par_oc[0] = fethick / 2;
210   gMC->Gsvolu("UT7O", "TRAP", idtmed[1305-1], par_oc, nparoc);
211   // PE layer (cooling devices)
212   par_oc[0] = cothick / 2;
213   gMC->Gsvolu("UT8O", "TRAP", idtmed[1303-1], par_oc, nparoc);
214   // Water layer (cooling)
215   par_oc[0] = wathick / 2;
216   gMC->Gsvolu("UT9O", "TRAP", idtmed[1314-1], par_oc, nparoc);
217
218   //
219   // The neighbouring chambers
220   //
221
222   // The carbon frame (C) 
223   par_nc[0] = widmi - frame;
224   par_nc[1] = widma - frame;
225   par_nc[2] = zlenn / 2;
226   par_nc[3] = (rmax - rmin) / 2;
227   gMC->Gsvolu("UTCN", "TRD1", idtmed[1307-1], par_nc, nparnc);
228
229   // The inner part (Air) 
230   par_nc[0] -= ccframe;
231   par_nc[1] -= ccframe;
232   par_nc[2] -= ccframe;
233   gMC->Gsvolu("UTIN", "TRD1", idtmed[1302-1], par_nc, nparnc);
234
235   // Definition of the six modules within each outer chamber 
236   gMC->Gsdvn("UTMN", "UTIN", nmodul, 3);
237
238   // Definition of the layers of each chamber 
239   par_nc[0] = -1.;
240   par_nc[1] = -1.;
241   par_nc[2] = -1.;
242   // G10 layer (radiator layer)
243   par_nc[3] = sethick / 2;
244   gMC->Gsvolu("UT0N", "TRD1", idtmed[1313-1], par_nc, nparnc);
245   // CO2 layer (radiator)
246   par_nc[3] = rathick / 2;
247   gMC->Gsvolu("UT1N", "TRD1", idtmed[1312-1], par_nc, nparnc);
248   // PE layer (radiator)
249   par_nc[3] = pethick / 2;
250   gMC->Gsvolu("UT2N", "TRD1", idtmed[1303-1], par_nc, nparnc);
251   // Mylar layer (entrance window + HV cathode) 
252   par_nc[3] = mythick / 2;
253   gMC->Gsvolu("UT3N", "TRD1", idtmed[1308-1], par_nc, nparnc);
254   // Xe/Isobutane layer (gasvolume)
255   par_nc[3] = xethick / 2;
256   gMC->Gsvolu("UT4N", "TRD1", idtmed[1309-1], par_nc, nparnc);
257   // Cu layer (pad plane)
258   par_nc[3] = cuthick / 2;
259   gMC->Gsvolu("UT5N", "TRD1", idtmed[1305-1], par_nc, nparnc);
260   // G10 layer (support structure)
261   par_nc[3] = suthick / 2;
262   gMC->Gsvolu("UT6N", "TRD1", idtmed[1313-1], par_nc, nparnc);
263   // Cu layer (FEE + signal lines)
264   par_nc[3] = fethick / 2;
265   gMC->Gsvolu("UT7N", "TRD1", idtmed[1305-1], par_nc, nparnc);
266   // PE layer (cooling devices)
267   par_nc[3] = cothick / 2;
268   gMC->Gsvolu("UT8N", "TRD1", idtmed[1303-1], par_nc, nparnc);
269   // Water layer (cooling)
270   par_nc[3] = wathick / 2;
271   gMC->Gsvolu("UT9N", "TRD1", idtmed[1314-1], par_nc, nparnc);
272
273   //
274   // The inner chamber
275   //
276
277   // The carbon frame (C) 
278   par_ic[0] = widmi - frame;
279   par_ic[1] = widma - frame;
280   par_ic[2] = zleni / 2;
281   par_ic[3] = (rmax - rmin) / 2;
282   gMC->Gsvolu("UTCI", "TRD1", idtmed[1307-1], par_ic, nparic);
283
284   // The inner part (Air) 
285   par_ic[0] -= ccframe;
286   par_ic[1] -= ccframe;
287   par_ic[2] -= ccframe;
288   gMC->Gsvolu("UTII", "TRD1", idtmed[1302-1], par_ic, nparic);
289
290   // Definition of the six modules within each outer chamber 
291   gMC->Gsdvn("UTMI", "UTII", nmodul, 3);
292
293   // Definition of the layers of each inner chamber 
294   par_ic[0] = -1.;
295   par_ic[1] = -1.;
296   par_ic[2] = -1.;
297   // G10 layer (radiator layer)
298   par_ic[3] = sethick / 2;
299   gMC->Gsvolu("UT0I", "TRD1", idtmed[1313-1], par_ic, nparic);
300   // CO2 layer (radiator)
301   par_ic[3] = rathick / 2;
302   gMC->Gsvolu("UT1I", "TRD1", idtmed[1312-1], par_ic, nparic);
303   // PE layer (radiator)
304   par_ic[3] = pethick / 2;
305   gMC->Gsvolu("UT2I", "TRD1", idtmed[1303-1], par_ic, nparic);
306   // Mylar layer (entrance window + HV cathode) 
307   par_ic[3] = mythick / 2;
308   gMC->Gsvolu("UT3I", "TRD1", idtmed[1308-1], par_ic, nparic);
309   // Xe/Isobutane layer (gasvolume)
310   par_ic[3] = xethick / 2;
311   gMC->Gsvolu("UT4I", "TRD1", idtmed[1309-1], par_ic, nparic);
312   // Cu layer (pad plane)
313   par_ic[3] = cuthick / 2;
314   gMC->Gsvolu("UT5I", "TRD1", idtmed[1305-1], par_ic, nparic);
315   // G10 layer (support structure)
316   par_ic[3] = suthick / 2;
317   gMC->Gsvolu("UT6I", "TRD1", idtmed[1313-1], par_ic, nparic);
318   // Cu layer (FEE + signal lines)
319   par_ic[3] = fethick / 2;
320   gMC->Gsvolu("UT7I", "TRD1", idtmed[1305-1], par_ic, nparic);
321   // PE layer (cooling devices)
322   par_ic[3] = cothick / 2;
323   gMC->Gsvolu("UT8I", "TRD1", idtmed[1303-1], par_ic, nparic);
324   // Water layer (cooling)
325   par_ic[3] = wathick / 2;
326   gMC->Gsvolu("UT9I", "TRD1", idtmed[1314-1], par_ic, nparic);
327
328   //////////////////////////////////////////////////////////////////////////
329   //     Positioning of Volumes 
330   //////////////////////////////////////////////////////////////////////////
331
332   // The rotation matrices 
333   AliMatrix(idmat[0],  90., 180.,  90.,  90.,   0.,   0.);
334   AliMatrix(idmat[1],  90.,  90., 180.,   0.,  90.,   0.);
335   AliMatrix(idmat[2],  90., 180.,  90., 270.,   0.,   0.);
336
337   // Position of the layers in a TRD module 
338   f = TMath::Tan(theoc * kDegrad);
339   gMC->Gspos("UT9O", 1, "UTMO", 0., f*wazpos, wazpos, 0, "ONLY");
340   gMC->Gspos("UT8O", 1, "UTMO", 0., f*cozpos, cozpos, 0, "ONLY");
341   gMC->Gspos("UT7O", 1, "UTMO", 0., f*fezpos, fezpos, 0, "ONLY");
342   gMC->Gspos("UT6O", 1, "UTMO", 0., f*suzpos, suzpos, 0, "ONLY");
343   gMC->Gspos("UT5O", 1, "UTMO", 0., f*cuzpos, cuzpos, 0, "ONLY");
344   gMC->Gspos("UT4O", 1, "UTMO", 0., f*xezpos, xezpos, 0, "ONLY");
345   gMC->Gspos("UT3O", 1, "UTMO", 0., f*myzpos, myzpos, 0, "ONLY");
346   gMC->Gspos("UT1O", 1, "UTMO", 0., f*razpos, razpos, 0, "ONLY");
347   gMC->Gspos("UT0O", 1, "UTMO", 0., f*sezpos, sezpos, 0, "ONLY");
348   gMC->Gspos("UT2O", 1, "UT1O", 0., f*pezpos, pezpos, 0, "ONLY");
349
350   gMC->Gspos("UT9N", 1, "UTMN", 0.,       0., wazpos, 0, "ONLY");
351   gMC->Gspos("UT8N", 1, "UTMN", 0.,       0., cozpos, 0, "ONLY");
352   gMC->Gspos("UT7N", 1, "UTMN", 0.,       0., fezpos, 0, "ONLY");
353   gMC->Gspos("UT6N", 1, "UTMN", 0.,       0., suzpos, 0, "ONLY");
354   gMC->Gspos("UT5N", 1, "UTMN", 0.,       0., cuzpos, 0, "ONLY");
355   gMC->Gspos("UT4N", 1, "UTMN", 0.,       0., xezpos, 0, "ONLY");
356   gMC->Gspos("UT3N", 1, "UTMN", 0.,       0., myzpos, 0, "ONLY");
357   gMC->Gspos("UT1N", 1, "UTMN", 0.,       0., razpos, 0, "ONLY");
358   gMC->Gspos("UT0N", 1, "UTMN", 0.,       0., sezpos, 0, "ONLY");
359   gMC->Gspos("UT2N", 1, "UT1N", 0.,       0., pezpos, 0, "ONLY");
360
361   gMC->Gspos("UT9I", 1, "UTMI", 0.,       0., wazpos, 0, "ONLY");
362   gMC->Gspos("UT8I", 1, "UTMI", 0.,       0., cozpos, 0, "ONLY");
363   gMC->Gspos("UT7I", 1, "UTMI", 0.,       0., fezpos, 0, "ONLY");
364   gMC->Gspos("UT6I", 1, "UTMI", 0.,       0., suzpos, 0, "ONLY");
365   gMC->Gspos("UT5I", 1, "UTMI", 0.,       0., cuzpos, 0, "ONLY");
366   gMC->Gspos("UT4I", 1, "UTMI", 0.,       0., xezpos, 0, "ONLY");
367   gMC->Gspos("UT3I", 1, "UTMI", 0.,       0., myzpos, 0, "ONLY");
368   gMC->Gspos("UT1I", 1, "UTMI", 0.,       0., razpos, 0, "ONLY");
369   gMC->Gspos("UT0I", 1, "UTMI", 0.,       0., sezpos, 0, "ONLY");
370   gMC->Gspos("UT2I", 1, "UT1I", 0.,       0., pezpos, 0, "ONLY");
371
372   // Position of the inner part of the chambers 
373   xpos = 0.;
374   ypos = 0.;
375   zpos = 0.;
376   gMC->Gspos("UTII", 1, "UTCI", xpos, ypos, zpos, 0, "ONLY");
377   gMC->Gspos("UTIN", 1, "UTCN", xpos, ypos, zpos, 0, "ONLY");
378   gMC->Gspos("UTIO", 1, "UTCO", xpos, ypos, zpos, 0, "ONLY");
379
380   // Position of the chambers in the support frame 
381   xpos = 0.;
382   ypos = ((zmax1 + zmax2) / 2 + zlenn + zleni / 2) / 2;
383   zpos = 0.;
384   gMC->Gspos("UTCO", 1, "UTRI", xpos, ypos, zpos, idmat[2], "ONLY");
385   gMC->Gspos("UTCO", 2, "UTRI", xpos,-ypos, zpos,       0 , "ONLY");
386   xpos = 0.;
387   ypos = (zlenn + zleni) / 2;
388   zpos = 0.;
389   gMC->Gspos("UTCN", 1, "UTRI", xpos, ypos, zpos,       0 , "ONLY");
390   gMC->Gspos("UTCN", 2, "UTRI", xpos,-ypos, zpos,       0 , "ONLY");
391   xpos = 0.;
392   ypos = 0.;
393   zpos = 0.;
394   gMC->Gspos("UTCI", 1, "UTRI", xpos, ypos, zpos,       0 , "ONLY");
395
396   // Position of the inner part of the detector frame
397   xpos = (rmax + rmin) / 2;
398   ypos = 0.;
399   zpos = 0.;
400   gMC->Gspos("UTRI", 1, "UTRS", xpos, ypos, zpos, idmat[1], "ONLY");
401
402   // Position of the two arms of the detector
403   xpos = 0.;
404   ypos = 0.;
405   zpos = 0.;
406   gMC->Gspos("UTRD", 1, "TRD ", xpos, ypos, zpos,        0, "ONLY");
407   gMC->Gspos("UTRD", 2, "TRD ", xpos, ypos, zpos, idmat[0], "ONLY");
408
409   // Position of TRD mother volume in ALICE experiment 
410   xpos = 0.;
411   ypos = 0.;
412   zpos = 0.;
413   gMC->Gspos("TRD ", 1, "ALIC", xpos, ypos, zpos,        0, "ONLY");
414
415 }
416  
417 //_____________________________________________________________________________
418 void AliTRDv1::DrawModule()
419 {
420   //
421   // Draw a shaded view of the Transition Radiation Detector version 1
422   //
423
424   // Set everything unseen
425   gMC->Gsatt("*", "seen", -1);
426   // 
427   // Set ALIC mother transparent
428   gMC->Gsatt("ALIC","SEEN",0);
429   //
430   // Set the volumes visible
431   gMC->Gsatt("TRD" ,"SEEN",0);
432   gMC->Gsatt("UTRD","SEEN",0);
433   gMC->Gsatt("UTRS","SEEN",0);
434   gMC->Gsatt("UTRI","SEEN",0);
435   gMC->Gsatt("UTCO","SEEN",0);
436   gMC->Gsatt("UTIO","SEEN",0);
437   gMC->Gsatt("UTMO","SEEN",0);
438   gMC->Gsatt("UTCN","SEEN",0);
439   gMC->Gsatt("UTIN","SEEN",0);
440   gMC->Gsatt("UTMN","SEEN",0);
441   gMC->Gsatt("UTCI","SEEN",0);
442   gMC->Gsatt("UTII","SEEN",0);
443   gMC->Gsatt("UTMI","SEEN",0);
444   gMC->Gsatt("UT1O","SEEN",1);
445   gMC->Gsatt("UT4O","SEEN",1);
446   gMC->Gsatt("UT1N","SEEN",1);
447   gMC->Gsatt("UT4N","SEEN",1);
448   gMC->Gsatt("UT1I","SEEN",1);
449   gMC->Gsatt("UT4I","SEEN",1);
450   //
451   gMC->Gdopt("hide", "on");
452   gMC->Gdopt("shad", "on");
453   gMC->Gsatt("*", "fill", 7);
454   gMC->SetClipBox(".");
455   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
456   gMC->DefaultRange();
457   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
458   gMC->Gdhead(1111, "Transition Radiation Detector Version 1");
459   gMC->Gdman(18, 4, "MAN");
460 }
461
462 //_____________________________________________________________________________
463 void AliTRDv1::CreateMaterials()
464 {
465   //
466   // Create materials for the Transition Radiation Detector version 1
467   //
468   AliTRD::CreateMaterials();
469 }
470
471 //_____________________________________________________________________________
472 void AliTRDv1::Init() 
473 {
474   //
475   // Initialise the Transition Radiation Detector after the geometry is built
476   //
477   AliTRD::Init();
478   // Retrieve the numeric identifier of the sensitive volumes (gas volume)
479   fIdSens1 = gMC->VolId("UT4I");
480   fIdSens2 = gMC->VolId("UT4N");
481   fIdSens3 = gMC->VolId("UT4O");
482 }
483
484 //_____________________________________________________________________________
485 void AliTRDv1::StepManager() 
486 {
487   //
488   // Procedure called at every step in the TRD
489   //
490
491   Int_t         vol[3]; 
492   Int_t         icopy1, icopy2;
493   Int_t         idSens, icSens; 
494   TLorentzVector pos;
495   
496   Float_t       hits[4];
497   
498   TClonesArray &lhits = *fHits;
499
500   // Use only charged tracks and count them only once per volume
501   if (gMC->TrackCharge() && gMC->IsTrackExiting()) {
502     
503     // Check on sensitive volume
504     idSens = gMC->CurrentVolID(icSens);
505
506     // Check on sensitive volume
507     idSens = gMC->CurrentVolID(icSens);
508     if ((idSens == fIdSens1) || 
509         (idSens == fIdSens2) ||
510         (idSens == fIdSens3)) { 
511       
512       // The sector number
513       gMC->CurrentVolOffID(5,icopy1);
514       gMC->CurrentVolOffID(6,icopy2);
515       if (icopy2 == 1)
516         vol[0] =     icopy1;
517       else
518         vol[0] = 6 - icopy1 + 5;
519       
520       // The chamber number 
521       //   1: outer left
522       //   2: neighbouring left
523       //   3: inner
524       //   4: neighbouring right
525       //   5: outer right
526       gMC->CurrentVolOffID(3,icopy1);
527       if      (idSens == fIdSens3)
528         vol[1] = 4 * icopy1 - 3; 
529       else if (idSens == fIdSens2)
530         vol[1] = 2 * icopy1;
531       else 
532         vol[1] = 3;
533       
534       // The plane number
535       gMC->CurrentVolOffID(1,icopy1);
536       vol[2] = icopy1;
537
538       if (fSensSelect) {
539         Int_t addthishit = 1;
540         if ((fSensPlane)   && (vol[2] != fSensPlane  )) addthishit = 0;
541         if ((fSensChamber) && (vol[1] != fSensChamber)) addthishit = 0;
542         if ((fSensSector)  && (vol[0] != fSensSector )) addthishit = 0;
543         if (addthishit) {
544           gMC->TrackPosition(pos);
545           hits[0] = pos[0];
546           hits[1] = pos[1];
547           hits[2] = pos[2];
548           hits[3] = 0;
549           new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
550         }
551       }
552       else {      
553         gMC->TrackPosition(pos);
554         hits[0] = pos[0];
555         hits[1] = pos[1];
556         hits[2] = pos[2];
557         hits[3] = 0;
558         new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
559       }
560
561     }
562
563   } 
564
565 }