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