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