]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv5T0.cxx
Added new method DisIntegrate(AliMUONHit&, TList& digits) to replace the one in
[u/mrichter/AliRoot.git] / TOF / AliTOFv5T0.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
19 Revision 0.1 2004 November G. Cara Romeo and A. De Caro
20         Implement new TOF geometry version
21         in order to
22            suppress few volume overlaps
23                 (in the 4th TOF geometry version),
24            insert the realistic strip numbers and positions
25
26 */
27
28 ///////////////////////////////////////////////////////////////////////////////
29 //                                                                           //
30 //  This class contains the functions for version 5 of the Time Of Flight    //
31 //  detector.                                                                //
32 //                                                                           //
33 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
34 //                                                                           //
35 //  FULL COVERAGE VERSION + OPTION for PHOS holes                            //
36 //                                                                           //
37 //                                                                           //
38 //Begin_Html                                                                 //
39 /*                                                                           //
40 <img src="picts/AliTOFv5T0Class.gif">                                        //
41 */                                                                           //
42 //End_Html                                                                   //
43 //                                                                           //
44 ///////////////////////////////////////////////////////////////////////////////
45
46 #include "Riostream.h"
47 #include <stdlib.h>
48
49 #include "TVirtualMC.h"
50 #include <TBRIK.h>
51 #include <TGeometry.h>
52 #include <TLorentzVector.h>
53 #include <TNode.h>
54 #include <TObject.h>
55 #include <TVirtualMC.h>
56
57 #include "AliLog.h"
58 #include "AliConst.h"
59 #include "AliRun.h"
60 #include "AliMC.h"
61 #include "AliMagF.h"
62
63 #include "AliTOFGeometry.h"
64 #include "AliTOFGeometryV5.h"
65 #include "AliTOFv5T0.h"
66
67 ClassImp(AliTOFv5T0)
68
69 //_____________________________________________________________________________
70 AliTOFv5T0::AliTOFv5T0()
71 {
72   //
73   // Default constructor
74   //
75 }
76  
77 //_____________________________________________________________________________
78 AliTOFv5T0::AliTOFv5T0(const char *name, const char *title)
79         : AliTOF(name,title,"tzero")
80 {
81   //
82   // Standard constructor
83   //
84   //
85   // Check that FRAME is there otherwise we have no place where to
86   // put TOF
87
88
89   AliModule* frame=gAlice->GetModule("FRAME");
90   if(!frame) {
91     AliFatal("TOF needs FRAME to be present");
92   } else{
93     
94     if (fTOFGeometry) delete fTOFGeometry;
95     fTOFGeometry = new AliTOFGeometryV5();
96
97     if(frame->IsVersion()==1) {
98       AliInfo(Form("Frame version %d", frame->IsVersion())); 
99       AliInfo("Full Coverage for TOF");
100       fTOFHoles=false;}    
101     else {
102       AliInfo(Form("Frame version %d", frame->IsVersion())); 
103       AliInfo("TOF with Holes for PHOS");
104       fTOFHoles=true;}      
105   }
106   fTOFGeometry->SetHoles(fTOFHoles);
107
108   //AliTOF::fTOFGeometry = fTOFGeometry;
109
110   // Save the geometry
111   TDirectory* saveDir = gDirectory;
112   gAlice->GetRunLoader()->CdGAFile();
113   fTOFGeometry->Write("TOFgeometry");
114   saveDir->cd();
115
116
117
118 //____________________________________________________________________________
119 void AliTOFv5T0::BuildGeometry()
120 {
121   //
122   // Build TOF ROOT geometry for the ALICE event display
123   //
124   TNode *node, *top;
125   const int kColorTOF  = 27;
126   
127   // Find top TNODE
128   top = gAlice->GetGeometry()->GetNode("alice");
129   
130   // Position the different copies
131   const Float_t krTof  =(fTOFGeometry->Rmax()+fTOFGeometry->Rmin())/2.;
132   const Float_t khTof  = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
133   const Int_t   kNTof  = fTOFGeometry->NSectors();
134   const Float_t kangle = k2PI/kNTof;
135
136   const Float_t kInterCentrModBorder1 = 49.5;
137   const Float_t kInterCentrModBorder2 = 57.5;
138
139   Float_t ang;
140   
141   // define offset for nodes
142   Float_t zOffsetB = (fTOFGeometry->ZlenA()*0.5 + (kInterCentrModBorder1+kInterCentrModBorder2)*0.5)*0.5;
143   Float_t zOffsetA = 0.;
144   // Define TOF basic volume
145   
146   char nodeName0[7], nodeName1[7], nodeName2[7];
147   char nodeName3[7], nodeName4[7], rotMatNum[7];
148
149   if (fTOFHoles) {
150     new TBRIK("S_TOF_B","TOF box","void",
151               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
152     new TBRIK("S_TOF_C","TOF box","void",
153               fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
154   }
155   new TBRIK("S_TOF_A","TOF box","void",
156             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenA()*0.5);
157   
158   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
159     
160     if (nodeNum<10) {
161       sprintf(rotMatNum,"rot50%i",nodeNum);
162       sprintf(nodeName0,"FTO00%i",nodeNum);
163       sprintf(nodeName1,"FTO10%i",nodeNum);
164       sprintf(nodeName2,"FTO20%i",nodeNum);
165       sprintf(nodeName3,"FTO30%i",nodeNum);
166       sprintf(nodeName4,"FTO40%i",nodeNum);
167     }
168     if (nodeNum>9) {
169       sprintf(rotMatNum,"rot5%i",nodeNum);
170       sprintf(nodeName0,"FTO0%i",nodeNum);
171       sprintf(nodeName1,"FTO1%i",nodeNum);
172       sprintf(nodeName2,"FTO2%i",nodeNum);
173       sprintf(nodeName3,"FTO3%i",nodeNum);
174       sprintf(nodeName4,"FTO4%i",nodeNum);
175     }
176     
177     new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
178     ang = (4.5-nodeNum) * kangle;
179
180     if (fTOFHoles) {   
181       top->cd();
182       node = new TNode(nodeName2,nodeName2,"S_TOF_B", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetB,rotMatNum);
183       node->SetLineColor(kColorTOF);
184       fNodes->Add(node);
185       
186       top->cd();
187       node = new TNode(nodeName3,nodeName3,"S_TOF_C", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang),-zOffsetB,rotMatNum);
188       node->SetLineColor(kColorTOF);
189       fNodes->Add(node);
190     }
191
192     top->cd();
193     node = new TNode(nodeName4,nodeName4,"S_TOF_A", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetA,rotMatNum);
194     node->SetLineColor(kColorTOF);
195     fNodes->Add(node);
196   } // end loop on nodeNum
197
198 }
199
200 //_____________________________________________________________________________
201 void AliTOFv5T0::CreateGeometry()
202 {
203   //
204   // Create geometry for Time Of Flight version 0
205   //
206   //Begin_Html
207   /*
208     <img src="picts/AliTOFv5T0.gif">
209   */
210   //End_Html
211   //
212   // Creates common geometry
213   //
214   AliTOF::CreateGeometry();
215 }
216  
217
218 //_____________________________________________________________________________
219 void AliTOFv5T0::TOFpc(Float_t xtof,  Float_t ytof, Float_t zlenA,
220                        Float_t zlenB)
221 {
222
223   const Float_t kPi = TMath::Pi();
224
225   const Float_t kInterCentrModBorder1 = 49.5;
226   const Float_t kInterCentrModBorder2 = 57.5;
227   const Float_t kExterInterModBorder1 = 196.0;
228   const Float_t kExterInterModBorder2 = 203.5;
229
230   const Float_t kLengthExInModBorder  = 4.7;
231   const Float_t kLengthInCeModBorder  = 7.0;
232
233   const Float_t khAlWall = 0.1;
234
235   // module wall thickness
236   const Float_t kModuleWallThickness = 0.3;
237
238   //  1.5 cm Al honeycomb layer between strips and cards
239   const Float_t kHoneycombLayerThickness = 1.5;
240
241   AliDebug(2,Form("zlenA*0.5 = %d", zlenA*0.5));
242   AliDebug(1, "************************* TOF geometry **************************");
243   
244   // Definition of the Time Of Fligh Resistive Plate Chambers
245   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
246   
247   Float_t  ycoor, zcoor;
248   Float_t  par[3];
249   Int_t    *idtmed = fIdtmed->GetArray()-499;
250   Int_t    idrotm[100];
251
252   par[0] =  xtof * 0.5;
253   par[1] =  ytof * 0.5;
254   par[2] = zlenA * 0.5;
255   gMC->Gsvolu("FTOA", "BOX ", idtmed[503], par, 3);  // fibre glass
256   
257   if (fTOFHoles) {
258     par[2] = (zlenA*0.5 - kInterCentrModBorder1)*0.5;
259     gMC->Gsvolu("FTOB", "BOX ", idtmed[503], par, 3);
260     gMC->Gsvolu("FTOC", "BOX ", idtmed[503], par, 3);
261   }
262
263   // Positioning of modules
264   
265   //AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,-90.);
266   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90.,270.); // adc
267
268   Float_t zcor3 = 0.;
269
270   gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
271   gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
272   
273   if (fTOFHoles) {
274     zcor3 = (zlenA*0.5 + kInterCentrModBorder1)*0.5;
275     gMC->Gspos("FTOB", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
276     gMC->Gspos("FTOC", 0, "BTO2", 0,-zcor3,  0, idrotm[0], "ONLY");
277   }
278   else gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
279
280   // Large not sensitive volumes with Insensitive Freon  (FLTA, FLTB and FLTC)
281
282   Float_t xFLT, yFLT, zFLTA;
283   
284   xFLT  = xtof  - kModuleWallThickness*2.;
285   yFLT  = ytof  - kModuleWallThickness*2.;
286   zFLTA = zlenA - kModuleWallThickness*2.;
287   
288   par[0] = xFLT*0.5;
289   par[1] = yFLT*0.5;
290
291   par[2] = zFLTA*0.5;
292   gMC->Gsvolu("FLTA", "BOX ", idtmed[507], par, 3); //  Freon mix     ok
293   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
294
295   if (fTOFHoles) {
296     par[2] = (zlenA*0.5 - kInterCentrModBorder1-kModuleWallThickness)*0.5;
297     gMC->Gsvolu("FLTB", "BOX ", idtmed[507], par, 3); // Freon mix
298     gMC->Gspos ("FLTB", 0, "FTOB", 0., 0.,  kModuleWallThickness*0.5, 0, "ONLY");
299     gMC->Gsvolu("FLTC", "BOX ", idtmed[507], par, 3); // Freon mix
300     gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., -kModuleWallThickness*0.5, 0, "ONLY");
301   }
302
303   // Layer of Aluminum after detector
304   //par[0] = xFLT*0.5;
305   par[1] = khAlWall*0.5;
306
307   par[2] = zFLTA *0.5;
308   ycoor = (-yFLT + khAlWall)*0.5;
309   gMC->Gsvolu("FALA", "BOX ", idtmed[505], par, 3); // Alluminium     ok
310   gMC->Gspos ("FALA", 0, "FLTA", 0., -ycoor, 0., 0, "ONLY");
311
312   if (fTOFHoles) {
313     par[2] = (zlenA*0.5 - kInterCentrModBorder2-kModuleWallThickness)*0.5;
314     gMC->Gsvolu("FALB", "BOX ", idtmed[505], par, 3); // Alluminium
315     gMC->Gspos ("FALB", 1, "FLTB", 0.,-ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
316     gMC->Gspos ("FALB", 2, "FLTC", 0.,-ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
317   }
318
319   Float_t y0, alpha, beta, tgbe, trpa[11], dy, zcoo;
320   dy  = yFLT*0.5;
321
322   // wall between central and intermediate modules
323   y0    = kLengthInCeModBorder;
324   zcoor = kInterCentrModBorder1;
325   zcoo  = kInterCentrModBorder2;
326   alpha = TMath::ATan((dy-2.*y0)/(zcoo-zcoor));
327   beta = (kPi*0.5-alpha)*0.5;
328   tgbe = TMath::Tan(beta);
329   trpa[0]  = xFLT*0.5;//par[0];
330   trpa[1]  = 0.;
331   trpa[2]  = 0.;
332   trpa[3]  = kModuleWallThickness;
333   trpa[4]  = (y0-kModuleWallThickness*tgbe)*0.5;
334   trpa[5]  = (y0+kModuleWallThickness*tgbe)*0.5;
335   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
336   trpa[7]  = kModuleWallThickness;
337   trpa[8]  = (y0-kModuleWallThickness*tgbe)*0.5;
338   trpa[9]  = (y0+kModuleWallThickness*tgbe)*0.5;
339   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
340
341   gMC->Gsvolu("FWZ1","TRAP", idtmed[503], trpa, 11);   // fibre glass
342
343   AliMatrix (idrotm[1],90., 90.,180.,0.,90.,180.);
344   ycoor = -dy + y0*0.5;
345   gMC->Gspos("FWZ1", 1,"FLTA",0.,ycoor, zcoor,idrotm[1],"ONLY");
346
347   AliMatrix (idrotm[4],90., 90.,  0.,0.,90.,  0.);
348   gMC->Gspos("FWZ1", 2,"FLTA",0.,ycoor,-zcoor,idrotm[4],"ONLY");
349
350   if (fTOFHoles) {
351     Float_t y0B = y0 - kModuleWallThickness*0.5*tgbe;
352     Float_t ycoorB = ycoor - kModuleWallThickness*0.25/tgbe;
353     trpa[0]  = xFLT*0.5;//par[0];
354     trpa[1]  = 0.;
355     trpa[2]  = 0.;
356     trpa[3]  = kModuleWallThickness*0.5;
357     trpa[4]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
358     trpa[5]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
359     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
360     trpa[7]  = kModuleWallThickness*0.5;
361     trpa[8]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
362     trpa[9]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
363     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
364     gMC->Gsvolu("FZ1B","TRAP", idtmed[503], trpa, 11);   // fibre glass
365     gMC->Gspos("FZ1B", 5,"FLTB",0.,ycoorB,-zcoor+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[4],"ONLY");
366     gMC->Gspos("FZ1B", 6,"FLTC",0.,ycoorB,+zcoor-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[1],"ONLY");
367   }
368
369   AliMatrix (idrotm[2],90.,270.,  0.,0.,90.,180.);
370   ycoor = -y0*0.5;
371   gMC->Gspos("FWZ1", 3,"FLTA",0.,ycoor, zcoo,idrotm[2],"ONLY");
372   AliMatrix (idrotm[5],90.,270.,180.,0.,90.,  0.);
373   gMC->Gspos("FWZ1", 4,"FLTA",0.,ycoor,-zcoo,idrotm[5],"ONLY");
374
375   if (fTOFHoles) {
376     Float_t y0B = y0 + kModuleWallThickness*0.5*tgbe;
377     Float_t ycoorB = ycoor - kModuleWallThickness*0.25/tgbe;
378     trpa[0]  = xFLT*0.5;//par[0];
379     trpa[1]  = 0.;
380     trpa[2]  = 0.;
381     trpa[3]  = kModuleWallThickness*0.5;
382     trpa[4]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
383     trpa[5]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
384     trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
385     trpa[7]  = kModuleWallThickness*0.5;
386     trpa[8]  = (y0B-kModuleWallThickness*0.5*tgbe)*0.5;
387     trpa[9]  = (y0B+kModuleWallThickness*0.5*tgbe)*0.5;
388     trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
389     gMC->Gsvolu("FZ1C","TRAP", idtmed[503], trpa, 11);   // fibre glass
390     gMC->Gspos("FZ1C", 7,"FLTB",0.,ycoorB,-zcoo+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[5],"ONLY");
391     gMC->Gspos("FZ1C", 8,"FLTC",0.,ycoorB, zcoo-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[2],"ONLY");
392   }
393
394   trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
395   trpa[1] = kModuleWallThickness;
396   trpa[2] = xFLT*0.5;//par[0];
397   trpa[3] = -beta*kRaddeg;
398   trpa[4] = 0.;
399   trpa[5] = 0.;
400   gMC->Gsvolu("FWZ2","PARA", idtmed[503], trpa, 6);    // fibre glass
401   AliMatrix (idrotm[3],     alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
402   gMC->Gspos("FWZ2", 1,"FLTA",0.,-dy*0.5, (zcoo+zcoor)*0.5,idrotm[3],"ONLY");
403   AliMatrix (idrotm[6],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,  0.);
404   gMC->Gspos("FWZ2", 2,"FLTA",0.,-dy*0.5,-(zcoo+zcoor)*0.5,idrotm[6],"ONLY");
405
406   if (fTOFHoles) {
407     trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
408     trpa[1] = kModuleWallThickness*0.5;
409     trpa[2] = xFLT*0.5;//par[0];
410     trpa[3] = -beta*kRaddeg;
411     trpa[4] = 0.;
412     trpa[5] = 0.;
413     gMC->Gsvolu("FZ2B","PARA", idtmed[503], trpa, 6);    // fibre glass
414     gMC->Gspos("FZ2B", 3,"FLTB",0.,-dy*0.5-kModuleWallThickness*0.5/tgbe,-(zcoo+zcoor)*0.5+(zlenA*0.5+kInterCentrModBorder1)*0.5-kModuleWallThickness,idrotm[6],"ONLY");
415     gMC->Gspos("FZ2B", 4,"FLTC",0.,-dy*0.5-kModuleWallThickness*0.5/tgbe,+(zcoo+zcoor)*0.5-(zlenA*0.5+kInterCentrModBorder1)*0.5+kModuleWallThickness,idrotm[3],"ONLY");
416   }
417
418   // wall between intermediate and lateral modules
419   y0    = kLengthExInModBorder;//4.7;
420   zcoor = kExterInterModBorder1;//196.;
421   zcoo  = kExterInterModBorder2;//203.5;
422   alpha = TMath::ATan((dy-2.*y0)/(zcoo-zcoor));
423   beta = (kPi*0.5-alpha)*0.5;
424   tgbe = TMath::Tan(beta);
425   trpa[0]  = xFLT*0.5;//par[0];
426   trpa[1]  = 0.;
427   trpa[2]  = 0.;
428   trpa[3]  = kModuleWallThickness;
429   trpa[4]  = (y0-kModuleWallThickness*tgbe)*0.5;
430   trpa[5]  = (y0+kModuleWallThickness*tgbe)*0.5;
431   trpa[6]  = TMath::ATan(tgbe*0.5)*kRaddeg;
432   trpa[7]  = kModuleWallThickness;
433   trpa[8]  = (y0-kModuleWallThickness*tgbe)*0.5;
434   trpa[9]  = (y0+kModuleWallThickness*tgbe)*0.5;
435   trpa[10] = TMath::ATan(tgbe*0.5)*kRaddeg;
436   gMC->Gsvolu("FWZ3","TRAP", idtmed[503], trpa, 11);    // fibre glass
437   ycoor = -y0*0.5;
438   gMC->Gspos("FWZ3", 1,"FLTA",0.,ycoor, zcoor,idrotm[5],"ONLY");
439   gMC->Gspos("FWZ3", 2,"FLTA",0.,ycoor,-zcoor,idrotm[2],"ONLY");
440
441   if (fTOFHoles) {
442     gMC->Gspos("FWZ3", 5,"FLTB",0.,ycoor,-zcoor+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[2],"ONLY");
443     gMC->Gspos("FWZ3", 6,"FLTC",0.,ycoor, zcoor-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[5],"ONLY");
444   }
445   ycoor = -dy+y0*0.5;
446   gMC->Gspos("FWZ3", 3,"FLTA",0.,ycoor, zcoo,idrotm[4],"ONLY");
447   gMC->Gspos("FWZ3", 4,"FLTA",0.,ycoor,-zcoo,idrotm[1],"ONLY");
448
449   if (fTOFHoles) {
450     gMC->Gspos("FWZ3", 7,"FLTB",0.,ycoor,-zcoo+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[1],"ONLY");
451     gMC->Gspos("FWZ3", 8,"FLTC",0.,ycoor, zcoo-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[4],"ONLY");
452   }
453
454   trpa[0] = 0.5*(zcoo-zcoor)/TMath::Cos(alpha);
455   trpa[1] = kModuleWallThickness;
456   trpa[2] = xFLT*0.5;//par[0];
457   trpa[3] = -beta*kRaddeg;
458   trpa[4] = 0.;
459   trpa[5] = 0.;
460   gMC->Gsvolu("FWZ4","PARA", idtmed[503], trpa, 6);    // fibre glass
461   AliMatrix (idrotm[3],alpha*kRaddeg,90.,90.+alpha*kRaddeg,90.,90.,180.);
462   AliMatrix (idrotm[6],180.-alpha*kRaddeg,90.,90.-alpha*kRaddeg,90.,90.,0.);
463   gMC->Gspos("FWZ4", 1,"FLTA",0.,-dy*0.5, (zcoo+zcoor)*0.5,idrotm[6],"ONLY");
464   gMC->Gspos("FWZ4", 2,"FLTA",0.,-dy*0.5,-(zcoo+zcoor)*0.5,idrotm[3],"ONLY");
465
466   if (fTOFHoles) {
467     gMC->Gspos("FWZ4", 3,"FLTB",0.,-dy*0.5,-(zcoo+zcoor)*0.5+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[3],"ONLY");
468     gMC->Gspos("FWZ4", 4,"FLTC",0.,-dy*0.5, (zcoo+zcoor)*0.5-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[6],"ONLY");
469   }
470
471   ///////////////// Detector itself //////////////////////
472
473   const Int_t    knx   = fTOFGeometry->NpadX();  // number of pads along x
474   const Int_t    knz   = fTOFGeometry->NpadZ();  // number of pads along z
475   const Float_t  kPadX = fTOFGeometry->XPad();   // pad length along x
476   const Float_t  kPadZ = fTOFGeometry->ZPad();   // pad length along z
477
478   // new description for strip volume -double stack strip-
479   // -- all constants are expressed in cm
480   // heigth of different layers
481   const Float_t khhony   = 1.0    ;   // heigth of HONY  Layer
482   const Float_t khpcby   = 0.08   ;   // heigth of PCB   Layer
483   const Float_t khrgly   = 0.055  ;   // heigth of RED GLASS  Layer
484   const Float_t khglfy   = 0.285  ;   // heigth of GLASS+FISHLINE  Layer
485   const Float_t khcpcby  = 0.16   ;   // heigth of PCB  Central Layer
486   const Float_t kwhonz   = 8.1    ;   // z dimension of HONEY  Layer
487   const Float_t kwpcbz1  = 10.6   ;   // z dimension of PCB  Lower Layer
488   const Float_t kwpcbz2  = 11.6   ;   // z dimension of PCB  Upper Layer
489   const Float_t kwcpcbz  = 12.4   ;   // z dimension of PCB  Central Layer
490   const Float_t kwrglz   = 8.     ;   // z dimension of RED GLASS  Layer
491   const Float_t kwglfz   = 7.     ;   // z dimension of GLASS+FISHLN Layer
492   const Float_t klsensmx = knx*kPadX; // length of Sensitive Layer
493   const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer // ADC
494   const Float_t kwsensmz = knz*kPadZ; // width of Sensitive Layer
495   
496   // heigth of the FSTR Volume (the strip volume)
497   const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;
498
499   // width  of the FSTR Volume (the strip volume)
500   const Float_t kwstripz = kwcpcbz;
501   // length of the FSTR Volume (the strip volume)
502   const Float_t klstripx = fTOFGeometry->StripLength();//122.;
503   
504   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
505   // Coordinates of the strip center in the strip reference frame;
506   // used for positioning internal strip volumes
507   Float_t posfp[3]={0.,0.,0.};  
508
509   // FSTR volume definition-filling this volume with non sensitive Gas Mixture
510   gMC->Gsvolu("FSTR","BOX",idtmed[507],parfp,3);     // Freon mix
511
512   //-- HONY Layer definition
513   parfp[1] = khhony*0.5;
514   parfp[2] = kwhonz*0.5;
515   gMC->Gsvolu("FHON","BOX",idtmed[501],parfp,3);     // honeycomb (Nomex)
516   // positioning 2 HONY Layers on FSTR volume
517   posfp[1] =-khstripy*0.5+parfp[1];
518   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
519   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
520   
521   //-- PCB Layer definition
522   parfp[1] = khpcby*0.5;
523   parfp[2] = kwpcbz1*0.5;
524   gMC->Gsvolu("FPC1","BOX",idtmed[502],parfp,3);     // G10
525   parfp[2] = kwpcbz2*0.5;
526   gMC->Gsvolu("FPC2","BOX",idtmed[502],parfp,3);     // G10
527   // positioning 2 PCB Layers on FSTR volume
528   posfp[1] =-khstripy*0.5+khhony+parfp[1];
529   gMC->Gspos("FPC1",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
530   gMC->Gspos("FPC2",1,"FSTR",0., posfp[1],0.,0,"ONLY");
531
532   //-- central PCB layer definition
533   parfp[1] = khcpcby*0.5;
534   parfp[2] = kwcpcbz*0.5;
535   gMC->Gsvolu("FPCB","BOX",idtmed[502],parfp,3);     // G10
536   // positioning the central PCB layer
537   gMC->Gspos("FPCB",1,"FSTR",0.,0.,0.,0,"ONLY");
538   
539   //      Sensitive volume
540   Float_t parfs[3] = {klsensmx*0.5, khsensmy*0.5, kwsensmz*0.5};
541   gMC->Gsvolu("FSEN","BOX",idtmed[508],parfs,3);     // sensitive ...
542   // dividing FSEN along z in knz=2 and along x in knx=48
543   gMC->Gsdvn("FSEZ","FSEN",knz,3);
544   gMC->Gsdvn("FPAD","FSEZ",knx,1);
545   // positioning a Sensitive layer inside FPCB
546   gMC->Gspos("FSEN",1,"FPCB",0.,0.,0.,0,"ONLY");
547
548   //-- RED GLASS Layer definition
549   parfp[1] = khrgly*0.5;
550   parfp[2] = kwrglz*0.5;
551   gMC->Gsvolu("FRGL","BOX",idtmed[509],parfp,3);     // glass
552   // positioning 4 RED GLASS Layers on FSTR volume
553   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
554   gMC->Gspos("FRGL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
555   gMC->Gspos("FRGL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
556   posfp[1] = (khcpcby+khrgly)*0.5;
557   gMC->Gspos("FRGL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
558   gMC->Gspos("FRGL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
559
560   //-- GLASS+FISHLINE Layer definition
561   parfp[1] = khglfy*0.5;
562   parfp[2] = kwglfz*0.5;
563   gMC->Gsvolu("FGLF","BOX",idtmed[504],parfp,3);
564
565   // positioning 2 GLASS+FISHLINE Layers on FSTR volume
566   posfp[1] = (khcpcby+khglfy)*0.5+khrgly;
567   gMC->Gspos("FGLF",1,"FSTR",0.,-posfp[1],0.,0,"ONLY");
568   gMC->Gspos("FGLF",2,"FSTR",0., posfp[1],0.,0,"ONLY");
569
570
571   //  Positioning the Strips  (FSTR) in the FLT volumes
572   Int_t maxStripNumbers [5] ={fTOFGeometry->NStripC(),
573                               fTOFGeometry->NStripB(),
574                               fTOFGeometry->NStripA(),
575                               fTOFGeometry->NStripB(),
576                               fTOFGeometry->NStripC()};
577
578   Int_t totalStrip = 0;
579   Float_t zpos, ypos, ang;
580   for(Int_t iplate =0; iplate < fTOFGeometry->NPlates(); iplate++){
581     if (iplate>0) totalStrip += maxStripNumbers[iplate-1];
582     for(Int_t istrip =0; istrip < maxStripNumbers[iplate]; istrip++){
583
584       ang = fTOFGeometry->GetAngles(iplate,istrip);
585       AliDebug(1, Form(" iplate = %1i, istrip = %2i ---> ang = %f", iplate, istrip, ang));
586  
587       if (ang>0.)       AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90., ang, 90.);
588       else if (ang==0.) AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.,90., 0., 0.);
589       else if (ang<0.)  AliMatrix (idrotm[istrip+totalStrip+1],90.,0.,90.+ang,90.,-ang,270.);
590
591
592       zpos = fTOFGeometry->GetDistances(iplate,istrip);
593       ypos = fTOFGeometry->GetHeights(iplate,istrip);
594
595       gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTA",0.,ypos,-zpos,idrotm[istrip+totalStrip+1],  "ONLY");
596
597       if (fTOFHoles) {
598         if (istrip+totalStrip+1>53) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTC",0.,ypos,-zpos-(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
599         if (istrip+totalStrip+1<39) gMC->Gspos("FSTR",istrip+totalStrip+1,"FLTB",0.,ypos,-zpos+(zlenA*0.5 + kInterCentrModBorder1 - kModuleWallThickness)*0.5,idrotm[istrip+totalStrip+1],"ONLY");
600       }
601     }
602   }
603
604   //  1.5 cm Al honeycomb layer between strips and cards
605   par[0] = xFLT*0.5;
606   par[1] = kHoneycombLayerThickness*0.5;
607   par[2] = zFLTA*0.5;
608   ycoor  = kHoneycombLayerThickness*0.5;
609   gMC->Gsvolu("FPEA", "BOX ", idtmed[506], par, 3);   // Al honeycomb ok giovanni cara romeo
610   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
611
612   if (fTOFHoles) {
613     par[2] = (zlenA*0.5 - kInterCentrModBorder2-kModuleWallThickness)*0.5;
614     ycoor = kHoneycombLayerThickness*0.5;
615     gMC->Gsvolu("FPEB", "BOX ", idtmed[506], par, 3);   // Al honeycomb ok giovanni cara romeo
616     gMC->Gspos ("FPEB", 1, "FLTB", 0., ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
617     gMC->Gspos ("FPEB", 2, "FLTC", 0., ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
618   }
619
620   // frame of Air
621   ycoor += kHoneycombLayerThickness*0.5;
622   //par[0] = xFLT*0.5;
623   par[1] = (yFLT*0.5-kHoneycombLayerThickness-khAlWall)*0.5;
624   par[2] = zFLTA *0.5;
625   ycoor += (yFLT*0.5-kHoneycombLayerThickness-khAlWall)*0.5;
626   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
627   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
628
629   if (fTOFHoles) {
630     par[2] = (zlenA*0.5 - kInterCentrModBorder2 - kModuleWallThickness)*0.5;
631     gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
632     gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, -(kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
633     gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
634     gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor,  (kInterCentrModBorder2-kInterCentrModBorder1)*0.5, 0, "ONLY");
635   }
636
637   // start with cards and cooling tubes
638   // finally, cards, cooling tubes and layer for thermal dispersion
639   // 3 volumes
640   
641   // see GEOM200 in GEANT manual
642
643   //AliMatrix(idrotm[98], 90., 0., 90., 90., 0., 0.); // 0 deg
644   
645   Float_t cardpar[3];
646
647   // card volume definition
648   cardpar[0]= xFLT*0.5;
649   cardpar[1]= 5.;
650   cardpar[2]= 0.1;
651   gMC->Gsvolu("FCAR", "BOX ", idtmed[502], cardpar, 3); // PCB Card 
652
653   //alu plate volume definition
654   cardpar[1]= 3.5;
655   cardpar[2]= 0.05;
656   gMC->Gsvolu("FALP", "BOX ", idtmed[505], cardpar, 3); // Alu Plate
657
658   // tube volume definition
659   Float_t tubepar[3];
660   tubepar[0]= 0.;
661   tubepar[1]= 0.4;
662   tubepar[2]= 61.;
663   gMC->Gsvolu("FTUB", "TUBE", idtmed[511], tubepar, 3); // cooling tubes (steel)
664
665   //tubepar[0]= 0.;
666   tubepar[1]= 0.35;
667   //tubepar[2]= 61.;
668   gMC->Gsvolu("FITU", "TUBE", idtmed[510], tubepar, 3); // cooling water
669   // positioning water tube into the steel one
670   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
671
672   // rotation matrix
673   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
674
675   // central module positioning
676   Float_t cardpos[3], aplpos2;
677   Float_t stepforcardA=6.625;
678   Float_t tdis=0.6;
679   Float_t aplpos1 = -2.;
680
681   cardpos[0]= 0.;
682   cardpos[1]= -0.5;
683   cardpos[2]= -53.;
684   //  tubepos= -53.+tdis;
685   Int_t icard;
686   for (icard=39; icard<54; ++icard) {
687     cardpos[2]= cardpos[2]+stepforcardA;
688     aplpos2 = cardpos[2]+0.15;
689     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],     cardpos[2],         0,"ONLY"); 
690     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],   aplpos1,        aplpos2,         0,"ONLY");
691     gMC->Gspos("FTUB",icard,"FAIA",        0.,cardpos[1],cardpos[2]+tdis,idrotm[99],"ONLY");
692   }
693   
694   // intermediate module positioning
695   Float_t stepforcardB= 7.05;
696   Float_t offs = 53.;
697
698   cardpos[2]= offs;
699   for (icard=20; icard<39; ++icard) {
700     cardpos[2]= cardpos[2]+stepforcardB;
701     aplpos2 = cardpos[2]+0.15;
702
703     gMC->Gspos("FCAR",icard+34,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY");
704     gMC->Gspos("FALP",icard+34,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
705     gMC->Gspos("FTUB",icard+34,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
706     gMC->Gspos("FCAR",58-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
707     gMC->Gspos("FALP",58-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
708     gMC->Gspos("FTUB",58-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
709
710     if (fTOFHoles) {
711       gMC->Gspos("FCAR",icard+34+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
712       gMC->Gspos("FALP",icard+34+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
713       gMC->Gspos("FTUB",icard+34+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
714       gMC->Gspos("FCAR",58-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
715       gMC->Gspos("FALP",58-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
716       gMC->Gspos("FTUB",58-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
717     }
718     
719   }
720
721   // outer module positioning
722   Float_t stepforcardC= 8.45238;
723   offs += zlenB;
724   cardpos[2]= offs;
725   for (icard=1; icard<20; ++icard) {
726     cardpos[2]= cardpos[2]+stepforcardC;
727     aplpos2 = cardpos[2]+0.15;
728
729     gMC->Gspos("FCAR",icard+72,"FAIA",cardpos[0],cardpos[1],      cardpos[2],         0,"ONLY"); 
730     gMC->Gspos("FALP",icard+72,"FAIA",cardpos[0],   aplpos1,         aplpos2,         0,"ONLY");
731     gMC->Gspos("FTUB",icard+72,"FAIA",        0.,cardpos[1], cardpos[2]+tdis,idrotm[99],"ONLY");
732     gMC->Gspos("FCAR",20-icard,"FAIA",cardpos[0],cardpos[1],     -cardpos[2],         0,"ONLY");
733     gMC->Gspos("FALP",20-icard,"FAIA",cardpos[0],   aplpos1,        -aplpos2,         0,"ONLY");
734     gMC->Gspos("FTUB",20-icard,"FAIA",        0.,cardpos[1],-cardpos[2]-tdis,idrotm[99],"ONLY");
735
736     if (fTOFHoles) {
737       gMC->Gspos("FCAR",icard+72+182,"FAIC",cardpos[0],cardpos[1],      cardpos[2]-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
738       gMC->Gspos("FALP",icard+72+182,"FAIC",cardpos[0],   aplpos1,         aplpos2-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
739       gMC->Gspos("FTUB",icard+72+182,"FAIC",        0.,cardpos[1], cardpos[2]+tdis-(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
740       gMC->Gspos("FCAR",20-icard+ 91,"FAIB",cardpos[0],cardpos[1],     -cardpos[2]+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
741       gMC->Gspos("FALP",20-icard+ 91,"FAIB",cardpos[0],   aplpos1,        -aplpos2+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,         0,"ONLY");
742       gMC->Gspos("FTUB",20-icard+ 91,"FAIB",        0.,cardpos[1],-cardpos[2]-tdis+(zlenA*0.5 + kInterCentrModBorder2 - kModuleWallThickness)*0.5,idrotm[99],"ONLY");
743     }
744   }
745
746 }
747 //_____________________________________________________________________________
748 void AliTOFv5T0::DrawModule() const
749 {
750   //
751   // Draw a shaded view of the Time Of Flight version 4
752   //
753
754   // Set everything unseen
755   gMC->Gsatt("*", "seen", -1);
756
757   //
758   //Set volumes visible
759   // 
760
761   //Set ALIC mother transparent
762   gMC->Gsatt("ALIC","SEEN", 0);
763
764 //=====> Level 1
765   // Level 1 for TOF volumes
766   gMC->Gsatt("B077","seen", 0);
767
768 //=====> Level 2
769   // Level 2 for TOF volumes
770   gMC->Gsatt("B071","seen", 0);
771   gMC->Gsatt("B074","seen", 0);
772   gMC->Gsatt("B075","seen", 0);
773   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
774   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
775
776   // Level 2 of B071
777   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
778   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
779   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
780   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
781   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
782
783   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
784   gMC->Gsatt("BTO1","seen", 0);
785
786   // Level 2 of B074
787   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
788   gMC->Gsatt("BTO2","seen", 0);
789
790   // Level 2 of B075
791   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
792   gMC->Gsatt("BTO3","seen", 0);
793
794   // Level 3 of B071, B074 and B075
795   gMC->Gsatt("FTOA","SEEN", 0);
796   if (fTOFHoles) gMC->Gsatt("FTOB","SEEN", 0);
797
798   // Level 4 of B071, B074 and B075
799   gMC->Gsatt("FLTA","SEEN", 0);
800   if (fTOFHoles) gMC->Gsatt("FLTB","SEEN",0);
801   if (fTOFHoles) gMC->Gsatt("FLTC","SEEN",0);
802
803   // Level 5 of B071, B074 and B075
804   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
805   if (fTOFHoles) gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
806   if (fTOFHoles) gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
807
808   gMC->Gsatt("FALA","SEEN", 0);
809   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
810
811   gMC->Gsatt("FPEA","SEEN", 1);
812   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 1);
813
814   gMC->Gsatt("FSTR","SEEN",-1);  // all FSTR sub-levels skipped   -
815
816   gMC->Gsatt("FWZ1","SEEN", 0);
817   gMC->Gsatt("FWZ2","SEEN", 0);
818   gMC->Gsatt("FWZ3","SEEN", 0);
819   gMC->Gsatt("FWZ4","SEEN", 0);
820   if (fTOFHoles) {
821     gMC->Gsatt("FZ1B","SEEN", 0);
822     gMC->Gsatt("FZ1C","SEEN", 0);
823     gMC->Gsatt("FZ2B","SEEN", 0);
824   }
825
826   gMC->Gdopt("hide", "on");
827   gMC->Gdopt("shad", "on");
828   gMC->Gsatt("*", "fill", 7);
829   gMC->SetClipBox(".");
830   gMC->SetClipBox("*", 100, 1000, 100, 1000, 100, 1000);
831   gMC->DefaultRange();
832   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
833   gMC->Gdhead(1111, "Time Of Flight");
834   gMC->Gdman(18, 3, "MAN");
835   gMC->Gdopt("hide","off");
836 }
837 //_____________________________________________________________________________
838 void AliTOFv5T0::DrawDetectorModules()
839 {
840   //
841   // Draw a shaded view of the TOF detector version 4
842   //
843  
844   // Set everything unseen
845   gMC->Gsatt("*", "seen", -1);
846
847   //
848   //Set volumes visible
849   // 
850
851   //Set ALIC mother transparent
852   gMC->Gsatt("ALIC","SEEN", 0);
853
854 //=====> Level 1
855   // Level 1 for TOF volumes
856   gMC->Gsatt("B077","seen", 0);
857
858 //=====> Level 2
859   // Level 2 for TOF volumes
860   gMC->Gsatt("B071","seen", 0);
861   gMC->Gsatt("B074","seen", 0);
862   gMC->Gsatt("B075","seen", 0);
863   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
864   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
865
866   // Level 2 of B071
867   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
868   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
869   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
870   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
871   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
872
873   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
874   gMC->Gsatt("BTO1","seen", 0);
875
876   // Level 2 of B074
877   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
878   gMC->Gsatt("BTO2","seen", 0);
879
880   // Level 2 of B075
881   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
882   gMC->Gsatt("BTO3","seen", 0);
883
884   // Level 3 of B071, B075 and B074
885   gMC->Gsatt("FTOA","seen",-2);  // all FTOA sub-levels skipped   -
886   if (fTOFHoles) {
887     gMC->Gsatt("FTOB","seen",-2);  // all FTOB sub-levels skipped   -
888     gMC->Gsatt("FTOC","seen",-2);  // all FTOC sub-levels skipped   -
889   }
890
891   gMC->Gdopt("hide","on");
892   gMC->Gdopt("shad","on");
893   gMC->Gsatt("*", "fill", 5);
894   gMC->SetClipBox(".");
895   gMC->SetClipBox("*", 100, 1000, 100, 1000, 0, 1000);
896   gMC->DefaultRange();
897   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
898   gMC->Gdhead(1111,"TOF detector");
899   gMC->Gdman(18, 3, "MAN");
900   gMC->Gdopt("hide","off");
901 }                                 
902
903 //_____________________________________________________________________________
904 void AliTOFv5T0::DrawDetectorStrips()
905 {
906   //
907   // Draw a shaded view of the TOF strips for version 4
908   //
909
910   // Set everything unseen
911   gMC->Gsatt("*", "seen", -1);
912
913   //
914   //Set volumes visible
915   // 
916   
917   //Set ALIC mother transparent
918   gMC->Gsatt("ALIC","SEEN", 0);
919   
920 //=====> Level 1
921   // Level 1 for TOF volumes
922   gMC->Gsatt("B077","seen", 0);
923
924 //=====> Level 2
925   // Level 2 for TOF volumes
926   gMC->Gsatt("B071","seen", 0);
927   gMC->Gsatt("B074","seen", 0);
928   gMC->Gsatt("B075","seen", 0);
929   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
930   gMC->Gsatt("B080","seen", 0);  // B080 does not has sub-level                
931
932   // Level 2 of B071
933   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
934   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
935   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
936   gMC->Gsatt("B056","seen", 0);  // B056 does not has sub-levels  -
937   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
938
939   gMC->Gsatt("BTR1","seen", 0);  // all BTR1 sub-levels skipped   -
940   gMC->Gsatt("BTO1","seen", 0);
941
942   // Level 2 of B074
943   gMC->Gsatt("BTR2","seen", 0);  // all BTR1 sub-levels skipped   -
944   gMC->Gsatt("BTO2","seen", 0);
945
946   // Level 2 of B075
947   gMC->Gsatt("BTR3","seen", 0);  // all BTR1 sub-levels skipped   -
948   gMC->Gsatt("BTO3","seen", 0);
949
950   // Level 3 of B071, B074 and B075
951   gMC->Gsatt("FTOA","SEEN", 0);
952   if (fTOFHoles) {
953     gMC->Gsatt("FTOB","SEEN", 0);
954     gMC->Gsatt("FTOC","SEEN", 0);
955   }
956
957   // Level 4 of B071, B074 and B075
958   gMC->Gsatt("FLTA","SEEN", 0);
959   if (fTOFHoles) {
960     gMC->Gsatt("FLTB","SEEN", 0);
961     gMC->Gsatt("FLTC","SEEN", 0);
962   }
963
964   // Level 5 of B071, B074 and B075
965   gMC->Gsatt("FAIA","SEEN",-1);  // all FAIA sub-levels skipped   -
966   if (fTOFHoles) {
967     gMC->Gsatt("FAIB","SEEN",-1);  // all FAIB sub-levels skipped   -
968     gMC->Gsatt("FAIC","SEEN",-1);  // all FAIC sub-levels skipped   -
969   }
970
971   gMC->Gsatt("FALA","SEEN", 0);
972   if (fTOFHoles) gMC->Gsatt("FALB","SEEN", 0);
973
974   gMC->Gsatt("FPEA","SEEN", 0);
975   if (fTOFHoles) gMC->Gsatt("FPEB","SEEN", 0);
976
977   gMC->Gsatt("FSTR","SEEN",-2);  // all FSTR sub-levels skipped   -
978
979   gMC->Gsatt("FWZ1","SEEN", 0);
980   gMC->Gsatt("FWZ2","SEEN", 0);
981   gMC->Gsatt("FWZ3","SEEN", 0);
982   gMC->Gsatt("FWZ4","SEEN", 0);
983   if (fTOFHoles){
984     gMC->Gsatt("FZ1B","SEEN", 0);
985     gMC->Gsatt("FZ1C","SEEN", 0);
986     gMC->Gsatt("FZ2B","SEEN", 0);
987   }
988
989   /*
990   // Level 2 of FAIA
991   // Level 2 of FAIB
992   // Level 2 of FAIC
993   gMC->Gsatt("FALP","SEEN",0);
994   gMC->Gsatt("FCAR","SEEN",0);
995   gMC->Gsatt("FTUB","SEEN",-1);  // all FTUB sub-levels skipped   -
996
997   // Level 2 of FTUB
998   gMC->Gsatt("FITU","SEEN",0);
999   */
1000
1001   /*
1002   // Level 2 of FSTR
1003   gMC->Gsatt("FGLF","SEEN",0);
1004   gMC->Gsatt("FHON","SEEN",0);
1005   gMC->Gsatt("FPC1","SEEN",0);
1006   gMC->Gsatt("FPC2","SEEN",0);
1007   gMC->Gsatt("FPCB","SEEN",0);
1008   gMC->Gsatt("FRGL","SEEN",0);
1009
1010   // Level 2 of FPCB => Level 3 of FSTR
1011   gMC->Gsatt("FSEN","SEEN",0);
1012   gMC->Gsatt("FSEZ","SEEN",0);
1013   gMC->Gsatt("FPAD","SEEN",1);
1014   */
1015
1016   gMC->Gdopt("hide","on");
1017   gMC->Gdopt("shad","on");
1018   gMC->Gsatt("*", "fill", 5);
1019   gMC->SetClipBox(".");
1020   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
1021   gMC->DefaultRange();
1022   gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .018, .018);
1023   gMC->Gdhead(1111,"TOF Strips");
1024   gMC->Gdman(18, 3, "MAN");
1025   gMC->Gdopt("hide","off");
1026 }
1027
1028 //_____________________________________________________________________________
1029 void AliTOFv5T0::CreateMaterials()
1030 {
1031   //
1032   // Define materials for the Time Of Flight
1033   //
1034
1035   //AliTOF::CreateMaterials();
1036
1037   Int_t   isxfld = gAlice->Field()->Integ();
1038   Float_t sxmgmx = gAlice->Field()->Max();
1039   Float_t we[7], ae[7], na[7], fr[7], vl[7];
1040   Int_t i;
1041
1042   //
1043   //--- Quartz (SiO2) to simulate float glass
1044   //    density tuned to have correct float glass 
1045   //    radiation length
1046   Float_t   aq[2] = { 28.0855,15.9994 };
1047   Float_t   zq[2] = { 14.,8. };
1048   Float_t   wq[2] = { 1.,2. };
1049   Float_t   dq = 2.55; // std value: 2.2
1050   Int_t nq = -2;
1051
1052   // --- Nomex
1053   Float_t anox[4] = {12.01,1.01,16.00,14.01};
1054   Float_t znox[4] = { 6.,  1.,  8.,  7.};
1055   Float_t wnox[4] = {14., 22., 2., 2.};
1056   Float_t dnox  = 0.048;
1057   Int_t nnox   = -4;
1058
1059   //  { Si, C, H, O }
1060   Float_t ag10[4] = {28.09,12.01,1.01,16.00};
1061   Float_t zg10[4] = {14.,  6.,  1.,  8.};
1062   Float_t wmatg10[4];
1063   Int_t nlmatg10  = 4;
1064   for (i = 0; i < nlmatg10; ++i) {
1065     ae[i] = ag10[i];
1066     vl[i] = 1.;
1067   }
1068   ae[4] = 16.00;
1069   vl[4] = 1.;
1070   na[0] = 1.; 
1071   na[1] = 14.;
1072   na[2] = 20.;
1073   na[3] = 2.;
1074   na[4] = 3.;
1075   fr[0] = 0.6;
1076   fr[1] = 0.4;
1077   fr[2] = 0.4;
1078   fr[3] = 0.6;
1079   fr[4] = 0.4;
1080   MaterialMixer(we,ae,na,fr,vl,5);
1081   we[3] += we[4];
1082   wmatg10[0]= we[0];
1083   wmatg10[1]= we[1];
1084   wmatg10[2]= we[2];
1085   wmatg10[3]= we[3];
1086   Float_t densg10 = 1.7;
1087
1088   // -- Water
1089   Float_t awa[2] = {  1., 16. };
1090   Float_t zwa[2] = {  1.,  8. };
1091   Float_t wwa[2] = {  2.,  1. };
1092   Float_t dwa    = 1.0;
1093   Int_t nwa = -2;
1094
1095   // stainless steel
1096   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
1097   Float_t zsteel[4] = { 26.,24.,28.,14. };
1098   Float_t wsteel[4] = { .715,.18,.1,.005 };
1099
1100   // AIR
1101   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
1102   Float_t zAir[4]={6.,7.,8.,18.};
1103   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
1104   Float_t dAir = 1.20479E-3;
1105
1106   // --- fibre glass
1107   Float_t afg[4] = {28.09,16.00,12.01,1.01};
1108   Float_t zfg[4] = {14., 8., 6., 1.};
1109   Float_t wfg[4] = {0.12906,0.29405,0.51502,0.06187};
1110   Float_t dfg  = 1.111;
1111   Int_t nfg   = 4;
1112
1113   // --- Freon C2F4H2 + SF6
1114   Float_t afre[4]= {12.01,1.01,19.00,32.07};
1115   Float_t zfre[4]= { 6., 1., 9., 16.};
1116   Float_t wfre[4]= {0.21250,0.01787,0.74827,0.021355};
1117   Float_t densfre= 0.00375;
1118   Int_t nfre  = 4;
1119
1120   char namat[15] = "            ";
1121   Float_t ama[2], zma[2], dma, radl, absl, buf[1];
1122   Int_t nbuf;
1123
1124   AliMixture ( 0, "Air$", aAir, zAir, dAir, 4, wAir);
1125   AliMixture ( 1, "Nomex$", anox, znox, dnox, nnox, wnox);
1126   AliMixture ( 2, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
1127   AliMixture ( 3, "fibre glass$", afg, zfg, dfg, nfg, wfg);
1128   AliMaterial( 4, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
1129   AliMaterial( 5, "Al honeycomb$", 26.98, 13., 0.0496, 483., 2483.);
1130   AliMixture ( 6, "Freon$",  afre, zfre, densfre, nfre, wfre);
1131   AliMixture ( 7, "Glass$", aq, zq, dq, nq, wq);
1132
1133   // get freon and glass
1134   gMC->Gfmate((*fIdmate)[6],namat,ama[0],zma[0],dma,radl,absl,buf,nbuf);
1135   gMC->Gfmate((*fIdmate)[7],namat,ama[1],zma[1],dma,radl,absl,buf,nbuf);
1136
1137   // --- glass-freon
1138   Float_t wgfr[2]= {0.0011,0.9989};
1139   Float_t dgfr = 1.434;
1140   Int_t ngfr  = 2;
1141   AliMixture ( 8, "glass-freon$", ama, zma, dgfr, ngfr, wgfr);
1142   AliMixture ( 9, "Water$",  awa, zwa, dwa, nwa, wwa);
1143   AliMixture (10, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
1144
1145   Float_t epsil, stmin, deemax, stemax;
1146  
1147   //   Previous data
1148   //       EPSIL  = 0.1   ! Tracking precision,
1149   //       STEMAX = 0.1   ! Maximum displacement for multiple scattering
1150   //       DEEMAX = 0.1   ! Maximum fractional energy loss, DLS
1151   //       STMIN  = 0.1
1152
1153   //   New data
1154   epsil  = .001;  // Tracking precision,
1155   stemax = -1.;   // Maximum displacement for multiple scattering
1156   deemax = -.3;   // Maximum fractional energy loss, DLS
1157   stmin  = -.8;
1158
1159   AliMedium( 1, "Air$",         0, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1160   AliMedium( 2,"Nomex$",        1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1161   AliMedium( 3,"G10$",          2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1162   AliMedium( 4,"fibre glass$",  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1163   AliMedium( 5,"glass-freon$",  8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1164   AliMedium( 6,"Al Frame$",     4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1165   AliMedium( 7,"Al honeycomb$", 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1166   AliMedium( 8,"Fre$",          6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1167   AliMedium( 9,"PCB-S$",        2, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1168   AliMedium(10,"Glass$",        7, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1169   AliMedium(11,"Water$",        9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1170   AliMedium(12,"STEEL$",       10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1171
1172 }
1173 //_____________________________________________________________________________
1174 void AliTOFv5T0::Init()
1175 {
1176   //
1177   // Initialise the detector after the geometry has been defined
1178   //
1179   AliDebug(1, "**************************************"
1180            "  TOF  "
1181            "**************************************");
1182   AliDebug(1, "  Version 4 of TOF initialing, "
1183            "symmetric TOF - Full Coverage version");
1184   
1185   AliTOF::Init();
1186   
1187   fIdFTOA = gMC->VolId("FTOA");
1188   if (fTOFHoles) {
1189     fIdFTOB = gMC->VolId("FTOB");
1190     fIdFTOC = gMC->VolId("FTOC");
1191   }
1192   fIdFLTA = gMC->VolId("FLTA");
1193   if (fTOFHoles) {
1194     fIdFLTB = gMC->VolId("FLTB");
1195     fIdFLTC = gMC->VolId("FLTC");
1196   }
1197
1198   AliDebug(1, "**************************************"
1199            "  TOF  "
1200            "**************************************");
1201 }
1202  
1203 //_____________________________________________________________________________
1204 void AliTOFv5T0::StepManager()
1205 {
1206
1207   //
1208   // Procedure called at each step in the Time Of Flight
1209   //
1210
1211   TLorentzVector mom, pos;
1212   Float_t xm[3],pm[3],xpad[3],ppad[3];
1213   Float_t hits[14],phi,phid;
1214   Int_t   vol[5];
1215   Int_t   plate = -1;
1216   Int_t   sector, padx, padz, strip;
1217   Int_t   copy, padzid, padxid, stripid, i;
1218   Int_t   *idtmed = fIdtmed->GetArray()-499;
1219   Float_t incidenceAngle;
1220
1221   if(
1222      gMC->IsTrackEntering()
1223      && gMC->TrackCharge()
1224      && gMC->GetMedium()==idtmed[508]
1225      && gMC->CurrentVolID(copy)==fIdSens
1226      )
1227   {
1228
1229     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1230
1231     // getting information about hit volumes
1232     
1233     padzid=gMC->CurrentVolOffID(1,copy);
1234     padz=copy;
1235     padz--;
1236
1237     padxid=gMC->CurrentVolOffID(0,copy);
1238     padx=copy; 
1239     padx--;
1240     
1241     stripid=gMC->CurrentVolOffID(4,copy);
1242     strip=copy; 
1243     strip--;
1244
1245     gMC->TrackPosition(pos);
1246     gMC->TrackMomentum(mom);
1247
1248     Double_t normMom=1./mom.Rho();
1249
1250     //  getting the coordinates in pad ref system
1251
1252     xm[0] = (Float_t)pos.X();
1253     xm[1] = (Float_t)pos.Y();
1254     xm[2] = (Float_t)pos.Z();
1255
1256     pm[0] = (Float_t)mom.X()*normMom;
1257     pm[1] = (Float_t)mom.Y()*normMom;
1258     pm[2] = (Float_t)mom.Z()*normMom;
1259  
1260     gMC->Gmtod(xm,xpad,1); // from MRS to DRS: coordinates convertion
1261     gMC->Gmtod(pm,ppad,2); // from MRS to DRS: direction cosinus convertion
1262
1263
1264     if (TMath::Abs(ppad[1])>1) {
1265       AliWarning("Abs(ppad) > 1");
1266       ppad[1]=TMath::Sign((Float_t)1,ppad[1]);
1267     }
1268     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1269
1270     phi = pos.Phi();
1271     if (phi>=0.) phid = phi*kRaddeg;
1272     else phid = phi*kRaddeg + 360.;
1273
1274     sector = Int_t (phid/20.);
1275
1276     if      (strip <  fTOFGeometry->NStripC()) {
1277       plate = 0;
1278       //strip = strip;
1279     }
1280     else if (strip >= fTOFGeometry->NStripC() && 
1281              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB()) {
1282       plate = 1;
1283       strip = strip - fTOFGeometry->NStripC();
1284     }
1285     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() &&
1286              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA()) {
1287       plate = 2;
1288       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB();
1289     }
1290     else if (strip >= fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() &&
1291              strip <  fTOFGeometry->NStripC() + fTOFGeometry->NStripB() + fTOFGeometry->NStripA() + fTOFGeometry->NStripB()) {
1292       plate = 3;
1293       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA();
1294     }
1295     else                                {
1296       plate = 4;
1297       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA() - fTOFGeometry->NStripB();
1298     }
1299
1300     for(i=0;i<3;++i) {
1301       hits[i]   = pos[i];
1302       hits[i+3] = pm[i];
1303     }
1304
1305     hits[6] = mom.Rho();
1306     hits[7] = pos[3];
1307     hits[8] = xpad[0];
1308     hits[9] = xpad[1];
1309     hits[10]= xpad[2];
1310     hits[11]= incidenceAngle;
1311     hits[12]= gMC->Edep();
1312     hits[13]= gMC->TrackLength();
1313     
1314     vol[0]= sector;
1315     vol[1]= plate;
1316     vol[2]= strip;
1317     vol[3]= padx;
1318     vol[4]= padz;    
1319
1320     AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1321   }
1322 }
1323 //-------------------------------------------------------------------
1324 void AliTOFv5T0::MaterialMixer(Float_t* p,Float_t* a,Float_t* m,Float_t* d,Float_t* s,Int_t n) {
1325   // a[] atomic weights vector  (in)
1326   //     (atoms present in more compound appear separately)
1327   // m[] number of corresponding atoms in the mixture  (in)
1328   // d[] fraction of the compound relative to the corresponding atoms  (in)
1329   // s[] further possible weights     "        "        "        "     (in)
1330   Float_t t = 0.;
1331   for (Int_t i = 0; i < n; ++i) {
1332     p[i] = a[i]*m[i]*d[i]*s[i];
1333     t  += p[i];
1334   }
1335   for (Int_t i = 0; i < n; ++i) {
1336     p[i] = p[i]/t;
1337     //    AliInfo(Form((\n weight[%i] = %f (,i,p[i]));
1338   }
1339 }