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