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