]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CRT/AliCRTv1.cxx
Moving to the new VMC naming convention
[u/mrichter/AliRoot.git] / CRT / AliCRTv1.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // ALICE Cosmic Ray Trigger                                                  //
21 //                                                                           //
22 //  This class contains the functions for version 0 of the ALICE Cosmic Ray  //
23 //  Trigger. This vesion is suposed to work as standalone module             //
24 //                                                                           //
25 //
26 //   Authors:
27 //
28 //   Arturo Fernandez <afernand@fcfm.buap.mx>
29 //   Enrique Gamez    <egamez@fcfm.buap.mx>
30 //
31 //   Universidad Autonoma de Puebla
32 //
33 //
34 //Begin_Html
35 /*
36 <img src="picts/AliCRTv1Class.gif">
37 </pre>
38 <br clear=left>
39 <p>The responsible person for this module is
40 <a href="mailto:egamez@fcfm.buap.mx">Enrique Gamez</a>.
41 </font>
42 <pre>
43 */
44 //End_Html
45 //                                                                           //
46 ///////////////////////////////////////////////////////////////////////////////
47
48
49 #include <TBRIK.h>
50 #include <TGeometry.h>
51 #include <TLorentzVector.h>
52 #include <TNode.h>
53 #include <TPDGCode.h>
54
55 #include "AliCRTConstants.h"
56 #include "AliCRTv1.h"
57 #include "AliConst.h"
58 #include "AliMagF.h"
59 #include "AliRun.h"
60
61 ClassImp(AliCRTv1)
62  
63 //_____________________________________________________________________________
64 AliCRTv1::AliCRTv1() : AliCRTv0()
65 {
66   //
67   // Default constructor for CRT
68   //
69   fCRTStatus = kTRUE;
70   fRICHStatus = kFALSE;
71   fTPCStatus = kFALSE;
72   fMagnetStatus = kTRUE;
73
74   fCRTModule = kFALSE;
75 }
76  
77 //_____________________________________________________________________________
78 AliCRTv1::AliCRTv1(const char *name, const char *title)
79   : AliCRTv0(name,title)
80 {
81   //
82   // Standard constructor for CRT
83   //
84   //Begin_Html
85   /*
86     <img src="picts/AliCRTv1.gif">
87   */
88   //End_Html
89   fCRTStatus = kTRUE;
90   fCRTModule = kFALSE;
91
92   fRICHStatus = kFALSE;
93   fTPCStatus = kFALSE;
94   fMagnetStatus = kFALSE;
95 }
96
97 //_____________________________________________________________________________
98 AliCRTv1::AliCRTv1(const AliCRTv1& crt)
99 {
100   //
101   // Copy ctor.
102   //
103   crt.Copy(*this);
104 }
105
106 //_____________________________________________________________________________
107 AliCRTv1& AliCRTv1::operator= (const AliCRTv1& crt)
108 {
109   //
110   // Asingment operator
111   //
112   crt.Copy(*this);
113   return *this;
114 }
115
116 //_____________________________________________________________________________
117 void AliCRTv1::CreateGeometry()
118 {
119   //
120   // Create geometry for the CRT array
121   //
122
123   Int_t  idrotm[2499];    // The rotation matrix.
124
125   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
126
127   //
128   // Shafts.
129   this->CreateShafts();
130
131   //
132   // Molasse.
133   this->CreateMolasse();
134
135
136   //
137   // Scintillators
138
139   Float_t box[3];
140   box[0] = AliCRTConstants::fgCageLenght/2.; // Half Length of the box along the X axis, cm.
141   box[1] = AliCRTConstants::fgCageHeight/2.; // Half Length of the box along the Y axis, cm.
142   box[2] = AliCRTConstants::fgCageWidth/2.;  // Half Length of the box along the Z axis, cm.
143
144   //
145   // Create a big voluem with air barrel above the magnet
146   Float_t barrel[10];
147   Float_t magnetSides = 3.;
148   Float_t planesPerpendicularToZ = 2.;
149   Float_t rMin = 790.;
150   Float_t rMax = rMin + 20.; // 20 cm width
151   barrel[0] = 22.5;
152   barrel[1] = 45*magnetSides;
153   barrel[2] = magnetSides;
154   barrel[3] = planesPerpendicularToZ;
155   barrel[4] = -600.;
156   barrel[5] = rMin;
157   barrel[6] = rMax;
158   barrel[7] = 600.;
159   barrel[8] = rMin;
160   barrel[9] = rMax;
161   gMC->Gsvolu("CRT4", "PGON", idtmed[1114], barrel, 10);
162   gMC->Gspos("CRT4", 1 , "CRT", 0., -30., 0., 0, "ONLY");
163   
164
165   // Create  the current sicuiitllator arry
166   // Define the Scintillators. as a big box.
167   Float_t scint[3];
168   scint[0] = AliCRTConstants::fgActiveAreaLenght/2.;   // Half Length in X
169   scint[1] = AliCRTConstants::fgActiveAreaHeight/2.;   // Half Length in Y
170   scint[2] = AliCRTConstants::fgActiveAreaWidth/2.;    // Half Length in Z
171   gMC->Gsvolu("CRT1", "BOX ", idtmed[1112], scint, 3); // Scintillators
172   //
173   // -- X axis.
174   // we'll start dawing from the center.
175   Float_t initX = 0.;
176   
177   //
178   // -- Y axis
179   Float_t gapY   = 30.;        // 30 cms. above the barrel.
180   // For the height we staimate the from the center of the ceiling,
181   // if were a cilinder, must be about 280cm.
182   Float_t barrelc = 790.; // Barrel radius.
183   Float_t height  = barrelc + gapY - 30.;
184   Float_t initY = height;
185   
186   //
187   // -- Z axis.
188   // we'll start dawing from the center.
189   
190   //
191   // Put 4 modules on the top of the magnet
192   Int_t step = 4;
193   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
194     gMC->Gspos("CRT1", i, "CRT", initX, initY, (i-step)*box[2], 0, "ONLY");
195     step--;
196   }
197   
198   // Modules on the barrel sides.
199   // Because the openenig angle for each face is 22.5, and if we want to
200   //    put the modules right in the middle
201   Float_t xtragap = 10.;
202   Float_t initXside = (height+xtragap)*TMath::Sin(2*22.5*kDegrad);//rigthside
203   Float_t initYside = (height+xtragap)*TMath::Cos(2*22.5*kDegrad);
204   
205   // Put 4 modules on the left side of the magnet
206   // The rotation matrix parameters, for the left side.
207   AliMatrix(idrotm[232], 90., 315., 90., 45., 0., 337.5);
208   Int_t stepl = 4;
209   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
210     gMC->Gspos("CRT1", i+4, "CRT", initXside, initYside, (i-stepl)*box[2],
211                idrotm[232], "ONLY");
212     stepl--;
213   }
214   
215   // Put 4 modules on the right side of the magnet
216   // The rotation matrix parameters for the right side.
217   AliMatrix(idrotm[231], 90., 45., 90., 315., 180., 202.5);
218   Int_t stepr = 4;
219   for ( Int_t i = 1 ; i <= 4 ; i++ ) {
220     gMC->Gspos("CRT1", i+8, "CRT", -initXside, initYside, (i-stepr)*box[2],
221                idrotm[231], "ONLY");
222     stepr--;
223   }
224   
225   this->CreateMagnetGeometry();
226   this->CreateRICHGeometry();
227   this->CreateTPCGeometry();
228   
229 }
230
231 //_____________________________________________________________________________
232 void AliCRTv1::CreateMagnetGeometry()
233 {
234   
235   cout<<"\n\n\tYou are requiring the CRT with the Magnet Activated!\n\n";
236   
237   Int_t  idrotm[2499];    // The rotation matrix.
238
239   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
240
241   // Disable the CRT StepManager method.
242   fCRTStatus = kFALSE;
243
244   Float_t barrel[10];
245   Float_t magnetSides = 3.;
246   Float_t planesPerpendicularToZ = 2.;
247   //Float_t rMin = 790.;
248   //Float_t rMax = rMin + 20.; // 20 cm width
249
250   // MAgnet
251   // Create the upper faces of the magnet.
252   barrel[0] = 22.5;
253   barrel[1] = 360.;
254   barrel[2] = 8.;
255   barrel[3] = 2.;
256   barrel[4] = -600.;
257   barrel[5] = 580.;
258   barrel[6] = 790.;
259   barrel[7] = 600.;
260   barrel[8] = 580.;
261   barrel[9] = 790.;
262   gMC->Gsvolu("C3MO", "PGON", idtmed[1114], barrel, 10);
263   gMC->Gspos("C3MO", 1, "CRT", 0., -30., 0., 0, "ONLY");
264
265   // Define coils 
266   
267   barrel[5] = 585.;
268   barrel[6] = 690.;
269   barrel[8] = 585.;
270   barrel[9] = 690.;
271   gMC->Gsvolu("C3CO", "PGON", idtmed[1108], barrel, 10); //Aluminium
272   gMC->Gspos("C3CO", 1, "C3MO", 0., 0., 0., 0, "ONLY");
273   
274   barrel[5] = 580.;
275   barrel[6] = 585.;
276   barrel[8] = 580.;
277   barrel[9] = 585.;
278   gMC->Gsvolu("C3C1", "PGON", idtmed[1128], barrel, 10);// Aluminium
279   gMC->Gspos("C3C1", 1, "C3MO", 0., 0., 0., 0, "ONLY");
280
281   // Define yoke 
282   
283   barrel[5] = 690.;
284   barrel[6] = 790.;
285   barrel[8] = 690.;
286   barrel[9] = 790.;
287   gMC->Gsvolu("C3YO", "PGON", idtmed[1109], barrel, 10); // Iron
288   gMC->Gspos("C3YO", 1, "C3MO", 0., 0., 0., 0, "ONLY");
289
290
291   // Now create one inside the magnet as L3C1
292   // voulme for tracking.
293   barrel[0] = 22.5;
294   barrel[1] = 45*magnetSides;
295   barrel[2] = magnetSides;
296   barrel[3] = planesPerpendicularToZ;
297   barrel[4] = -600.;
298   barrel[5] = 575.;
299   barrel[6] = 580.;
300   barrel[7] = 600.;
301   barrel[8] = 575.;
302   barrel[9] = 580.;
303   gMC->Gsvolu("C3CI", "PGON", idtmed[1134], barrel, 10);
304   gMC->Gspos("C3CI", 1 , "CRT", 0., -30., 0., 0, "ONLY");
305
306   // And a detector layer in the door 10 cm thick
307   // Volume for tracking.
308   barrel[0] = 22.5;
309   barrel[1] = 360.;
310   barrel[2] = 8.;
311   barrel[3] = 2.;
312   barrel[4] = 590.;
313   barrel[5] = 0.;
314   barrel[6] = 580.;
315   barrel[7] = 600.;
316   barrel[8] = barrel[5];
317   barrel[9] = barrel[6];
318   gMC->Gsvolu("C3C2", "PGON", idtmed[1154], barrel, 10); // Air
319   gMC->Gspos("C3C2", 1, "CRT",  0., -30., 0., 0, "ONLY");
320   AliMatrix(idrotm[1010], 90., 0., 90., 90., 180., 0.);
321   gMC->Gspos("C3C2", 2, "CRT",  0., -30., 0., idrotm[1010], "ONLY");
322
323
324
325   barrel[4] = 600.;
326   barrel[5] = 0.;
327   barrel[6] = 790.;
328   barrel[7] = 700.;
329   barrel[8] = barrel[5];
330   barrel[9] = barrel[6];
331   gMC->Gsvolu("C3DO", "PGON", idtmed[1174], barrel, 10); // Air
332   gMC->Gspos("C3DO", 1, "CRT", 0., -30., 0., 0, "ONLY");
333   AliMatrix(idrotm[1010], 90., 0., 90., 90., 180., 0.);
334   gMC->Gspos("C3DO", 2, "CRT", 0., -30., 0., idrotm[1010], "ONLY");
335
336   barrel[4] = 610.;
337   barrel[5] = 0.;
338   barrel[6] = 790.;
339   barrel[7] = 700.;
340   barrel[8] = barrel[5];
341   barrel[9] = barrel[6];
342   gMC->Gsvolu("C3FR", "PGON", idtmed[1149], barrel, 10); // Iron
343   gMC->Gspos("C3FR", 1, "C3DO", 0., 0., 0., 0, "ONLY");
344   // INNER LAYER 
345   
346   barrel[4] = 600.;
347   barrel[7] = 610.;
348   gMC->Gsvolu("C3IR", "PGON", idtmed[1149], barrel, 10); //Iron
349   gMC->Gspos("C3IR", 1, "C3DO", 0., 0., 0., 0, "ONLY");
350
351 }
352
353 //_____________________________________________________________________________
354 void AliCRTv1::CreateTPCGeometry()
355 {
356   cout<<"\n\n\tYou are requiring the CRT with the TPC Activated!\n\n";
357   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
358
359   // Disable the CRT StepManager method.
360   fCRTStatus = kFALSE;
361   // Disable the MAgnet
362   fMagnetStatus = kFALSE;
363   // Disable th RICH
364   fRICHStatus = kFALSE;
365
366   // TPC
367   // Tpc SAndwich 1 - Al
368   // TSA1
369   Float_t tube[5];
370   tube[0]=274.8124;
371   tube[1]=278.;
372   tube[2]=252.1;
373   tube[3] = 0.;
374   tube[4] = 180.;
375   gMC->Gsvolu("CSA1","TUBS",idtmed[1154],tube,5);
376   // TSA1->TOCV (0.,0.,3.) ->TOIN (0.,0.,0.)->TPC (0.,0.,0.)->ALIC(0.,0.,0.)
377   gMC->Gspos("CSA1 ",1,"CRT",0.,0.,0.,0,"ONLY");
378
379 }
380
381 //_____________________________________________________________________________
382 void AliCRTv1::CreateRICHGeometry()
383 {
384
385   cout<<"\n\n\tYou are requiring the CRT with the RICH Activated!\n\n";
386
387   Int_t  idrotm[2499];    // The rotation matrix.
388
389   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
390
391   // Disable the CRT StepManager method.
392   fCRTStatus = kFALSE;
393   // Disable the MAgnet
394   fMagnetStatus = kFALSE;
395
396
397   // now create  volume to simulate the HMPID volume. CSI
398   Float_t csi_length = 160*.8 + 2.6;
399   Float_t csi_width = 144*.84 + 2*2.6;
400   Float_t tbox[3];
401   tbox[0] = csi_width/2;
402   tbox[1] = 11.5;
403   tbox[2] = csi_length/2;
404   gMC->Gsvolu("CRIC ", "BOX ", idtmed[1174], tbox, 3);
405
406   Double_t dOffset = 490+1.267 - 8/2;  // distance from center of mother volume ALIC to methane
407   
408   Double_t dAlpha = 19.5; // angle between centers of chambers - y-z plane
409   Double_t dAlphaRad = dAlpha*kDegrad;
410   
411   Double_t dBeta = 20.;   // angle between center of chambers - y-x plane
412   Double_t dBetaRad = dBeta*kDegrad;
413    
414   Double_t dRotAngle = 60.;     // the whole RICH is to be rotated in x-y plane + means clockwise rotation 
415   Double_t dRotAngleRad = dRotAngle*kDegrad;
416    
417     
418    TRotMatrix *pRotMatrix; // tmp pointer
419    
420    TVector3 vector(0,dOffset,0); // Position of chamber 2 without rotation
421
422    // Chamber 0  standalone (no other chambers in this row) 
423    AliMatrix(idrotm[1000],90, -dRotAngle+360,90-dAlpha, 90-dRotAngle, dAlpha, -90+300);
424    pRotMatrix=new TRotMatrix("rot993","rot993",90,-dRotAngle, 90-dAlpha,90-dRotAngle,dAlpha, -90);
425    
426    vector.SetXYZ(0,dOffset,0);  vector.RotateX(dAlphaRad); 
427    vector.RotateZ(-dRotAngleRad);
428    
429    gMC->Gspos("CRIC",1,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1000], "ONLY");
430    
431    // Chamber 1   
432    AliMatrix(idrotm[1001],90,-dBeta-dRotAngle,90,90-dBeta-dRotAngle, 0,0);
433
434    pRotMatrix=new TRotMatrix("rot994","rot994",90,-dBeta-dRotAngle,90,90-dBeta-dRotAngle,0,0);  
435    
436    vector.SetXYZ(0,dOffset,0);  vector.RotateZ(-dBetaRad); 
437    vector.RotateZ(-dRotAngleRad);
438    
439    gMC->Gspos("CRIC",2,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1001], "ONLY");           
440    
441    // Chamber 2   the top one with no Alpha-Beta rotation
442    AliMatrix(idrotm[1002],90,-dRotAngle,90,90-dRotAngle,0,0);
443
444    pRotMatrix=new TRotMatrix("rot995","rot995",90,-dRotAngle,90,90-dRotAngle,0,0);
445    
446    vector.SetXYZ(0,dOffset,0);
447    vector.RotateZ(-dRotAngleRad);
448    
449    gMC->Gspos("CRIC",3,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1002], "ONLY");           
450    
451    // Chamber 3
452    AliMatrix(idrotm[1003],90,dBeta-dRotAngle,90.,90+dBeta-dRotAngle,0,0);
453    pRotMatrix=new TRotMatrix("rot996","rot996", 90,dBeta-dRotAngle,90.,90+dBeta-dRotAngle,0,0);
454    
455    vector.SetXYZ(0,dOffset,0);  vector.RotateZ(dBetaRad); 
456    vector.RotateZ(-dRotAngleRad);
457    
458    gMC->Gspos("CRIC",4,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1003], "ONLY");
459
460    // Chamber 4
461    AliMatrix(idrotm[1004],90,360-dBeta-dRotAngle,108.2,90-dBeta-dRotAngle,18.2,90-dBeta-60);
462    pRotMatrix=new TRotMatrix("rot997","rot997",90,360-dBeta-dRotAngle,108.2,90-dBeta-dRotAngle,18.2,90-dBeta);
463    
464    vector.SetXYZ(0,dOffset,0);  vector.RotateZ(-dBetaRad); vector.RotateX(-dAlphaRad); 
465    vector.RotateZ(-dRotAngleRad);
466    
467    gMC->Gspos("CRIC",5,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1004], "ONLY");
468
469    // Chamber 5
470    AliMatrix(idrotm[1005],90,-dRotAngle+360,90+dAlpha,90-dRotAngle,dAlpha,90-60);     
471
472    pRotMatrix=new TRotMatrix("rot998","rot998",90,-dRotAngle,90+dAlpha,90-dRotAngle,dAlpha,90);     
473    
474    vector.SetXYZ(0,dOffset,0); vector.RotateX(-dAlphaRad); 
475    vector.RotateZ(-dRotAngleRad);
476    
477    gMC->Gspos("CRIC",6,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1005], "ONLY");           
478    
479    // Chamber 6           
480    AliMatrix(idrotm[1006],90,dBeta-dRotAngle+360,108.2,90+dBeta-dRotAngle,18.2,90+dBeta-60);
481
482    pRotMatrix=new TRotMatrix("rot999","rot999",90,dBeta-dRotAngle,108.2,90+dBeta-dRotAngle,18.2,90+dBeta);    
483    
484    vector.SetXYZ(0,dOffset,0);  vector.RotateZ(dBetaRad); vector.RotateX(-dAlphaRad); 
485    vector.RotateZ(-dRotAngleRad);
486    
487    gMC->Gspos("CRIC",7,"CRT",vector.X(),vector.Y(),vector.Z(),idrotm[1006], "ONLY");
488    
489 }
490
491 //_____________________________________________________________________________
492 void AliCRTv1::CreateMolasse()
493 {
494   //
495   //
496   //
497
498   Int_t  idrotm[2499];    // The rotation matrix.
499
500   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
501
502   //
503   // Molasse
504   //
505
506   // Exactly above the hall
507   Float_t tspar[5];
508   tspar[0] = 1170.;
509   tspar[1] = 1170. + 375.;
510   tspar[2] = (1900.+1150.)/2.+100.;
511   tspar[3] = 0.;
512   tspar[4] = 180.;
513   gMC->Gsvolu("CMO1", "TUBS", idtmed[1123], tspar, 5);
514   gMC->Gspos("CMO1", 1, "CRT", 0., 500., 1900.-tspar[2]+400., 0, "MANY");
515
516   Float_t tbox[3];
517   tbox[0] = 1250.;
518   tbox[1] = (4420. - 1670.)/2.;
519   tbox[2] = (1900.+1150.)/2. + 200.;
520   gMC->Gsvolu("CM12", "BOX", idtmed[1123], tbox, 3);
521   gMC->Gspos("CM12", 1, "CRT", 0., 4420. -tbox[1], 1900.-tbox[2]+400., 0, "MANY");
522
523   AliMatrix(idrotm[2003], 0., 0., 90., 0., 90., 90.);
524   // Along the PM25
525   Float_t tube[3];
526   tube[0] = 455. + 100.;
527   tube[1] = 555. + 375.;
528   tube[2] = (5150. - 1166.)/2.;
529   gMC->Gsvolu("CMO2", "TUBE", idtmed[1123], tube, 3);
530   gMC->Gspos("CMO2", 1, "CRT", -2100., 4420.-tube[2], 0., idrotm[2003], "MANY");
531
532
533   // Along the PGC2
534   tube[0] = 650.;
535   tube[1] = 2987.7;
536   tube[2] = (5150. - 690.)/2.;
537   gMC->Gsvolu("CMO3", "TUBE", idtmed[1123], tube, 3);
538   gMC->Gspos("CMO3", 1, "CRT", 375., 4420.-tube[2], 1900.+2987.7, idrotm[2003], "MANY");
539   // Behind the PGC2 up to the end of the M. volume.
540   tbox[0] = 12073.;
541   tbox[1] = 2575. + 95.;
542   tbox[2] = (12073. - 1900.-2987.7-650.)/2.;
543   gMC->Gsvolu("CMO7", "BOX", idtmed[1123], tbox, 3);
544   gMC->Gspos("CMO7", 1, "CRT", 0., 4420.-tbox[1], 1900.+2987.7+650.+tbox[2], 0, "MANY");
545
546   // Along the PX24 , upper part.
547   tube[0] = 1250.;
548   tube[1] = 2300;
549   tube[2] = 2575. - 1300. + 95.;
550   gMC->Gsvolu("CMO4", "TUBE", idtmed[1123], tube, 3);
551   gMC->Gspos("CMO4", 1, "CRT", 0., 404.+1300.+tube[2], -2300., idrotm[2003], "MANY");
552
553   // Along the PX24 , lower part
554   tspar[0] = 1250.;
555   tspar[1] = 2300;
556   tspar[2] = 1300.;
557   tspar[3] = kRaddeg*TMath::ASin(1070./1150.);
558   tspar[4] = 360. - tspar[3];
559   gMC->Gsvolu("CMO5", "TUBS", idtmed[1123], tspar, 5);
560   gMC->Gspos("CMO5", 1, "CRT", 0., 404., -2300., idrotm[2003], "MANY");
561   // behind the PX24
562   tbox[0] = 12073.;
563   tbox[1] = 2575. + 95.;
564   tbox[2] = 8523./2.;
565   gMC->Gsvolu("CMO6", "BOX", idtmed[1123], tbox, 3);
566   gMC->Gspos("CMO6", 1, "CRT", 0., 4420.-tbox[1], -3550.-tbox[2], 0, "MANY");
567
568
569   // On the right side of th hall
570   tbox[0] = (12073. - 1250.)/2.;
571   tbox[1] = 2575. + 95.;
572   tbox[2] = (8437.7+650.)/2.;
573   gMC->Gsvolu("CMO8", "BOX", idtmed[1123], tbox, 3);
574   gMC->Gspos("CMO8", 1, "CRT", 1250.+tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
575
576   // on the left side of the hall, behind 
577   tbox[0] = (12073. - 2755.)/2.;
578   tbox[1] = 2575. + 95.;
579   tbox[2] = (8437.7+650.)/2.;
580   gMC->Gsvolu("CMO9", "BOX", idtmed[1123], tbox, 3);
581   gMC->Gspos("CMO9", 1, "CRT", -2755.-tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
582
583
584   // Molasse betwen the PX24 & PM25 on the left side.
585   tbox[0] = (2755. - 1250.)/2.;
586   tbox[1] = 2575. + 95.;
587   tbox[2] = (3550. - 555.)/2.;
588   gMC->Gsvolu("CM10", "BOX", idtmed[1123], tbox, 3);
589   gMC->Gspos("CM10", 1, "CRT", -1250.-tbox[0], 4420.-tbox[1], -tbox[2]-555., 0, "MANY");
590
591
592   // Molasse betwen the PGC2 & PM25 on the left side.
593   tbox[0] = (2755. - 1250.)/2.;
594   tbox[1] = 2575. + 95.;
595   tbox[2] = (1900.+2987.7 - 555. + 650.)/2.;
596   gMC->Gsvolu("CM11", "BOX", idtmed[1123], tbox, 3);
597   gMC->Gspos("CM11", 1, "CRT", -1250.-tbox[0], 4420.-tbox[1], 555.+tbox[2], 0, "MANY");
598
599
600 }
601
602 //_____________________________________________________________________________
603 void AliCRTv1::CreateShafts()
604 {
605   //
606   //
607   //
608   Int_t  idrotm[2499];    // The rotation matrix.
609
610   Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
611
612   // Create a mother volume.
613   Float_t pbox[3];
614   //pbox[0] = AliCRTConstants::fgDepth*TMath::Tan(67.5*kDegrad);
615   pbox[0] = 12073.;
616   pbox[1] = AliCRTConstants::fgDepth;
617   pbox[2] = pbox[0];
618   gMC->Gsvolu("CRT", "BOX", idtmed[1114], pbox, 3);
619   gMC->Gspos("CRT", 1, "ALIC", 0., 0., 0., 0, "ONLY");
620
621   // HAll ceiling
622   Float_t ptubs[5];
623   ptubs[0] = 1070.;
624   ptubs[1] = 1170.;
625   ptubs[2] = 1900.;
626   ptubs[3] = 0.;
627   ptubs[4] = 180.;
628   gMC->Gsvolu("CHC1", "TUBS", idtmed[1116], ptubs, 5);
629   gMC->Gspos("CHC1", 1, "CRT", 0., 500., 0., 0, "ONLY");
630
631
632   //
633   // Acces shafts
634   //
635   AliMatrix(idrotm[2001], 0., 0., 90., 0., 90., 90.);
636   
637   // PX24
638   ptubs[0] = 1150.;
639   ptubs[1] = 1250.;
640   ptubs[2] = 1300.;
641   ptubs[3] = kRaddeg*TMath::ASin(1070./ptubs[0]);
642   ptubs[4] = 360 - ptubs[3];
643   gMC->Gsvolu("CSF1", "TUBS", idtmed[1116], ptubs, 5);
644   gMC->Gspos("CSF1", 1, "CRT", 0., 404., -2300., idrotm[2001], "MANY");
645
646   Float_t ptube[3];
647   ptube[0] = ptubs[0];
648   ptube[1] = ptubs[1];
649   ptube[2] = 2575. - ptubs[2] + 95.;
650   gMC->Gsvolu("CSF2", "TUBE", idtmed[1116], ptube, 3);
651   gMC->Gspos("CSF2", 1, "CRT", 0., 404.+ptubs[2]+ptube[2], -2300., idrotm[2001], "MANY");
652   
653   // Concrete walls along the shaft
654   pbox[0] = 585./2.;
655   pbox[1] = 2575. + 95.;
656   pbox[2] = 20.;
657   gMC->Gsvolu("CSW1", "BOX", idtmed[1116], pbox, 3);
658   gMC->Gspos("CSW1", 1, "CRT", -290-pbox[0], 404.-1300.+pbox[1], -3450.+210.*2, 0, "MANY");
659   
660   //
661   pbox[0] = 750./2.;
662   pbox[1] = 2575. + 95.;
663   pbox[2] = 20.;
664   gMC->Gsvolu("CSW3", "BOX", idtmed[1116], pbox, 3);
665   gMC->Gspos("CSW3", 1, "CRT", 420.-290.+pbox[0], 404.-1300.+pbox[1], -3450.+210.*2, 0, "MANY");
666   
667   //
668   pbox[0] = 60.;
669   pbox[1] = 2575. + 95.;
670   pbox[2] = 210.;
671   gMC->Gsvolu("CSW2", "BOX", idtmed[1116], pbox, 3);
672   gMC->Gspos("CSW2", 1, "CRT", -290-pbox[0], 404.-1300.+pbox[1], -3450.+pbox[2], 0, "MANY");
673   gMC->Gspos("CSW2", 2, "CRT", 420.-290.+pbox[0], 404.-1300.+pbox[1], -3450.+pbox[2], 0, "MANY");
674   
675   
676   // 
677   pbox[0] = 1000.;
678   pbox[1] = 80.;
679   pbox[2] = 200.;
680   gMC->Gsvolu("CSP1", "BOX", idtmed[1116], pbox, 3);
681   gMC->Gspos("CSP1", 1, "CRT", 0., 2600.-700., -1150-pbox[2], 0, "MANY");
682   
683   //
684   pbox[0] = 340.8;
685   pbox[1] = 300./2.;
686   pbox[2] = 460./2.;
687   gMC->Gsvolu("CSP2", "BOX", idtmed[1116], pbox, 3);
688   gMC->Gspos("CSP2", 1, "CRT", 0., 2950.-700., -3450+pbox[2], 0, "MANY");
689   
690   //
691   pbox[0] = 600.;
692   pbox[1] = 150.;
693   pbox[2] = 75.;
694   gMC->Gsvolu("CSP3", "BOX", idtmed[1116], pbox, 3);
695   gMC->Gspos("CSP3", 1, "CRT", 0., 2950.-700., -1150.-210.-pbox[2], 0, "MANY");
696   
697   //
698   pbox[0] = 600.;
699   pbox[1] = 250.;
700   pbox[2] = 38.;
701   gMC->Gsvolu("CSP4", "BOX", idtmed[1116], pbox, 3);
702   gMC->Gspos("CSP4", 1, "CRT", 0., 2950.-700.+155.+pbox[1], -1150.-210.-pbox[2], 0, "MANY");
703   
704   
705   // Shielding plug
706   pbox[0] = 850.;
707   pbox[1] = 90.;
708   pbox[2] = 720.;
709   gMC->Gsvolu("CSP5", "BOX", idtmed[1116], pbox, 3);
710   gMC->Gspos("CSP5", 1, "CRT", 0., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
711   
712   //
713   pbox[0] = 80.;
714   pbox[1] = 150.;
715   pbox[2] = 720.;
716   gMC->Gsvolu("CSP6", "BOX", idtmed[1116], pbox, 3);
717   gMC->Gspos("CSP6", 1, "CRT", 1150.-600., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
718   gMC->Gspos("CSP6", 2, "CRT", -1150.+600., 2950.-700., -3450.+460.+pbox[2], 0, "MANY");
719   
720   
721   //
722   pbox[0] = 130.;
723   pbox[1] = 60.;
724   pbox[2] = 750.;
725   gMC->Gsvolu("CSP7", "BOX", idtmed[1116], pbox, 3);
726   gMC->Gspos("CSP7", 1, "CRT", 850.+pbox[0], 2950.-700.+100., -3450.+460.+pbox[2], 0, "MANY");
727   gMC->Gspos("CSP7", 2, "CRT", -850.-pbox[0], 2950.-700.+100., -3450.+460.+pbox[2], 0, "MANY");
728   
729   
730   // PM25 Acces Shaft
731   ptube[0] = 910./2.;
732   ptube[1] = ptube[0] + 100.;
733   ptube[2] = (5150. - 1166.)/2.;
734   gMC->Gsvolu("CSF3", "TUBE", idtmed[1116], ptube, 3);
735   gMC->Gspos("CSF3", 1, "CRT", -2100., AliCRTConstants::fgDepth-ptube[2], 0., idrotm[2001], "MANY");
736   
737   // PGC2 Access Shaft
738   ptube[0] = 1100./2.;
739   ptube[1] = ptube[0] + 100.;
740   ptube[2] = (5150. - 690.)/2.;
741   gMC->Gsvolu("CSF4", "TUBE", idtmed[1116], ptube, 3);
742   gMC->Gspos("CSF4", 1, "CRT", 375., AliCRTConstants::fgDepth-ptube[2], 1900.+2987.7, idrotm[2001], "MANY");
743
744 }
745
746 //_____________________________________________________________________________
747 void AliCRTv1::DrawDetector()
748 {
749   //
750   // Draw a shaded view of the L3 magnet
751   //
752   cout << "AliCRTv1::DrawModule() : Drawing the module" << endl;
753   
754   
755   Int_t able = 1;
756   Int_t enable = 0;
757   gMC->Gsatt("*", "seen", -1);
758   gMC->Gsatt("alic", "seen", 0);
759   
760   gMC->Gsatt("ALIC","seen",enable);
761   gMC->Gsatt("CRT", "seen",enable);
762   gMC->Gsatt("L3MO","seen",  able); // L3 Magnet
763   //gMC->Gsatt("CRT1","seen",  able); // Scintillators
764   gMC->Gsatt("CRT4","seen",  able); // Scintillators barrel
765   
766   // Draw the molasse volumes
767   gMC->Gsatt("CMO1","seen",enable); // Exactly above the HALL
768   gMC->Gsatt("CMO2","seen",enable); // Molasse, along the PM25
769   gMC->Gsatt("CMO3","seen",enable); // molasse along the PGC2
770   gMC->Gsatt("CMO4","seen",enable); // Molasse, behind the PX24 upper part
771   gMC->Gsatt("CMO5","seen",enable); // molasse behind px24, lower part
772   gMC->Gsatt("CMO6","seen",enable); // behind the PX24
773   gMC->Gsatt("CMO7","seen",enable); // behind the PGC2
774   gMC->Gsatt("CMO8","seen",enable); // on the right side.
775   gMC->Gsatt("CMO9","seen",enable); // on the left side.
776   gMC->Gsatt("CM10","seen",enable); // betwen PX24 & PM25.
777   gMC->Gsatt("CM11","seen",enable); // betwen PGC2 & PM25.
778   gMC->Gsatt("CM12","seen",enable); // box above the hall.
779   
780   gMC->Gdopt("hide", "on");
781   gMC->Gdopt("edge","off");
782   gMC->Gdopt("shad", "on");
783   gMC->Gsatt("*", "fill", 7);
784   gMC->SetClipBox("ALIC", 0, 3000, -3000, 3000, -6000, 6000);
785   gMC->DefaultRange();
786   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .009, .009);
787   gMC->Gdhead(1111, "View of CRT(ACORDE)");
788   gMC->Gdman(18, 4, "MAN");
789   
790   
791 }
792
793 //_____________________________________________________________________________
794 void AliCRTv1::Init()
795 {
796   //
797   // Initialise L3 magnet after it has been built
798   Int_t i;
799   //
800   if(fDebug) {
801     printf("\n%s: ",ClassName());
802     for(i=0;i<35;i++) printf("*");
803     printf(" CRTv1_INIT ");
804     for(i=0;i<35;i++) printf("*");
805     printf("\n%s: ",ClassName());
806     //
807     // Here the CRTv1 initialisation code (if any!)
808     for(i=0;i<80;i++) printf("*");
809     printf("\n");
810   }
811
812 }
813
814 //____________________________________________________________________________
815 void AliCRTv1::StepManager()
816 {
817   //
818   // Called for every step in the Cosmic Ray Trigger
819   //
820   static Int_t   vol[5];
821   Int_t          ipart;
822   TLorentzVector pos;
823   TLorentzVector mom;
824
825   static Float_t hits[14];
826   static Float_t eloss;
827   static Float_t elossMag;
828
829   if ( !gMC->IsTrackAlive() ) return;
830
831   if (gMC->IsNewTrack()) {
832     // Reset the deposited energy
833     eloss = 0.;
834     elossMag = 0.;
835   }
836
837   // Add th energy loss in each step.
838   eloss += gMC->Edep();
839
840   gMC->TrackPosition(pos);
841
842   //
843   // CRT
844   //
845
846   if ( gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"CRT4") == 0)
847        &&(gMC->TrackPid() == kMuonMinus || gMC->TrackPid() == kMuonPlus) ) {
848     
849     // Get current particle id(ipart),track position (pos) and momentum (mom)
850     gMC->TrackPosition(pos);
851     gMC->TrackMomentum(mom);
852     ipart = gMC->TrackPid();
853     
854     vol[0] = 1;
855     vol[1] = 0;
856     vol[2] = 0;
857     vol[3] = 0;
858     vol[4] = 0;
859
860     ipart = gMC->TrackPid();
861     hits[0]  = (Float_t)ipart; //                 (fId)
862     
863     hits[1]  = pos[0]; // X coordinate (fX)
864     hits[2]  = pos[1]; // Y coordinate (fY)
865     hits[3]  = pos[2]; // Z coordinate (fZ)
866     hits[4]  = mom[0]; // Px           (fpxug)
867     hits[5]  = mom[1]; // Py           (fpyug)
868     hits[6]  = mom[2]; // Pz           (fpzug)
869     
870     hits[7]  = gMC->GetMedium();  //layer(flay)
871     hits[8] = eloss;              // Energy loss
872     
873     hits[9] = 1; // CRT mother activated.
874     hits[10] = 0;
875     hits[11] = 0;
876     hits[12] = 0;
877     hits[13] = 0;
878
879     //hits[9] = gAlice->GetCurrentTrackNumber();
880     
881     AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
882     
883     eloss = 0.;
884
885   } else if (gMC->IsTrackEntering()&&(strcmp(gMC->CurrentVolName(),"CRT1")==0)
886              &&(gMC->TrackPid()==kMuonMinus || gMC->TrackPid()==kMuonPlus)) {
887     
888     vol[0] = 0;
889     vol[1] = 1;
890     vol[2] = 0;
891     vol[3] = 0;
892     vol[4] = 0;
893
894     hits[9] = 0; // CRT mother activated.
895     hits[10] = 1;
896     hits[11] = 0;
897     hits[12] = 0;
898     hits[13] = 0;
899
900     //hits[10] = 1;
901     
902     //AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
903     
904     //eloss = 0.;
905
906
907   } else if (gMC->IsTrackEntering()&&(strcmp(gMC->CurrentVolName(),"C3CI")==0)
908       &&(gMC->TrackPid()==kMuonMinus || gMC->TrackPid()==kMuonPlus)) {
909
910     //
911     // Inside the magnet, upper part.
912     //
913   
914     // Get current particle id(ipart),track position (pos) and momentum (mom)
915
916     vol[0] = 0;
917     vol[1] = 0;
918     vol[2] = 1;
919     vol[3] = 0;
920     vol[4] = 0;
921
922     hits[9] = 0; // CRT mother activated.
923     hits[10] = 0;
924     hits[11] = 1;
925     hits[12] = 0;
926     hits[13] = 0;
927       
928     AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
929     
930     //eloss = 0.;
931
932   } else if ( gMC->IsTrackEntering()&&(strcmp(gMC->CurrentVolName(),"CRIC")==0)
933        && (gMC->TrackPid()==kMuonMinus || gMC->TrackPid()==kMuonPlus) ) {
934
935     //
936     // HMPID
937     //
938     
939     // Get current particle id(ipart),track position (pos) and momentum (mom)
940
941     vol[0] = 0;
942     vol[1] = 0;
943     vol[2] = 0;
944     vol[3] = 1;
945     vol[4] = 0;
946
947     hits[9] = 0;
948     hits[10] = 0;
949     hits[11] = 0;
950     hits[12] = 1;
951     hits[13] = 0;
952     
953     AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
954     
955     //eloss = 0.;
956
957
958   } else if (gMC->IsTrackEntering()&&(strcmp(gMC->CurrentVolName(),"CSA1")==0)
959              &&(gMC->TrackPid()==kMuonMinus || gMC->TrackPid()==kMuonPlus)) {
960
961     //
962     // TPC
963     //
964     
965     // Get current particle id(ipart),track position (pos) and momentum (mom)
966     
967     vol[0] = 0;
968     vol[1] = 0;
969     vol[2] = 0;
970     vol[3] = 0;
971     vol[4] = 1;
972
973     hits[9] = 0;
974     hits[10] = 0;
975     hits[11] = 0;
976     hits[12] = 0;
977     hits[13] = 1;
978
979     
980     AddHit(gAlice->GetCurrentTrackNumber(),vol, hits);
981     
982     //eloss = 0.;
983
984   } else {
985     return;
986   }
987
988
989 }