]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv2.cxx
New files for folders and Stack
[u/mrichter/AliRoot.git] / TOF / AliTOFv2.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.19  2001/05/04 10:09:48  vicinanz
19 Major upgrades to the strip structure
20
21 Revision 1.18  2000/12/04 08:48:20  alibrary
22 Fixing problems in the HEAD
23
24 Revision 1.17  2000/10/02 21:28:17  fca
25 Removal of useless dependecies via forward declarations
26
27 Revision 1.16  2000/05/10 16:52:18  vicinanz
28 New TOF version with holes for PHOS/RICH
29
30 Revision 1.14.2.1  2000/05/10 09:37:16  vicinanz
31 New version with Holes for PHOS/RICH
32
33 Revision 1.14  1999/11/05 22:39:06  fca
34 New hits structure
35
36 Revision 1.13  1999/11/02 11:26:39  fca
37 added stdlib.h for exit
38
39 Revision 1.12  1999/11/01 20:41:57  fca
40 Added protections against using the wrong version of FRAME
41
42 Revision 1.11  1999/10/22 08:04:14  fca
43 Correct improper use of negative parameters
44
45 Revision 1.10  1999/10/16 19:30:06  fca
46 Corrected Rotation Matrix and CVS log
47
48 Revision 1.9  1999/10/15 15:35:20  fca
49 New version for frame1099 with and without holes
50
51 Revision 1.8  1999/09/29 09:24:33  fca
52 Introduction of the Copyright and cvs Log
53
54 */
55
56 ///////////////////////////////////////////////////////////////////////////////
57 //                                                                           //
58 //  Time Of Flight: design of C.Williams                    
59 //
60 //  This class contains the functions for version 1 of the Time Of Flight    //
61 //  detector.                                                                //
62 //
63 //  VERSION WITH 5 MODULES AND TILTED STRIPS 
64 //  
65 //  HOLES FOR PHOS AND RICH DETECTOR
66 //
67 //   Authors:
68 //
69 //   Alessio Seganti
70 //   Domenico Vicinanza
71 //
72 //   University of Salerno - Italy
73 //
74 //   Fabrizio Pierella
75 //   University of Bologna - Italy
76 //
77 //
78 //Begin_Html
79 /*
80 <img src="picts/AliTOFv2Class.gif">
81 */
82 //End_Html
83 //                                                                           //
84 ///////////////////////////////////////////////////////////////////////////////
85
86 #include <iostream.h>
87 #include <stdlib.h>
88
89 #include "AliTOFv2.h"
90 #include "TBRIK.h"
91 #include "TGeometry.h"
92 #include "TNode.h"
93 #include <TLorentzVector.h>
94 #include "TObject.h"
95 #include "AliRun.h"
96 #include "AliMC.h"
97 #include "AliMagF.h"
98 #include "AliConst.h"
99
100  
101 ClassImp(AliTOFv2)
102  
103 //_____________________________________________________________________________
104 AliTOFv2::AliTOFv2()
105 {
106   //
107   // Default constructor
108   //
109 }
110  
111 //_____________________________________________________________________________
112 AliTOFv2::AliTOFv2(const char *name, const char *title)
113         : AliTOF(name,title)
114 {
115   //
116   // Standard constructor
117   //
118   //
119   // Check that FRAME is there otherwise we have no place where to
120   // put TOF
121   AliModule* frame=gAlice->GetModule("FRAME");
122   if(!frame) {
123     Error("Ctor","TOF needs FRAME to be present\n");
124     exit(1);
125   } else
126     if(frame->IsVersion()!=1) {
127       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
128       exit(1);
129     }
130
131 }
132
133 //____________________________________________________________________________
134 AliTOFv2::~AliTOFv2()
135 {
136   // destructor
137
138   if ( fHits) {
139     fHits->Delete() ; 
140     delete fHits ;
141     fHits = 0 ; 
142   }
143 /*
144   if ( fSDigits) {
145     fSDigits->Delete() ; 
146     delete fSDigits ;
147     fSDigits = 0 ; 
148   }
149 */
150   if ( fDigits) {
151     fDigits->Delete() ; 
152     delete fDigits ;
153     fDigits = 0 ; 
154   }
155   
156 }
157
158 //_____________________________________________________________________________
159 void AliTOFv2::BuildGeometry()
160 {
161   //
162   // Build TOF ROOT geometry for the ALICE event display
163   //
164   TNode *node, *top;
165   const int kColorTOF  = 27;
166
167   // Find top TNODE
168   top = gAlice->GetGeometry()->GetNode("alice");
169
170   // Position the different copies
171   const Float_t krTof  =(fRmax+fRmin)/2;
172   const Float_t khTof  = fRmax-fRmin;
173   const Int_t   kNTof = fNTof;
174   const Float_t kPi   = TMath::Pi();
175   const Float_t kangle = 2*kPi/kNTof;
176   Float_t ang;
177
178   // Define TOF basic volume
179   
180   char nodeName0[6], nodeName1[6], nodeName2[6]; 
181   char nodeName3[6], nodeName4[6], rotMatNum[6];
182
183   new TBRIK("S_TOF_C","TOF box","void",
184             120*0.5,khTof*0.5,fZlenC*0.5);
185   new TBRIK("S_TOF_B","TOF box","void",
186             120*0.5,khTof*0.5,fZlenB*0.5);
187   new TBRIK("S_TOF_A","TOF box","void",
188             120*0.5,khTof*0.5,fZlenA*0.5);
189
190   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
191      
192       if (nodeNum<10) {
193            sprintf(rotMatNum,"rot50%i",nodeNum);
194            sprintf(nodeName0,"FTO00%i",nodeNum);
195            sprintf(nodeName1,"FTO10%i",nodeNum);
196            sprintf(nodeName2,"FTO20%i",nodeNum);
197            sprintf(nodeName3,"FTO30%i",nodeNum);
198            sprintf(nodeName4,"FTO40%i",nodeNum);
199       }
200       if (nodeNum>9) {
201            sprintf(rotMatNum,"rot5%i",nodeNum);
202            sprintf(nodeName0,"FTO0%i",nodeNum);
203            sprintf(nodeName1,"FTO1%i",nodeNum);
204            sprintf(nodeName2,"FTO2%i",nodeNum);
205            sprintf(nodeName3,"FTO3%i",nodeNum);
206            sprintf(nodeName4,"FTO4%i",nodeNum);
207       }
208  
209       new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
210       ang = (4.5-nodeNum) * kangle;
211
212       top->cd();
213       node = new TNode(nodeName0,nodeName0,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),299.15,rotMatNum);
214       node->SetLineColor(kColorTOF);
215       fNodes->Add(node); 
216
217       top->cd(); 
218       node = new TNode(nodeName1,nodeName1,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-299.15,rotMatNum);
219       node->SetLineColor(kColorTOF);
220       fNodes->Add(node); 
221 if (nodeNum !=1 && nodeNum!=2 && nodeNum !=18)
222     {
223       top->cd();
224       node = new TNode(nodeName2,nodeName2,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),146.45,rotMatNum);
225       node->SetLineColor(kColorTOF);
226       fNodes->Add(node); 
227
228       top->cd();
229       node = new TNode(nodeName3,nodeName3,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-146.45,rotMatNum);
230       node->SetLineColor(kColorTOF);
231       fNodes->Add(node); 
232   } // Holes for RICH detector
233
234 if ((nodeNum<8 || nodeNum>12) && nodeNum !=1 && nodeNum!=2 && nodeNum !=18)
235     { 
236       top->cd();
237       node = new TNode(nodeName4,nodeName4,"S_TOF_A",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),0.,rotMatNum);
238       node->SetLineColor(kColorTOF);
239       fNodes->Add(node); 
240      } // Holes for PHOS detector (+ Holes for RICH detector, central part)
241   } // end loop on nodeNum
242 }
243
244  
245 //_____________________________________________________________________________
246 void AliTOFv2::CreateGeometry()
247 {
248   //
249   // Create geometry for Time Of Flight version 0
250   //
251   //Begin_Html
252   /*
253     <img src="picts/AliTOFv2.gif">
254   */
255   //End_Html
256   //
257   // Creates common geometry
258   //
259   AliTOF::CreateGeometry();
260 }
261  
262 //_____________________________________________________________________________
263 void AliTOFv2::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
264                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
265 {
266   //
267   // Definition of the Time Of Fligh Resistive Plate Chambers
268   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
269   
270   Float_t  ycoor, zcoor;
271   Float_t  par[3];
272   Int_t    *idtmed = fIdtmed->GetArray()-499;
273   Int_t    idrotm[100];
274   Int_t    nrot = 0;
275   Float_t  hTof = fRmax-fRmin;
276   
277   Float_t radius = fRmin+2.;//cm
278
279   par[0] =  xtof * 0.5;
280   par[1] =  ytof * 0.5;
281   par[2] = zlenC * 0.5;
282   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
283   par[2] = zlenB * 0.5;
284   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
285   par[2] = zlenA * 0.5;
286   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
287
288
289 // Positioning of modules
290
291    Float_t zcor1 = ztof0 - zlenC*0.5;
292    Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
293    Float_t zcor3 = 0.;
294
295    AliMatrix(idrotm[0], 90.,  0., 0., 0., 90,-90.);
296    AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
297    gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
298    gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
299    gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
300    gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
301    gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
302    gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
303
304    gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
305    gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
306    gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
307    gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
308
309    gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
310
311   Float_t db = 0.5;//cm
312   Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
313
314   xFLT = fStripLn;
315   yFLT = ytof;
316   zFLTA = zlenA;
317   zFLTB = zlenB;
318   zFLTC = zlenC;
319
320   xFST = xFLT-fDeadBndX*2;//cm
321
322 // Sizes of MRPC pads
323
324   Float_t yPad = 0.505;//cm 
325   
326 // Large not sensitive volumes with Insensitive Freon
327   par[0] = xFLT*0.5;
328   par[1] = yFLT*0.5;
329   
330   if(fDebug) 
331     cout <<ClassName()
332          <<": ************************* TOF geometry **************************"
333          <<endl;
334
335   par[2] = (zFLTA *0.5);
336   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
337   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
338
339   par[2] = (zFLTB * 0.5);
340   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
341   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
342
343   par[2] = (zFLTC * 0.5);
344   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
345   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
346
347 ////////// Layers of Aluminum before and after detector //////////
348 ////////// Aluminum Box for Modules (2.0 mm thickness)  /////////
349 ////////// lateral walls not simulated
350   par[0] = xFLT*0.5;
351   par[1] = 0.1;//cm
352   ycoor = -yFLT/2 + par[1];
353   par[2] = (zFLTA *0.5);
354   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
355   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
356   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
357   par[2] = (zFLTB *0.5);
358   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
359   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
360   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
361   par[2] = (zFLTC *0.5);
362   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
363   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
364   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
365   
366 ///////////////// Detector itself //////////////////////
367
368   const Float_t  kdeadBound  =  fDeadBndZ; //cm non-sensitive between the pad edge 
369                                           //and the boundary of the strip
370   const Int_t    knx    = fNpadX;          // number of pads along x
371   const Int_t    knz    = fNpadZ;          // number of pads along z
372   const Float_t  kspace = fSpace;            //cm distance from the front plate of the box
373
374   Float_t zSenStrip  = fZpad*fNpadZ;//cm
375   Float_t stripWidth = zSenStrip + 2*kdeadBound;
376
377   par[0] = xFLT*0.5;
378   par[1] = yPad*0.5; 
379   par[2] = stripWidth*0.5;
380   
381 // new description for strip volume
382 // -- all constants are expressed in cm
383 // heigth of different layers
384   const Float_t khhony = 1.      ;   // heigth of HONY  Layer
385   const Float_t khpcby = 0.15    ;   // heigth of PCB   Layer
386   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
387   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
388   const Float_t khglasseiy = 0.32;   // 2.2 Ext. Glass + 1. Semi Int. Glass (mm)
389   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
390   const Float_t kwsensmz = 2*3.5 ;   // cm
391   const Float_t klsensmx = 48*2.5;   // cm
392   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
393   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
394   
395   // heigth of the FSTR Volume (the strip volume)
396   const Float_t khstripy = 2*(khhony+khpcby+khmyly+khgraphy+khglasseiy)+khsensmy;
397   // width  of the FSTR Volume (the strip volume)
398   const Float_t kwstripz = 10.;
399   // length of the FSTR Volume (the strip volume)
400   const Float_t klstripx = 122.;
401   
402   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
403 // coordinates of the strip center in the strip reference frame; used for positioning
404 // internal strip volumes
405   Float_t posfp[3]={0.,0.,0.};   
406   
407   // FSTR volume definition and filling this volume with non sensitive Gas Mixture
408   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
409   //-- HONY Layer definition
410 //  parfp[0] = -1;
411   parfp[1] = khhony*0.5;
412 //  parfp[2] = -1;
413   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
414   // positioning 2 HONY Layers on FSTR volume
415   posfp[1]=-khstripy*0.5+parfp[1];
416   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
417   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
418   
419   //-- PCB Layer definition 
420   parfp[1] = khpcby*0.5;
421   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
422   // positioning 2 PCB Layers on FSTR volume
423   posfp[1]=-khstripy*0.5+khhony+parfp[1];
424   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
425   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
426   
427   //-- MYLAR Layer definition
428   parfp[1] = khmyly*0.5;
429   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
430   // positioning 2 MYLAR Layers on FSTR volume
431   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1]; 
432   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
433   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
434
435   //-- Graphite Layer definition
436   parfp[1] = khgraphy*0.5;
437   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
438   // positioning 2 Graphite Layers on FSTR volume
439   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
440   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
441   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
442
443   //-- Glass (EXT. +Semi INT.) Layer definition
444   parfp[1] = khglasseiy*0.5;
445   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
446   // positioning 2 Glass Layers on FSTR volume
447   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
448   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
449   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
450   
451   //-- Sensitive Mixture Layer definition
452   parfp[0] = klsensmx*0.5;
453   parfp[1] = khsensmy*0.5;
454   parfp[2] = kwsensmz*0.5;  
455   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
456   // positioning the sensitive gas Layer on FSTR volume
457   gMC->Gspos("FSEN",0,"FSTR",0.,0.,0.,0,"ONLY");
458
459   // dividing FSEN along z in knz=2 and along x in knx=48
460   gMC->Gsdvn("FSEZ","FSEN",knz,3);
461   gMC->Gsdvn("FSEX","FSEZ",knx,1);
462   
463   // FPAD volume definition
464   parfp[0] = klpadx*0.5;    
465   parfp[1] = khsensmy*0.5;
466   parfp[2] = kwpadz*0.5;
467   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
468   // positioning the FPAD volumes on previous divisions
469   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
470   
471 ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
472
473   // Plate A (Central) 
474   
475   Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
476
477   Float_t gap  = fGapA; //cm  distance between the strip axis
478   Float_t zpos = 0;
479   Float_t ang  = 0;
480   Int_t i=1,j=1;
481   nrot  = 0;
482   zcoor = 0;
483   ycoor = -14.5 + kspace ; //2 cm over front plate
484
485   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
486   gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
487
488   if(fDebug) {
489      printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i); 
490      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
491   }
492
493   zcoor -= zSenStrip;
494   j++;
495   Int_t upDown = -1; // upDown=-1 -> Upper strip
496                      // upDown=+1 -> Lower strip
497   do{
498      ang = atan(zcoor/radius);
499      ang *= kRaddeg;
500      AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
501      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
502      ang /= kRaddeg;
503      ycoor = -14.5+ kspace; //2 cm over front plate
504      ycoor += (1-(upDown+1)/2)*gap;
505      gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
506      gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
507
508      if(fDebug) {
509        printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i); 
510        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
511      }
512
513      j += 2;
514      upDown*= -1; // Alternate strips 
515      zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
516              upDown*gap*TMath::Tan(ang)-
517              (zSenStrip/2)/TMath::Cos(ang);
518   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
519   
520   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
521           upDown*gap*TMath::Tan(ang)+
522           (zSenStrip/2)/TMath::Cos(ang);
523
524   gap = fGapB;
525   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
526           upDown*gap*TMath::Tan(ang)-
527           (zSenStrip/2)/TMath::Cos(ang);
528
529   ang = atan(zcoor/radius);
530   ang *= kRaddeg;
531   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
532   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
533   ang /= kRaddeg;
534           
535   ycoor = -14.5+ kspace; //2 cm over front plate
536   ycoor += (1-(upDown+1)/2)*gap;
537   gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
538   gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
539
540   if(fDebug) {
541      printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i); 
542      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
543   }
544
545   ycoor = -hTof/2.+ kspace;//2 cm over front plate
546
547   // Plate  B
548
549   nrot = 0;
550   i=1;
551   upDown = 1;
552   Float_t deadRegion = 1.0;//cm
553   
554   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
555          upDown*gap*TMath::Tan(ang)-
556          (zSenStrip/2)/TMath::Cos(ang)-
557          deadRegion/TMath::Cos(ang);
558
559   ang = atan(zpos/radius);
560   ang *= kRaddeg;
561   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
562   ang /= kRaddeg;
563   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
564   ycoor += (1-(upDown+1)/2)*gap;
565   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
566   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
567
568   if(fDebug) {
569      printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
570      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
571   }
572
573   i++;
574   upDown*=-1;
575
576   do {
577      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
578             upDown*gap*TMath::Tan(ang)-
579             (zSenStrip/2)/TMath::Cos(ang);
580      ang = atan(zpos/radius);
581      ang *= kRaddeg;
582      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
583      ang /= kRaddeg;
584      ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
585      ycoor += (1-(upDown+1)/2)*gap;
586      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
587      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
588
589      if(fDebug) {
590        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
591        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
592      }
593
594      upDown*=-1;
595      i++;
596   } while (TMath::Abs(ang*kRaddeg)<22.5);
597   //till we reach a tilting angle of 22.5 degrees
598
599   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
600   zpos = zpos - zSenStrip/TMath::Cos(ang);
601
602   do {
603      ang = atan(zpos/radius);
604      ang *= kRaddeg;
605      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
606      ang /= kRaddeg;
607      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
608      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
609      zpos = zpos - zSenStrip/TMath::Cos(ang);
610      if(fDebug) {
611        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
612        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
613      }
614      i++;
615
616   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
617
618   // Plate  C
619   
620   zpos = zpos + zSenStrip/TMath::Cos(ang);
621
622   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
623          gap*TMath::Tan(ang)-
624          (zSenStrip/2)/TMath::Cos(ang);
625
626   nrot = 0;
627   i=0;
628   ycoor= -hTof*0.5+kspace+gap;
629
630   do {
631      i++;
632      ang = atan(zpos/radius);
633      ang *= kRaddeg;
634      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
635      ang /= kRaddeg;
636      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
637      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
638
639      if(fDebug) {
640        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i); 
641        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
642      }
643
644      zpos = zpos - zSenStrip/TMath::Cos(ang);
645   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
646
647
648 ////////// Layers after strips /////////////////
649 // honeycomb (Polyethilene) Layer after (1.2cm)
650
651   Float_t overSpace = fOverSpc;//cm
652
653   par[0] = xFLT*0.5;
654   par[1] = 0.6;
655   par[2] = (zFLTA *0.5);
656   ycoor = -yFLT/2 + overSpace + par[1];
657   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
658   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
659   par[2] = (zFLTB *0.5);
660   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
661   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
662   par[2] = (zFLTC *0.5);
663   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
664   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
665
666 // Electronics (Cu) after
667   ycoor += par[1];
668   par[0] = xFLT*0.5;
669   par[1] = 1.43*0.05*0.5; // 5% of X0
670   par[2] = (zFLTA *0.5);
671   ycoor += par[1];
672   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
673   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
674   par[2] = (zFLTB *0.5);
675   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
676   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
677   par[2] = (zFLTC *0.5);
678   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
679   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
680
681 // cooling WAter after
682   ycoor += par[1];
683   par[0] = xFLT*0.5;
684   par[1] = 36.1*0.02*0.5; // 2% of X0
685   par[2] = (zFLTA *0.5);
686   ycoor += par[1];
687   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
688   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
689   par[2] = (zFLTB *0.5);
690   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
691   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
692   par[2] = (zFLTC *0.5);
693   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
694   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
695
696 // frame of Air
697   ycoor += par[1];
698   par[0] = xFLT*0.5;
699   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
700   par[2] = (zFLTA *0.5);
701   ycoor += par[1];
702   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
703   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
704   par[2] = (zFLTB *0.5);
705   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
706   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
707   par[2] = (zFLTC *0.5);
708   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
709   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
710 /* fp
711 //Back Plate honycomb (2cm)
712   par[0] = -1;
713   par[1] = 2 *0.5;
714   par[2] = -1;
715   ycoor = yFLT/2 - par[1];
716   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
717   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
718   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
719   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
720   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
721   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
722 fp */
723 }
724
725 //_____________________________________________________________________________
726 void AliTOFv2::DrawModule()
727 {
728   //
729   // Draw a shaded view of the Time Of Flight version 1
730   //
731   // Set everything unseen
732   gMC->Gsatt("*", "seen", -1);
733   // 
734   // Set ALIC mother transparent
735   gMC->Gsatt("ALIC","SEEN",0);
736   //
737   // Set the volumes visible
738   gMC->Gsatt("ALIC","SEEN",0);
739
740   gMC->Gsatt("FTOA","SEEN",1);
741   gMC->Gsatt("FTOB","SEEN",1);
742   gMC->Gsatt("FTOC","SEEN",1);
743   gMC->Gsatt("FLTA","SEEN",1);
744   gMC->Gsatt("FLTB","SEEN",1);
745   gMC->Gsatt("FLTC","SEEN",1);
746   gMC->Gsatt("FPLA","SEEN",1);
747   gMC->Gsatt("FPLB","SEEN",1);
748   gMC->Gsatt("FPLC","SEEN",1);
749   gMC->Gsatt("FSTR","SEEN",1);
750   gMC->Gsatt("FPEA","SEEN",1);
751   gMC->Gsatt("FPEB","SEEN",1);
752   gMC->Gsatt("FPEC","SEEN",1);
753   
754   gMC->Gsatt("FLZ1","SEEN",0);
755   gMC->Gsatt("FLZ2","SEEN",0);
756   gMC->Gsatt("FLZ3","SEEN",0);
757   gMC->Gsatt("FLX1","SEEN",0);
758   gMC->Gsatt("FLX2","SEEN",0);
759   gMC->Gsatt("FLX3","SEEN",0);
760   gMC->Gsatt("FPAD","SEEN",0);
761
762   gMC->Gdopt("hide", "on");
763   gMC->Gdopt("shad", "on");
764   gMC->Gsatt("*", "fill", 7);
765   gMC->SetClipBox(".");
766   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
767   gMC->DefaultRange();
768   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
769   gMC->Gdhead(1111, "Time Of Flight");
770   gMC->Gdman(18, 4, "MAN");
771   gMC->Gdopt("hide","off");
772 }
773
774 //_____________________________________________________________________________
775 void AliTOFv2::CreateMaterials()
776 {
777   //
778   // Define materials for the Time Of Flight
779   //
780   AliTOF::CreateMaterials();
781 }
782  
783 //_____________________________________________________________________________
784 void AliTOFv2::Init()
785 {
786   //
787   // Initialise the detector after the geometry has been defined
788   //
789   if(fDebug) {
790     printf("%s: **************************************"
791            "  TOF  "
792            "**************************************\n",ClassName());
793     printf("\n%s:   Version 2 of TOF initialing, "
794            "TOF with holes for PHOS and RICH \n",ClassName());
795   }
796
797   AliTOF::Init();
798
799   fIdFTOA = gMC->VolId("FTOA");
800   fIdFTOB = gMC->VolId("FTOB");
801   fIdFTOC = gMC->VolId("FTOC");
802   fIdFLTA = gMC->VolId("FLTA");
803   fIdFLTB = gMC->VolId("FLTB");
804   fIdFLTC = gMC->VolId("FLTC");
805
806   if(fDebug) {
807     printf("%s: **************************************"
808            "  TOF  "
809            "**************************************\n",ClassName());
810   }
811 }
812  
813 //_____________________________________________________________________________
814 void AliTOFv2::StepManager()
815 {
816   //
817   // Procedure called at each step in the Time Of Flight
818   //
819   TLorentzVector mom, pos;
820   Float_t xm[3],pm[3],xpad[3],ppad[3];
821   Float_t hits[13],phi,phid,z;
822   Int_t   vol[5];
823   Int_t   sector, plate, padx, padz, strip;
824   Int_t   copy, padzid, padxid, stripid, i;
825   Int_t   *idtmed = fIdtmed->GetArray()-499;
826   Float_t incidenceAngle;
827   
828   if(gMC->GetMedium()==idtmed[513] && 
829      gMC->IsTrackEntering() && gMC->TrackCharge()
830      && gMC->CurrentVolID(copy)==fIdSens) 
831   {    
832     // getting information about hit volumes
833     
834     padzid=gMC->CurrentVolOffID(2,copy);
835     padz=copy;  
836     
837     padxid=gMC->CurrentVolOffID(1,copy);
838     padx=copy;  
839     
840     stripid=gMC->CurrentVolOffID(4,copy);
841     strip=copy;  
842
843     gMC->TrackPosition(pos);
844     gMC->TrackMomentum(mom);
845
846 //    Double_t NormPos=1./pos.Rho();
847     Double_t normMom=1./mom.Rho();
848
849 //  getting the cohordinates in pad ref system
850     xm[0] = (Float_t)pos.X();
851     xm[1] = (Float_t)pos.Y();
852     xm[2] = (Float_t)pos.Z();
853
854     pm[0] = (Float_t)mom.X()*normMom;
855     pm[1] = (Float_t)mom.Y()*normMom;
856     pm[2] = (Float_t)mom.Z()*normMom;
857  
858     gMC->Gmtod(xm,xpad,1);
859     gMC->Gmtod(pm,ppad,2);
860
861     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
862
863     z = pos[2];
864
865     plate = 0;   
866     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 3;
867     if (z < (fZlenA*0.5+fZlenB) && 
868         z >  fZlenA*0.5)               plate = 4;
869     if (z >-(fZlenA*0.5+fZlenB) &&
870         z < -fZlenA*0.5)               plate = 2;
871     if (z > (fZlenA*0.5+fZlenB))       plate = 5;
872     if (z <-(fZlenA*0.5+fZlenB))       plate = 1;
873
874     phi = pos.Phi();
875     phid = phi*kRaddeg+180.;
876     sector = Int_t (phid/20.);
877     sector++;
878
879     for(i=0;i<3;++i) {
880       hits[i]   = pos[i];
881       hits[i+3] = pm[i];
882     }
883
884     hits[6] = mom.Rho();
885     hits[7] = pos[3];
886     hits[8] = xpad[0];
887     hits[9] = xpad[1];
888     hits[10]= xpad[2];
889     hits[11]= incidenceAngle;
890     hits[12]= gMC->Edep();
891     
892     vol[0]= sector;
893     vol[1]= plate;
894     vol[2]= strip;
895     vol[3]= padx;
896     vol[4]= padz;
897     
898     AddHit(gAlice->CurrentTrack(),vol, hits);
899   }
900 }