]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv5T0.cxx
Adding a comment.
[u/mrichter/AliRoot.git] / TOF / AliTOFv5T0.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  2006/02/27 18:12:14  decaro
19 Remove in StepManager the dependence of hit indexes from parametrized TOF position
20
21 Revision 1.1  2005/12/15 08:55:33  decaro
22 New TOF geometry description (V5) -G. Cara Romeo and A. De Caro
23
24
25 Revision 0.1 2004 November G. Cara Romeo and A. De Caro
26         Implement new TOF geometry version
27         in order to
28            suppress few volume overlaps
29                 (in the 4th TOF geometry version),
30            insert the realistic strip numbers and positions
31
32 */
33
34 ///////////////////////////////////////////////////////////////////////////////
35 //                                                                           //
36 //  This class contains the functions for version 5 of the Time Of Flight    //
37 //  detector.                                                                //
38 //                                                                           //
39 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
40 //                                                                           //
41 //  FULL COVERAGE VERSION + OPTION for PHOS holes                            //
42 //                                                                           //
43 //                                                                           //
44 //Begin_Html                                                                 //
45 /*                                                                           //
46 <img src="picts/AliTOFv5T0Class.gif">                                        //
47 */                                                                           //
48 //End_Html                                                                   //
49 //                                                                           //
50 ///////////////////////////////////////////////////////////////////////////////
51
52 #include "Riostream.h"
53 #include <stdlib.h>
54
55 #include "TVirtualMC.h"
56 #include <TBRIK.h>
57 #include <TGeometry.h>
58 #include <TLorentzVector.h>
59 #include <TNode.h>
60 #include <TObject.h>
61 #include <TVirtualMC.h>
62
63 #include "AliLog.h"
64 #include "AliConst.h"
65 #include "AliRun.h"
66 #include "AliMC.h"
67 #include "AliMagF.h"
68
69 #include "AliTOFGeometry.h"
70 #include "AliTOFGeometryV5.h"
71 #include "AliTOFv5T0.h"
72
73 ClassImp(AliTOFv5T0)
74
75 //_____________________________________________________________________________
76 AliTOFv5T0::AliTOFv5T0()
77 {
78   //
79   // Default constructor
80   //
81 }
82  
83 //_____________________________________________________________________________
84 AliTOFv5T0::AliTOFv5T0(const char *name, const char *title)
85         : AliTOF(name,title,"tzero")
86 {
87   //
88   // Standard constructor
89   //
90   //
91   // Check that FRAME is there otherwise we have no place where to
92   // put TOF
93
94
95   AliModule* frame=gAlice->GetModule("FRAME");
96   if(!frame) {
97     AliFatal("TOF needs FRAME to be present");
98   } else{
99     
100     if (fTOFGeometry) delete fTOFGeometry;
101     fTOFGeometry = new AliTOFGeometryV5();
102
103     if(frame->IsVersion()==1) {
104       AliInfo(Form("Frame version %d", frame->IsVersion())); 
105       AliInfo("Full Coverage for TOF");
106       fTOFHoles=false;}    
107     else {
108       AliInfo(Form("Frame version %d", frame->IsVersion())); 
109       AliInfo("TOF with Holes for PHOS");
110       fTOFHoles=true;}      
111   }
112   fTOFGeometry->SetHoles(fTOFHoles);
113
114   //AliTOF::fTOFGeometry = fTOFGeometry;
115
116   // Save the geometry
117   TDirectory* saveDir = gDirectory;
118   gAlice->GetRunLoader()->CdGAFile();
119   fTOFGeometry->Write("TOFgeometry");
120   saveDir->cd();
121
122
123
124 //____________________________________________________________________________
125 void AliTOFv5T0::BuildGeometry()
126 {
127   //
128   // Build TOF ROOT geometry for the ALICE event display
129   //
130   TNode *node, *top;
131   const int kColorTOF  = 27;
132   
133   // Find top TNODE
134   top = gAlice->GetGeometry()->GetNode("alice");
135   
136   // Position the different copies
137   const Float_t krTof  =(fTOFGeometry->Rmax()+fTOFGeometry->Rmin())/2.;
138   const Float_t khTof  = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
139   const Int_t   kNTof  = fTOFGeometry->NSectors();
140   const Float_t kangle = k2PI/kNTof;
141
142   const Float_t kInterCentrModBorder1 = 49.5;
143   const Float_t kInterCentrModBorder2 = 57.5;
144
145   Float_t ang;
146   
147   // define offset for nodes
148   Float_t zOffsetB = (fTOFGeometry->ZlenA()*0.5 + (kInterCentrModBorder1+kInterCentrModBorder2)*0.5)*0.5;
149   Float_t zOffsetA = 0.;
150   // Define TOF basic volume
151   
152   char nodeName0[7], nodeName1[7], nodeName2[7];
153   char nodeName3[7], nodeName4[7], rotMatNum[7];
154
155   if (fTOFHoles) {
156     new TBRIK("S_TOF_B","TOF box","void",
157               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
158     new TBRIK("S_TOF_C","TOF box","void",
159               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
160   }
161   new TBRIK("S_TOF_A","TOF box","void",
162             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenA()*0.5);
163   
164   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
165     
166     if (nodeNum<10) {
167       sprintf(rotMatNum,"rot50%i",nodeNum);
168       sprintf(nodeName0,"FTO00%i",nodeNum);
169       sprintf(nodeName1,"FTO10%i",nodeNum);
170       sprintf(nodeName2,"FTO20%i",nodeNum);
171       sprintf(nodeName3,"FTO30%i",nodeNum);
172       sprintf(nodeName4,"FTO40%i",nodeNum);
173     }
174     if (nodeNum>9) {
175       sprintf(rotMatNum,"rot5%i",nodeNum);
176       sprintf(nodeName0,"FTO0%i",nodeNum);
177       sprintf(nodeName1,"FTO1%i",nodeNum);
178       sprintf(nodeName2,"FTO2%i",nodeNum);
179       sprintf(nodeName3,"FTO3%i",nodeNum);
180       sprintf(nodeName4,"FTO4%i",nodeNum);
181     }
182     
183     new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
184     ang = (4.5-nodeNum) * kangle;
185
186     if (fTOFHoles) {   
187       top->cd();
188       node = new TNode(nodeName2,nodeName2,"S_TOF_B", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetB,rotMatNum);
189       node->SetLineColor(kColorTOF);
190       fNodes->Add(node);
191       
192       top->cd();
193       node = new TNode(nodeName3,nodeName3,"S_TOF_C", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang),-zOffsetB,rotMatNum);
194       node->SetLineColor(kColorTOF);
195       fNodes->Add(node);
196     }
197
198     top->cd();
199     node = new TNode(nodeName4,nodeName4,"S_TOF_A", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetA,rotMatNum);
200     node->SetLineColor(kColorTOF);
201     fNodes->Add(node);
202   } // end loop on nodeNum
203
204 }
205
206 //_____________________________________________________________________________
207 void AliTOFv5T0::CreateGeometry()
208 {
209   //
210   // Create geometry for Time Of Flight version 0
211   //
212   //Begin_Html
213   /*
214     <img src="picts/AliTOFv5T0.gif">
215   */
216   //End_Html
217   //
218   // Creates common geometry
219   //
220   AliTOF::CreateGeometry();
221 }
222  
223
224 //_____________________________________________________________________________
225 void AliTOFv5T0::TOFpc(Float_t xtof,  Float_t ytof, Float_t zlenA,
226                        Float_t zlenB)
227 {
228
229   const Float_t kPi = TMath::Pi();
230
231   const Float_t kInterCentrModBorder1 = 49.5;
232   const Float_t kInterCentrModBorder2 = 57.5;
233   const Float_t kExterInterModBorder1 = 196.0;
234   const Float_t kExterInterModBorder2 = 203.5;
235
236   const Float_t kLengthExInModBorder  = 4.7;
237   const Float_t kLengthInCeModBorder  = 7.0;
238
239   const Float_t khAlWall = 0.1;
240
241   // module wall thickness
242   const Float_t kModuleWallThickness = 0.3;
243
244   //  1.5 cm Al honeycomb layer between strips and cards
245   const Float_t kHoneycombLayerThickness = 1.5;
246
247   AliDebug(2,Form("zlenA*0.5 = %d", zlenA*0.5));
248   AliDebug(1, "************************* TOF geometry **************************");
249   
250   // Definition of the Time Of Fligh Resistive Plate Chambers
251   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
252   
253   Float_t  ycoor, zcoor;
254   Float_t  par[3];
255   Int_t    *idtmed = fIdtmed->GetArray()-499;
256   Int_t    idrotm[100];
257
258   par[0] =  xtof * 0.5;
259   par[1] =  ytof * 0.5;
260   par[2] = zlenA * 0.5;
261   gMC->Gsvolu("FTOA", "BOX ", idtmed[503], par, 3);  // fibre glass
262   
263   if (fTOFHoles) {
264     par[2] = (zlenA*0.5 - kInterCentrModBorder1)*0.5;
265     gMC->Gsvolu("FTOB", "BOX ", idtmed[503], par, 3);
266     gMC->Gsvolu("FTOC", "BOX ", idtmed[503], par, 3);
267   }
268
269   // Positioning of modules
270   
271   //AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,-90.);
272   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,270.); // adc
273
274   Float_t zcor3 = 0.;
275
276   gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
277   gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
278   
279   if (fTOFHoles) {
280     zcor3 = (zlenA*0.5 + kInterCentrModBorder1)*0.5;
281     gMC->Gspos("FTOB", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
282     gMC->Gspos("FTOC", 0, "BTO2", 0,-zcor3,  0, idrotm[0], "ONLY");
283   }
284   else gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
285
286   // Large not sensitive volumes with Insensitive Freon  (FLTA, FLTB and FLTC)
287
288   Float_t xFLT, yFLT, zFLTA;
289   
290   xFLT  = xtof  - kModuleWallThickness*2.;
291   yFLT  = ytof  - kModuleWallThickness*2.;
292   zFLTA = zlenA - kModuleWallThickness*2.;
293   
294   par[0] = xFLT*0.5;
295   par[1] = yFLT*0.5;
296
297   par[2] = zFLTA*0.5;
298   gMC->Gsvolu("FLTA", "BOX ", idtmed[507], par, 3); //  Freon mix     ok
299   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
300
301   if (fTOFHoles) {
302     par[2] = (zlenA*0.5 - kInterCentrModBorder1-kModuleWallThickness)*0.5;
303     gMC->Gsvolu("FLTB", "BOX ", idtmed[507], par, 3); // Freon mix
304     gMC->Gspos ("FLTB", 0, "FTOB", 0., 0.,  kModuleWallThickness*0.5, 0, "ONLY");
305     gMC->Gsvolu("FLTC", "BOX ", idtmed[507], par, 3); // Freon mix
306     gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., -kModuleWallThickness*0.5, 0, "ONLY");
307   }
308
309   // Layer of Aluminum after detector
310   //par[0] = xFLT*0.5;
311   par[1] = khAlWall*0.5;
312
313   par[2] = zFLTA *0.5;
314   ycoor = (-yFLT + khAlWall)*0.5;
315   gMC->Gsvolu("FALA", "BOX ", idtmed[505], par, 3); // Alluminium     ok
316   gMC->Gspos ("FALA", 0, "FLTA", 0., -ycoor, 0., 0, "ONLY");
317
318   if (fTOFHoles) {
319     par[2] = (zlenA*0.5 - kInterCentrModBorder2-kModuleWallThickness)*0.5;
320     gMC->Gsvolu("FALB", "BOX ", idtmed[505], par, 3); // Alluminium
321     gMC->Gspos ("FALB", 1, "FLTB", 0.,-ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
322     gMC->Gspos ("FALB", 2, "FLTC", 0.,-ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
323   }
324
325   Float_t y0, alpha, beta, tgbe, trpa[11], dy, zcoo;
326   dy  = yFLT*0.5;
327
328   // wall between central and intermediate modules
329   y0    = kLengthInCeModBorder;
330   zcoor = kInterCentrModBorder1;
331   zcoo  = kInterCentrModBorder2;
332   alpha = TMath::ATan((dy-2.*y0)/(zcoo-zcoor));
333   beta = (kPi*0.5-alpha)*0.5;
334   tgbe = TMath::Tan(beta);
335   trpa[0]  = xFLT*0.5;//par[0];
336   trpa[1]  = 0.;
337   trpa[2]  = 0.;
338   trpa[3]  = kModuleWallThickness;
339   trpa[4]  = (y0-kModuleWallThickness*tgbe)*0.5;
340   trpa[5]  = (y0+kModuleWallThickness*tgbe)*0.5;
341   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
342   trpa[7]  = kModuleWallThickness;
343   trpa[8]  = (y0-kModuleWallThickness*tgbe)*0.5;
344   trpa[9]  = (y0+kModuleWallThickness*tgbe)*0.5;
345   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
346
347   gMC->Gsvolu("FWZ1","TRAP", idtmed[503], trpa, 11);   // fibre glass
348
349   AliMatrix (idrotm[1],90., 90.,180.,0.,90.,180.);
350   ycoor = -dy + y0*0.5;
351   gMC->Gspos("FWZ1", 1,"FLTA",0.,ycoor, zcoor,idrotm[1],"ONLY");
352
353   AliMatrix (idrotm[4],90., 90.,  0.,0.,90.,  0.);
354   gMC->Gspos("FWZ1", 2,"FLTA",0.,ycoor,-zcoor,idrotm[4],"ONLY");
355
356   if (fTOFHoles) {
357     Float_t y0B = y0 - kModuleWallThickness*0.5*tgbe;
358     Float_t ycoorB = ycoor - kModuleWallThickness*0.25/tgbe;
359     trpa[0]  = xFLT*0.5;//par[0];
360     trpa[1]  = 0.;
361     trpa[2]  = 0.;
362     trpa[3]  = kModuleWallThickness*0.5;
363     trpa[4]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
364     trpa[5]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
365     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
366     trpa[7]  = kModuleWallThickness*0.5;
367     trpa[8]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
368     trpa[9]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
369     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
370     gMC->Gsvolu("FZ1B","TRAP", idtmed[503], trpa, 11);   // fibre glass
371     gMC->Gspos("FZ1B", 5,"FLTB",0.,ycoorB,-zcoor+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[4],"ONLY");
372     gMC->Gspos("FZ1B", 6,"FLTC",0.,ycoorB,+zcoor-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[1],"ONLY");
373   }
374
375   AliMatrix (idrotm[2],90.,270.,  0.,0.,90.,180.);
376   ycoor = -y0*0.5;
377   gMC->Gspos("FWZ1", 3,"FLTA",0.,ycoor, zcoo,idrotm[2],"ONLY");
378   AliMatrix (idrotm[5],90.,270.,180.,0.,90.,  0.);
379   gMC->Gspos("FWZ1", 4,"FLTA",0.,ycoor,-zcoo,idrotm[5],"ONLY");
380
381   if (fTOFHoles) {
382     Float_t y0B = y0 + kModuleWallThickness*0.5*tgbe;
383     Float_t ycoorB = ycoor - kModuleWallThickness*0.25/tgbe;
384     trpa[0]  = xFLT*0.5;//par[0];
385     trpa[1]  = 0.;
386     trpa[2]  = 0.;
387     trpa[3]  = kModuleWallThickness*0.5;
388     trpa[4]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
389     trpa[5]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
390     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
391     trpa[7]  = kModuleWallThickness*0.5;
392     trpa[8]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
393     trpa[9]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
394     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
395     gMC->Gsvolu("FZ1C","TRAP", idtmed[503], trpa, 11);   // fibre glass
396     gMC->Gspos("FZ1C", 7,"FLTB",0.,ycoorB,-zcoo+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[5],"ONLY");
397     gMC->Gspos("FZ1C", 8,"FLTC",0.,ycoorB, zcoo-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[2],"ONLY");
398   }
399
400   trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
401   trpa[1] = kModuleWallThickness;
402   trpa[2] = xFLT*0.5;//par[0];
403   trpa[3] = -beta*kRaddeg;
404   trpa[4] = 0.;
405   trpa[5] = 0.;
406   gMC->Gsvolu("FWZ2","PARA", idtmed[503], trpa, 6);    // fibre glass
407   AliMatrix (idrotm[3],     alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
408   gMC->Gspos("FWZ2", 1,"FLTA",0.,-dy*0.5, (zcoo+zcoor)*0.5,idrotm[3],"ONLY");
409   AliMatrix (idrotm[6],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,  0.);
410   gMC->Gspos("FWZ2", 2,"FLTA",0.,-dy*0.5,-(zcoo+zcoor)*0.5,idrotm[6],"ONLY");
411
412   if (fTOFHoles) {
413     trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
414     trpa[1] = kModuleWallThickness*0.5;
415     trpa[2] = xFLT*0.5;//par[0];
416     trpa[3] = -beta*kRaddeg;
417     trpa[4] = 0.;
418     trpa[5] = 0.;
419     gMC->Gsvolu("FZ2B","PARA", idtmed[503], trpa, 6);    // fibre glass
420     gMC->Gspos("FZ2B", 3,"FLTB",0.,-dy*0.5-kModuleWallThickness*0.5/tgbe,-(zcoo+zcoor)*0.5+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[6],"ONLY");
421     gMC->Gspos("FZ2B", 4,"FLTC",0.,-dy*0.5-kModuleWallThickness*0.5/tgbe,+(zcoo+zcoor)*0.5-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[3],"ONLY");
422   }
423
424   // wall between intermediate and lateral modules
425   y0    = kLengthExInModBorder;//4.7;
426   zcoor = kExterInterModBorder1;//196.;
427   zcoo  = kExterInterModBorder2;//203.5;
428   alpha = TMath::ATan((dy-2.*y0)/(zcoo-zcoor));
429   beta = (kPi*0.5-alpha)*0.5;
430   tgbe = TMath::Tan(beta);
431   trpa[0]  = xFLT*0.5;//par[0];
432   trpa[1]  = 0.;
433   trpa[2]  = 0.;
434   trpa[3]  = kModuleWallThickness;
435   trpa[4]  = (y0-kModuleWallThickness*tgbe)*0.5;
436   trpa[5]  = (y0+kModuleWallThickness*tgbe)*0.5;
437   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
438   trpa[7]  = kModuleWallThickness;
439   trpa[8]  = (y0-kModuleWallThickness*tgbe)*0.5;
440   trpa[9]  = (y0+kModuleWallThickness*tgbe)*0.5;
441   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
442   gMC->Gsvolu("FWZ3","TRAP", idtmed[503], trpa, 11);    // fibre glass
443   ycoor = -y0*0.5;
444   gMC->Gspos("FWZ3", 1,"FLTA",0.,ycoor, zcoor,idrotm[5],"ONLY");
445   gMC->Gspos("FWZ3", 2,"FLTA",0.,ycoor,-zcoor,idrotm[2],"ONLY");
446
447   if (fTOFHoles) {
448     gMC->Gspos("FWZ3", 5,"FLTB",0.,ycoor,-zcoor+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[2],"ONLY");
449     gMC->Gspos("FWZ3", 6,"FLTC",0.,ycoor, zcoor-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[5],"ONLY");
450   }
451   ycoor = -dy+y0*0.5;
452   gMC->Gspos("FWZ3", 3,"FLTA",0.,ycoor, zcoo,idrotm[4],"ONLY");
453   gMC->Gspos("FWZ3", 4,"FLTA",0.,ycoor,-zcoo,idrotm[1],"ONLY");
454
455   if (fTOFHoles) {
456     gMC->Gspos("FWZ3", 7,"FLTB",0.,ycoor,-zcoo+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[1],"ONLY");
457     gMC->Gspos("FWZ3", 8,"FLTC",0.,ycoor, zcoo-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[4],"ONLY");
458   }
459
460   trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
461   trpa[1] = kModuleWallThickness;
462   trpa[2] = xFLT*0.5;//par[0];
463   trpa[3] = -beta*kRaddeg;
464   trpa[4] = 0.;
465   trpa[5] = 0.;
466   gMC->Gsvolu("FWZ4","PARA", idtmed[503], trpa, 6);    // fibre glass
467   AliMatrix (idrotm[3],alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
468   AliMatrix (idrotm[6],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,0.);
469   gMC->Gspos("FWZ4", 1,"FLTA",0.,-dy*0.5, (zcoo+zcoor)*0.5,idrotm[6],"ONLY");
470   gMC->Gspos("FWZ4", 2,"FLTA",0.,-dy*0.5,-(zcoo+zcoor)*0.5,idrotm[3],"ONLY");
471
472   if (fTOFHoles) {
473     gMC->Gspos("FWZ4", 3,"FLTB",0.,-dy*0.5,-(zcoo+zcoor)*0.5+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[3],"ONLY");
474     gMC->Gspos("FWZ4", 4,"FLTC",0.,-dy*0.5, (zcoo+zcoor)*0.5-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[6],"ONLY");
475   }
476
477   ///////////////// Detector itself //////////////////////
478
479   const Int_t    knx   = fTOFGeometry->NpadX();  // number of pads along x
480   const Int_t    knz   = fTOFGeometry->NpadZ();  // number of pads along z
481   const Float_t  kPadX = fTOFGeometry->XPad();   // pad length along x
482   const Float_t  kPadZ = fTOFGeometry->ZPad();   // pad length along z
483
484   // new description for strip volume -double stack strip-
485   // -- all constants are expressed in cm
486   // heigth of different layers
487   const Float_t khhony   = 1.0    ;   // heigth of HONY  Layer
488   const Float_t khpcby   = 0.08   ;   // heigth of PCB   Layer
489   const Float_t khrgly   = 0.055  ;   // heigth of RED GLASS  Layer
490   const Float_t khglfy   = 0.285  ;   // heigth of GLASS+FISHLINE  Layer
491   const Float_t khcpcby  = 0.16   ;   // heigth of PCB  Central Layer
492   const Float_t kwhonz   = 8.1    ;   // z dimension of HONEY  Layer
493   const Float_t kwpcbz1  = 10.6   ;   // z dimension of PCB  Lower Layer
494   const Float_t kwpcbz2  = 11.6   ;   // z dimension of PCB  Upper Layer
495   const Float_t kwcpcbz  = 12.4   ;   // z dimension of PCB  Central Layer
496   const Float_t kwrglz   = 8.     ;   // z dimension of RED GLASS  Layer
497   const Float_t kwglfz   = 7.     ;   // z dimension of GLASS+FISHLN Layer
498   const Float_t klsensmx = knx*kPadX; // length of Sensitive Layer
499   const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer // ADC
500   const Float_t kwsensmz = knz*kPadZ; // width of Sensitive Layer
501   
502   // heigth of the FSTR Volume (the strip volume)
503   const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;
504
505   // width  of the FSTR Volume (the strip volume)
506   const Float_t kwstripz = kwcpcbz;
507   // length of the FSTR Volume (the strip volume)
508   const Float_t klstripx = fTOFGeometry->StripLength();//122.;
509   
510   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
511   // Coordinates of the strip center in the strip reference frame;
512   // used for positioning internal strip volumes
513   Float_t posfp[3]={0.,0.,0.};  
514
515   // FSTR volume definition-filling this volume with non sensitive Gas Mixture
516   gMC->Gsvolu("FSTR","BOX",idtmed[507],parfp,3);     // Freon mix
517
518   //-- HONY Layer definition
519   parfp[1] = khhony*0.5;
520   parfp[2] = kwhonz*0.5;
521   gMC->Gsvolu("FHON","BOX",idtmed[501],parfp,3);     // honeycomb (Nomex)
522   // positioning 2 HONY Layers on FSTR volume
523   posfp[1] =-khstripy*0.5+parfp[1];
524   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
525   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
526   
527   //-- PCB Layer definition
528   parfp[1] = khpcby*0.5;
529   parfp[2] = kwpcbz1*0.5;
530   gMC->Gsvolu("FPC1","BOX",idtmed[502],parfp,3);     // G10
531   parfp[2] = kwpcbz2*0.5;
532   gMC->Gsvolu("FPC2","BOX",idtmed[502],parfp,3);     // G10
533   // positioning 2 PCB Layers on FSTR volume
534   posfp[1] =-khstripy*0.5+khhony+parfp[1];
535   gMC->Gspos("FPC1",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
536   gMC->Gspos("FPC2",1,"FSTR",0., posfp[1],0.,0,"ONLY");
537
538   //-- central PCB layer definition
539   parfp[1] = khcpcby*0.5;
540   parfp[2] = kwcpcbz*0.5;
541   gMC->Gsvolu("FPCB","BOX",idtmed[502],parfp,3);     // G10
542   // positioning the central PCB layer
543   gMC->Gspos("FPCB",1,"FSTR",0.,0.,0.,0,"ONLY");
544   
545   //      Sensitive volume
546   Float_t parfs[3] = {klsensmx*0.5, khsensmy*0.5, kwsensmz*0.5};
547   gMC->Gsvolu("FSEN","BOX",idtmed[508],parfs,3);     // sensitive ...
548   // dividing FSEN along z in knz=2 and along x in knx=48
549   gMC->Gsdvn("FSEZ","FSEN",knz,3);
550   gMC->Gsdvn("FPAD","FSEZ",knx,1);
551   // positioning a Sensitive layer inside FPCB
552   gMC->Gspos("FSEN",1,"FPCB",0.,0.,0.,0,"ONLY");
553
554   //-- RED GLASS Layer definition
555   parfp[1] = khrgly*0.5;
556   parfp[2] = kwrglz*0.5;
557   gMC->Gsvolu("FRGL","BOX",idtmed[509],parfp,3);     // glass
558   // positioning 4 RED GLASS Layers on FSTR volume
559   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
560   gMC->Gspos("FRGL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
561   gMC->Gspos("FRGL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
562   posfp[1] = (khcpcby+khrgly)*0.5;
563   gMC->Gspos("FRGL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
564   gMC->Gspos("FRGL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
565
566   //-- GLASS+FISHLINE Layer definition
567   parfp[1] = khglfy*0.5;
568   parfp[2] = kwglfz*0.5;
569   gMC->Gsvolu("FGLF","BOX",idtmed[504],parfp,3);
570
571   // positioning 2 GLASS+FISHLINE Layers on FSTR volume
572   posfp[1] = (khcpcby+khglfy)*0.5+khrgly;
573   gMC->Gspos("FGLF",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
574   gMC->Gspos("FGLF",2,"FSTR",0., posfp[1],0.,0,"ONLY");
575
576
577   //  Positioning the Strips  (FSTR) in the FLT volumes
578   Int_t maxStripNumbers [5] ={fTOFGeometry->NStripC(),
579                               fTOFGeometry->NStripB(),
580                               fTOFGeometry->NStripA(),
581                               fTOFGeometry->NStripB(),
582                               fTOFGeometry->NStripC()};
583
584   Int_t totalStrip = 0;
585   Float_t zpos, ypos, ang;
586   for(Int_t iplate =0; iplate < fTOFGeometry->NPlates(); iplate++){
587     if (iplate>0) totalStrip += maxStripNumbers[iplate-1];
588     for(Int_t istrip =0; istrip < maxStripNumbers[iplate]; istrip++){
589
590       ang = fTOFGeometry->GetAngles(iplate,istrip);
591       AliDebug(1, Form(" iplate = %1i, istrip = %2i ---> ang = %f", iplate, istrip, ang));
592  
593       if (ang>0.)       AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90., ang, 90.);
594       else if (ang==0.) AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.,90., 0., 0.);
595       else if (ang<0.)  AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90.,-ang,270.);
596
597
598       zpos = fTOFGeometry->GetDistances(iplate,istrip);
599       ypos = fTOFGeometry->GetHeights(iplate,istrip);
600
601       gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTA",0.,ypos,-zpos,idrotm[istrip+totalStrip+1],  "ONLY");
602
603       if (fTOFHoles) {
604         if (istrip+totalStrip+1>53) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTC",0.,ypos,-zpos-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
605         if (istrip+totalStrip+1<39) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTB",0.,ypos,-zpos+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
606       }
607     }
608   }
609
610   //  1.5 cm Al honeycomb layer between strips and cards
611   par[0] = xFLT*0.5;
612   par[1] = kHoneycombLayerThickness*0.5;
613   par[2] = zFLTA*0.5;
614   ycoor  = kHoneycombLayerThickness*0.5;
615   gMC->Gsvolu("FPEA", "BOX ", idtmed[506], par, 3);   // Al honeycomb ok giovanni cara romeo
616   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
617
618   if (fTOFHoles) {
619     par[2] = (zlenA*0.5 - kInterCentrModBorder2-kModuleWallThickness)*0.5;
620     ycoor = kHoneycombLayerThickness*0.5;
621     gMC->Gsvolu("FPEB", "BOX ", idtmed[506], par, 3);   // Al honeycomb ok giovanni cara romeo
622     gMC->Gspos ("FPEB", 1, "FLTB", 0., ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
623     gMC->Gspos ("FPEB", 2, "FLTC", 0., ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
624   }
625
626   // frame of Air
627   ycoor += kHoneycombLayerThickness*0.5;
628   //par[0] = xFLT*0.5;
629   par[1] = (yFLT*0.5-kHoneycombLayerThickness-khAlWall)*0.5;
630   par[2] = zFLTA *0.5;
631   ycoor += (yFLT*0.5-kHoneycombLayerThickness-khAlWall)*0.5;
632   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
633   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
634
635   if (fTOFHoles) {
636     par[2] = (zlenA*0.5 - kInterCentrModBorder2 - kModuleWallThickness)*0.5;
637     gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
638     gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
639     gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
640     gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
641   }
642
643   // start with cards and cooling tubes
644   // finally, cards, cooling tubes and layer for thermal dispersion
645   // 3 volumes
646   
647   // see GEOM200 in GEANT manual
648
649   //AliMatrix(idrotm[98], 90., 0., 90., 90., 0., 0.); // 0 deg
650   
651   Float_t cardpar[3];
652
653   // card volume definition
654   cardpar[0]= xFLT*0.5;
655   cardpar[1]= 5.;
656   cardpar[2]= 0.1;
657   gMC->Gsvolu("FCAR", "BOX ", idtmed[502], cardpar, 3); // PCB Card 
658
659   //alu plate volume definition
660   cardpar[1]= 3.5;
661   cardpar[2]= 0.05;
662   gMC->Gsvolu("FALP", "BOX ", idtmed[505], cardpar, 3); // Alu Plate
663
664   // tube volume definition
665   Float_t tubepar[3];
666   tubepar[0]= 0.;
667   tubepar[1]= 0.4;
668   tubepar[2]= 61.;
669   gMC->Gsvolu("FTUB", "TUBE", idtmed[511], tubepar, 3); // cooling tubes (steel)
670
671   //tubepar[0]= 0.;
672   tubepar[1]= 0.35;
673   //tubepar[2]= 61.;
674   gMC->Gsvolu("FITU", "TUBE", idtmed[510], tubepar, 3); // cooling water
675   // positioning water tube into the steel one
676   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
677
678   // rotation matrix
679   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
680
681   // central module positioning
682   Float_t cardpos[3], aplpos2;
683   Float_t stepforcardA=6.625;
684   Float_t tdis=0.6;
685   Float_t aplpos1 = -2.;
686
687   cardpos[0]= 0.;
688   cardpos[1]= -0.5;
689   cardpos[2]= -53.;
690   //  tubepos= -53.+tdis;
691   Int_t icard;
692   for (icard=39; icard<54; ++icard) {
693     cardpos[2]= cardpos[2]+stepforcardA;
694     aplpos2 = cardpos[2]+0.15;
695     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],     cardpos[2],         0,"ONLY"); 
696     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],   aplpos1,        aplpos2,         0,"ONLY");
697     gMC->Gspos("FTUB",icard,"FAIA",        0.,cardpos[1],cardpos[2]+tdis,idrotm[99],"ONLY");
698   }
699   
700   // intermediate module positioning
701   Float_t stepforcardB= 7.05;
702   Float_t offs = 53.;
703
704   cardpos[2]= offs;
705   for (icard=20; icard<39; ++icard) {
706     cardpos[2]= cardpos[2]+stepforcardB;
707     aplpos2 = cardpos[2]+0.15;
708
709     gMC->Gspos("FCAR",icard+34,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY");
710     gMC->Gspos("FALP",icard+34,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
711     gMC->Gspos("FTUB",icard+34,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
712     gMC->Gspos("FCAR",58-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
713     gMC->Gspos("FALP",58-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
714     gMC->Gspos("FTUB",58-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
715
716     if (fTOFHoles) {
717       gMC->Gspos("FCAR",icard+34+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
718       gMC->Gspos("FALP",icard+34+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
719       gMC->Gspos("FTUB",icard+34+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
720       gMC->Gspos("FCAR",58-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
721       gMC->Gspos("FALP",58-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
722       gMC->Gspos("FTUB",58-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
723     }
724     
725   }
726
727   // outer module positioning
728   Float_t stepforcardC= 8.45238;
729   offs += zlenB;
730   cardpos[2]= offs;
731   for (icard=1; icard<20; ++icard) {
732     cardpos[2]= cardpos[2]+stepforcardC;
733     aplpos2 = cardpos[2]+0.15;
734
735     gMC->Gspos("FCAR",icard+72,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY"); 
736     gMC->Gspos("FALP",icard+72,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
737     gMC->Gspos("FTUB",icard+72,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
738     gMC->Gspos("FCAR",20-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
739     gMC->Gspos("FALP",20-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
740     gMC->Gspos("FTUB",20-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
741
742     if (fTOFHoles) {
743       gMC->Gspos("FCAR",icard+72+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
744       gMC->Gspos("FALP",icard+72+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
745       gMC->Gspos("FTUB",icard+72+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
746       gMC->Gspos("FCAR",20-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
747       gMC->Gspos("FALP",20-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
748       gMC->Gspos("FTUB",20-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
749     }
750   }
751
752 }
753 //_____________________________________________________________________________
754 void AliTOFv5T0::DrawModule() const
755 {
756   //
757   // Draw a shaded view of the Time Of Flight version 4
758   //
759
760   // Set everything unseen
761   gMC->Gsatt("*", "seen", -1);
762
763   //
764   //Set volumes visible
765   // 
766
767   //Set ALIC mother transparent
768   gMC->Gsatt("ALIC","SEEN", 0);
769
770 //=====> Level 1
771   // Level 1 for TOF volumes
772   gMC->Gsatt("B077","seen", 0);
773
774 //=====> Level 2
775   // Level 2 for TOF volumes
776   gMC->Gsatt("B071","seen", 0);
777   gMC->Gsatt("B074","seen", 0);
778   gMC->Gsatt("B075","seen", 0);
779   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
780   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
781
782   // Level 2 of B071
783   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
784   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
785   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
786   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
787   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
788
789   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
790   gMC->Gsatt("BTO1","seen", 0);
791
792   // Level 2 of B074
793   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
794   gMC->Gsatt("BTO2","seen", 0);
795
796   // Level 2 of B075
797   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
798   gMC->Gsatt("BTO3","seen", 0);
799
800   // Level 3 of B071, B074 and B075
801   gMC->Gsatt("FTOA","SEEN", 0);
802   if (fTOFHoles) gMC->Gsatt("FTOB","SEEN", 0);
803
804   // Level 4 of B071, B074 and B075
805   gMC->Gsatt("FLTA","SEEN", 0);
806   if (fTOFHoles) gMC->Gsatt("FLTB","SEEN",0);
807   if (fTOFHoles) gMC->Gsatt("FLTC","SEEN",0);
808
809   // Level 5 of B071, B074 and B075
810   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
811   if (fTOFHoles) gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
812   if (fTOFHoles) gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
813
814   gMC->Gsatt("FALA","SEEN", 0);
815   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
816
817   gMC->Gsatt("FPEA","SEEN", 1);
818   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 1);
819
820   gMC->Gsatt("FSTR","SEEN",-1);  // all FSTR sub-levels skipped   -
821
822   gMC->Gsatt("FWZ1","SEEN", 0);
823   gMC->Gsatt("FWZ2","SEEN", 0);
824   gMC->Gsatt("FWZ3","SEEN", 0);
825   gMC->Gsatt("FWZ4","SEEN", 0);
826   if (fTOFHoles) {
827     gMC->Gsatt("FZ1B","SEEN", 0);
828     gMC->Gsatt("FZ1C","SEEN", 0);
829     gMC->Gsatt("FZ2B","SEEN", 0);
830   }
831
832   gMC->Gdopt("hide", "on");
833   gMC->Gdopt("shad", "on");
834   gMC->Gsatt("*", "fill", 7);
835   gMC->SetClipBox(".");
836   gMC->SetClipBox("*", 100, 1000, 100, 1000, 100, 1000);
837   gMC->DefaultRange();
838   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
839   gMC->Gdhead(1111, "Time Of Flight");
840   gMC->Gdman(18, 3, "MAN");
841   gMC->Gdopt("hide","off");
842 }
843 //_____________________________________________________________________________
844 void AliTOFv5T0::DrawDetectorModules()
845 {
846   //
847   // Draw a shaded view of the TOF detector version 4
848   //
849  
850   // Set everything unseen
851   gMC->Gsatt("*", "seen", -1);
852
853   //
854   //Set volumes visible
855   // 
856
857   //Set ALIC mother transparent
858   gMC->Gsatt("ALIC","SEEN", 0);
859
860 //=====> Level 1
861   // Level 1 for TOF volumes
862   gMC->Gsatt("B077","seen", 0);
863
864 //=====> Level 2
865   // Level 2 for TOF volumes
866   gMC->Gsatt("B071","seen", 0);
867   gMC->Gsatt("B074","seen", 0);
868   gMC->Gsatt("B075","seen", 0);
869   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
870   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
871
872   // Level 2 of B071
873   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
874   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
875   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
876   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
877   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
878
879   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
880   gMC->Gsatt("BTO1","seen", 0);
881
882   // Level 2 of B074
883   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
884   gMC->Gsatt("BTO2","seen", 0);
885
886   // Level 2 of B075
887   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
888   gMC->Gsatt("BTO3","seen", 0);
889
890   // Level 3 of B071, B075 and B074
891   gMC->Gsatt("FTOA","seen",-2);  // all FTOA sub-levels skipped   -
892   if (fTOFHoles) {
893     gMC->Gsatt("FTOB","seen",-2);  // all FTOB sub-levels skipped   -
894     gMC->Gsatt("FTOC","seen",-2);  // all FTOC sub-levels skipped   -
895   }
896
897   gMC->Gdopt("hide","on");
898   gMC->Gdopt("shad","on");
899   gMC->Gsatt("*", "fill", 5);
900   gMC->SetClipBox(".");
901   gMC->SetClipBox("*", 100, 1000, 100, 1000, 0, 1000);
902   gMC->DefaultRange();
903   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
904   gMC->Gdhead(1111,"TOF detector");
905   gMC->Gdman(18, 3, "MAN");
906   gMC->Gdopt("hide","off");
907 }                                 
908
909 //_____________________________________________________________________________
910 void AliTOFv5T0::DrawDetectorStrips()
911 {
912   //
913   // Draw a shaded view of the TOF strips for version 4
914   //
915
916   // Set everything unseen
917   gMC->Gsatt("*", "seen", -1);
918
919   //
920   //Set volumes visible
921   // 
922   
923   //Set ALIC mother transparent
924   gMC->Gsatt("ALIC","SEEN", 0);
925   
926 //=====> Level 1
927   // Level 1 for TOF volumes
928   gMC->Gsatt("B077","seen", 0);
929
930 //=====> Level 2
931   // Level 2 for TOF volumes
932   gMC->Gsatt("B071","seen", 0);
933   gMC->Gsatt("B074","seen", 0);
934   gMC->Gsatt("B075","seen", 0);
935   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
936   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
937
938   // Level 2 of B071
939   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
940   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
941   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
942   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
943   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
944
945   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
946   gMC->Gsatt("BTO1","seen", 0);
947
948   // Level 2 of B074
949   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
950   gMC->Gsatt("BTO2","seen", 0);
951
952   // Level 2 of B075
953   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
954   gMC->Gsatt("BTO3","seen", 0);
955
956   // Level 3 of B071, B074 and B075
957   gMC->Gsatt("FTOA","SEEN", 0);
958   if (fTOFHoles) {
959     gMC->Gsatt("FTOB","SEEN", 0);
960     gMC->Gsatt("FTOC","SEEN", 0);
961   }
962
963   // Level 4 of B071, B074 and B075
964   gMC->Gsatt("FLTA","SEEN", 0);
965   if (fTOFHoles) {
966     gMC->Gsatt("FLTB","SEEN", 0);
967     gMC->Gsatt("FLTC","SEEN", 0);
968   }
969
970   // Level 5 of B071, B074 and B075
971   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
972   if (fTOFHoles) {
973     gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
974     gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
975   }
976
977   gMC->Gsatt("FALA","SEEN", 0);
978   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
979
980   gMC->Gsatt("FPEA","SEEN", 0);
981   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 0);
982
983   gMC->Gsatt("FSTR","SEEN",-2);  // all FSTR sub-levels skipped   -
984
985   gMC->Gsatt("FWZ1","SEEN", 0);
986   gMC->Gsatt("FWZ2","SEEN", 0);
987   gMC->Gsatt("FWZ3","SEEN", 0);
988   gMC->Gsatt("FWZ4","SEEN", 0);
989   if (fTOFHoles){
990     gMC->Gsatt("FZ1B","SEEN", 0);
991     gMC->Gsatt("FZ1C","SEEN", 0);
992     gMC->Gsatt("FZ2B","SEEN", 0);
993   }
994
995   /*
996   // Level 2 of FAIA
997   // Level 2 of FAIB
998   // Level 2 of FAIC
999   gMC->Gsatt("FALP","SEEN",0);
1000   gMC->Gsatt("FCAR","SEEN",0);
1001   gMC->Gsatt("FTUB","SEEN",-1);  // all FTUB sub-levels skipped   -
1002
1003   // Level 2 of FTUB
1004   gMC->Gsatt("FITU","SEEN",0);
1005   */
1006
1007   /*
1008   // Level 2 of FSTR
1009   gMC->Gsatt("FGLF","SEEN",0);
1010   gMC->Gsatt("FHON","SEEN",0);
1011   gMC->Gsatt("FPC1","SEEN",0);
1012   gMC->Gsatt("FPC2","SEEN",0);
1013   gMC->Gsatt("FPCB","SEEN",0);
1014   gMC->Gsatt("FRGL","SEEN",0);
1015
1016   // Level 2 of FPCB => Level 3 of FSTR
1017   gMC->Gsatt("FSEN","SEEN",0);
1018   gMC->Gsatt("FSEZ","SEEN",0);
1019   gMC->Gsatt("FPAD","SEEN",1);
1020   */
1021
1022   gMC->Gdopt("hide","on");
1023   gMC->Gdopt("shad","on");
1024   gMC->Gsatt("*", "fill", 5);
1025   gMC->SetClipBox(".");
1026   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
1027   gMC->DefaultRange();
1028   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
1029   gMC->Gdhead(1111,"TOF Strips");
1030   gMC->Gdman(18, 3, "MAN");
1031   gMC->Gdopt("hide","off");
1032 }
1033
1034 //_____________________________________________________________________________
1035 void AliTOFv5T0::CreateMaterials()
1036 {
1037   //
1038   // Define materials for the Time Of Flight
1039   //
1040
1041   //AliTOF::CreateMaterials();
1042
1043   Int_t   isxfld = gAlice->Field()->Integ();
1044   Float_t sxmgmx = gAlice->Field()->Max();
1045   Float_t we[7], ae[7], na[7], fr[7], vl[7];
1046   Int_t i;
1047
1048   //
1049   //--- Quartz (SiO2) to simulate float glass
1050   //    density tuned to have correct float glass 
1051   //    radiation length
1052   Float_t   aq[2] = { 28.0855,15.9994 };
1053   Float_t   zq[2] = { 14.,8. };
1054   Float_t   wq[2] = { 1.,2. };
1055   Float_t   dq = 2.55; // std value: 2.2
1056   Int_t nq = -2;
1057
1058   // --- Nomex
1059   Float_t anox[4] = {12.01,1.01,16.00,14.01};
1060   Float_t znox[4] = { 6.,  1.,  8.,  7.};
1061   Float_t wnox[4] = {14., 22., 2., 2.};
1062   Float_t dnox  = 0.048;
1063   Int_t nnox   = -4;
1064
1065   //  { Si, C, H, O }
1066   Float_t ag10[4] = {28.09,12.01,1.01,16.00};
1067   Float_t zg10[4] = {14.,  6.,  1.,  8.};
1068   Float_t wmatg10[4];
1069   Int_t nlmatg10  = 4;
1070   for (i = 0; i < nlmatg10; ++i) {
1071     ae[i] = ag10[i];
1072     vl[i] = 1.;
1073   }
1074   ae[4] = 16.00;
1075   vl[4] = 1.;
1076   na[0] = 1.; 
1077   na[1] = 14.;
1078   na[2] = 20.;
1079   na[3] = 2.;
1080   na[4] = 3.;
1081   fr[0] = 0.6;
1082   fr[1] = 0.4;
1083   fr[2] = 0.4;
1084   fr[3] = 0.6;
1085   fr[4] = 0.4;
1086   MaterialMixer(we,ae,na,fr,vl,5);
1087   we[3] += we[4];
1088   wmatg10[0]= we[0];
1089   wmatg10[1]= we[1];
1090   wmatg10[2]= we[2];
1091   wmatg10[3]= we[3];
1092   Float_t densg10 = 1.7;
1093
1094   // -- Water
1095   Float_t awa[2] = {  1., 16. };
1096   Float_t zwa[2] = {  1.,  8. };
1097   Float_t wwa[2] = {  2.,  1. };
1098   Float_t dwa    = 1.0;
1099   Int_t nwa = -2;
1100
1101   // stainless steel
1102   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
1103   Float_t zsteel[4] = { 26.,24.,28.,14. };
1104   Float_t wsteel[4] = { .715,.18,.1,.005 };
1105
1106   // AIR
1107   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
1108   Float_t zAir[4]={6.,7.,8.,18.};
1109   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
1110   Float_t dAir = 1.20479E-3;
1111
1112   // --- fibre glass
1113   Float_t afg[4] = {28.09,16.00,12.01,1.01};
1114   Float_t zfg[4] = {14., 8., 6., 1.};
1115   Float_t wfg[4] = {0.12906,0.29405,0.51502,0.06187};
1116   Float_t dfg  = 1.111;
1117   Int_t nfg   = 4;
1118
1119   // --- Freon C2F4H2 + SF6
1120   Float_t afre[4]= {12.01,1.01,19.00,32.07};
1121   Float_t zfre[4]= { 6., 1., 9., 16.};
1122   Float_t wfre[4]= {0.21250,0.01787,0.74827,0.021355};
1123   Float_t densfre= 0.00375;
1124   Int_t nfre  = 4;
1125
1126   char namat[15] = "            ";
1127   Float_t ama[2], zma[2], dma, radl, absl, buf[1];
1128   Int_t nbuf;
1129
1130   AliMixture ( 0, "Air$", aAir, zAir, dAir, 4, wAir);
1131   AliMixture ( 1, "Nomex$", anox, znox, dnox, nnox, wnox);
1132   AliMixture ( 2, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
1133   AliMixture ( 3, "fibre glass$", afg, zfg, dfg, nfg, wfg);
1134   AliMaterial( 4, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
1135   AliMaterial( 5, "Al honeycomb$", 26.98, 13., 0.0496, 483., 2483.);
1136   AliMixture ( 6, "Freon$",  afre, zfre, densfre, nfre, wfre);
1137   AliMixture ( 7, "Glass$", aq, zq, dq, nq, wq);
1138
1139   // get freon and glass
1140   gMC->Gfmate((*fIdmate)[6],namat,ama[0],zma[0],dma,radl,absl,buf,nbuf);
1141   gMC->Gfmate((*fIdmate)[7],namat,ama[1],zma[1],dma,radl,absl,buf,nbuf);
1142
1143   // --- glass-freon
1144   Float_t wgfr[2]= {0.0011,0.9989};
1145   Float_t dgfr = 1.434;
1146   Int_t ngfr  = 2;
1147   AliMixture ( 8, "glass-freon$", ama, zma, dgfr, ngfr, wgfr);
1148   AliMixture ( 9, "Water$",  awa, zwa, dwa, nwa, wwa);
1149   AliMixture (10, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
1150
1151   Float_t epsil, stmin, deemax, stemax;
1152  
1153   //   Previous data
1154   //       EPSIL  = 0.1   ! Tracking precision,
1155   //       STEMAX = 0.1   ! Maximum displacement for multiple scattering
1156   //       DEEMAX = 0.1   ! Maximum fractional energy loss, DLS
1157   //       STMIN  = 0.1
1158
1159   //   New data
1160   epsil  = .001;  // Tracking precision,
1161   stemax = -1.;   // Maximum displacement for multiple scattering
1162   deemax = -.3;   // Maximum fractional energy loss, DLS
1163   stmin  = -.8;
1164
1165   AliMedium( 1, "Air$",         0, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1166   AliMedium( 2,"Nomex$",        1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1167   AliMedium( 3,"G10$",          2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1168   AliMedium( 4,"fibre glass$",  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1169   AliMedium( 5,"glass-freon$",  8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1170   AliMedium( 6,"Al Frame$",     4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1171   AliMedium( 7,"Al honeycomb$", 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1172   AliMedium( 8,"Fre$",          6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1173   AliMedium( 9,"PCB-S$",        2, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1174   AliMedium(10,"Glass$",        7, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1175   AliMedium(11,"Water$",        9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1176   AliMedium(12,"STEEL$",       10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1177
1178 }
1179 //_____________________________________________________________________________
1180 void AliTOFv5T0::Init()
1181 {
1182   //
1183   // Initialise the detector after the geometry has been defined
1184   //
1185   AliDebug(1, "**************************************"
1186            "  TOF  "
1187            "**************************************");
1188   AliDebug(1, "  Version 4 of TOF initialing, "
1189            "symmetric TOF - Full Coverage version");
1190   
1191   AliTOF::Init();
1192   
1193   fIdFTOA = gMC->VolId("FTOA");
1194   if (fTOFHoles) {
1195     fIdFTOB = gMC->VolId("FTOB");
1196     fIdFTOC = gMC->VolId("FTOC");
1197   }
1198   fIdFLTA = gMC->VolId("FLTA");
1199   if (fTOFHoles) {
1200     fIdFLTB = gMC->VolId("FLTB");
1201     fIdFLTC = gMC->VolId("FLTC");
1202   }
1203
1204   AliDebug(1, "**************************************"
1205            "  TOF  "
1206            "**************************************");
1207 }
1208  
1209 //_____________________________________________________________________________
1210 void AliTOFv5T0::StepManager()
1211 {
1212
1213   //
1214   // Procedure called at each step in the Time Of Flight
1215   //
1216
1217   TLorentzVector mom, pos;
1218   Float_t xm[3],pm[3],xpad[3],ppad[3];
1219   Float_t hits[14];
1220   Int_t   vol[5];
1221   Int_t   sector, plate, padx, padz, strip;
1222   Int_t   copy, padzid, padxid, stripid, i;
1223   Int_t   *idtmed = fIdtmed->GetArray()-499;
1224   Float_t incidenceAngle;
1225
1226   const char * path71 = "B071";
1227   const char * path75 = "B075";
1228   const char * path74 = "B074";
1229   const char* volpath;
1230
1231   Int_t index = 0;
1232
1233   if(
1234      gMC->IsTrackEntering()
1235      && gMC->TrackCharge()
1236      //&& gMC->GetMedium()==idtmed[508]
1237      && gMC->CurrentMedium()==idtmed[508]
1238      && gMC->CurrentVolID(copy)==fIdSens
1239      )
1240   {
1241
1242     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1243
1244     // getting information about hit volumes
1245     
1246     padzid=gMC->CurrentVolOffID(1,copy);
1247     padz=copy;
1248     padz--;
1249
1250     padxid=gMC->CurrentVolOffID(0,copy);
1251     padx=copy; 
1252     padx--;
1253     
1254     stripid=gMC->CurrentVolOffID(4,copy);
1255     strip=copy; 
1256     strip--;
1257
1258     gMC->TrackPosition(pos);
1259     gMC->TrackMomentum(mom);
1260
1261     Double_t normMom=1./mom.Rho();
1262
1263     //  getting the coordinates in pad ref system
1264
1265     xm[0] = (Float_t)pos.X();
1266     xm[1] = (Float_t)pos.Y();
1267     xm[2] = (Float_t)pos.Z();
1268
1269     pm[0] = (Float_t)mom.X()*normMom;
1270     pm[1] = (Float_t)mom.Y()*normMom;
1271     pm[2] = (Float_t)mom.Z()*normMom;
1272  
1273     gMC->Gmtod(xm,xpad,1); // from MRS to DRS: coordinates convertion
1274     gMC->Gmtod(pm,ppad,2); // from MRS to DRS: direction cosinus convertion
1275
1276
1277     if (TMath::Abs(ppad[1])>1) {
1278       AliWarning("Abs(ppad) > 1");
1279       ppad[1]=TMath::Sign((Float_t)1,ppad[1]);
1280     }
1281     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1282
1283     plate = -1;
1284     if      (strip <  fTOFGeometry->NStripC()) {
1285       plate = 0;
1286       //strip = strip;
1287     }
1288     else if (strip >= fTOFGeometry->NStripC() && 
1289              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB()) {
1290       plate = 1;
1291       strip = strip - fTOFGeometry->NStripC();
1292     }
1293     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() &&
1294              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA()) {
1295       plate = 2;
1296       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB();
1297     }
1298     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() &&
1299              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() + fTOFGeometry->NStripB()) {
1300       plate = 3;
1301       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA();
1302     }
1303     else                                {
1304       plate = 4;
1305       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA() - fTOFGeometry->NStripB();
1306     }
1307
1308     volpath=gMC->CurrentVolOffName(8);
1309     index=gMC->CurrentVolOffID(8,copy);
1310     index=copy;
1311
1312     sector=-1;
1313     if(strcmp(path71,volpath)==0 && index <6) sector=12+index;
1314     if(strcmp(path71,volpath)==0 && index >=6) sector=index-3;
1315     if(strcmp(path75,volpath)==0) sector=index-1;
1316     if(strcmp(path74,volpath)==0) sector=10+index;
1317
1318     for(i=0;i<3;++i) {
1319       hits[i]   = pos[i];
1320       hits[i+3] = pm[i];
1321     }
1322
1323     hits[6] = mom.Rho();
1324     hits[7] = pos[3];
1325     hits[8] = xpad[0];
1326     hits[9] = xpad[1];
1327     hits[10]= xpad[2];
1328     hits[11]= incidenceAngle;
1329     hits[12]= gMC->Edep();
1330     hits[13]= gMC->TrackLength();
1331     
1332     vol[0]= sector;
1333     vol[1]= plate;
1334     vol[2]= strip;
1335     vol[3]= padx;
1336     vol[4]= padz;    
1337
1338     AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1339   }
1340 }
1341 //-------------------------------------------------------------------
1342 void AliTOFv5T0::MaterialMixer(Float_t* p,Float_t* a,Float_t* m,Float_t* d,Float_t* s,Int_t n) {
1343   // a[] atomic weights vector  (in)
1344   //     (atoms present in more compound appear separately)
1345   // m[] number of corresponding atoms in the mixture  (in)
1346   // d[] fraction of the compound relative to the corresponding atoms  (in)
1347   // s[] further possible weights     "        "        "        "     (in)
1348   Float_t t = 0.;
1349   for (Int_t i = 0; i < n; ++i) {
1350     p[i] = a[i]*m[i]*d[i]*s[i];
1351     t  += p[i];
1352   }
1353   for (Int_t i = 0; i < n; ++i) {
1354     p[i] = p[i]/t;
1355     //    AliInfo(Form((\n weight[%i] = %f (,i,p[i]));
1356   }
1357 }