updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry
[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.20  2007/10/03 18:07:22  arcelli
19 right handling of l2t matrices and alignable entries in case of TOF holes (Annalisa)
20
21 Revision 1.19  2007/10/03 10:41:12  arcelli
22 adding tracking-to-local matrices for new AliTOFcluster
23
24 Revision 1.18  2007/07/27 08:14:48  morsch
25 Write all track references into the same branch.
26
27 Revision 1.17  2007/05/14 14:41:13  decaro
28 Fix a bug in FTOA volume positionig inside BTOF13,14,15,16,17 in case of holes in 11th and 12th sectors
29
30 Revision 1.16  2007/05/04 12:59:26  arcelli
31 Change the TOF SM paths for misalignment (one layer up)
32
33 Revision 1.15  2007/02/19 15:41:55  decaro
34 Coding convention: few corrections
35
36 Revision 1.14  2006/10/17 15:33:14  arcelli
37 Moving some printout from Info to Debug level
38
39 Revision 1.13  2006/10/12 16:35:43  arcelli
40 definition of the alignable volumes symbolic names added
41
42 Revision 1.12  2006/08/22 13:34:46  arcelli
43 removal of effective c++ warnings (C.Zampolli)
44
45 Revision 1.11  2006/07/12 16:03:44  arcelli
46 updates to match the new numbering of the TOF/TRD mother volumes in FRAME (ALICE convention)
47
48 Revision 1.10  2006/05/10 18:40:17  hristov
49 Larger strings for the names
50
51 Revision 1.9  2006/05/04 19:41:42  hristov
52 Possibility for partial TOF geometry (S.Arcelli)
53
54 Revision 1.8  2006/04/20 22:30:50  hristov
55 Coding conventions (Annalisa)
56
57 Revision 1.7  2006/04/16 22:29:05  hristov
58 Coding conventions (Annalisa)
59
60 Revision 1.6  2006/03/20 08:20:35  decaro
61 Al layer: positioning correction
62
63 Revision 1.5  2006/03/20 07:54:20  decaro
64 Correction of some layer thickness
65
66 Revision 1.4  2006/03/13 12:35:44  decaro
67 Suppression of fractional Z warning
68
69 Revision 1.3  2006/02/28 10:38:00  decaro
70 AliTOFGeometry::fAngles, AliTOFGeometry::fHeights,
71 AliTOFGeometry::fDistances arrays: dimension definition in the right
72 location
73
74 Revision 1.2  2006/02/27 18:12:14  decaro
75 Remove in StepManager the dependence of hit indexes from parametrized
76 TOF position
77
78 Revision 1.1  2005/12/15 08:55:33  decaro
79 New TOF geometry description (V5) -G. Cara Romeo and A. De Caro
80
81
82 Revision 0.1 2004 November G. Cara Romeo and A. De Caro
83         Implement new TOF geometry version
84         in order to
85            suppress few volume overlaps
86                 (in the 4th TOF geometry version),
87            insert the realistic strip numbers and positions
88
89 */
90
91 ///////////////////////////////////////////////////////////////////////////////
92 //                                                                           //
93 //  This class contains the functions for version 5 of the Time Of Flight    //
94 //  detector.                                                                //
95 //                                                                           //
96 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
97 //                                                                           //
98 //  FULL COVERAGE VERSION + OPTION for PHOS holes                            //
99 //                                                                           //
100 //                                                                           //
101 //Begin_Html                                                                 //
102 /*                                                                           //
103 <img src="picts/AliTOFv5T0Class.gif">                                        //
104 */                                                                           //
105 //End_Html                                                                   //
106 //                                                                           //
107 ///////////////////////////////////////////////////////////////////////////////
108
109 #include "TBRIK.h"
110 #include "TGeometry.h"
111 #include "TLorentzVector.h"
112 #include "TNode.h"
113 #include "TVirtualMC.h"
114 #include "TGeoManager.h"
115 #include <TGeoMatrix.h>
116 #include <TGeoPhysicalNode.h>
117 #include <TGeoVolume.h>
118
119 #include "AliConst.h"
120 #include "AliLog.h"
121 #include "AliMagF.h"
122 #include "AliMC.h"
123 #include "AliRun.h"
124 #include "AliTrackReference.h"
125
126 #include "AliTOFGeometry.h"
127 #include "AliTOFv5T0.h"
128
129 extern TDirectory *gDirectory;
130 extern TVirtualMC *gMC;
131 extern TGeoManager *gGeoManager;
132
133 extern AliRun *gAlice;
134
135 ClassImp(AliTOFv5T0)
136
137 //_____________________________________________________________________________
138   AliTOFv5T0::AliTOFv5T0():
139   fIdFTOA(-1),
140   fIdFTOB(-1),
141   fIdFTOC(-1),
142   fIdFLTA(-1),
143   fIdFLTB(-1),
144   fIdFLTC(-1),
145   fTOFHoles(kFALSE)
146 {
147   //
148   // Default constructor
149   //
150 }
151  
152 //_____________________________________________________________________________
153 AliTOFv5T0::AliTOFv5T0(const char *name, const char *title):
154   AliTOF(name,title,"tzero"),
155   fIdFTOA(-1),
156   fIdFTOB(-1),
157   fIdFTOC(-1),
158   fIdFLTA(-1),
159   fIdFLTB(-1),
160   fIdFLTC(-1),
161   fTOFHoles(kFALSE)
162 {
163   //
164   // Standard constructor
165   //
166   //
167   // Check that FRAME is there otherwise we have no place where to
168   // put TOF
169
170
171   AliModule* frame = (AliModule*)gAlice->GetModule("FRAME");
172   if(!frame) {
173     AliFatal("TOF needs FRAME to be present");
174   } else{
175     
176     if (fTOFGeometry) delete fTOFGeometry;
177     fTOFGeometry = new AliTOFGeometry();
178
179     if(frame->IsVersion()==1) {
180       AliDebug(1,Form("Frame version %d", frame->IsVersion())); 
181       AliDebug(1,"Full Coverage for TOF");
182       fTOFHoles=false;}    
183     else {
184       AliDebug(1,Form("Frame version %d", frame->IsVersion())); 
185       AliDebug(1,"TOF with Holes for PHOS");
186       fTOFHoles=true;}      
187   }
188   fTOFGeometry->SetHoles(fTOFHoles);
189
190   //AliTOF::fTOFGeometry = fTOFGeometry;
191
192   // Save the geometry
193   TDirectory* saveDir = gDirectory;
194   gAlice->GetRunLoader()->CdGAFile();
195   fTOFGeometry->Write("TOFgeometry");
196   saveDir->cd();
197
198
199
200 //_____________________________________________________________________________
201 void AliTOFv5T0::AddAlignableVolumes() const
202 {
203   //
204   // Create entries for alignable volumes associating the symbolic volume
205   // name with the corresponding volume path. Needs to be syncronized with
206   // eventual changes in the geometry.
207   //
208
209   TString volPath;
210   TString symName;
211
212   TString vpL0  = "ALIC_1/B077_1/BSEGMO";
213   TString vpL1 = "_1/BTOF";
214   TString vpL2 = "_1";
215   TString vpL3 = "/FTOA_0";
216   TString vpL4 = "/FLTA_0/FSTR_";
217
218   TString snSM  = "TOF/sm";
219   TString snSTRIP = "/strip";
220
221   Int_t nSectors=fTOFGeometry->NSectors();
222   Int_t nStrips =fTOFGeometry->NStripA()+
223                  2*fTOFGeometry->NStripB()+
224                  2*fTOFGeometry->NStripC();
225
226   //
227   // The TOF MRPC Strips
228   // The symbolic names are: TOF/sm00/strip01
229   //                           ...
230   //                         TOF/sm17/strip91
231  
232   Int_t imod=0;
233
234   for (Int_t isect = 0; isect < nSectors; isect++) {
235     for (Int_t istr = 1; istr <= nStrips; istr++) {
236
237       if (fTOFHoles && (isect==11 || isect==12)) {
238         if (istr<39) {
239           vpL3 = "/FTOB_0";
240           vpL4 = "/FLTB_0/FSTR_";
241         }
242         else if (istr>53) {
243           vpL3 = "/FTOC_0";
244           vpL4 = "/FLTC_0/FSTR_";
245         }
246         else continue;
247       }
248       else {
249         vpL3 = "/FTOA_0";
250         vpL4 = "/FLTA_0/FSTR_";
251       }
252
253       volPath  = vpL0;
254       volPath += isect;
255       volPath += vpL1;
256       volPath += isect;
257       volPath += vpL2;
258       volPath += vpL3;
259       volPath += vpL4;
260       volPath += istr;
261
262       
263       symName  = snSM;
264       symName += Form("%02d",isect);
265       symName += snSTRIP;
266       symName += Form("%02d",istr);
267             
268       AliDebug(2,"--------------------------------------------"); 
269       AliDebug(2,Form("Alignable object %d", imod)); 
270       AliDebug(2,Form("volPath=%s\n",volPath.Data()));
271       AliDebug(2,Form("symName=%s\n",symName.Data()));
272       AliDebug(2,"--------------------------------------------"); 
273               
274       gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
275
276       //T2L matrices for alignment
277       TGeoPNEntry *e = gGeoManager->GetAlignableEntry(symName.Data());
278       if (e) {
279         const char *path = e->GetTitle();
280         if (!gGeoManager->cd(path)) {
281           AliFatal(Form("Volume path %s not valid!",path));
282         }
283         TGeoHMatrix *globMatrix = gGeoManager->GetCurrentMatrix();
284         Double_t phi = 20.0 * (isect % 18) + 10.0;
285         TGeoHMatrix *t2l  = new TGeoHMatrix();
286         t2l->RotateZ(phi);
287         t2l->MultiplyLeft(&(globMatrix->Inverse()));
288         e->SetMatrix(t2l);
289       }
290       else {
291         AliError(Form("Alignable entry %s is not valid!",symName.Data()));
292       }
293       imod++;
294     }
295   }
296
297
298   //
299   // The TOF supermodules
300   // The symbolic names are: TOF/sm00
301   //                           ...
302   //                         TOF/sm17
303   //
304   for (Int_t isect = 0; isect < nSectors; isect++) {
305
306     volPath  = vpL0;
307     volPath += isect;
308     volPath += vpL1;
309     volPath += isect;
310     volPath += vpL2;
311
312     symName  = snSM;
313     symName += Form("%02d",isect);
314
315       AliDebug(2,"--------------------------------------------"); 
316       AliDebug(2,Form("Alignable object %d", isect+imod)); 
317       AliDebug(2,Form("volPath=%s\n",volPath.Data()));
318       AliDebug(2,Form("symName=%s\n",symName.Data()));
319       AliDebug(2,"--------------------------------------------"); 
320               
321     gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
322
323   }
324   
325 }
326 //____________________________________________________________________________
327 void AliTOFv5T0::BuildGeometry()
328 {
329   //
330   // Build TOF ROOT geometry for the ALICE event display
331   //
332   TNode *node, *top;
333   const int kColorTOF  = 27;
334   
335   TGeometry *globalGeometry = (TGeometry*)gAlice->GetGeometry();
336
337   // Find top TNODE
338   top = globalGeometry->GetNode("alice");
339   
340   // Position the different copies
341   const Float_t krTof  =(fTOFGeometry->Rmax()+fTOFGeometry->Rmin())/2.;
342   const Float_t khTof  = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
343   const Int_t   kNTof  = fTOFGeometry->NSectors();
344   const Float_t kangle = k2PI/kNTof;
345
346   const Float_t kInterCentrModBorder1 = 49.5;
347   const Float_t kInterCentrModBorder2 = 57.5;
348
349   Float_t ang;
350   
351   // define offset for nodes
352   Float_t zOffsetB = (fTOFGeometry->ZlenA()*0.5 + (kInterCentrModBorder1+kInterCentrModBorder2)*0.5)*0.5;
353   Float_t zOffsetA = 0.;
354   // Define TOF basic volume
355   
356   char nodeName0[16], nodeName1[16], nodeName2[16];
357   char nodeName3[16], nodeName4[16], rotMatNum[16];
358
359   if (fTOFHoles) {
360     new TBRIK("S_TOF_B","TOF box","void",
361               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
362     new TBRIK("S_TOF_C","TOF box","void",
363               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
364   }
365   new TBRIK("S_TOF_A","TOF box","void",
366             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenA()*0.5);
367   
368   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
369     
370     if (nodeNum<10) {
371       sprintf(rotMatNum,"rot50%i",nodeNum);
372       sprintf(nodeName0,"FTO00%i",nodeNum);
373       sprintf(nodeName1,"FTO10%i",nodeNum);
374       sprintf(nodeName2,"FTO20%i",nodeNum);
375       sprintf(nodeName3,"FTO30%i",nodeNum);
376       sprintf(nodeName4,"FTO40%i",nodeNum);
377     }
378     if (nodeNum>9) {
379       sprintf(rotMatNum,"rot5%i",nodeNum);
380       sprintf(nodeName0,"FTO0%i",nodeNum);
381       sprintf(nodeName1,"FTO1%i",nodeNum);
382       sprintf(nodeName2,"FTO2%i",nodeNum);
383       sprintf(nodeName3,"FTO3%i",nodeNum);
384       sprintf(nodeName4,"FTO4%i",nodeNum);
385     }
386     
387     new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
388     ang = (4.5-nodeNum) * kangle;
389
390     if (fTOFHoles) {   
391       top->cd();
392       node = new TNode(nodeName2,nodeName2,"S_TOF_B", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetB,rotMatNum);
393       node->SetLineColor(kColorTOF);
394       fNodes->Add(node);
395       
396       top->cd();
397       node = new TNode(nodeName3,nodeName3,"S_TOF_C", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang),-zOffsetB,rotMatNum);
398       node->SetLineColor(kColorTOF);
399       fNodes->Add(node);
400     }
401
402     top->cd();
403     node = new TNode(nodeName4,nodeName4,"S_TOF_A", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetA,rotMatNum);
404     node->SetLineColor(kColorTOF);
405     fNodes->Add(node);
406   } // end loop on nodeNum
407
408 }
409
410 //_____________________________________________________________________________
411 void AliTOFv5T0::CreateGeometry()
412 {
413   //
414   // Create geometry for Time Of Flight version 0
415   //
416   //Begin_Html
417   /*
418     <img src="picts/AliTOFv5T0.gif">
419   */
420   //End_Html
421   //
422   // Creates common geometry
423   //
424   AliTOF::CreateGeometry();
425 }
426  
427
428 //_____________________________________________________________________________
429 void AliTOFv5T0::TOFpc(Float_t xtof,  Float_t ytof, Float_t zlenA,
430                        Float_t zlenB)
431 {
432   //
433   // Definition of the Time Of Fligh Resistive Plate Chambers
434   //
435
436   const Float_t kPi = TMath::Pi();
437
438   const Float_t kInterCentrModBorder1 = 49.5;
439   const Float_t kInterCentrModBorder2 = 57.5;
440   const Float_t kExterInterModBorder1 = 196.0;
441   const Float_t kExterInterModBorder2 = 203.5;
442
443   const Float_t kLengthExInModBorder  = 4.7;
444   const Float_t kLengthInCeModBorder  = 7.0;
445
446   // Al layers over all internal module walls (cm)
447   const Float_t khAlWall = 0.03;
448
449   // module wall thickness (cm)
450   const Float_t kModuleWallThickness = 0.3;
451
452   // Al honeycomb layer between strips and cards (cm)
453   const Float_t kHoneycombLayerThickness = 1.5;
454
455   AliDebug(2,Form("zlenA*0.5 = %d", zlenA*0.5));
456   AliDebug(1, "************************* TOF geometry **************************");
457   
458   // Definition of the Time Of Fligh Resistive Plate Chambers
459   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
460   
461   Float_t  xcoor, ycoor, zcoor;
462   Float_t  par[3];
463   Int_t    *idtmed = fIdtmed->GetArray()-499;
464   Int_t    idrotm[100];
465
466   par[0] =  xtof * 0.5;
467   par[1] =  ytof * 0.5;
468   par[2] = zlenA * 0.5;
469   gMC->Gsvolu("FTOA", "BOX ", idtmed[503], par, 3);  // fibre glass
470   
471   if (fTOFHoles) {
472     par[0] =  xtof * 0.5;
473     par[1] =  ytof * 0.5;
474     par[2] = (zlenA*0.5 - kInterCentrModBorder1)*0.5;
475     gMC->Gsvolu("FTOB", "BOX ", idtmed[503], par, 3);  // fibre glass
476     gMC->Gsvolu("FTOC", "BOX ", idtmed[503], par, 3);  // fibre glass
477   }
478
479   // Positioning of fibre glass modules (FTOA, FTOB and FTOC)
480   
481   //AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,-90.);
482   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,270.);
483
484   xcoor = 0.;
485   ycoor = 0.;
486   zcoor = 0.;
487   for(Int_t isec=0;isec<18;isec++){
488     if(fTOFSectors[isec]==-1)continue;
489     char name[16];
490     sprintf(name, "BTOF%d",isec);
491     if (fTOFHoles && (isec==11||isec==12)) {
492     //    if (fTOFHoles && (isec==16||isec==17)) { \\Old 6h convention
493       xcoor = 0.;
494       ycoor = (zlenA*0.5 + kInterCentrModBorder1)*0.5;
495       zcoor = 0.;
496       gMC->Gspos("FTOB", 0, name, xcoor, ycoor, zcoor, idrotm[0], "ONLY");
497       gMC->Gspos("FTOC", 0, name, xcoor,-ycoor, zcoor, idrotm[0], "ONLY");
498     }
499     else {
500       xcoor = 0.;
501       ycoor = 0.;
502       zcoor = 0.;
503       gMC->Gspos("FTOA", 0,name, xcoor, ycoor, zcoor, idrotm[0], "ONLY");
504     }
505
506   }
507   // Large not sensitive volumes with Insensitive Freon (FLTA, FLTB and FLTC)
508   
509   Float_t xFLT, yFLT, zFLTA;
510   
511   xFLT  = xtof  - kModuleWallThickness*2.;
512   yFLT  = ytof  - kModuleWallThickness*2.;
513   zFLTA = zlenA - kModuleWallThickness*2.;
514   
515   par[0] = xFLT*0.5;
516   par[1] = yFLT*0.5;
517   par[2] = zFLTA*0.5;
518   gMC->Gsvolu("FLTA", "BOX ", idtmed[507], par, 3); //  Freon mix
519
520   xcoor = 0.;
521   ycoor = 0.;
522   zcoor = 0.;
523   gMC->Gspos ("FLTA", 0, "FTOA", xcoor, ycoor, zcoor, 0, "ONLY");
524
525   if (fTOFHoles) {
526     par[0] = xFLT*0.5;
527     par[1] = yFLT*0.5;
528     par[2] = (zlenA*0.5 - kInterCentrModBorder1-kModuleWallThickness)*0.5;
529     gMC->Gsvolu("FLTB", "BOX ", idtmed[507], par, 3); // Freon mix
530     gMC->Gsvolu("FLTC", "BOX ", idtmed[507], par, 3); // Freon mix
531
532     xcoor = 0.;
533     ycoor = 0.;
534     zcoor = kModuleWallThickness*0.5;
535     gMC->Gspos ("FLTB", 0, "FTOB", xcoor, ycoor, zcoor, 0, "ONLY");
536     gMC->Gspos ("FLTC", 0, "FTOC", xcoor, ycoor,-zcoor, 0, "ONLY");
537   }
538
539   // Layer of Aluminum before detector (FALA, FALB and FALC)
540
541   par[0] = xFLT*0.5;
542   par[1] = khAlWall*0.5;
543   par[2] = kInterCentrModBorder1 - (kModuleWallThickness + khAlWall);
544   gMC->Gsvolu("FALA", "BOX ", idtmed[505], par, 3); // Alluminium
545
546   xcoor = 0.;
547   ycoor = (-yFLT + khAlWall)*0.5;
548   zcoor = 0.;
549   gMC->Gspos ("FALA", 0, "FLTA", xcoor, ycoor, zcoor, 0, "ONLY");
550
551   par[0] = xFLT*0.5;
552   par[1] = khAlWall*0.5;
553   par[2] = (kExterInterModBorder2 - kInterCentrModBorder1 - 2.*(kModuleWallThickness + khAlWall))*0.5;
554   gMC->Gsvolu("FALB", "BOX ", idtmed[505], par, 3); // Alluminium
555
556   xcoor = 0.;
557   ycoor = (-yFLT + khAlWall)*0.5;
558   zcoor = (kExterInterModBorder2 + kInterCentrModBorder1)*0.5;
559   gMC->Gspos ("FALB", 1, "FLTA", xcoor, ycoor, zcoor, 0, "ONLY");
560   gMC->Gspos ("FALB", 2, "FLTA", xcoor, ycoor,-zcoor, 0, "ONLY");
561
562   par[0] = xFLT*0.5;
563   par[1] = khAlWall*0.5;
564   par[2] = (zlenA*0.5 - kExterInterModBorder2 - 2.*(kModuleWallThickness + khAlWall))*0.5;
565   gMC->Gsvolu("FALC", "BOX ", idtmed[505], par, 3); // Alluminium
566
567   xcoor = 0.;
568   ycoor = (-yFLT + khAlWall)*0.5;
569   zcoor = (kExterInterModBorder2+zlenA*0.5)*0.5;
570   gMC->Gspos ("FALC", 1, "FLTA", xcoor, ycoor, zcoor, 0, "ONLY");
571   gMC->Gspos ("FALC", 2, "FLTA", xcoor, ycoor,-zcoor, 0, "ONLY");
572
573   if (fTOFHoles) {
574     xcoor = 0.;
575     ycoor = (-yFLT + khAlWall)*0.5;
576     zcoor = (zlenA*0.5 - kExterInterModBorder2)*0.5 - kModuleWallThickness*0.5;
577     gMC->Gspos ("FALB", 1, "FLTB", xcoor, ycoor, zcoor, 0, "ONLY");
578     gMC->Gspos ("FALB", 2, "FLTC", xcoor, ycoor,-zcoor, 0, "ONLY");
579
580     xcoor = 0.;
581     ycoor = (-yFLT + khAlWall)*0.5;
582     zcoor = (kExterInterModBorder2 - kInterCentrModBorder1)*0.5 + kModuleWallThickness*0.5;
583     gMC->Gspos ("FALC", 1, "FLTB", xcoor, ycoor,-zcoor, 0, "ONLY");
584     gMC->Gspos ("FALC", 2, "FLTC", xcoor, ycoor, zcoor, 0, "ONLY");
585   }
586
587   Float_t y0, alpha, tgal, beta, tgbe, trpa[11];
588
589   // Fibre glass walls between central and intermediate modules (FWZ1 and FWZ2; holes -> FZ1B, FZ1C, FZ2B)
590
591   tgal = (yFLT*0.5 - 2.*kLengthInCeModBorder)/(kInterCentrModBorder2 - kInterCentrModBorder1);
592   alpha = TMath::ATan(tgal);
593   beta = (kPi*0.5 - alpha)*0.5;
594   tgbe = TMath::Tan(beta);
595   trpa[0]  = xFLT*0.5;
596   trpa[1]  = 0.;
597   trpa[2]  = 0.;
598   trpa[3]  = kModuleWallThickness;
599   trpa[4]  = (kLengthInCeModBorder - kModuleWallThickness*tgbe)*0.5;
600   trpa[5]  = (kLengthInCeModBorder + kModuleWallThickness*tgbe)*0.5;
601   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
602   trpa[7]  = kModuleWallThickness;
603   trpa[8]  = (kLengthInCeModBorder - kModuleWallThickness*tgbe)*0.5;
604   trpa[9]  = (kLengthInCeModBorder + kModuleWallThickness*tgbe)*0.5;
605   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
606   gMC->Gsvolu("FWZ1","TRAP", idtmed[503], trpa, 11);   // fibre glass
607
608   AliMatrix (idrotm[1],90., 90.,180.,0.,90.,180.);
609   AliMatrix (idrotm[4],90., 90.,  0.,0.,90.,  0.);
610
611   xcoor = 0.;
612   ycoor = -yFLT*0.5 + kLengthInCeModBorder*0.5;
613   zcoor = kInterCentrModBorder1;
614   gMC->Gspos("FWZ1", 1,"FLTA", xcoor, ycoor, zcoor,idrotm[1],"ONLY");
615   gMC->Gspos("FWZ1", 2,"FLTA", xcoor, ycoor,-zcoor,idrotm[4],"ONLY");
616
617   if (fTOFHoles) {
618     y0 = kLengthInCeModBorder - kModuleWallThickness*0.5*tgbe;
619     trpa[0]  = xFLT*0.5;
620     trpa[1]  = 0.;
621     trpa[2]  = 0.;
622     trpa[3]  = kModuleWallThickness*0.5;
623     trpa[4]  = (y0 - kModuleWallThickness*0.5*tgbe)*0.5;
624     trpa[5]  = (y0 + kModuleWallThickness*0.5*tgbe)*0.5;
625     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
626     trpa[7]  = kModuleWallThickness*0.5;
627     trpa[8]  = (y0 - kModuleWallThickness*0.5*tgbe)*0.5;
628     trpa[9]  = (y0 + kModuleWallThickness*0.5*tgbe)*0.5;
629     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
630     gMC->Gsvolu("FZ1B","TRAP", idtmed[503], trpa, 11);   // fibre glass
631
632     xcoor = 0.;
633     ycoor = -yFLT*0.5 + kLengthInCeModBorder*0.5 - kModuleWallThickness*0.25*tgbe;
634     zcoor = -kInterCentrModBorder1 + (zlenA*0.5 + kInterCentrModBorder1)*0.5 - kModuleWallThickness;
635     gMC->Gspos("FZ1B", 1,"FLTB", xcoor, ycoor, zcoor,idrotm[4],"ONLY");
636     gMC->Gspos("FZ1B", 2,"FLTC", xcoor, ycoor,-zcoor,idrotm[1],"ONLY");
637   }
638
639   AliMatrix (idrotm[2],90.,270.,  0.,0.,90.,180.);
640   AliMatrix (idrotm[5],90.,270.,180.,0.,90.,  0.);
641
642   xcoor = 0.;
643   ycoor = -kLengthInCeModBorder*0.5;
644   zcoor = kInterCentrModBorder2;
645   gMC->Gspos("FWZ1", 3,"FLTA", xcoor, ycoor, zcoor,idrotm[2],"ONLY");
646   gMC->Gspos("FWZ1", 4,"FLTA", xcoor, ycoor,-zcoor,idrotm[5],"ONLY");
647
648   if (fTOFHoles) {
649     y0 = kLengthInCeModBorder + kModuleWallThickness*0.5*tgbe;
650     trpa[0]  = xFLT*0.5;
651     trpa[1]  = 0.;
652     trpa[2]  = 0.;
653     trpa[3]  = kModuleWallThickness*0.5;
654     trpa[4]  = (y0 - kModuleWallThickness*0.5*tgbe)*0.5;
655     trpa[5]  = (y0 + kModuleWallThickness*0.5*tgbe)*0.5;
656     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
657     trpa[7]  = kModuleWallThickness*0.5;
658     trpa[8]  = (y0 - kModuleWallThickness*0.5*tgbe)*0.5;
659     trpa[9]  = (y0 + kModuleWallThickness*0.5*tgbe)*0.5;
660     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
661     gMC->Gsvolu("FZ1C","TRAP", idtmed[503], trpa, 11);   // fibre glass
662
663     xcoor = 0.;
664     ycoor = -kLengthInCeModBorder*0.5 - kModuleWallThickness*0.25*tgbe;
665     zcoor = -kInterCentrModBorder2 + (zlenA*0.5 + kInterCentrModBorder1)*0.5 - kModuleWallThickness;
666     gMC->Gspos("FZ1C", 1,"FLTB", xcoor, ycoor, zcoor,idrotm[5],"ONLY");
667     gMC->Gspos("FZ1C", 2,"FLTC", xcoor, ycoor,-zcoor,idrotm[2],"ONLY");
668   }
669
670   trpa[0] = 0.5*(kInterCentrModBorder2 - kInterCentrModBorder1)/TMath::Cos(alpha);
671   trpa[1] = kModuleWallThickness;
672   trpa[2] = xFLT*0.5;
673   trpa[3] = -beta*kRaddeg;
674   trpa[4] = 0.;
675   trpa[5] = 0.;
676   gMC->Gsvolu("FWZ2","PARA", idtmed[503], trpa, 6);    // fibre glass
677
678   AliMatrix (idrotm[3],     alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
679   AliMatrix (idrotm[6],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,  0.);
680
681   xcoor = 0.;
682   ycoor = -yFLT*0.25;
683   zcoor = (kInterCentrModBorder2 + kInterCentrModBorder1)*0.5;
684   gMC->Gspos("FWZ2", 1,"FLTA", xcoor, ycoor, zcoor,idrotm[3],"ONLY");
685   gMC->Gspos("FWZ2", 2,"FLTA", xcoor, ycoor,-zcoor,idrotm[6],"ONLY");
686
687   if (fTOFHoles) {
688     trpa[0] = 0.5*(kInterCentrModBorder2 - kInterCentrModBorder1)/TMath::Cos(alpha);
689     trpa[1] = kModuleWallThickness*0.5;
690     trpa[2] = xFLT*0.5;
691     trpa[3] = -beta*kRaddeg;
692     trpa[4] = 0.;
693     trpa[5] = 0.;
694     gMC->Gsvolu("FZ2B","PARA", idtmed[503], trpa, 6);    // fibre glass
695
696     xcoor = 0.;
697     ycoor = -yFLT*0.25 - kModuleWallThickness*0.5*tgbe;
698     zcoor = -(kInterCentrModBorder2 + kInterCentrModBorder1)*0.5 + (zlenA*0.5 + kInterCentrModBorder1)*0.5 - kModuleWallThickness;
699     gMC->Gspos("FZ2B", 1,"FLTB", xcoor, ycoor, zcoor,idrotm[6],"ONLY");
700     gMC->Gspos("FZ2B", 2,"FLTC", xcoor, ycoor,-zcoor,idrotm[3],"ONLY");
701   }
702
703   // Fibre glass walls between intermediate and lateral modules (FWZ3 and FWZ4)
704
705   tgal = (yFLT*0.5 - 2.*kLengthExInModBorder)/(kExterInterModBorder2 - kExterInterModBorder1);
706   alpha = TMath::ATan(tgal);
707   beta = (kPi*0.5 - alpha)*0.5;
708   tgbe = TMath::Tan(beta);
709   trpa[0]  = xFLT*0.5;
710   trpa[1]  = 0.;
711   trpa[2]  = 0.;
712   trpa[3]  = kModuleWallThickness;
713   trpa[4]  = (kLengthExInModBorder - kModuleWallThickness*tgbe)*0.5;
714   trpa[5]  = (kLengthExInModBorder + kModuleWallThickness*tgbe)*0.5;
715   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
716   trpa[7]  = kModuleWallThickness;
717   trpa[8]  = (kLengthExInModBorder - kModuleWallThickness*tgbe)*0.5;
718   trpa[9]  = (kLengthExInModBorder + kModuleWallThickness*tgbe)*0.5;
719   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg; //TMath::ATan((trpa[5] - trpa[4])/(2.*trpa[3]))*kRaddeg;
720   gMC->Gsvolu("FWZ3","TRAP", idtmed[503], trpa, 11);    // fibre glass
721
722   xcoor = 0.;
723   ycoor = -kLengthExInModBorder*0.5;
724   zcoor = kExterInterModBorder1;
725   gMC->Gspos("FWZ3", 1,"FLTA", xcoor, ycoor, zcoor,idrotm[5],"ONLY");
726   gMC->Gspos("FWZ3", 2,"FLTA", xcoor, ycoor,-zcoor,idrotm[2],"ONLY");
727
728   if (fTOFHoles) {
729     xcoor = 0.;
730     ycoor = -kLengthExInModBorder*0.5;
731     zcoor = -kExterInterModBorder1 + (zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5;
732     gMC->Gspos("FWZ3", 5,"FLTB", xcoor, ycoor, zcoor,idrotm[2],"ONLY");
733     gMC->Gspos("FWZ3", 6,"FLTC", xcoor, ycoor,-zcoor,idrotm[5],"ONLY");
734   }
735
736   xcoor = 0.;
737   ycoor = -yFLT*0.5 + kLengthExInModBorder*0.5;
738   zcoor = kExterInterModBorder2;
739   gMC->Gspos("FWZ3", 3,"FLTA", xcoor, ycoor, zcoor,idrotm[4],"ONLY");
740   gMC->Gspos("FWZ3", 4,"FLTA", xcoor, ycoor,-zcoor,idrotm[1],"ONLY");
741
742   if (fTOFHoles) {
743     xcoor = 0.;
744     ycoor = -yFLT*0.5 + kLengthExInModBorder*0.5;
745     zcoor = -kExterInterModBorder2 + (zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5;
746     gMC->Gspos("FWZ3", 7,"FLTB", xcoor, ycoor, zcoor,idrotm[1],"ONLY");
747     gMC->Gspos("FWZ3", 8,"FLTC", xcoor, ycoor,-zcoor,idrotm[4],"ONLY");
748   }
749
750   trpa[0] = 0.5*(kExterInterModBorder2 - kExterInterModBorder1)/TMath::Cos(alpha);
751   trpa[1] = kModuleWallThickness;
752   trpa[2] = xFLT*0.5;
753   trpa[3] = -beta*kRaddeg;
754   trpa[4] = 0.;
755   trpa[5] = 0.;
756   gMC->Gsvolu("FWZ4","PARA", idtmed[503], trpa, 6);    // fibre glass
757
758   AliMatrix (idrotm[13],alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
759   AliMatrix (idrotm[16],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,0.);
760
761   xcoor = 0.;
762   ycoor = -yFLT*0.25;
763   zcoor = (kExterInterModBorder2 + kExterInterModBorder1)*0.5;
764   gMC->Gspos("FWZ4", 1,"FLTA", xcoor, ycoor, zcoor,idrotm[16],"ONLY");
765   gMC->Gspos("FWZ4", 2,"FLTA", xcoor, ycoor,-zcoor,idrotm[13],"ONLY");
766
767   if (fTOFHoles) {
768     xcoor = 0.;
769     ycoor = -yFLT*0.25;
770     zcoor = -(kExterInterModBorder2 + kExterInterModBorder1)*0.5 + (zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5;
771     gMC->Gspos("FWZ4", 3,"FLTB", xcoor, ycoor, zcoor,idrotm[13],"ONLY");
772     gMC->Gspos("FWZ4", 4,"FLTC", xcoor, ycoor,-zcoor,idrotm[16],"ONLY");
773   }
774
775
776   ///////////////// Detector itself //////////////////////
777
778   const Int_t    knx   = fTOFGeometry->NpadX();  // number of pads along x
779   const Int_t    knz   = fTOFGeometry->NpadZ();  // number of pads along z
780   const Float_t  kPadX = fTOFGeometry->XPad();   // pad length along x
781   const Float_t  kPadZ = fTOFGeometry->ZPad();   // pad length along z
782
783   // new description for strip volume -double stack strip-
784   // -- all constants are expressed in cm
785   // heigth of different layers
786   const Float_t khhony   = 1.0    ;   // heigth of HONY  Layer
787   const Float_t khpcby   = 0.08   ;   // heigth of PCB   Layer
788   const Float_t khrgly   = 0.055  ;   // heigth of RED GLASS  Layer
789
790   const Float_t khfiliy  = 0.125  ;   // heigth of FISHLINE  Layer
791   const Float_t khglassy = 0.160*0.5; // heigth of GLASS  Layer
792   const Float_t khglfy   = khfiliy+2.*khglassy;// heigth of GLASS+FISHLINE  Layer
793
794   const Float_t khcpcby  = 0.16   ;   // heigth of PCB  Central Layer
795   const Float_t kwhonz   = 8.1    ;   // z dimension of HONEY  Layer
796   const Float_t kwpcbz1  = 10.6   ;   // z dimension of PCB  Lower Layer
797   const Float_t kwpcbz2  = 11.6   ;   // z dimension of PCB  Upper Layer
798   const Float_t kwcpcbz  = 12.4   ;   // z dimension of PCB  Central Layer
799   const Float_t kwrglz   = 8.     ;   // z dimension of RED GLASS  Layer
800   const Float_t kwglfz   = 7.     ;   // z dimension of GLASS+FISHLN Layer
801   const Float_t klsensmx = knx*kPadX; // length of Sensitive Layer
802   const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer
803   const Float_t kwsensmz = knz*kPadZ; // width of Sensitive Layer
804   
805   // heigth of the FSTR Volume (the strip volume)
806   const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;
807
808   // width  of the FSTR Volume (the strip volume)
809   const Float_t kwstripz = kwcpcbz;
810   // length of the FSTR Volume (the strip volume)
811   const Float_t klstripx = fTOFGeometry->StripLength();
812   
813   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
814   // Coordinates of the strip center in the strip reference frame;
815   // used for positioning internal strip volumes
816   Float_t posfp[3]={0.,0.,0.};  
817
818   // FSTR volume definition-filling this volume with non sensitive Gas Mixture
819   gMC->Gsvolu("FSTR","BOX",idtmed[507],parfp,3);     // Freon mix
820
821   //-- HONY Layer definition
822   parfp[1] = khhony*0.5;
823   parfp[2] = kwhonz*0.5;
824   gMC->Gsvolu("FHON","BOX",idtmed[501],parfp,3);     // honeycomb (Nomex)
825   // positioning 2 HONY Layers on FSTR volume
826   posfp[1] =-khstripy*0.5+parfp[1];
827   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
828   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
829   
830   //-- PCB Layer definition
831   parfp[1] = khpcby*0.5;
832   parfp[2] = kwpcbz1*0.5;
833   gMC->Gsvolu("FPC1","BOX",idtmed[502],parfp,3);     // G10
834   parfp[2] = kwpcbz2*0.5;
835   gMC->Gsvolu("FPC2","BOX",idtmed[502],parfp,3);     // G10
836   // positioning 2 PCB Layers on FSTR volume
837   posfp[1] =-khstripy*0.5+khhony+parfp[1];
838   gMC->Gspos("FPC1",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
839   gMC->Gspos("FPC2",1,"FSTR",0., posfp[1],0.,0,"ONLY");
840
841   //-- central PCB layer definition
842   parfp[1] = khcpcby*0.5;
843   parfp[2] = kwcpcbz*0.5;
844   gMC->Gsvolu("FPCB","BOX",idtmed[502],parfp,3);     // G10
845   // positioning the central PCB layer
846   gMC->Gspos("FPCB",1,"FSTR",0.,0.,0.,0,"ONLY");
847   
848   //      Sensitive volume
849   Float_t parfs[3] = {klsensmx*0.5, khsensmy*0.5, kwsensmz*0.5};
850   gMC->Gsvolu("FSEN","BOX",idtmed[508],parfs,3);     // sensitive ...
851   // dividing FSEN along z in knz=2 and along x in knx=48
852   gMC->Gsdvn("FSEZ","FSEN",knz,3);
853   gMC->Gsdvn("FPAD","FSEZ",knx,1);
854   // positioning a Sensitive layer inside FPCB
855   gMC->Gspos("FSEN",1,"FPCB",0.,0.,0.,0,"ONLY");
856
857   //-- RED GLASS Layer definition
858   parfp[1] = khrgly*0.5;
859   parfp[2] = kwrglz*0.5;
860   gMC->Gsvolu("FRGL","BOX",idtmed[509],parfp,3);     // glass
861   // positioning 4 RED GLASS Layers on FSTR volume
862   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
863   gMC->Gspos("FRGL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
864   gMC->Gspos("FRGL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
865   posfp[1] = (khcpcby+khrgly)*0.5;
866   gMC->Gspos("FRGL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
867   gMC->Gspos("FRGL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
868
869   //-- GLASS Layer definition
870   parfp[1] = khglassy*0.5;
871   parfp[2] = kwglfz*0.5;
872   gMC->Gsvolu("FGLA","BOX",idtmed[509],parfp,3);     // glass
873
874   // positioning 4 GLASS Layers on FSTR volume
875   posfp[1] = -khstripy*0.5+khhony+khpcby+khrgly+parfp[1];
876   gMC->Gspos("FGLA",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
877   gMC->Gspos("FGLA",4,"FSTR",0., posfp[1],0.,0,"ONLY");
878   posfp[1] = khcpcby*0.5+khrgly+khglassy*0.5;
879   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
880   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
881
882   //-- FREON Layer definition
883   parfp[1] = khfiliy*0.5;
884   gMC->Gsvolu("FFIS","BOX",idtmed[507],parfp,3);     // freon
885
886   // positioning 2 FREON Layers on FSTR volume
887   posfp[1] = -khstripy*0.5+khhony+khpcby+khrgly+khglassy+parfp[1];
888   gMC->Gspos("FFIS",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
889   gMC->Gspos("FFIS",2,"FSTR",0., posfp[1],0.,0,"ONLY");
890
891   /*
892   //-- GLASS+FISHLINE Layer definition
893   parfp[1] = khglfy*0.5;
894   parfp[2] = kwglfz*0.5;
895   gMC->Gsvolu("FGLF","BOX",idtmed[504],parfp,3);
896
897   // positioning 2 GLASS+FISHLINE Layers on FSTR volume
898   posfp[1] = (khcpcby+khglfy)*0.5+khrgly;
899   gMC->Gspos("FGLF",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
900   gMC->Gspos("FGLF",2,"FSTR",0., posfp[1],0.,0,"ONLY");
901   */
902
903   //  Positioning the Strips  (FSTR) in the FLT volumes
904   Int_t maxStripNumbers [5] ={fTOFGeometry->NStripC(),
905                               fTOFGeometry->NStripB(),
906                               fTOFGeometry->NStripA(),
907                               fTOFGeometry->NStripB(),
908                               fTOFGeometry->NStripC()};
909
910   Int_t totalStrip = 0;
911   Float_t xpos, zpos, ypos, ang;
912   for(Int_t iplate =0; iplate < fTOFGeometry->NPlates(); iplate++){
913     if (iplate>0) totalStrip += maxStripNumbers[iplate-1];
914     for(Int_t istrip =0; istrip < maxStripNumbers[iplate]; istrip++){
915
916       ang = fTOFGeometry->GetAngles(iplate,istrip);
917       AliDebug(1, Form(" iplate = %1i, istrip = %2i ---> ang = %f", iplate, istrip, ang));
918  
919       if (ang>0.)       AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90., ang, 90.);
920       else if (ang==0.) AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.,90., 0., 0.);
921       else if (ang<0.)  AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90.,-ang,270.);
922
923       xpos = 0.;
924       zpos = fTOFGeometry->GetDistances(iplate,istrip);
925       ypos = fTOFGeometry->GetHeights(iplate,istrip);
926
927       gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTA", xpos, ypos,-zpos,idrotm[istrip+totalStrip+1],  "ONLY");
928
929       if (fTOFHoles) {
930         if (istrip+totalStrip+1>53) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTC", xpos, ypos,-zpos-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
931         if (istrip+totalStrip+1<39) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTB", xpos, ypos,-zpos+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
932       }
933     }
934   }
935
936   //  1.5 cm Al honeycomb layer between strips and cards
937   par[0] = xFLT*0.5;
938   par[1] = kHoneycombLayerThickness*0.5;
939   par[2] = zFLTA*0.5;
940   gMC->Gsvolu("FPEA", "BOX ", idtmed[506], par, 3);   // Al honeycomb
941
942   xcoor = 0.;
943   ycoor = kHoneycombLayerThickness*0.5;
944   zcoor = 0.;
945   gMC->Gspos ("FPEA", 0, "FLTA", xcoor, ycoor, zcoor, 0, "ONLY");
946
947   if (fTOFHoles) {
948     par[0] = xFLT*0.5;
949     par[1] = kHoneycombLayerThickness*0.5;
950     par[2] = (zlenA*0.5 - kInterCentrModBorder2-kModuleWallThickness)*0.5;
951     gMC->Gsvolu("FPEB", "BOX ", idtmed[506], par, 3);   // Al honeycomb
952
953     xcoor = 0.;
954     ycoor = kHoneycombLayerThickness*0.5;
955     zcoor = (kInterCentrModBorder2-kInterCentrModBorder1)*0.5;
956     gMC->Gspos ("FPEB", 1, "FLTB", xcoor, ycoor,-zcoor, 0, "ONLY");
957     gMC->Gspos ("FPEB", 2, "FLTC", xcoor, ycoor, zcoor, 0, "ONLY");
958   }
959
960   // frame of Air
961   par[0] = xFLT*0.5;
962   par[1] = (yFLT*0.5 - kHoneycombLayerThickness)*0.5;
963   par[2] = zFLTA *0.5;
964   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
965
966   xcoor = 0.;
967   ycoor = kHoneycombLayerThickness + (yFLT*0.5 - kHoneycombLayerThickness)*0.5;
968   zcoor = 0.;
969   gMC->Gspos ("FAIA", 0, "FLTA", xcoor, ycoor, zcoor, 0, "ONLY");
970
971   if (fTOFHoles) {
972     par[0] = xFLT*0.5;
973     par[1] = (yFLT*0.5 - kHoneycombLayerThickness)*0.5;
974     par[2] = (zlenA*0.5 - kInterCentrModBorder2 - kModuleWallThickness)*0.5;
975     gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
976     gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
977
978     xcoor = 0.;
979     ycoor = kHoneycombLayerThickness + (yFLT*0.5 - kHoneycombLayerThickness)*0.5;
980     zcoor = (kInterCentrModBorder2-kInterCentrModBorder1)*0.5;
981     gMC->Gspos ("FAIB", 0, "FLTB", xcoor, ycoor,-zcoor, 0, "ONLY");
982     gMC->Gspos ("FAIC", 0, "FLTC", xcoor, ycoor, zcoor, 0, "ONLY");
983   }
984
985   // start with cards and cooling tubes
986   // finally, cards, cooling tubes and layer for thermal dispersion
987   // 3 volumes
988   
989   // see GEOM200 in GEANT manual
990
991   Float_t cardpar[3];
992
993   // card volume definition
994   cardpar[0]= xFLT*0.5;
995   cardpar[1]= 5.;
996   cardpar[2]= 0.1;
997   gMC->Gsvolu("FCAR", "BOX ", idtmed[502], cardpar, 3); // PCB Card 
998
999   //alu plate volume definition
1000   cardpar[1]= 3.5;
1001   cardpar[2]= 0.05;
1002   gMC->Gsvolu("FALP", "BOX ", idtmed[505], cardpar, 3); // Alu Plate
1003
1004   // tube volume definition
1005   Float_t tubepar[3];
1006   tubepar[0]= 0.;
1007   tubepar[1]= 0.4;
1008   tubepar[2]= 61.;
1009   gMC->Gsvolu("FTUB", "TUBE", idtmed[511], tubepar, 3); // cooling tubes (steel)
1010
1011   //tubepar[0]= 0.;
1012   tubepar[1]= 0.35;
1013   //tubepar[2]= 61.;
1014   gMC->Gsvolu("FITU", "TUBE", idtmed[510], tubepar, 3); // cooling water
1015   // positioning water tube into the steel one
1016   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
1017
1018   // rotation matrix
1019   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
1020
1021   // central module positioning
1022   Float_t cardpos[3], aplpos2;
1023   Float_t stepforcardA = 6.625;
1024   Float_t tdis = 0.6;
1025   Float_t aplpos1 = -2.;
1026
1027   cardpos[0]= 0.;
1028   cardpos[1]= -0.5;
1029   cardpos[2]= -53.;
1030   //  tubepos= -53.+tdis;
1031   Int_t icard;
1032   for (icard=39; icard<54; ++icard) {
1033     cardpos[2]= cardpos[2]+stepforcardA;
1034     aplpos2 = cardpos[2]+0.15;
1035     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],     cardpos[2],         0,"ONLY"); 
1036     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],   aplpos1,        aplpos2,         0,"ONLY");
1037     gMC->Gspos("FTUB",icard,"FAIA",        0.,cardpos[1],cardpos[2]+tdis,idrotm[99],"ONLY");
1038   }
1039   
1040   // intermediate module positioning
1041   Float_t stepforcardB= 7.05;
1042   Float_t offs = 53.;
1043
1044   cardpos[2]= offs;
1045   for (icard=20; icard<39; ++icard) {
1046     cardpos[2]= cardpos[2]+stepforcardB;
1047     aplpos2 = cardpos[2]+0.15;
1048
1049     gMC->Gspos("FCAR",icard+34,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY");
1050     gMC->Gspos("FALP",icard+34,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
1051     gMC->Gspos("FTUB",icard+34,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
1052     gMC->Gspos("FCAR",58-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
1053     gMC->Gspos("FALP",58-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
1054     gMC->Gspos("FTUB",58-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
1055
1056     if (fTOFHoles) {
1057       gMC->Gspos("FCAR",icard+34+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1058       gMC->Gspos("FALP",icard+34+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1059       gMC->Gspos("FTUB",icard+34+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
1060       gMC->Gspos("FCAR",58-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1061       gMC->Gspos("FALP",58-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1062       gMC->Gspos("FTUB",58-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
1063     }
1064     
1065   }
1066
1067   // outer module positioning
1068   Float_t stepforcardC= 8.45238;
1069   offs += zlenB;
1070   cardpos[2]= offs;
1071   for (icard=1; icard<20; ++icard) {
1072     cardpos[2]= cardpos[2]+stepforcardC;
1073     aplpos2 = cardpos[2]+0.15;
1074
1075     gMC->Gspos("FCAR",icard+72,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY"); 
1076     gMC->Gspos("FALP",icard+72,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
1077     gMC->Gspos("FTUB",icard+72,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
1078     gMC->Gspos("FCAR",20-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
1079     gMC->Gspos("FALP",20-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
1080     gMC->Gspos("FTUB",20-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
1081
1082     if (fTOFHoles) {
1083       gMC->Gspos("FCAR",icard+72+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1084       gMC->Gspos("FALP",icard+72+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1085       gMC->Gspos("FTUB",icard+72+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
1086       gMC->Gspos("FCAR",20-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1087       gMC->Gspos("FALP",20-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
1088       gMC->Gspos("FTUB",20-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
1089     }
1090   }
1091
1092 }
1093 //_____________________________________________________________________________
1094 void AliTOFv5T0::DrawModule() const
1095 {
1096   //
1097   // Draw a shaded view of the Time Of Flight version 4
1098   //
1099
1100   // Set everything unseen
1101   gMC->Gsatt("*", "seen", -1);
1102
1103   //
1104   //Set volumes visible
1105   // 
1106
1107   //Set ALIC mother transparent
1108   gMC->Gsatt("ALIC","SEEN", 0);
1109
1110 //=====> Level 1
1111   // Level 1 for TOF volumes
1112   gMC->Gsatt("B077","seen", 0);
1113
1114 //=====> Level 2
1115   // Level 2 for TOF volumes
1116   gMC->Gsatt("B071","seen", 0);
1117   gMC->Gsatt("B074","seen", 0);
1118   gMC->Gsatt("B075","seen", 0);
1119   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
1120   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
1121
1122   // Level 2 of B071
1123   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
1124   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
1125   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
1126   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
1127   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
1128
1129   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
1130   gMC->Gsatt("BTO1","seen", 0);
1131
1132   // Level 2 of B074
1133   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
1134   gMC->Gsatt("BTO2","seen", 0);
1135
1136   // Level 2 of B075
1137   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
1138   gMC->Gsatt("BTO3","seen", 0);
1139
1140   // Level 3 of B071, B074 and B075
1141   gMC->Gsatt("FTOA","SEEN", 0);
1142   if (fTOFHoles) gMC->Gsatt("FTOB","SEEN", 0);
1143
1144   // Level 4 of B071, B074 and B075
1145   gMC->Gsatt("FLTA","SEEN", 0);
1146   if (fTOFHoles) gMC->Gsatt("FLTB","SEEN",0);
1147   if (fTOFHoles) gMC->Gsatt("FLTC","SEEN",0);
1148
1149   // Level 5 of B071, B074 and B075
1150   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
1151   if (fTOFHoles) gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
1152   if (fTOFHoles) gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
1153
1154   gMC->Gsatt("FALA","SEEN", 0);
1155   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
1156
1157   gMC->Gsatt("FPEA","SEEN", 1);
1158   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 1);
1159
1160   gMC->Gsatt("FSTR","SEEN",-1);  // all FSTR sub-levels skipped   -
1161
1162   gMC->Gsatt("FWZ1","SEEN", 0);
1163   gMC->Gsatt("FWZ2","SEEN", 0);
1164   gMC->Gsatt("FWZ3","SEEN", 0);
1165   gMC->Gsatt("FWZ4","SEEN", 0);
1166   if (fTOFHoles) {
1167     gMC->Gsatt("FZ1B","SEEN", 0);
1168     gMC->Gsatt("FZ1C","SEEN", 0);
1169     gMC->Gsatt("FZ2B","SEEN", 0);
1170   }
1171
1172   gMC->Gdopt("hide", "on");
1173   gMC->Gdopt("shad", "on");
1174   gMC->Gsatt("*", "fill", 7);
1175   gMC->SetClipBox(".");
1176   gMC->SetClipBox("*", 100, 1000, 100, 1000, 100, 1000);
1177   gMC->DefaultRange();
1178   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
1179   gMC->Gdhead(1111, "Time Of Flight");
1180   gMC->Gdman(18, 3, "MAN");
1181   gMC->Gdopt("hide","off");
1182 }
1183 //_____________________________________________________________________________
1184 void AliTOFv5T0::DrawDetectorModules() const
1185 {
1186   //
1187   // Draw a shaded view of the TOF detector version 4
1188   //
1189  
1190   // Set everything unseen
1191   gMC->Gsatt("*", "seen", -1);
1192
1193   //
1194   //Set volumes visible
1195   // 
1196
1197   //Set ALIC mother transparent
1198   gMC->Gsatt("ALIC","SEEN", 0);
1199
1200 //=====> Level 1
1201   // Level 1 for TOF volumes
1202   gMC->Gsatt("B077","seen", 0);
1203
1204 //=====> Level 2
1205   // Level 2 for TOF volumes
1206   gMC->Gsatt("B071","seen", 0);
1207   gMC->Gsatt("B074","seen", 0);
1208   gMC->Gsatt("B075","seen", 0);
1209   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
1210   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
1211
1212   // Level 2 of B071
1213   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
1214   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
1215   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
1216   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
1217   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
1218
1219   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
1220   gMC->Gsatt("BTO1","seen", 0);
1221
1222   // Level 2 of B074
1223   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
1224   gMC->Gsatt("BTO2","seen", 0);
1225
1226   // Level 2 of B075
1227   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
1228   gMC->Gsatt("BTO3","seen", 0);
1229
1230   // Level 3 of B071, B075 and B074
1231   gMC->Gsatt("FTOA","seen",-2);  // all FTOA sub-levels skipped   -
1232   if (fTOFHoles) {
1233     gMC->Gsatt("FTOB","seen",-2);  // all FTOB sub-levels skipped   -
1234     gMC->Gsatt("FTOC","seen",-2);  // all FTOC sub-levels skipped   -
1235   }
1236
1237   gMC->Gdopt("hide","on");
1238   gMC->Gdopt("shad","on");
1239   gMC->Gsatt("*", "fill", 5);
1240   gMC->SetClipBox(".");
1241   gMC->SetClipBox("*", 100, 1000, 100, 1000, 0, 1000);
1242   gMC->DefaultRange();
1243   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
1244   gMC->Gdhead(1111,"TOF detector");
1245   gMC->Gdman(18, 3, "MAN");
1246   gMC->Gdopt("hide","off");
1247 }                                 
1248
1249 //_____________________________________________________________________________
1250 void AliTOFv5T0::DrawDetectorStrips() const
1251 {
1252   //
1253   // Draw a shaded view of the TOF strips for version 4
1254   //
1255
1256   // Set everything unseen
1257   gMC->Gsatt("*", "seen", -1);
1258
1259   //
1260   //Set volumes visible
1261   // 
1262   
1263   //Set ALIC mother transparent
1264   gMC->Gsatt("ALIC","SEEN", 0);
1265   
1266 //=====> Level 1
1267   // Level 1 for TOF volumes
1268   gMC->Gsatt("B077","seen", 0);
1269
1270 //=====> Level 2
1271   // Level 2 for TOF volumes
1272   gMC->Gsatt("B071","seen", 0);
1273   gMC->Gsatt("B074","seen", 0);
1274   gMC->Gsatt("B075","seen", 0);
1275   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
1276   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
1277
1278   // Level 2 of B071
1279   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
1280   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
1281   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
1282   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
1283   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
1284
1285   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
1286   gMC->Gsatt("BTO1","seen", 0);
1287
1288   // Level 2 of B074
1289   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
1290   gMC->Gsatt("BTO2","seen", 0);
1291
1292   // Level 2 of B075
1293   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
1294   gMC->Gsatt("BTO3","seen", 0);
1295
1296   // Level 3 of B071, B074 and B075
1297   gMC->Gsatt("FTOA","SEEN", 0);
1298   if (fTOFHoles) {
1299     gMC->Gsatt("FTOB","SEEN", 0);
1300     gMC->Gsatt("FTOC","SEEN", 0);
1301   }
1302
1303   // Level 4 of B071, B074 and B075
1304   gMC->Gsatt("FLTA","SEEN", 0);
1305   if (fTOFHoles) {
1306     gMC->Gsatt("FLTB","SEEN", 0);
1307     gMC->Gsatt("FLTC","SEEN", 0);
1308   }
1309
1310   // Level 5 of B071, B074 and B075
1311   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
1312   if (fTOFHoles) {
1313     gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
1314     gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
1315   }
1316
1317   gMC->Gsatt("FALA","SEEN", 0);
1318   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
1319
1320   gMC->Gsatt("FPEA","SEEN", 0);
1321   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 0);
1322
1323   gMC->Gsatt("FSTR","SEEN",-2);  // all FSTR sub-levels skipped   -
1324
1325   gMC->Gsatt("FWZ1","SEEN", 0);
1326   gMC->Gsatt("FWZ2","SEEN", 0);
1327   gMC->Gsatt("FWZ3","SEEN", 0);
1328   gMC->Gsatt("FWZ4","SEEN", 0);
1329   if (fTOFHoles){
1330     gMC->Gsatt("FZ1B","SEEN", 0);
1331     gMC->Gsatt("FZ1C","SEEN", 0);
1332     gMC->Gsatt("FZ2B","SEEN", 0);
1333   }
1334
1335   /*
1336   // Level 2 of FAIA
1337   // Level 2 of FAIB
1338   // Level 2 of FAIC
1339   gMC->Gsatt("FALP","SEEN",0);
1340   gMC->Gsatt("FCAR","SEEN",0);
1341   gMC->Gsatt("FTUB","SEEN",-1);  // all FTUB sub-levels skipped   -
1342
1343   // Level 2 of FTUB
1344   gMC->Gsatt("FITU","SEEN",0);
1345   */
1346
1347   /*
1348   // Level 2 of FSTR
1349   gMC->Gsatt("FGLF","SEEN",0);
1350   gMC->Gsatt("FHON","SEEN",0);
1351   gMC->Gsatt("FPC1","SEEN",0);
1352   gMC->Gsatt("FPC2","SEEN",0);
1353   gMC->Gsatt("FPCB","SEEN",0);
1354   gMC->Gsatt("FRGL","SEEN",0);
1355
1356   // Level 2 of FPCB => Level 3 of FSTR
1357   gMC->Gsatt("FSEN","SEEN",0);
1358   gMC->Gsatt("FSEZ","SEEN",0);
1359   gMC->Gsatt("FPAD","SEEN",1);
1360   */
1361
1362   gMC->Gdopt("hide","on");
1363   gMC->Gdopt("shad","on");
1364   gMC->Gsatt("*", "fill", 5);
1365   gMC->SetClipBox(".");
1366   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
1367   gMC->DefaultRange();
1368   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
1369   gMC->Gdhead(1111,"TOF Strips");
1370   gMC->Gdman(18, 3, "MAN");
1371   gMC->Gdopt("hide","off");
1372 }
1373
1374 //_____________________________________________________________________________
1375 void AliTOFv5T0::CreateMaterials()
1376 {
1377   //
1378   // Define materials for the Time Of Flight
1379   //
1380
1381   //AliTOF::CreateMaterials();
1382
1383   AliMagF *magneticField = (AliMagF*)gAlice->Field();
1384
1385   Int_t   isxfld = magneticField->Integ();
1386   Float_t sxmgmx = magneticField->Max();
1387
1388   Float_t we[7], ae[7], na[7], fr[7], vl[7];
1389   Int_t i;
1390
1391   //--- Quartz (SiO2) to simulate float glass
1392   //    density tuned to have correct float glass 
1393   //    radiation length
1394   Float_t   aq[2] = { 28.0855,15.9994 };
1395   Float_t   zq[2] = { 14.,8. };
1396   Float_t   wq[2] = { 1.,2. };
1397   Float_t   dq = 2.55; // std value: 2.2
1398   Int_t nq = -2;
1399
1400   // --- Nomex
1401   Float_t anox[4] = {12.01,1.01,16.00,14.01};
1402   Float_t znox[4] = { 6.,  1.,  8.,  7.};
1403   Float_t wnox[4] = {14., 22., 2., 2.};
1404   Float_t dnox  = 0.048;
1405   Int_t nnox   = -4;
1406
1407   //  { Si, C, H, O }
1408   Float_t ag10[4] = {28.09,12.01,1.01,16.00};
1409   Float_t zg10[4] = {14.,  6.,  1.,  8.};
1410   Float_t wmatg10[4];
1411   Int_t nlmatg10  = 4;
1412   for (i = 0; i < nlmatg10; ++i) {
1413     ae[i] = ag10[i];
1414     vl[i] = 1.;
1415   }
1416   ae[4] = 16.00;
1417   vl[4] = 1.;
1418   na[0] = 1.; 
1419   na[1] = 14.;
1420   na[2] = 20.;
1421   na[3] = 2.;
1422   na[4] = 3.;
1423   fr[0] = 0.6;
1424   fr[1] = 0.4;
1425   fr[2] = 0.4;
1426   fr[3] = 0.6;
1427   fr[4] = 0.4;
1428   MaterialMixer(we,ae,na,fr,vl,5);
1429   we[3] += we[4];
1430   wmatg10[0]= we[0];
1431   wmatg10[1]= we[1];
1432   wmatg10[2]= we[2];
1433   wmatg10[3]= we[3];
1434   Float_t densg10 = 1.7;
1435
1436   // -- Water
1437   Float_t awa[2] = {  1., 16. };
1438   Float_t zwa[2] = {  1.,  8. };
1439   Float_t wwa[2] = {  2.,  1. };
1440   Float_t dwa    = 1.0;
1441   Int_t nwa = -2;
1442
1443   // stainless steel
1444   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
1445   Float_t zsteel[4] = { 26.,24.,28.,14. };
1446   Float_t wsteel[4] = { .715,.18,.1,.005 };
1447
1448   // AIR
1449   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
1450   Float_t zAir[4]={6.,7.,8.,18.};
1451   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
1452   Float_t dAir = 1.20479E-3;
1453
1454   // --- fibre glass
1455   Float_t afg[4] = {28.09,16.00,12.01,1.01};
1456   Float_t zfg[4] = {14., 8., 6., 1.};
1457   Float_t wfg[4] = {0.12906,0.29405,0.51502,0.06187};
1458   Float_t dfg  = 1.111;
1459   Int_t nfg   = 4;
1460
1461   // --- Freon C2F4H2 + SF6
1462   Float_t afre[4]= {12.01,1.01,19.00,32.07};
1463   Float_t zfre[4]= { 6., 1., 9., 16.};
1464   Float_t wfre[4]= {0.21250,0.01787,0.74827,0.021355};
1465   Float_t densfre= 0.00375;
1466   Int_t nfre  = 4;
1467
1468   //char namat[15] = "            ";
1469   //Float_t ama[2], zma[2], dma, radl, absl, buf[1];
1470   //Int_t nbuf;
1471
1472   AliMixture ( 0, "Air$", aAir, zAir, dAir, 4, wAir);
1473   AliMixture ( 1, "Nomex$", anox, znox, dnox, nnox, wnox);
1474   AliMixture ( 2, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
1475   AliMixture ( 3, "fibre glass$", afg, zfg, dfg, nfg, wfg);
1476   AliMaterial( 4, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
1477   AliMaterial( 5, "Al honeycomb$", 26.98, 13., 0.0496, 483., 2483.);
1478   AliMixture ( 6, "Freon$",  afre, zfre, densfre, nfre, wfre);
1479   AliMixture ( 7, "Glass$", aq, zq, dq, nq, wq);
1480   /*
1481   // get freon and glass
1482   gMC->Gfmate((*fIdmate)[6],namat,ama[0],zma[0],dma,radl,absl,buf,nbuf);
1483   gMC->Gfmate((*fIdmate)[7],namat,ama[1],zma[1],dma,radl,absl,buf,nbuf);
1484
1485   // --- glass-freon
1486   Float_t wgfr[2]= {0.0011,0.9989};
1487   Float_t dgfr = 1.434;
1488   Int_t ngfr  = 2;
1489   AliMixture ( 8, "glass-freon$", ama, zma, dgfr, ngfr, wgfr);
1490   */
1491   AliMixture ( 9, "Water$",  awa, zwa, dwa, nwa, wwa);
1492   AliMixture (10, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
1493
1494   Float_t epsil, stmin, deemax, stemax;
1495  
1496   //   Previous data
1497   //       EPSIL  = 0.1   ! Tracking precision,
1498   //       STEMAX = 0.1   ! Maximum displacement for multiple scattering
1499   //       DEEMAX = 0.1   ! Maximum fractional energy loss, DLS
1500   //       STMIN  = 0.1
1501
1502   //   New data
1503   epsil  = .001;  // Tracking precision,
1504   stemax = -1.;   // Maximum displacement for multiple scattering
1505   deemax = -.3;   // Maximum fractional energy loss, DLS
1506   stmin  = -.8;
1507
1508   AliMedium( 1, "Air$",         0, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1509   AliMedium( 2,"Nomex$",        1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1510   AliMedium( 3,"G10$",          2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1511   AliMedium( 4,"fibre glass$",  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1512   //AliMedium( 5,"glass-freon$",  8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1513   AliMedium( 6,"Al Frame$",     4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1514   AliMedium( 7,"Al honeycomb$", 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1515   AliMedium( 8,"Fre$",          6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1516   AliMedium( 9,"PCB-S$",        2, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1517   AliMedium(10,"Glass$",        7, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1518   AliMedium(11,"Water$",        9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1519   AliMedium(12,"STEEL$",       10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1520
1521 }
1522 //_____________________________________________________________________________
1523 void AliTOFv5T0::Init()
1524 {
1525   //
1526   // Initialise the detector after the geometry has been defined
1527   //
1528   AliDebug(1, "**************************************"
1529            "  TOF  "
1530            "**************************************");
1531   AliDebug(1, "  Version 4 of TOF initialing, "
1532            "symmetric TOF - Full Coverage version");
1533   
1534   AliTOF::Init();
1535   
1536   fIdFTOA = gMC->VolId("FTOA");
1537   if (fTOFHoles) {
1538     fIdFTOB = gMC->VolId("FTOB");
1539     fIdFTOC = gMC->VolId("FTOC");
1540   }
1541   fIdFLTA = gMC->VolId("FLTA");
1542   if (fTOFHoles) {
1543     fIdFLTB = gMC->VolId("FLTB");
1544     fIdFLTC = gMC->VolId("FLTC");
1545   }
1546
1547   AliDebug(1, "**************************************"
1548            "  TOF  "
1549            "**************************************");
1550 }
1551  
1552 //_____________________________________________________________________________
1553 void AliTOFv5T0::StepManager()
1554 {
1555
1556   //
1557   // Procedure called at each step in the Time Of Flight
1558   //
1559
1560   TLorentzVector mom, pos;
1561   Float_t xm[3],pm[3],xpad[3],ppad[3];
1562   Float_t hits[14];
1563   Int_t   vol[5];
1564   Int_t   sector, plate, padx, padz, strip;
1565   Int_t   copy, padzid, padxid, stripid, i;
1566   Int_t   *idtmed = fIdtmed->GetArray()-499;
1567   Float_t incidenceAngle;
1568
1569   const char* volpath;
1570
1571   Int_t index = 0;
1572
1573   if(
1574      gMC->IsTrackEntering()
1575      && gMC->TrackCharge()
1576      //&& gMC->GetMedium()==idtmed[508]
1577      && gMC->CurrentMedium()==idtmed[508]
1578      && gMC->CurrentVolID(copy)==fIdSens
1579      )
1580   {
1581
1582     AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
1583
1584     AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kTOF);
1585     //AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1586
1587     // getting information about hit volumes
1588     
1589     padzid=gMC->CurrentVolOffID(1,copy);
1590     padz=copy;
1591     padz--;
1592
1593     padxid=gMC->CurrentVolOffID(0,copy);
1594     padx=copy; 
1595     padx--;
1596     
1597     stripid=gMC->CurrentVolOffID(4,copy);
1598     strip=copy; 
1599     strip--;
1600
1601     gMC->TrackPosition(pos);
1602     gMC->TrackMomentum(mom);
1603
1604     Double_t normMom=1./mom.Rho();
1605
1606     //  getting the coordinates in pad ref system
1607
1608     xm[0] = (Float_t)pos.X();
1609     xm[1] = (Float_t)pos.Y();
1610     xm[2] = (Float_t)pos.Z();
1611
1612     pm[0] = (Float_t)mom.X()*normMom;
1613     pm[1] = (Float_t)mom.Y()*normMom;
1614     pm[2] = (Float_t)mom.Z()*normMom;
1615  
1616     gMC->Gmtod(xm,xpad,1); // from MRS to DRS: coordinates convertion
1617     gMC->Gmtod(pm,ppad,2); // from MRS to DRS: direction cosinus convertion
1618
1619
1620     if (TMath::Abs(ppad[1])>1) {
1621       AliWarning("Abs(ppad) > 1");
1622       ppad[1]=TMath::Sign((Float_t)1,ppad[1]);
1623     }
1624     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1625
1626     plate = -1;
1627     if      (strip <  fTOFGeometry->NStripC()) {
1628       plate = 0;
1629       //strip = strip;
1630     }
1631     else if (strip >= fTOFGeometry->NStripC() && 
1632              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB()) {
1633       plate = 1;
1634       strip = strip - fTOFGeometry->NStripC();
1635     }
1636     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() &&
1637              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA()) {
1638       plate = 2;
1639       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB();
1640     }
1641     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() &&
1642              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() + fTOFGeometry->NStripB()) {
1643       plate = 3;
1644       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA();
1645     }
1646     else                                {
1647       plate = 4;
1648       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA() - fTOFGeometry->NStripB();
1649     }
1650
1651     volpath=gMC->CurrentVolOffName(7);
1652     index=atoi(&volpath[4]);
1653     sector=-1;
1654     sector=index;
1655
1656     //Old 6h convention
1657     // if(index<5){
1658     //   sector=index+13;
1659     //  }
1660     // else{
1661     //   sector=index-5;
1662     // } 
1663  
1664     for(i=0;i<3;++i) {
1665       hits[i]   = pos[i];
1666       hits[i+3] = pm[i];
1667     }
1668
1669     hits[6] = mom.Rho();
1670     hits[7] = pos[3];
1671     hits[8] = xpad[0];
1672     hits[9] = xpad[1];
1673     hits[10]= xpad[2];
1674     hits[11]= incidenceAngle;
1675     hits[12]= gMC->Edep();
1676     hits[13]= gMC->TrackLength();
1677     
1678     vol[0]= sector;
1679     vol[1]= plate;
1680     vol[2]= strip;
1681     vol[3]= padx;
1682     vol[4]= padz;    
1683
1684     AddT0Hit(mcApplication->GetCurrentTrackNumber(),vol, hits);
1685     //AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1686   }
1687 }
1688 //-------------------------------------------------------------------
1689 void AliTOFv5T0::MaterialMixer(Float_t* p,Float_t* a,Float_t* m,Float_t* d,Float_t* s,Int_t n) const
1690 {
1691   // a[] atomic weights vector  (in)
1692   //     (atoms present in more compound appear separately)
1693   // m[] number of corresponding atoms in the mixture  (in)
1694   // d[] fraction of the compound relative to the corresponding atoms  (in)
1695   // s[] further possible weights     "        "        "        "     (in)
1696   Float_t t = 0.;
1697   for (Int_t i = 0; i < n; ++i) {
1698     p[i] = a[i]*m[i]*d[i]*s[i];
1699     t  += p[i];
1700   }
1701   for (Int_t i = 0; i < n; ++i) {
1702     p[i] = p[i]/t;
1703     //    AliInfo(Form((\n weight[%i] = %f (,i,p[i]));
1704   }
1705 }