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