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