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