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