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