]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CRT/AliCRTv0.cxx
New methods and data member added by M. Horner.
[u/mrichter/AliRoot.git] / CRT / AliCRTv0.cxx
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 Revision 1.10  2002/10/29 17:20:37  hristov
19 Corrections for subscript out of range (Alpha)
20
21 Revision 1.9  2002/10/23 06:47:56  alibrary
22 Introducing Riostream.h
23
24 Revision 1.8  2002/10/14 14:55:34  hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
26
27 Revision 1.4.2.4  2002/10/10 14:40:31  hristov
28 Updating VirtualMC to v3-09-02
29
30 Revision 1.7  2002/10/07 11:13:25  gamez
31 Access shafts added
32
33 Revision 1.6  2002/07/26 06:21:12  gamez
34 CRT3 volume taken as sensitive volume
35
36 Revision 1.5  2002/07/25 12:52:34  morsch
37 AddHit call only if hit has been defined.
38
39 Revision 1.4  2002/07/12 12:57:29  gamez
40 Division of CRT1 corrected
41
42 Revision 1.3.2.1  2002/07/12 12:32:50  gamez
43 Division of CRT1 corrected
44
45 Revision 1.3  2002/07/10 15:57:04  gamez
46 CreateHall() removed, and new Molasse volumes
47
48 Revision 1.2  2002/07/09 08:45:35  hristov
49 Old style include files needed on HP (aCC)
50
51 Revision 1.1  2002/06/16 17:08:19  hristov
52 First version of CRT
53
54
55 */
56
57 ///////////////////////////////////////////////////////////////////////////////
58 //                                                                           //
59 // ALICE Cosmic Ray Trigger                                                  //
60 //                                                                           //
61 //  This class contains the functions for version 0 of the ALICE Cosmic Ray  //
62 //  Trigger. This version will be used to simulation comic rays in alice     //
63 //  with all the detectors.                                                  //
64 //
65 //   Authors:
66 //
67 //   Arturo Fernandez <afernand@fcfm.buap.mx>
68 //   Enrique Gamez    <egamez@fcfm.buap.mx>
69 //
70 //   Universidad Autonoma de Puebla
71 //
72 //
73 //Begin_Html
74 /*
75 <img src="picts/AliCRTv0Class.gif">
76 </pre>
77 <br clear=left>
78 <p>The responsible person for this module is
79 <a href="mailto:egamez@fcfm.buap.mx">Enrique Gamez</a>.
80 </font>
81 <pre>
82 */
83 //End_Html
84 //                                                                           //
85 ///////////////////////////////////////////////////////////////////////////////
86
87 #include <Riostream.h>
88
89 #include <TGeometry.h>
90 #include <TBRIK.h>
91 #include <TNode.h>
92 #include <TLorentzVector.h>
93
94 #include "AliRun.h"
95 #include "AliMagF.h"
96 #include "AliConst.h"
97 #include "AliPDG.h"
98
99 #include "AliCRTv0.h"
100 #include "AliCRTConstants.h"
101
102 ClassImp(AliCRTv0)
103  
104 //_____________________________________________________________________________
105 AliCRTv0::AliCRTv0() : AliCRT()
106 {
107   //
108   // Default constructor for CRT v0
109   //
110 }
111  
112 //_____________________________________________________________________________
113 AliCRTv0::AliCRTv0(const char *name, const char *title)
114   : AliCRT(name,title)
115 {
116   //
117   // Standard constructor for CRT v0
118   //
119   //Begin_Html
120   /*
121     <img src="picts/AliCRTv0.gif">
122   */
123   //End_Html
124 }
125
126 //_____________________________________________________________________________
127 AliCRTv0::AliCRTv0(const AliCRTv0& crt)
128 {
129   //
130   // Copy ctor.
131   //
132   crt.Copy(*this);
133 }
134
135 //_____________________________________________________________________________
136 AliCRTv0& AliCRTv0::operator= (const AliCRTv0& crt)
137 {
138   //
139   // Asingment operator.
140   //
141   crt.Copy(*this);
142   return *this;
143 }
144
145 //_____________________________________________________________________________
146 void AliCRTv0::BuildGeometry()
147 {
148   //
149   // Create the ROOT TNode geometry for the CRT
150   //
151
152   TNode *node, *top;
153
154   const Int_t kColorCRT = kRed;
155
156   // Find the top node alice.
157   top = gAlice->GetGeometry()->GetNode("alice");
158
159   new TBRIK("S_CRT_A", "CRT box", "void", 
160             AliCRTConstants::fgActiveAreaLenght/2., 
161             AliCRTConstants::fgActiveAreaHeight/2., 
162             AliCRTConstants::fgActiveAreaWidth/2.);
163
164   
165   new TRotMatrix("Left", "Left", 90., 315., 90., 45., 0., 337.5);
166   new TRotMatrix("Right", "Right", 90., 45., 90., 315., 180., 202.5);
167   new TRotMatrix("Up", "Up", 90., 0., 90., 90., 0., 90.);
168   top->cd();
169
170   //
171   // Put 4 modules on the top of the magnet
172   Float_t box = AliCRTConstants::fgCageWidth/2.;
173   top->cd();
174   node = new TNode("upper1", "upper1", "S_CRT_A", 0., 790.,  3.*box, "Up");
175   node->SetLineColor(kColorCRT);
176   fNodes->Add(node);
177
178   top->cd();
179   node = new TNode("upper2", "upper2", "S_CRT_A", 0., 790.,    box, "Up");
180   node->SetLineColor(kColorCRT);
181   fNodes->Add(node);
182
183   top->cd();
184   node = new TNode("upper3", "upper3", "S_CRT_A", 0., 790., -1.*box, "Up");
185   node->SetLineColor(kColorCRT);
186   fNodes->Add(node);
187
188   top->cd();
189   node = new TNode("upper4", "upper4", "S_CRT_A", 0., 790., -3.*box, "Up");
190   node->SetLineColor(kColorCRT);
191   fNodes->Add(node);
192
193
194   // Modules on the left side.
195   Float_t xtragap = 10.;
196   Float_t initXside = (790.+xtragap)*TMath::Sin(2*22.5*kDegrad); //rigth side
197   Float_t initYside = (790.+xtragap)*TMath::Cos(2*22.5*kDegrad);
198   top->cd();
199   node = new TNode("upper5", "upper5", "S_CRT_A", initXside, initYside,  3.*box, "Left");
200   node->SetLineColor(kColorCRT);
201   fNodes->Add(node);
202
203   top->cd();
204   node = new TNode("upper6", "upper6", "S_CRT_A", initXside, initYside,    box, "Left");
205   node->SetLineColor(kColorCRT);
206   fNodes->Add(node);
207
208   top->cd();
209   node = new TNode("upper7", "upper7", "S_CRT_A", initXside, initYside, -1.*box, "Left");
210   node->SetLineColor(kColorCRT);
211   fNodes->Add(node);
212
213   top->cd();
214   node = new TNode("upper8", "upper8", "S_CRT_A", initXside, initYside, -3.*box, "Left");
215   node->SetLineColor(kColorCRT);
216   fNodes->Add(node);
217
218
219   // Modules on the right side.
220   top->cd();
221   node = new TNode("upper9", "upper9", "S_CRT_A", -initXside, initYside,  3.*box, "Right");
222   node->SetLineColor(kColorCRT);
223   fNodes->Add(node);
224
225   top->cd();
226   node = new TNode("upper10", "upper10", "S_CRT_A", -initXside, initYside,    box, "Right");
227   node->SetLineColor(kColorCRT);
228   fNodes->Add(node);
229
230   top->cd();
231   node = new TNode("upper11","upper11", "S_CRT_A", -initXside, initYside, -1.*box, "Right");
232   node->SetLineColor(kColorCRT);
233   fNodes->Add(node);
234
235   top->cd();
236   node = new TNode("upper12","upper12", "S_CRT_A", -initXside, initYside, -3.*box, "Right");
237   node->SetLineColor(kColorCRT);
238   fNodes->Add(node);
239
240
241 }
242
243 //_____________________________________________________________________________
244 void AliCRTv0::CreateGeometry()
245 {
246   //
247   // Create geometry for the CRT array
248   //
249   Int_t  idrotm[2499];    // The rotation matrix.
250
251   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
252
253   //
254   // Molasse
255   CreateMolasse();
256
257   //
258   // Scintillators
259
260   Float_t box[3];
261   box[0] = AliCRTConstants::fgCageLenght/2.; // Half Length of the box along the X axis, cm.
262   box[1] = AliCRTConstants::fgCageHeight/2.; // Half Length of the box along the Y axis, cm.
263   box[2] = AliCRTConstants::fgCageWidth/2.;  // Half Length of the box along the Z axis, cm.
264
265
266   // Define the Scintillators. as a big box.
267   Float_t scint[3];
268   scint[0] = AliCRTConstants::fgActiveAreaLenght/2.;       // Half Length in X
269   scint[1] = AliCRTConstants::fgActiveAreaHeight/2.;       // Half Length in Y
270   scint[2] = AliCRTConstants::fgActiveAreaWidth/2.;        // Half Length in Z
271   gMC->Gsvolu("CRT1", "BOX ", idtmed[1112], scint, 3);     // Scintillators
272
273   //
274   // Define the coordinates where the draw will begin.
275   //
276
277   //
278   // -- X axis.
279   // we'll start dawing from the center.
280   Float_t initX = 0.;
281
282   //
283   // -- Y axis
284   Float_t gapY   = 30.;        // 30 cms. above the barrel.
285   // For the height we staimate the from the center of the ceiling,
286   // if were a cilinder, must be about 280cm.
287   Float_t barrel = 790.; // Barrel radius.
288   Float_t height  = barrel + gapY - 30.;
289   Float_t initY = height;
290
291   //
292   // -- Z axis.
293   // we'll start dawing from the center.
294
295   //
296   // Put 4 modules on the top of the magnet
297   Int_t step = 4;
298   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
299     gMC->Gspos("CRT1", i, "ALIC", initX, initY, (i-step)*box[2], 0, "ONLY");
300     step--;
301   }
302
303   // Modules on the barrel sides.
304   // Because the openenig angle for each face is 22.5, and if we want to
305   //    put the modules right in the middle
306   Float_t xtragap = 10.;
307   Float_t initXside = (height+xtragap)*TMath::Sin(2*22.5*kDegrad); //rigth side
308   Float_t initYside = (height+xtragap)*TMath::Cos(2*22.5*kDegrad);
309
310   // Put 4 modules on the left side of the magnet
311   // The rotation matrix parameters, for the left side.
312   AliMatrix(idrotm[232], 90., 315., 90., 45., 0., 337.5);
313   Int_t stepl = 4;
314   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
315     gMC->Gspos("CRT1", i+4, "ALIC", initXside, initYside, (i-stepl)*box[2],
316                idrotm[232], "ONLY");
317     stepl--;
318   }
319
320   // Put 4 modules on the right side of the magnet
321   // The rotation matrix parameters for the right side.
322   AliMatrix(idrotm[231], 90., 45., 90., 315., 180., 202.5);
323   Int_t stepr = 4;
324   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
325     gMC->Gspos("CRT1", i+8, "ALIC", -initXside, initYside, (i-stepr)*box[2],
326                idrotm[231], "ONLY");
327     stepr--;
328   }
329
330   // Divide the modules in 2 planes.
331   //gMC->Gsdvn("CRT2", "CRT1", 2, 2);
332   // Now divide each plane in 8 palettes
333   //gMC->Gsdvn("CRT3", "CRT2", 8, 3);
334
335 }
336
337 //_____________________________________________________________________________
338 void AliCRTv0::CreateMolasse()
339 {
340   Int_t  idrotm[2499];    // The rotation matrix.
341
342   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
343
344   //
345   // Molasse
346   //
347
348   // Exactly above the hall
349   Float_t tspar[5];
350   tspar[0] = 1170.;
351   tspar[1] = 1170. + 375.;
352   tspar[2] = (1900.+1150.)/2.+100.;
353   tspar[3] = 0.;
354   tspar[4] = 180.;
355   gMC->Gsvolu("CMO1", "TUBS", idtmed[1123], tspar, 5);
356   gMC->Gspos("CMO1", 1, "ALIC", 0., 500., 1900.-tspar[2]+400., 0, "MANY");
357
358   Float_t tbox[3];
359   tbox[0] = 1250.;
360   tbox[1] = (4420. - 1670.)/2.;
361   tbox[2] = (1900.+1150.)/2. + 200.;
362   gMC->Gsvolu("CM12", "BOX", idtmed[1123], tbox, 3);
363   gMC->Gspos("CM12", 1, "ALIC", 0., 4420. -tbox[1], 1900.-tbox[2]+400., 0, "MANY");
364
365   AliMatrix(idrotm[2003], 0., 0., 90., 0., 90., 90.);
366   // Along the PM25
367   Float_t tube[3];
368   tube[0] = 455. + 100.;
369   tube[1] = 555. + 375.;
370   tube[2] = (5150. - 1166.)/2.;
371   gMC->Gsvolu("CMO2", "TUBE", idtmed[1123], tube, 3);
372   gMC->Gspos("CMO2", 1, "ALIC", -2100., 4420.-tube[2], 0., idrotm[2003], "MANY");
373
374
375   // Along the PGC2
376   tube[0] = 650.;
377   tube[1] = 2987.7;
378   tube[2] = (5150. - 690.)/2.;
379   gMC->Gsvolu("CMO3", "TUBE", idtmed[1123], tube, 3);
380   gMC->Gspos("CMO3", 1, "ALIC", 375., 4420.-tube[2], 1900.+2987.7, idrotm[2003], "MANY");
381   // Behind the PGC2 up to the end of the M. volume.
382   tbox[0] = 12073.;
383   tbox[1] = 2575. + 95.;
384   tbox[2] = (12073. - 1900.-2987.7-650.)/2.;
385   gMC->Gsvolu("CMO7", "BOX", idtmed[1123], tbox, 3);
386   gMC->Gspos("CMO7", 1, "ALIC", 0., 4420.-tbox[1], 1900.+2987.7+650.+tbox[2], 0, "MANY");
387
388   // Along the PX24 , upper part.
389   tube[0] = 1250.;
390   tube[1] = 2300;
391   tube[2] = 2575. - 1300. + 95.;
392   gMC->Gsvolu("CMO4", "TUBE", idtmed[1123], tube, 3);
393   gMC->Gspos("CMO4", 1, "ALIC", 0., 404.+1300.+tube[2], -2300., idrotm[2003], "MANY");
394
395   // Along the PX24 , lower part
396   tspar[0] = 1250.;
397   tspar[1] = 2300;
398   tspar[2] = 1300.;
399   tspar[3] = kRaddeg*TMath::ASin(1070./1150.);
400   tspar[4] = 360. - tspar[3];
401   gMC->Gsvolu("CMO5", "TUBS", idtmed[1123], tspar, 5);
402   gMC->Gspos("CMO5", 1, "ALIC", 0., 404., -2300., idrotm[2003], "MANY");
403   // behind the PX24
404   tbox[0] = 12073.;
405   tbox[1] = 2575. + 95.;
406   tbox[2] = 8523./2.;
407   gMC->Gsvolu("CMO6", "BOX", idtmed[1123], tbox, 3);
408   gMC->Gspos("CMO6", 1, "ALIC", 0., 4420.-tbox[1], -3550.-tbox[2], 0, "MANY");
409
410
411   // On the right side of th hall
412   tbox[0] = (12073. - 1250.)/2.;
413   tbox[1] = 2575. + 95.;
414   tbox[2] = (8437.7+650.)/2.;
415   gMC->Gsvolu("CMO8", "BOX", idtmed[1123], tbox, 3);
416   gMC->Gspos("CMO8", 1, "ALIC", 1250.+tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
417
418   // on the left side of the hall, behind 
419   tbox[0] = (12073. - 2755.)/2.;
420   tbox[1] = 2575. + 95.;
421   tbox[2] = (8437.7+650.)/2.;
422   gMC->Gsvolu("CMO9", "BOX", idtmed[1123], tbox, 3);
423   gMC->Gspos("CMO9", 1, "ALIC", -2755.-tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
424
425
426   // Molasse betwen the PX24 & PM25 on the left side.
427   tbox[0] = (2755. - 1250.)/2.;
428   tbox[1] = 2575. + 95.;
429   tbox[2] = (3550. - 555.)/2.;
430   gMC->Gsvolu("CM10", "BOX", idtmed[1123], tbox, 3);
431   gMC->Gspos("CM10", 1, "ALIC", -1250.-tbox[0], 4420.-tbox[1], -tbox[2]-555., 0, "MANY");
432
433
434   // Molasse betwen the PGC2 & PM25 on the left side.
435   tbox[0] = (2755. - 1250.)/2.;
436   tbox[1] = 2575. + 95.;
437   tbox[2] = (1900.+2987.7 - 555. + 650.)/2.;
438   gMC->Gsvolu("CM11", "BOX", idtmed[1123], tbox, 3);
439   gMC->Gspos("CM11", 1, "ALIC", -1250.-tbox[0], 4420.-tbox[1], 555.+tbox[2], 0, "MANY");
440
441
442 }
443
444 //_____________________________________________________________________________
445 void AliCRTv0::CreateShafts()
446 {
447   //
448   //
449   //
450   Int_t  idrotm[2499];    // The rotation matrix.
451
452   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
453
454   // HAll ceiling
455   Float_t ptubs[5];
456   ptubs[0] = 1070.;
457   ptubs[1] = 1170.;
458   ptubs[2] = 1900.;
459   ptubs[3] = 0.;
460   ptubs[4] = 180.;
461   gMC->Gsvolu("CHC1", "TUBS", idtmed[1116], ptubs, 5);
462   gMC->Gspos("CHC1", 1, "ALIC", 0., 500., 0., 0, "ONLY");
463
464
465   //
466   // Acces shafts
467   //
468   AliMatrix(idrotm[2001], 0., 0., 90., 0., 90., 90.);
469   
470   // PX24
471   ptubs[0] = 1150.;
472   ptubs[1] = 1250.;
473   ptubs[2] = 1300.;
474   ptubs[3] = kRaddeg*TMath::ASin(1070./ptubs[0]);
475   ptubs[4] = 360 - ptubs[3];
476   gMC->Gsvolu("CSF1", "TUBS", idtmed[1116], ptubs, 5);
477   gMC->Gspos("CSF1", 1, "ALIC", 0., 404., -2300., idrotm[2001], "MANY");
478
479   Float_t ptube[3];
480   ptube[0] = ptubs[0];
481   ptube[1] = ptubs[1];
482   ptube[2] = 2575. - ptubs[2] + 95.;
483   gMC->Gsvolu("CSF2", "TUBE", idtmed[1116], ptube, 3);
484   gMC->Gspos("CSF2", 1, "ALIC", 0., 404.+ptubs[2]+ptube[2], -2300., idrotm[2001], "MANY");
485   
486   // Concrete walls along the shaft
487   Float_t pbox[3];
488   pbox[0] = 585./2.;
489   pbox[1] = 2575. + 95.;
490   pbox[2] = 20.;
491   gMC->Gsvolu("CSW1", "BOX", idtmed[1116], pbox, 3);
492   gMC->Gspos("CSW1", 1, "ALIC", -290-pbox[0], 404.-1300.+pbox[1], -3450.+210.*2, 0, "MANY");
493   
494   //
495   pbox[0] = 750./2.;
496   pbox[1] = 2575. + 95.;
497   pbox[2] = 20.;
498   gMC->Gsvolu("CSW3", "BOX", idtmed[1116], pbox, 3);
499   gMC->Gspos("CSW3", 1, "ALIC", 420.-290.+pbox[0], 404.-1300.+pbox[1], -3450.+210.*2, 0, "MANY");
500   
501   //
502   pbox[0] = 60.;
503   pbox[1] = 2575. + 95.;
504   pbox[2] = 210.;
505   gMC->Gsvolu("CSW2", "BOX", idtmed[1116], pbox, 3);
506   gMC->Gspos("CSW2", 1, "ALIC", -290-pbox[0], 404.-1300.+pbox[1], -3450.+pbox[2], 0, "MANY");
507   gMC->Gspos("CSW2", 2, "ALIC", 420.-290.+pbox[0], 404.-1300.+pbox[1], -3450.+pbox[2], 0, "MANY");
508   
509   
510   // 
511   pbox[0] = 1000.;
512   pbox[1] = 80.;
513   pbox[2] = 200.;
514   gMC->Gsvolu("CSP1", "BOX", idtmed[1116], pbox, 3);
515   gMC->Gspos("CSP1", 1, "ALIC", 0., 2600.-700., -1150-pbox[2], 0, "MANY");
516   
517   //
518   pbox[0] = 340.8;
519   pbox[1] = 300./2.;
520   pbox[2] = 460./2.;
521   gMC->Gsvolu("CSP2", "BOX", idtmed[1116], pbox, 3);
522   gMC->Gspos("CSP2", 1, "ALIC", 0., 2950.-700., -3450+pbox[2], 0, "MANY");
523   
524   //
525   pbox[0] = 600.;
526   pbox[1] = 150.;
527   pbox[2] = 75.;
528   gMC->Gsvolu("CSP3", "BOX", idtmed[1116], pbox, 3);
529   gMC->Gspos("CSP3", 1, "ALIC", 0., 2950.-700., -1150.-210.-pbox[2], 0, "MANY");
530   
531   //
532   pbox[0] = 600.;
533   pbox[1] = 250.;
534   pbox[2] = 38.;
535   gMC->Gsvolu("CSP4", "BOX", idtmed[1116], pbox, 3);
536   gMC->Gspos("CSP4", 1, "ALIC", 0., 2950.-700.+155.+pbox[1], -1150.-210.-pbox[2], 0, "MANY");
537   
538   
539   // Shielding plug
540   pbox[0] = 850.;
541   pbox[1] = 90.;
542   pbox[2] = 720.;
543   gMC->Gsvolu("CSP5", "BOX", idtmed[1116], pbox, 3);
544   gMC->Gspos("CSP5", 1, "ALIC", 0., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
545   
546   //
547   pbox[0] = 80.;
548   pbox[1] = 150.;
549   pbox[2] = 720.;
550   gMC->Gsvolu("CSP6", "BOX", idtmed[1116], pbox, 3);
551   gMC->Gspos("CSP6", 1, "ALIC", 1150.-600., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
552   gMC->Gspos("CSP6", 2, "ALIC", -1150.+600., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
553   
554   
555   //
556   pbox[0] = 130.;
557   pbox[1] = 60.;
558   pbox[2] = 750.;
559   gMC->Gsvolu("CSP7", "BOX", idtmed[1116], pbox, 3);
560   gMC->Gspos("CSP7", 1, "ALIC", 850.+pbox[0], 2950.-700.+100., -3450.+460.+pbox[2], 0, "MANY");
561   gMC->Gspos("CSP7", 2, "ALIC", -850.-pbox[0], 2950.-700.+100., -3450.+460.+pbox[2], 0, "MANY");
562   
563   
564   // PM25 Acces Shaft
565   ptube[0] = 910./2.;
566   ptube[1] = ptube[0] + 100.;
567   ptube[2] = (5150. - 1166.)/2.;
568   gMC->Gsvolu("CSF3", "TUBE", idtmed[1116], ptube, 3);
569   gMC->Gspos("CSF3", 1, "ALIC", -2100., AliCRTConstants::fgDepth-ptube[2], 0., idrotm[2001], "MANY");
570   
571   // PGC2 Access Shaft
572   ptube[0] = 1100./2.;
573   ptube[1] = ptube[0] + 100.;
574   ptube[2] = (5150. - 690.)/2.;
575   gMC->Gsvolu("CSF4", "TUBE", idtmed[1116], ptube, 3);
576   gMC->Gspos("CSF4", 1, "ALIC", 375., AliCRTConstants::fgDepth-ptube[2], 1900.+2987.7, idrotm[2001], "MANY");
577
578 }
579
580 //_____________________________________________________________________________
581
582 void AliCRTv0::CreateMaterials()
583 {
584   // Use the standard materials.
585   AliCRT::CreateMaterials();  
586 }
587
588
589 //_____________________________________________________________________________
590 void AliCRTv0::DrawDetector()
591 {
592   //
593   // Draw a shaded view of the L3 magnet
594   //
595    cout << "AliCRTv0::DrawModule() : Drawing the module" << endl;
596
597    gMC->Gsatt("*", "seen", -1);
598    gMC->Gsatt("alic", "seen", 0);
599
600    gMC->Gsatt("ALIC","seen",0);
601    gMC->Gsatt("L3MO","seen",1); // L3 Magnet
602    gMC->Gsatt("CRT1","seen",1); // Scintillators
603
604    // Draw the molasse volumes
605    gMC->Gsatt("CMO1","seen",0); // Exactly above the HALL
606    gMC->Gsatt("CMO2","seen",0); // Molasse, along the PM25
607    gMC->Gsatt("CMO3","seen",0); // molasse along the PGC2
608    gMC->Gsatt("CMO4","seen",0); // Molasse, behind the PX24 upper part
609    gMC->Gsatt("CMO5","seen",0); // molasse behind px24, lower part
610    gMC->Gsatt("CMO6","seen",0); // behind the PX24
611    gMC->Gsatt("CMO7","seen",0); // behind the PGC2
612    gMC->Gsatt("CMO8","seen",0); // on the right side.
613    gMC->Gsatt("CMO9","seen",0); // on the left side.
614    gMC->Gsatt("CM10","seen",0); // betwen PX24 & PM25.
615    gMC->Gsatt("CM11","seen",0); // betwen PGC2 & PM25.
616    gMC->Gsatt("CM12","seen",0); // box above the hall.
617
618    gMC->Gdopt("hide", "on");
619    gMC->Gdopt("edge","off");
620    gMC->Gdopt("shad", "on");
621    gMC->Gsatt("*", "fill", 7);
622    gMC->SetClipBox("ALIC", 0, 3000, -3000, 3000, -6000, 6000);
623    gMC->DefaultRange();
624    gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .009, .009);
625    gMC->Gdhead(1111, "View of CRT(ACORDE)");
626    gMC->Gdman(18, 4, "MAN");
627
628
629 }
630
631 //_____________________________________________________________________________
632 void AliCRTv0::Init()
633 {
634   //
635   // Initialise L3 magnet after it has been built
636   Int_t i;
637   //
638   if(fDebug) {
639     printf("\n%s: ",ClassName());
640     for(i=0;i<35;i++) printf("*");
641     printf(" CRTv0_INIT ");
642     for(i=0;i<35;i++) printf("*");
643     printf("\n%s: ",ClassName());
644     //
645     // Here the CRTv0 initialisation code (if any!)
646     for(i=0;i<80;i++) printf("*");
647     printf("\n");
648   }
649
650 }
651
652 //_____________________________________________________________________________
653 void AliCRTv0::StepManager()
654 {
655   //
656   // Called for every step in the Cosmic Ray Trigger
657   //
658   static Int_t   vol[5];
659   Int_t          copy;
660   Int_t          ipart;
661   TLorentzVector pos;
662   TLorentzVector mom;
663
664   static Float_t hits[14];
665   Int_t tracknumber = gAlice->CurrentTrack();
666
667   static Float_t eloss;
668   static Float_t tlength;
669   Float_t theta;
670   Float_t phi;
671
672   if ( !gMC->IsTrackAlive() ) return;
673
674   if (gMC->IsNewTrack()) {
675     // Reset the deposited energy
676     eloss = 0.;
677   }
678   
679   eloss += gMC->Edep(); // Store the energy loss along the trajectory.
680   tlength += gMC->TrackStep();
681
682   if (gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"CM12") == 0) ) {
683
684   // Get current particle id (ipart), track position (pos) and momentum (mom)
685     gMC->TrackPosition(pos);
686     gMC->TrackMomentum(mom);
687     ipart = gMC->TrackPid();
688
689     Double_t tc   = mom[0]*mom[0]+mom[1]*mom[1];
690     Double_t pt   = TMath::Sqrt(tc);
691     theta   = Float_t(TMath::ATan2(pt,Double_t(mom[2])))*kRaddeg;
692     phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
693
694
695     vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
696     vol[2]    = gMC->CurrentVolID(copy);
697     vol[3]    = copy;
698     
699     hits[0]  = 0.f; //                 (fnmou)
700     hits[1]  = (Float_t)ipart; //      (fId)
701
702     hits[2]  = pos[0]; // X coordinate (fX)
703     hits[3]  = pos[1]; // Y coordinate (fY)
704     hits[4]  = pos[2]; // Z coordinate (fZ)
705     hits[5]  = mom[0]; // Px           (fpxug)
706     hits[6]  = mom[1]; // Py           (fpyug)
707     hits[7]  = mom[2]; // Pz           (fpzug)
708     
709     hits[8]  = gMC->GetMedium();//layer(flay)
710     hits[9]  = theta;   // arrival angle
711     hits[10] = phi;     // 
712     hits[11] = eloss;   // Energy loss
713     hits[12] = tlength; // Trajectory lenght
714     hits[13] = (Float_t)tracknumber;
715
716     AddHit(gAlice->CurrentTrack(),vol, hits);
717
718   }
719
720 }
721