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