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