]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDv0.cxx
Coding rule violation corrected.
[u/mrichter/AliRoot.git] / PMD / AliPMDv0.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 /* $Id$ */
17
18 //
19 ///////////////////////////////////////////////////////////////////////////////
20 //                                                                           //
21 //  Photon Multiplicity Detector Version 1                                   //
22 //                                                                           //
23 //Begin_Html
24 /*
25 <img src="picts/AliPMDv0Class.gif">
26 */
27 //End_Html
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30 ////
31
32 #include <Riostream.h>
33 #include <TGeoManager.h>
34 #include <TGeoGlobalMagField.h>
35 #include <TVirtualMC.h>
36
37 #include "AliConst.h" 
38 #include "AliMagF.h" 
39 #include "AliPMDv0.h"
40 #include "AliRun.h"
41 #include "AliMC.h"
42 #include "AliLog.h"
43
44 const Int_t   AliPMDv0::fgkNcellHole  = 24;       // Hole dimension
45 const Float_t AliPMDv0::fgkCellRadius = 0.25;     // Radius of a hexagonal cell
46 const Float_t AliPMDv0::fgkCellWall   = 0.02;     // Thickness of cell Wall
47 const Float_t AliPMDv0::fgkCellDepth  = 0.50;     // Gas thickness
48 const Float_t AliPMDv0::fgkBoundary   = 0.7;      // Thickness of Boundary wall
49 const Float_t AliPMDv0::fgkThBase     = 0.3;      // Thickness of Base plate
50 const Float_t AliPMDv0::fgkThAir      = 0.1;      // Thickness of Air
51 const Float_t AliPMDv0::fgkThPCB      = 0.16;     // Thickness of PCB
52 const Float_t AliPMDv0::fgkThLead     = 1.5;      // Thickness of Pb
53 const Float_t AliPMDv0::fgkThSteel    = 0.5;      // Thickness of Steel
54 const Float_t AliPMDv0::fgkZdist      = 361.5;    // z-position of the detector
55 const Float_t AliPMDv0::fgkSqroot3    = 1.7320508;// Square Root of 3
56 const Float_t AliPMDv0::fgkSqroot3by2 = 0.8660254;// Square Root of 3 by 2
57 const Float_t AliPMDv0::fgkPi         = 3.14159;  // pi
58
59 ClassImp(AliPMDv0)
60  
61 //_____________________________________________________________________________
62 AliPMDv0::AliPMDv0():
63   fSMthick(0.),
64   fSMLength(0.),
65   fMedSens(0),
66   fNcellSM(0)
67 {
68   //
69   // Default constructor 
70   //
71 }
72  
73 //_____________________________________________________________________________
74 AliPMDv0::AliPMDv0(const char *name, const char *title):
75   AliPMD(name,title),
76   fSMthick(0.),
77   fSMLength(0.),
78   fMedSens(0),
79   fNcellSM(0)
80 {
81   //
82   // Standard constructor
83   //
84 }
85
86 //_____________________________________________________________________________
87 void AliPMDv0::CreateGeometry()
88 {
89   //
90   // Create geometry for Photon Multiplicity Detector Version 3 :
91   // April 2, 2001
92   //
93   //Begin_Html
94   /*
95     <img src="picts/AliPMDv0.gif">
96   */
97   //End_Html
98   //Begin_Html
99   /*
100     <img src="picts/AliPMDv0Tree.gif">
101   */
102   //End_Html
103   GetParameters();
104   CreateSupermodule();
105   CreatePMD();
106 }
107
108 //_____________________________________________________________________________
109 void AliPMDv0::CreateSupermodule()
110 {
111   //
112   // Creates the geometry of the cells, places them in  supermodule which
113   // is a rhombus object.
114
115   // *** DEFINITION OF THE GEOMETRY OF THE PMD  *** 
116   // *** HEXAGONAL CELLS WITH CELL RADIUS 0.25 cm (see "GetParameters")
117   // -- Author :     S. Chattopadhyay, 02/04/1999. 
118
119   // Basic unit is ECAR, a hexagonal cell made of Ar+CO2, which is placed inside another 
120   // hexagonal cell made of Cu (ECCU) with larger radius, compared to ECAR. The difference
121   // in radius gives the dimension of half width of each cell wall.
122   // These cells are placed as 72 x 72 array in a 
123   // rhombus shaped supermodule (EHC1). The rhombus shaped modules are designed
124   // to have closed packed structure.
125   //
126   // Each supermodule (ESMA, ESMB), made of G10 is filled with following components
127   //  EAIR --> Air gap between gas hexagonal cells and G10 backing.
128   //  EHC1 --> Rhombus shaped parallelopiped containing the hexagonal cells
129   //  EAIR --> Air gap between gas hexagonal cells and G10 backing.
130   //
131   // ESMA, ESMB are placed in EMM1 along with EMPB (Pb converter) 
132   // and EMFE (iron support) 
133
134   // EMM1 made of
135   //    ESMB --> Normal supermodule, mirror image of ESMA
136   //    EMPB --> Pb converter
137   //    EMFE --> Fe backing
138   //    ESMA --> Normal supermodule
139   //
140   // ESMX, ESMY are placed in EMM2 along with EMPB (Pb converter) 
141   // and EMFE (iron support) 
142
143   // EMM2 made of 
144   //    ESMY --> Special supermodule, mirror image of ESMX, 
145   //    EMPB --> Pb converter
146   //    EMFE --> Fe backing
147   //    ESMX --> First of the two Special supermodules near the hole
148
149  // EMM3 made of
150   //    ESMQ --> Special supermodule, mirror image of ESMX, 
151   //    EMPB --> Pb converter
152   //    EMFE --> Fe backing
153   //    ESMP --> Second of the two Special supermodules near the hole
154   
155   // EMM2 and EMM3 are used to create the hexagonal  HOLE
156
157   //
158   //                                 EPMD
159   //                                   |             
160   //                                   |
161   //   ---------------------------------------------------------------------------
162   //   |              |                       |                     |            |
163   //  EHOL           EMM1                    EMM2                  EMM3         EALM
164   //                  |                       |                     |
165   //      --------------------   --------------------      -------------------- 
166   //      |    |      |     |    |     |      |     |      |     |      |     | 
167   //     ESMB  EMPB  EMFE ESMA  ESMY  EMPB  EMFE  ESMX    ESMQ  EMPB  EMFE  ESMP
168   //      |                      |                         |                 
169   //   ------------          ------------             -------------           
170   //  |     |     |         |     |     |             |     |     |           
171   // EAIR EHC1   EAIR      EAIR  EHC2  EAIR          EAIR  EHC3  EAIR          
172   //        |                     |                         |                  
173   //      ECCU                   ECCU                      ECCU                 
174   //       |                      |                         |                  
175   //      ECAR                   ECAR                      ECAR                 
176   
177
178   Int_t i, j;
179   Float_t xb, yb, zb;
180   Int_t number;
181   Int_t ihrotm,irotdm;
182   Int_t *idtmed = fIdtmed->GetArray()-599;
183  
184   AliMatrix(ihrotm, 90., 30.,   90.,  120., 0., 0.);
185   AliMatrix(irotdm, 90., 180.,  90.,  270., 180., 0.);
186  
187   //Subhasis, dimensional parameters of rhombus (dpara) as given to gsvolu
188   // rhombus to accomodate 72 x 72 hexagons, and with total 1.2cm extension  
189   //(1mm tolerance on both side and 5mm thick G10 wall)
190   // 
191   // **** CELL SIZE 20 mm^2 EQUIVALENT
192   // Inner hexagon filled with gas (Ar+CO2)
193
194   Float_t hexd2[10] = {0.,360.,6,2,-0.25,0.,0.23,0.25,0.,0.23};
195
196   hexd2[4]=  -fgkCellDepth/2.;
197   hexd2[7]=   fgkCellDepth/2.;
198   hexd2[6]=   fgkCellRadius - fgkCellWall;
199   hexd2[9]=   fgkCellRadius - fgkCellWall;
200   
201   // Gas replaced by vacuum for v0(insensitive) version of PMD.
202
203   gMC->Gsvolu("ECAR", "PGON", idtmed[697], hexd2,10);
204   gGeoManager->SetVolumeAttribute("ECAR", "SEEN", 0);
205   
206   // Outer hexagon made of Copper
207   
208   Float_t hexd1[10] = {0.,360.,6,2,-0.25,0.,0.25,0.25,0.,0.25};
209
210   hexd1[4]=  -fgkCellDepth/2.;
211   hexd1[7]=   fgkCellDepth/2.;
212   hexd1[6]=   fgkCellRadius;
213   hexd1[9]=   fgkCellRadius;
214
215   gMC->Gsvolu("ECCU", "PGON", idtmed[614], hexd1,10);
216   gGeoManager->SetVolumeAttribute("ECCU", "SEEN", 1);
217
218   // --- place  inner hex inside outer hex 
219
220   gMC->Gspos("ECAR", 1, "ECCU", 0., 0., 0., 0, "ONLY");
221
222   // Rhombus shaped supermodules (defined by PARA) 
223   
224   // volume for SUPERMODULE 
225    
226   Float_t dparasm1[6] = {12.5,12.5,0.8,30.,0.,0.};
227   dparasm1[0] = (fNcellSM+0.25)*hexd1[6] ;
228   dparasm1[1] = dparasm1[0] *fgkSqroot3by2;
229   dparasm1[2] = fSMthick/2.;
230   
231   //
232   gMC->Gsvolu("ESMA","PARA", idtmed[607], dparasm1, 6);
233   gGeoManager->SetVolumeAttribute("ESMA", "SEEN", 0);
234   //
235   gMC->Gsvolu("ESMB","PARA", idtmed[607], dparasm1, 6);
236   gGeoManager->SetVolumeAttribute("ESMB", "SEEN", 0);
237   
238   // Air residing between the PCB and the base
239   
240   Float_t dparaair[6] = {12.5,12.5,8.,30.,0.,0.};
241   dparaair[0]= dparasm1[0];
242   dparaair[1]= dparasm1[1];
243   dparaair[2]= fgkThAir/2.;
244   
245   gMC->Gsvolu("EAIR","PARA", idtmed[698], dparaair, 6);
246   gGeoManager->SetVolumeAttribute("EAIR", "SEEN", 0);
247   
248   // volume for honeycomb chamber EHC1 
249   
250   Float_t dpara1[6] = {12.5,12.5,0.4,30.,0.,0.};
251   dpara1[0] = dparasm1[0];
252   dpara1[1] = dparasm1[1];
253   dpara1[2] = fgkCellDepth/2.;
254
255   gMC->Gsvolu("EHC1","PARA", idtmed[698], dpara1, 6);
256   gGeoManager->SetVolumeAttribute("EHC1", "SEEN", 1);
257   
258   // Place hexagonal cells ECCU cells  inside EHC1 (72 X 72)
259
260   Int_t xrow = 1;
261
262   yb = -dpara1[1] + (1./fgkSqroot3by2)*hexd1[6];
263   zb = 0.;
264
265   for (j = 1; j <= fNcellSM; ++j) {
266     xb =-(dpara1[0] + dpara1[1]*0.577) + 2*hexd1[6]; //0.577=tan(30deg)
267     if(xrow >= 2){
268       xb = xb+(xrow-1)*hexd1[6];
269     }
270     for (i = 1; i <= fNcellSM; ++i) {
271       number = i+(j-1)*fNcellSM;
272       gMC->Gspos("ECCU", number, "EHC1", xb,yb,zb, ihrotm, "ONLY");
273       xb += (hexd1[6]*2.);
274     }
275     xrow = xrow+1;
276     yb += (hexd1[6]*fgkSqroot3);
277   }
278
279
280   // Place EHC1 and EAIR into  ESMA and ESMB
281
282   Float_t zAir1,zAir2,zGas; 
283
284   //ESMA is normal supermodule with base at bottom, with EHC1
285   zAir1= -dparasm1[2] + fgkThBase + dparaair[2]; 
286   gMC->Gspos("EAIR", 1, "ESMA", 0., 0., zAir1, 0, "ONLY");
287   zGas=zAir1+dparaair[2]+ fgkThPCB + dpara1[2]; 
288   //Line below Commented for version 0 of PMD routine
289   //  gMC->Gspos("EHC1", 1, "ESMA", 0., 0., zGas, 0, "ONLY");
290   zAir2=zGas+dpara1[2]+ fgkThPCB + dparaair[2]; 
291   gMC->Gspos("EAIR", 2, "ESMA", 0., 0., zAir2, 0, "ONLY");
292
293   // ESMB is mirror image of ESMA, with base at top, with EHC1
294
295   zAir1= -dparasm1[2] + fgkThPCB + dparaair[2]; 
296   gMC->Gspos("EAIR", 3, "ESMB", 0., 0., zAir1, 0, "ONLY");
297   zGas=zAir1+dparaair[2]+ fgkThPCB + dpara1[2]; 
298   //Line below Commented for version 0 of PMD routine
299   //  gMC->Gspos("EHC1", 2, "ESMB", 0., 0., zGas, 0, "ONLY");
300   zAir2=zGas+dpara1[2]+ fgkThPCB + dparaair[2]; 
301   gMC->Gspos("EAIR", 4, "ESMB", 0., 0., zAir2, 0, "ONLY");
302
303
304   // special supermodule EMM2(GEANT only) containing 6 unit modules
305   // volume for SUPERMODULE 
306
307   Float_t dparasm2[6] = {12.5,12.5,0.8,30.,0.,0.};
308   dparasm2[0]=(fNcellSM+0.25)*hexd1[6] ;
309   dparasm2[1] = (fNcellSM - fgkNcellHole + 0.25) * fgkSqroot3by2 * hexd1[6];
310   dparasm2[2] = fSMthick/2.;
311
312   gMC->Gsvolu("ESMX","PARA", idtmed[607], dparasm2, 6);
313   gGeoManager->SetVolumeAttribute("ESMX", "SEEN", 0);
314   //
315   gMC->Gsvolu("ESMY","PARA", idtmed[607], dparasm2, 6);
316   gGeoManager->SetVolumeAttribute("ESMY", "SEEN", 0);
317
318   Float_t dpara2[6] = {12.5,12.5,0.4,30.,0.,0.};
319   dpara2[0] = dparasm2[0];
320   dpara2[1] = dparasm2[1];
321   dpara2[2] = fgkCellDepth/2.;
322
323   gMC->Gsvolu("EHC2","PARA", idtmed[698], dpara2, 6);
324   gGeoManager->SetVolumeAttribute("EHC2", "SEEN", 1);
325
326
327   // Air residing between the PCB and the base
328
329   Float_t dpara2Air[6] = {12.5,12.5,8.,30.,0.,0.};
330   dpara2Air[0]= dparasm2[0];
331   dpara2Air[1]= dparasm2[1];
332   dpara2Air[2]= fgkThAir/2.;
333
334   gMC->Gsvolu("EAIX","PARA", idtmed[698], dpara2Air, 6);
335   gGeoManager->SetVolumeAttribute("EAIX", "SEEN", 0);
336
337   // Place hexagonal single cells ECCU inside EHC2
338   // skip cells which go into the hole in top left corner.
339
340   xrow=1;
341   yb = -dpara2[1] + (1./fgkSqroot3by2)*hexd1[6];
342   zb = 0.;
343   for (j = 1; j <= (fNcellSM - fgkNcellHole); ++j) {
344     xb =-(dpara2[0] + dpara2[1]*0.577) + 2*hexd1[6];
345     if(xrow >= 2){
346       xb = xb+(xrow-1)*hexd1[6];
347     }
348     for (i = 1; i <= fNcellSM; ++i) {
349       number = i+(j-1)*fNcellSM;
350             gMC->Gspos("ECCU", number, "EHC2", xb,yb,zb, ihrotm, "ONLY");
351       xb += (hexd1[6]*2.);
352     }
353     xrow = xrow+1;
354     yb += (hexd1[6]*fgkSqroot3);
355   }
356
357
358   // ESMX is normal supermodule with base at bottom, with EHC2
359   
360   zAir1= -dparasm2[2] + fgkThBase + dpara2Air[2]; 
361   gMC->Gspos("EAIX", 1, "ESMX", 0., 0., zAir1, 0, "ONLY");
362   zGas=zAir1+dpara2Air[2]+ fgkThPCB + dpara2[2]; 
363   //Line below Commented for version 0 of PMD routine
364   //  gMC->Gspos("EHC2", 1, "ESMX", 0., 0., zGas, 0, "ONLY");
365   zAir2=zGas+dpara2[2]+ fgkThPCB + dpara2Air[2]; 
366   gMC->Gspos("EAIX", 2, "ESMX", 0., 0., zAir2, 0, "ONLY");
367
368   // ESMY is mirror image of ESMX with base at bottom, with EHC2
369   
370   zAir1= -dparasm2[2] + fgkThPCB + dpara2Air[2]; 
371   gMC->Gspos("EAIX", 3, "ESMY", 0., 0., zAir1, 0, "ONLY");
372   zGas=zAir1+dpara2Air[2]+ fgkThPCB + dpara2[2]; 
373   //Line below Commented for version 0 of PMD routine
374   //  gMC->Gspos("EHC2", 2, "ESMY", 0., 0., zGas, 0, "ONLY");
375   zAir2=zGas+dpara2[2]+ fgkThPCB + dpara2Air[2]; 
376   gMC->Gspos("EAIX", 4, "ESMY", 0., 0., zAir2, 0, "ONLY");
377
378   //
379   // special supermodule EMM3 (GEANT only) containing 2 unit modules
380   // volume for SUPERMODULE 
381   //
382   Float_t dparaSM3[6] = {12.5,12.5,0.8,30.,0.,0.};
383   dparaSM3[0]=(fNcellSM - fgkNcellHole +0.25)*hexd1[6] ;
384   dparaSM3[1] = (fgkNcellHole + 0.25) * hexd1[6] * fgkSqroot3by2;
385   dparaSM3[2] = fSMthick/2.;
386
387   gMC->Gsvolu("ESMP","PARA", idtmed[607], dparaSM3, 6);
388   gGeoManager->SetVolumeAttribute("ESMP", "SEEN", 0);
389   //
390   gMC->Gsvolu("ESMQ","PARA", idtmed[607], dparaSM3, 6);
391   gGeoManager->SetVolumeAttribute("ESMQ", "SEEN", 0);
392
393   Float_t dpara3[6] = {12.5,12.5,0.4,30.,0.,0.};
394   dpara3[0] = dparaSM3[0];
395   dpara3[1] = dparaSM3[1];
396   dpara3[2] = fgkCellDepth/2.;
397
398   gMC->Gsvolu("EHC3","PARA", idtmed[698], dpara3, 6);
399   gGeoManager->SetVolumeAttribute("EHC3", "SEEN", 1);
400
401   // Air residing between the PCB and the base
402
403   Float_t dpara3Air[6] = {12.5,12.5,8.,30.,0.,0.};
404   dpara3Air[0]= dparaSM3[0];
405   dpara3Air[1]= dparaSM3[1];
406   dpara3Air[2]= fgkThAir/2.;
407
408   gMC->Gsvolu("EAIP","PARA", idtmed[698], dpara3Air, 6);
409   gGeoManager->SetVolumeAttribute("EAIP", "SEEN", 0);
410
411
412   // Place hexagonal single cells ECCU inside EHC3
413   // skip cells which go into the hole in top left corner.
414
415   xrow=1;
416   yb = -dpara3[1] + (1./fgkSqroot3by2)*hexd1[6];
417   zb = 0.;
418   for (j = 1; j <= fgkNcellHole; ++j) {
419     xb =-(dpara3[0] + dpara3[1]*0.577) + 2*hexd1[6];
420     if(xrow >= 2){
421       xb = xb+(xrow-1)*hexd1[6];
422     }
423     for (i = 1; i <= (fNcellSM - fgkNcellHole); ++i) {
424       number = i+(j-1)*(fNcellSM - fgkNcellHole);
425       gMC->Gspos("ECCU", number, "EHC3", xb,yb,zb, ihrotm, "ONLY");
426       xb += (hexd1[6]*2.);
427     }
428     xrow = xrow+1;
429     yb += (hexd1[6]*fgkSqroot3);
430   }
431
432   // ESMP is normal supermodule with base at bottom, with EHC3
433   
434   zAir1= -dparaSM3[2] + fgkThBase + dpara3Air[2]; 
435   gMC->Gspos("EAIP", 1, "ESMP", 0., 0., zAir1, 0, "ONLY");
436   zGas=zAir1+dpara3Air[2]+ fgkThPCB + dpara3[2]; 
437   //Line below Commented for version 0 of PMD routine
438   //  gMC->Gspos("EHC3", 1, "ESMP", 0., 0., zGas, 0, "ONLY");
439   zAir2=zGas+dpara3[2]+ fgkThPCB + dpara3Air[2]; 
440   gMC->Gspos("EAIP", 2, "ESMP", 0., 0., zAir2, 0, "ONLY");
441   
442   // ESMQ is mirror image of ESMP with base at bottom, with EHC3
443   
444   zAir1= -dparaSM3[2] + fgkThPCB + dpara3Air[2]; 
445   gMC->Gspos("EAIP", 3, "ESMQ", 0., 0., zAir1, 0, "ONLY");
446   zGas=zAir1+dpara3Air[2]+ fgkThPCB + dpara3[2]; 
447   //Line below Commented for version 0 of PMD routine
448   //  gMC->Gspos("EHC3", 2, "ESMQ", 0., 0., zGas, 0, "ONLY");
449   zAir2=zGas+dpara3[2]+ fgkThPCB + dpara3Air[2]; 
450   gMC->Gspos("EAIP", 4, "ESMQ", 0., 0., zAir2, 0, "ONLY");
451   
452 }
453
454 //_____________________________________________________________________________
455
456 void AliPMDv0::CreatePMD()
457 {
458   //
459   // Create final detector from supermodules
460   //
461   // -- Author :     Y.P. VIYOGI, 07/05/1996. 
462   // -- Modified:    P.V.K.S.Baba(JU), 15-12-97. 
463   // -- Modified:    For New Geometry YPV, March 2001.
464
465   Float_t  xp, yp, zp;
466   Int_t i,j;
467   Int_t nummod;
468   Int_t jhrot12,jhrot13, irotdm;
469   Int_t *idtmed = fIdtmed->GetArray()-599;
470   
471   //  VOLUMES Names : begining with "E" for all PMD volumes, 
472   // The names of SIZE variables begin with S and have more meaningful
473   // characters as shown below. 
474   //            VOLUME  SIZE    MEDIUM  :       REMARKS 
475   //            ------  -----   ------  : --------------------------- 
476   //            EPMD    GASPMD   AIR    : INSIDE PMD  and its SIZE 
477   // *** Define the  EPMD   Volume and fill with air *** 
478   // Gaspmd, the dimension of HEXAGONAL mother volume of PMD,
479
480
481   Float_t gaspmd[10] = {0.,360.,6,2,-4.,12.,150.,4.,12.,150.};
482
483   gaspmd[5] = fgkNcellHole * fgkCellRadius * 2. * fgkSqroot3by2;
484   gaspmd[8] = gaspmd[5];
485
486   gMC->Gsvolu("EPMD", "PGON", idtmed[698], gaspmd, 10);
487   gGeoManager->SetVolumeAttribute("EPMD", "SEEN", 0);
488
489   AliMatrix(irotdm, 90., 0.,  90.,  90., 180., 0.);
490    
491   AliMatrix(jhrot12, 90., 120., 90., 210., 0., 0.);
492   AliMatrix(jhrot13, 90., 240., 90., 330., 0., 0.);
493
494
495   Float_t dmthick = 2. * fSMthick + fgkThLead + fgkThSteel;
496
497   // dparaemm1 array contains parameters of the imaginary volume EMM1, 
498   // EMM1 is a master module of type 1, which has 24 copies in the PMD.
499   // EMM1 : normal volume as in old cases
500
501
502   Float_t dparaemm1[6] = {12.5,12.5,0.8,30.,0.,0.};
503   dparaemm1[0] = fSMLength/2.;
504   dparaemm1[1] = dparaemm1[0] *fgkSqroot3by2;
505   dparaemm1[2] = dmthick/2.;
506
507   gMC->Gsvolu("EMM1","PARA", idtmed[698], dparaemm1, 6);
508   gGeoManager->SetVolumeAttribute("EMM1", "SEEN", 1);
509
510   //
511   // --- DEFINE Modules, iron, and lead volumes 
512   //   Pb Convertor for EMM1
513
514   Float_t dparapb1[6] = {12.5,12.5,8.,30.,0.,0.};
515   dparapb1[0] = fSMLength/2.;
516   dparapb1[1] = dparapb1[0] * fgkSqroot3by2;
517   dparapb1[2] = fgkThLead/2.;
518
519   gMC->Gsvolu("EPB1","PARA", idtmed[600], dparapb1, 6);
520   gGeoManager->SetVolumeAttribute ("EPB1", "SEEN", 0);
521
522   //   Fe Support for EMM1
523   Float_t dparafe1[6] = {12.5,12.5,8.,30.,0.,0.};
524   dparafe1[0] = dparapb1[0];
525   dparafe1[1] = dparapb1[1];
526   dparafe1[2] = fgkThSteel/2.;
527
528   gMC->Gsvolu("EFE1","PARA", idtmed[618], dparafe1, 6);
529   gGeoManager->SetVolumeAttribute ("EFE1", "SEEN", 0);
530
531   //  
532   // position supermodule ESMA, ESMB, EPB1, EFE1 inside EMM1
533
534   Float_t zps,zpb,zfe,zcv; 
535   
536   zps = -dparaemm1[2] + fSMthick/2.;
537   gMC->Gspos("ESMB", 1, "EMM1", 0., 0., zps, 0, "ONLY");
538   zpb = zps+fSMthick/2.+dparapb1[2];
539   gMC->Gspos("EPB1", 1, "EMM1", 0., 0., zpb, 0, "ONLY");
540   zfe = zpb+dparapb1[2]+dparafe1[2];
541   gMC->Gspos("EFE1", 1, "EMM1", 0., 0., zfe, 0, "ONLY");
542   zcv = zfe+dparafe1[2]+fSMthick/2.;
543   gMC->Gspos("ESMA", 1, "EMM1", 0., 0., zcv, 0, "ONLY");
544
545   // EMM2 : special master module having full row of cells but the number
546   //        of rows limited by hole.
547
548   Float_t dparaemm2[6] = {12.5,12.5,0.8,30.,0.,0.};
549   dparaemm2[0] = fSMLength/2.;
550   dparaemm2[1] = (fNcellSM - fgkNcellHole + 0.25)*fgkCellRadius*fgkSqroot3by2;
551   dparaemm2[2] = dmthick/2.;
552
553   gMC->Gsvolu("EMM2","PARA", idtmed[698], dparaemm2, 6);
554   gGeoManager->SetVolumeAttribute("EMM2", "SEEN", 1);
555
556   //   Pb Convertor for EMM2
557   Float_t dparapb2[6] = {12.5,12.5,8.,30.,0.,0.};
558   dparapb2[0] = dparaemm2[0];
559   dparapb2[1] = dparaemm2[1];
560   dparapb2[2] = fgkThLead/2.;
561
562   gMC->Gsvolu("EPB2","PARA", idtmed[600], dparapb2, 6);
563   gGeoManager->SetVolumeAttribute ("EPB2", "SEEN", 0);
564
565   //   Fe Support for EMM2
566   Float_t dparafe2[6] = {12.5,12.5,8.,30.,0.,0.};
567   dparafe2[0] = dparapb2[0];
568   dparafe2[1] = dparapb2[1];
569   dparafe2[2] = fgkThSteel/2.;
570
571   gMC->Gsvolu("EFE2","PARA", idtmed[618], dparafe2, 6);
572   gGeoManager->SetVolumeAttribute ("EFE2", "SEEN", 0);
573
574   // position supermodule  ESMX, ESMY inside EMM2
575
576   zps = -dparaemm2[2] + fSMthick/2.;
577   gMC->Gspos("ESMY", 1, "EMM2", 0., 0., zps, 0, "ONLY");
578   zpb = zps + fSMthick/2.+dparapb2[2];
579   gMC->Gspos("EPB2", 1, "EMM2", 0., 0., zpb, 0, "ONLY");
580   zfe = zpb + dparapb2[2]+dparafe2[2];
581   gMC->Gspos("EFE2", 1, "EMM2", 0., 0., zfe, 0, "ONLY");
582   zcv = zfe + dparafe2[2]+fSMthick/2.;
583   gMC->Gspos("ESMX", 1, "EMM2", 0., 0., zcv, 0, "ONLY");
584   // 
585   // EMM3 : special master module having truncated rows and columns of cells 
586   //        limited by hole.
587
588   Float_t dparaemm3[6] = {12.5,12.5,0.8,30.,0.,0.};
589   dparaemm3[0] = dparaemm2[1]/fgkSqroot3by2;
590   dparaemm3[1] = (fgkNcellHole + 0.25) * fgkCellRadius *fgkSqroot3by2;
591   dparaemm3[2] = dmthick/2.;
592
593   gMC->Gsvolu("EMM3","PARA", idtmed[698], dparaemm3, 6);
594   gGeoManager->SetVolumeAttribute("EMM3", "SEEN", 1);
595
596   //   Pb Convertor for EMM3
597   Float_t dparapb3[6] = {12.5,12.5,8.,30.,0.,0.};
598   dparapb3[0] = dparaemm3[0];
599   dparapb3[1] = dparaemm3[1];
600   dparapb3[2] = fgkThLead/2.;
601
602   gMC->Gsvolu("EPB3","PARA", idtmed[600], dparapb3, 6);
603   gGeoManager->SetVolumeAttribute ("EPB3", "SEEN", 0);
604
605   //   Fe Support for EMM3
606   Float_t dparafe3[6] = {12.5,12.5,8.,30.,0.,0.};
607   dparafe3[0] = dparapb3[0];
608   dparafe3[1] = dparapb3[1];
609   dparafe3[2] = fgkThSteel/2.;
610
611   gMC->Gsvolu("EFE3","PARA", idtmed[618], dparafe3, 6);
612   gGeoManager->SetVolumeAttribute ("EFE3", "SEEN", 0);
613
614   // position supermodule  ESMP, ESMQ inside EMM3
615
616   zps = -dparaemm3[2] + fSMthick/2.;
617   gMC->Gspos("ESMQ", 1, "EMM3", 0., 0., zps, 0, "ONLY");
618   zpb = zps + fSMthick/2.+dparapb3[2];
619   gMC->Gspos("EPB3", 1, "EMM3", 0., 0., zpb, 0, "ONLY");
620   zfe = zpb + dparapb3[2]+dparafe3[2];
621   gMC->Gspos("EFE3", 1, "EMM3", 0., 0., zfe, 0, "ONLY");
622   zcv = zfe + dparafe3[2] + fSMthick/2.;
623   gMC->Gspos("ESMP", 1, "EMM3", 0., 0., zcv, 0, "ONLY");
624   // 
625
626   // EHOL is a tube structure made of air
627   //
628   //Float_t d_hole[3];
629   //d_hole[0] = 0.;
630   //d_hole[1] = fgkNcellHole * fgkCellRadius *2. * fgkSqroot3by2 + boundary;
631   //d_hole[2] = dmthick/2.;
632   //
633   //gMC->Gsvolu("EHOL", "TUBE", idtmed[698], d_hole, 3);
634   //gGeoManager->SetVolumeAttribute("EHOL", "SEEN", 1);
635
636   //Al-rod as boundary of the supermodules
637
638   Float_t alRod[3] ;
639   alRod[0] = fSMLength * 3/2. - gaspmd[5]/2 - fgkBoundary ;
640   alRod[1] = fgkBoundary;
641   alRod[2] = dmthick/2.;
642
643   gMC->Gsvolu("EALM","BOX ", idtmed[698], alRod, 3);
644   gGeoManager->SetVolumeAttribute ("EALM", "SEEN", 1);
645   Float_t xalm[3];
646   xalm[0]=alRod[0] + gaspmd[5] + 3.0*fgkBoundary;
647   xalm[1]=-xalm[0]/2.;
648   xalm[2]=xalm[1];
649
650   Float_t yalm[3];
651   yalm[0]=0.;
652   yalm[1]=xalm[0]*fgkSqroot3by2;
653   yalm[2]=-yalm[1];
654
655   // delx = full side of the supermodule
656   Float_t delx=fSMLength * 3.;
657   Float_t x1= delx*fgkSqroot3by2 /2.;
658   Float_t x4=delx/4.; 
659
660   // placing master modules and Al-rod in PMD
661
662   Float_t dx = fSMLength;
663   Float_t dy = dx * fgkSqroot3by2;
664   Float_t xsup[9] = {-dx/2., dx/2., 3.*dx/2., 
665                      -dx,    0.,       dx,
666                      -3.*dx/2., -dx/2., dx/2.};
667
668   Float_t ysup[9] = {dy,  dy,  dy, 
669                      0.,  0.,  0., 
670                     -dy, -dy, -dy};
671
672   // xpos and ypos are the x & y coordinates of the centres of EMM1 volumes
673
674   Float_t xoff = fgkBoundary * TMath::Tan(fgkPi/6.);
675   Float_t xmod[3]={x4 + xoff , x4 + xoff, -2.*x4-fgkBoundary/fgkSqroot3by2};
676   Float_t ymod[3] = {-x1 - fgkBoundary, x1 + fgkBoundary, 0.};
677   Float_t xpos[9], ypos[9], x2, y2, x3, y3;
678
679   Float_t xemm2 = fSMLength/2. - 
680                   (fNcellSM + fgkNcellHole + 0.25) * fgkCellRadius * 0.5
681                   + xoff;
682   Float_t yemm2 = -(fNcellSM + fgkNcellHole + 0.25)*fgkCellRadius*fgkSqroot3by2
683                   - fgkBoundary;
684
685   Float_t xemm3 = (fNcellSM + 0.5 * fgkNcellHole + 0.25) * fgkCellRadius +
686     xoff;
687   Float_t yemm3 = - (fgkNcellHole - 0.25) * fgkCellRadius * fgkSqroot3by2 -
688     fgkBoundary;
689
690   Float_t theta[3] = {0., 2.*fgkPi/3., 4.*fgkPi/3.};
691   Int_t irotate[3] = {0, jhrot12, jhrot13};
692   
693   nummod=0;
694   for (j=0; j<3; ++j) {
695      gMC->Gspos("EALM", j+1, "EPMD", xalm[j],yalm[j], 0., irotate[j], "ONLY");
696      x2=xemm2*TMath::Cos(theta[j]) - yemm2*TMath::Sin(theta[j]);
697      y2=xemm2*TMath::Sin(theta[j]) + yemm2*TMath::Cos(theta[j]);
698
699      gMC->Gspos("EMM2", j+1, "EPMD", x2,y2, 0., irotate[j], "ONLY");
700
701      x3=xemm3*TMath::Cos(theta[j]) - yemm3*TMath::Sin(theta[j]);
702      y3=xemm3*TMath::Sin(theta[j]) + yemm3*TMath::Cos(theta[j]);
703
704      gMC->Gspos("EMM3", j+4, "EPMD", x3,y3, 0., irotate[j], "ONLY");
705
706      for (i=1; i<9; ++i) {
707        xpos[i]=xmod[j] + xsup[i]*TMath::Cos(theta[j]) -
708          ysup[i]*TMath::Sin(theta[j]);
709        ypos[i]=ymod[j] + xsup[i]*TMath::Sin(theta[j]) +
710          ysup[i]*TMath::Cos(theta[j]);
711         
712        AliDebugClass(1,Form("xpos: %f, ypos: %f", xpos[i], ypos[i]));
713        
714        nummod = nummod+1;
715        
716        AliDebugClass(1,Form("nummod %d",nummod));
717        
718        gMC->Gspos("EMM1", nummod + 6, "EPMD", xpos[i],ypos[i], 0., irotate[j], "ONLY");
719        
720      }
721   }
722   
723   
724   // place EHOL in the centre of EPMD
725   // gMC->Gspos("EHOL", 1, "EPMD", 0.,0.,0., 0, "ONLY");
726   
727   // --- Place the EPMD in ALICE 
728   xp = 0.;
729   yp = 0.;
730   zp = fgkZdist;
731   
732   gMC->Gspos("EPMD", 1, "ALIC", xp,yp,zp, 0, "ONLY");
733     
734 }
735
736  
737 //_____________________________________________________________________________
738 void AliPMDv0::CreateMaterials()
739 {
740   //
741   // Create materials for the PMD
742   //
743   // ORIGIN    : Y. P. VIYOGI 
744   //
745   
746   //  cout << " Inside create materials " << endl;
747
748   Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
749   Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
750   
751   // --- Define the various materials for GEANT --- 
752
753   AliMaterial(1, "Pb    $", 207.19, 82., 11.35, .56, 18.5);
754   
755   // Argon
756
757   Float_t dAr   = 0.001782;   // --- Ar density in g/cm3 --- 
758   Float_t x0Ar = 19.55 / dAr;
759   AliMaterial(2, "Argon$", 39.95, 18., dAr, x0Ar, 6.5e4);
760
761   // --- CO2 --- 
762
763   Float_t aCO2[2] = { 12.,16. };
764   Float_t zCO2[2] = { 6.,8. };
765   Float_t wCO2[2] = { 1.,2. };
766   Float_t dCO2    = 0.001977;
767   AliMixture(3, "CO2  $", aCO2, zCO2, dCO2, -2, wCO2);
768
769   AliMaterial(4, "Al   $", 26.98, 13., 2.7, 8.9, 18.5);
770
771   // ArCO2
772
773   Float_t aArCO2[3] = {39.948,12.0107,15.9994};
774   Float_t zArCO2[3] = {18.,6.,8.};
775   Float_t wArCO2[3] = {0.7,0.08,0.22};
776   Float_t dArCO2    = dAr * 0.7 + dCO2 * 0.3;
777   AliMixture(5, "ArCO2$", aArCO2, zArCO2, dArCO2, 3, wArCO2);
778
779   AliMaterial(6, "Fe   $", 55.85, 26., 7.87, 1.76, 18.5);
780
781   // G10
782   
783   Float_t aG10[4]={1.,12.011,15.9994,28.086};
784   Float_t zG10[4]={1.,6.,8.,14.};
785   //PH  Float_t wG10[4]={0.148648649,0.104054054,0.483499056,0.241666667};
786   Float_t wG10[4]={0.15201,0.10641,0.49444,0.24714};
787   AliMixture(8,"G10",aG10,zG10,1.7,4,wG10);
788   
789   AliMaterial(15, "Cu   $", 63.54, 29., 8.96, 1.43, 15.);
790
791   // Steel
792   Float_t aSteel[4] = { 55.847,51.9961,58.6934,28.0855 };
793   Float_t zSteel[4] = { 26.,24.,28.,14. };
794   Float_t wSteel[4] = { .715,.18,.1,.005 };
795   Float_t dSteel    = 7.88;
796   AliMixture(19, "STAINLESS STEEL$", aSteel, zSteel, dSteel, 4, wSteel); 
797
798   //Air
799
800   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
801   Float_t zAir[4]={6.,7.,8.,18.};
802   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
803   Float_t dAir1 = 1.20479E-10;
804   Float_t dAir = 1.20479E-3;
805   AliMixture(98, "Vacum$", aAir,  zAir, dAir1, 4, wAir);
806   AliMixture(99, "Air  $", aAir,  zAir, dAir , 4, wAir);
807
808   // Define tracking media 
809   AliMedium(1,  "Pb conv.$", 1,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
810   AliMedium(4,  "Al      $", 4,  0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
811   AliMedium(5,  "ArCO2   $", 5,  1, 0, isxfld, sxmgmx, .1, .1, .10, .1);
812   AliMedium(6,  "Fe      $", 6,  0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
813   AliMedium(8,  "G10plate$", 8,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
814   AliMedium(15, "Cu      $", 15, 0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
815   AliMedium(19, "S  steel$", 19, 0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
816   AliMedium(98, "Vacuum  $", 98, 0, 0, isxfld, sxmgmx, 1., .1, .10, 10);
817   AliMedium(99, "Air gaps$", 99, 0, 0, isxfld, sxmgmx, 1., .1, .10, .1);
818
819 }
820
821 //_____________________________________________________________________________
822 void AliPMDv0::Init()
823 {
824   //
825   // Initialises PMD detector after it has been built
826   //
827   Int_t i;
828   //  kdet=1;
829   //
830   if(AliLog::GetGlobalDebugLevel()>0) {
831       printf("\n%s: ",ClassName());
832       for(i=0;i<35;i++) printf("*");
833       printf(" PMD_INIT ");
834       for(i=0;i<35;i++) printf("*");
835       printf("\n%s: ",ClassName());
836       printf("                 PMD simulation package (v0) initialised\n");
837       printf("%s: parameters of pmd\n", ClassName());
838       printf("%s: %10.2f %10.2f %10.2f \
839       %10.2f\n",ClassName(),fgkCellRadius,fgkCellWall,fgkCellDepth,fgkZdist );
840       printf("%s: ",ClassName());
841       for(i=0;i<80;i++) printf("*");
842       printf("\n");
843   }
844   Int_t *idtmed = fIdtmed->GetArray()-599;
845   fMedSens=idtmed[605-1];
846   // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
847   // removed all Gstpar and energy cut-offs moved to galice.cuts
848 }
849
850 //_____________________________________________________________________________
851 void AliPMDv0::StepManager()
852 {
853   //
854   // Called at each step in the PMD
855   //
856   Int_t   copy;
857   Float_t hits[5], destep;
858   Float_t center[3] = {0,0,0};
859   Int_t   vol[6];
860   //char *namep;
861   
862   if(gMC->CurrentMedium() == fMedSens && (destep = gMC->Edep())) {
863   
864     gMC->CurrentVolID(copy);
865     vol[0] = copy;
866     gMC->CurrentVolOffID(1,copy);
867     vol[1] = copy;
868     gMC->CurrentVolOffID(2,copy);
869     vol[2] = copy;
870     gMC->CurrentVolOffID(3,copy);
871     vol[3] = copy;
872     gMC->CurrentVolOffID(4,copy);
873     vol[4] = copy;
874     gMC->CurrentVolOffID(5,copy);
875     vol[5] = copy;
876
877     gMC->Gdtom(center,hits,1);
878     hits[3] = destep*1e9; //Number in eV
879
880    // this is for pile-up events
881     hits[4] = gMC->TrackTime();
882
883     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
884   }
885 }
886
887   
888 //------------------------------------------------------------------------
889 // Get parameters
890
891 void AliPMDv0::GetParameters()
892 {
893   // This gives all the parameters of the detector
894   // such as Length of Supermodules
895   // thickness of the Supermodule
896   //
897   Int_t ncellum, numum;
898   ncellum  = 24;
899   numum    = 3;
900   fNcellSM  = ncellum * numum;  //no. of cells in a row in one supermodule
901   fSMLength = (fNcellSM + 0.25 )*fgkCellRadius*2.;
902   fSMthick  = fgkThBase + fgkThAir + fgkThPCB + fgkCellDepth +
903     fgkThPCB + fgkThAir + fgkThPCB;
904 }