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