]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMD.cxx
ab5fc35bfd33e5856450e311e56287b9a2248d09
[u/mrichter/AliRoot.git] / PMD / AliPMD.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Photon Multiplicity Detector                                             //
4 //  This class contains the basic functions for the Photon Multiplicity      //
5 //  Detector. Functions specific to one particular geometry are              //
6 //  contained in the derived classes                                         //
7 //                                                                           //
8 //Begin_Html
9 /*
10 <img src="gif/AliPMDClass.gif">
11 </pre>
12 <br clear=left>
13 <font size=+2 color=red>
14 <p>The responsible person for this module is
15 <a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
16 </font>
17 <pre>
18 */
19 //End_Html
20 //                                                                           //
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include <TBRIK.h>
24 #include <TNode.h>
25 #include "AliPMD.h"
26 #include "AliRun.h"
27 #include "AliMC.h"
28 #include "AliConst.h" 
29  
30 static Float_t smod1[3], smod2[3], smod3[3], smod4[3];
31 static Int_t maxbox, kdet;
32 //static Float_t pmdin,pmdout,wafer;
33 static Float_t thgas,thcell,thmin,thmax,zdist,thlow,
34   thhigh,edge;
35 static Int_t numqu;
36 static Float_t xbox[40][40], ybox[40][40];
37 static Int_t pindex[40][40];
38
39 ClassImp(AliPMD)
40  
41 //_____________________________________________________________________________
42 AliPMD::AliPMD()
43 {
44   //
45   // Default constructor
46   //
47   fIshunt = 0;
48 }
49  
50 //_____________________________________________________________________________
51 AliPMD::AliPMD(const char *name, const char *title)
52   : AliDetector(name,title)
53 {
54   //
55   // Default constructor
56   //
57
58   // 
59   // Allocate the array of hits
60   fHits   = new TClonesArray("AliPMDhit",  405);
61   
62   fIshunt =  1;
63   
64   fPar[0] = 1;
65   fPar[1] = 1;
66   fPar[2] = 0.8;
67   fPar[3] = 0.02;
68   fIn[0]  = 6;
69   fIn[1]  = 20;
70   fIn[2]  = 600;
71   fIn[3]  = 27;
72   fIn[4]  = 27;
73   fGeo[0] = 0;
74   fGeo[1] = 0.2;
75   fGeo[2] = 4;
76   fPadSize[0] = 0.8;
77   fPadSize[1] = 1.0;
78   fPadSize[2] = 1.2;
79   fPadSize[3] = 1.5;
80 }
81
82 //_____________________________________________________________________________
83 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
84 {
85   //
86   // Add a PMD hit
87   //
88   TClonesArray &lhits = *fHits;
89   AliPMDhit *newcell, *curcell;
90   //  printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d\n",
91   //     hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3]);
92   newcell = new AliPMDhit(fIshunt, track, vol, hits);
93   Int_t i;
94   for (i=0; i<fNhits; i++) {
95     //
96     // See if this cell has already been hit
97     curcell=(AliPMDhit*) lhits[i];
98     if (*curcell==*newcell) {
99       //      printf("Cell with same numbers found\n") ; curcell->Print();
100       *curcell = *curcell+*newcell;
101       //      printf("Cell after addition\n") ; curcell->Print();
102       delete newcell;
103       return;
104     }
105   }
106   new(lhits[fNhits++]) AliPMDhit(newcell);
107   delete newcell;
108 }
109  
110 //_____________________________________________________________________________
111 void AliPMD::BuildGeometry()
112 {
113   //
114   // Build simple ROOT TNode geometry for event display
115   //
116
117   TNode *Node, *Top;
118   const int kColorPMD  = kRed;
119
120   //
121   Top=gAlice->GetGeometry()->GetNode("alice");
122
123   // PMD
124   new TBRIK("S_PMD","PMD box","void",300,300,5);
125   Top->cd();
126   Node = new TNode("PMD","PMD","S_PMD",0,0,600,"");
127   Node->SetLineColor(kColorPMD);
128   fNodes->Add(Node);
129 }
130
131 //_____________________________________________________________________________
132 Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t )
133 {
134   //
135   // Distance from mouse to detector on the screen
136   // dummy routine
137   //
138    return 9999;
139 }
140  
141 //_____________________________________________________________________________
142 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
143 {
144   //
145   // Set PMD parameters
146   //
147   fPar[0] = p1;
148   fPar[1] = p2;
149   fPar[2] = p3;
150   fPar[3] = p4;
151 }
152  
153 //_____________________________________________________________________________
154 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
155 {
156   //
157   // Set PMD parameters
158   //
159   fIn[0] = p1;
160   fIn[1] = p2;
161   fIn[2] = p3;
162   fIn[3] = p4;
163   fIn[4] = p5;
164 }
165  
166 //_____________________________________________________________________________
167 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
168 {
169   //
170   // Set geometry parameters
171   //
172   fGeo[0] = p1;
173   fGeo[1] = p2;
174   fGeo[2] = p3;
175 }
176  
177 //_____________________________________________________________________________
178 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
179 {
180   //
181   // Set pad size
182   //
183   fPadSize[0] = p1;
184   fPadSize[1] = p2;
185   fPadSize[2] = p3;
186   fPadSize[3] = p4;
187 }
188  
189 //_____________________________________________________________________________
190 void AliPMD::StepManager()
191 {
192   //
193   // Called at every step in PMD
194   //
195 }
196
197  
198 //_____________________________________________________________________________
199 void AliPMD::Undulation(char *undul, Float_t pitch, Float_t thick,
200                         Float_t zundul, Float_t rundul, char (*cone)[5])
201 {
202   //
203   // RUNDUL   : Internal radius of the undulated chamber
204   // THICK    : material thickness
205   // PITCH    : one-QUARTER wave of undulation (cm)
206   // ZUNDUL   : half length (cm)
207   //
208   // The undulated structure is desgned as a superposition of eight CONES
209   // of suitable sizes, where the inner/outer radius of the cone increases,
210   // then decreases, each half of the wave is assumed to be a semicircle,
211   // which allows to calculate the thickness and the radii of the cone, by
212   // dividing the semicircle into 4 parts of equal arc length.
213   // Thus apear the constants 0.293 and 0.707.
214   //
215
216   const Float_t const1 = .293;
217   const Float_t const2 = .707;
218   
219   AliMC* pMC = AliMC::GetMC();
220   
221   // Local variables 
222   Int_t j, nwave;
223   Float_t dcone1[5], dcone2[5], dcone3[5], dcone4[5], dcone5[5],
224     dcone6[5], dcone7[5], dcone8[5];
225   Float_t xc, yc, zc, dundul[3];
226   Int_t *idtmed = gAlice->Idtmed();
227   
228   // Function Body 
229   
230   dcone1[0] = const1 * pitch / 2;
231   dcone1[1] = rundul;
232   dcone1[2] = dcone1[1] + thick;
233   dcone1[3] = dcone1[1] + const2 * pitch;
234   dcone1[4] = dcone1[3] + thick;
235   
236   dcone2[0] = const2 * pitch / 2;
237   dcone2[1] = dcone1[3];
238   dcone2[2] = dcone1[4];
239   dcone2[3] = dcone2[1] + const1 * pitch;
240   dcone2[4] = dcone2[3] + thick;
241
242   dcone3[0] = dcone2[0];
243   dcone3[1] = dcone2[3];
244   dcone3[2] = dcone2[4];
245   dcone3[3] = dcone2[1];
246   dcone3[4] = dcone2[2];
247   
248   dcone4[0] = dcone1[0];
249   dcone4[1] = dcone1[3];
250   dcone4[2] = dcone1[4];
251   dcone4[3] = dcone1[1];
252   dcone4[4] = dcone1[2];
253   
254   dcone5[0] = dcone1[0];
255   dcone5[1] = dcone1[1] - thick;
256   dcone5[2] = dcone1[1];
257   dcone5[3] = dcone5[1] - const2 * pitch;
258   dcone5[4] = dcone5[3] + thick;
259   
260   dcone6[0] = dcone2[0];
261   dcone6[1] = dcone5[3];
262   dcone6[2] = dcone5[4];
263   dcone6[3] = dcone6[1] - const1 * pitch;
264   dcone6[4] = dcone6[3] + thick;
265   
266   dcone7[0] = dcone6[0];
267   dcone7[1] = dcone6[3];
268   dcone7[2] = dcone6[4];
269   dcone7[3] = dcone5[3];
270   dcone7[4] = dcone5[4];
271   
272   dcone8[0] = dcone5[0];
273   dcone8[1] = dcone7[3];
274   dcone8[2] = dcone7[4];
275   dcone8[3] = dcone5[1];
276   dcone8[4] = dcone5[2];
277   
278   pMC->Gsvolu(cone[0], "CONE", idtmed[606-1], dcone1, 5);
279   pMC->Gsvolu(cone[1], "CONE", idtmed[606-1], dcone2, 5);
280   pMC->Gsvolu(cone[2], "CONE", idtmed[606-1], dcone3, 5);
281   pMC->Gsvolu(cone[3], "CONE", idtmed[606-1], dcone4, 5);
282   pMC->Gsvolu(cone[4], "CONE", idtmed[606-1], dcone5, 5);
283   pMC->Gsvolu(cone[5], "CONE", idtmed[606-1], dcone6, 5);
284   pMC->Gsvolu(cone[6], "CONE", idtmed[606-1], dcone7, 5);
285   pMC->Gsvolu(cone[7], "CONE", idtmed[606-1], dcone8, 5);
286   pMC->Gsatt(cone[0], "SEEN", 0);
287   pMC->Gsatt(cone[1], "SEEN", 0);
288   pMC->Gsatt(cone[2], "SEEN", 0);
289   pMC->Gsatt(cone[3], "SEEN", 0);
290   pMC->Gsatt(cone[4], "SEEN", 0);
291   pMC->Gsatt(cone[5], "SEEN", 0);
292   pMC->Gsatt(cone[6], "SEEN", 0);
293   pMC->Gsatt(cone[7], "SEEN", 0);
294   
295   // DEFINE AN IMAGINARY TUBE VOLUME FOR UNDULATED CHAMBER, FILL WITH VACUUM
296     
297   nwave = Int_t (zundul / (pitch * 2) + .1);
298   dundul[2] = pitch * 2 * nwave;
299   dundul[1] = rundul + pitch + thick * 2;
300   //
301   dundul[0] = 1e-4;
302   pMC->Gsvolu(undul, "TUBE", idtmed[698-1], dundul, 3);
303   
304   xc = 0;
305   yc = 0;
306   zc = -dundul[2] + dcone1[0];
307   for (j = 1; j <= nwave; ++j) {
308     pMC->Gspos(cone[0], j, undul, xc, yc, zc, 0, "ONLY");
309     zc = zc + dcone1[0] + dcone2[0];
310     pMC->Gspos(cone[1], j, undul, xc, yc, zc, 0, "ONLY");
311     zc = zc + dcone2[0] + dcone3[0];
312     pMC->Gspos(cone[2], j, undul, xc, yc, zc, 0, "ONLY");
313     zc = zc + dcone3[0] + dcone4[0];
314     pMC->Gspos(cone[3], j, undul, xc, yc, zc, 0, "ONLY");
315     zc = zc + dcone4[0] + dcone5[0];
316     pMC->Gspos(cone[4], j, undul, xc, yc, zc, 0, "ONLY");
317     zc = zc + dcone5[0] + dcone6[0];
318     pMC->Gspos(cone[5], j, undul, xc, yc, zc, 0, "ONLY");
319     zc = zc + dcone6[0] + dcone7[0];
320     pMC->Gspos(cone[6], j, undul, xc, yc, zc, 0, "ONLY");
321     zc = zc + dcone7[0] + dcone8[0];
322     pMC->Gspos(cone[7], j, undul, xc, yc, zc, 0, "ONLY");
323     zc = zc + dcone8[0] + dcone1[0];
324   }
325 }
326
327 ///////////////////////////////////////////////////////////////////////////////
328 //                                                                           //
329 //  Photon Multiplicity Detector Version 1                                   //
330 //                                                                           //
331 //Begin_Html
332 /*
333 <img src="gif/AliPMDv1Class.gif">
334 */
335 //End_Html
336 //                                                                           //
337 ///////////////////////////////////////////////////////////////////////////////
338
339 ClassImp(AliPMDv1)
340  
341 //_____________________________________________________________________________
342 AliPMDv1::AliPMDv1() : AliPMD()
343 {
344   //
345   // Default constructor 
346   //
347   fMedSens=0;
348 }
349  
350 //_____________________________________________________________________________
351 AliPMDv1::AliPMDv1(const char *name, const char *title)
352   : AliPMD(name,title)
353 {
354   //
355   // Standard constructor
356   //
357   fMedSens=0;
358 }
359
360 //_____________________________________________________________________________
361 void AliPMDv1::Coordnew()
362 {
363   //
364   // Find coordinates for pad geometry
365   //
366   // Author Y.P. Viyogi, VECC Calcutta
367   //
368
369   Float_t th1, th2, dbox, dist;
370   //Float_t xoff[40][40], yoff[40][40];
371   Int_t i, j, nbox;
372   Int_t xoff1[3], yoff1[3], l;
373   Float_t dmax, hole;
374   Int_t kk, nhol;
375   Float_t rr, xx, yy;
376   
377   th1 = thmin * kPI / 180;
378   th2 = thmax * kPI / 180;
379   /* ESTIMATES FOR OCTAGON */
380   dist = zdist * TMath::Tan(th2);
381   /* ***  04.06.97 Fixed Module size of 6 cm, 0 mm boundary. */
382   /* ***  variable pad sizes of 0.3 mm, 0.5  mm, 1.0 mm and 1.2 mm */
383   dbox = edge * 2 + 24;
384   maxbox = Int_t(dist / dbox + .5);
385   dmax= maxbox * dbox;
386   /* NOW GET THE HOLE SIZE ETC. */
387   hole = zdist * TMath::Tan(th1);
388   nhol = Int_t(hole / dbox + .5);
389   hole = nhol * dbox;
390   
391   //rlow = zdist * TMath::Tan(thlow * kPI / 180);
392   //rhigh = zdist * TMath::Tan(thhigh * kPI / 180);
393   for (i = 1; i <= 40; ++i) {
394     for (j = 1; j <= 40; ++j) {
395       //index[j][i] = 0;
396       //xoff[j][i] = 0;
397       //yoff[j][i] = 0;
398       xbox[j][i] = 0;
399       /* L5: */
400       ybox[j][i] = 0;
401     }
402   }
403   
404   // NOW START PLACING THE BOXES IN VARIOUS LAYERS, START FROM THE CENTRE 
405   
406   yy = dbox / 2;
407   for(i=0;i<3;i++) yoff1[i]=0;
408   nbox = 0;
409   //        PRINT*,'MAXBOX=',MAXBOX 
410   for (i = 1; i <= maxbox; ++i) {
411     xx = dbox / 2;
412     for(j=0;j<3;j++) xoff1[j]=0;
413         for (j = 1; j <= maxbox; ++j) {
414           rr = sqrt(xx*xx+yy*yy);
415           if (rr >= hole && rr <= dmax) {
416             //  BOX CAN BE FITTED 
417             //index[j][i] = 2;
418             //if (rr < rlow) index[j][i] = 1;
419             //else if (rr > rhigh) index[j][i] = 3;
420             xbox[j][i] = xx;
421             ybox[j][i] = yy;
422               ++nbox;
423               //xoff[j][i] = xoff1[index[j][i] - 1];
424               //yoff[j][i] = yoff1[index[j][i] - 1];
425           }
426           if (kdet == 1) kk = 1; else kk = 0;
427           for (l = 1; l <= 3; ++l)
428             xoff1[l - 1] += fNumPads[l + kk - 1];
429           xx += dbox;
430         }
431         
432         if (kdet == 1) kk = 1; else kk=0;
433         
434         for (l = 1; l <= 3; ++l)
435           yoff1[l - 1] += fNumPads[l + kk - 1];
436         yy += dbox;
437   }
438 }
439
440 //_____________________________________________________________________________
441 void AliPMDv1::Coordinates()
442 {
443   //
444   //  SUBROUTINE TO COMPUTE THE X- AND Y- COORDINATES OF THE BOXES 
445   //  WHICH CAN FIT INTO THE CIRCULAR REGION BETWEEN THE GIVEN ANGLES. 
446   //  INPUT : ZDIST, THMIN, THMAX, PADSIZE (FOR INSIDE and OUTSIDE PMD). 
447   //  ALL DIMENSIONS IN CM. 
448   // -- Author :        Y.P. VIYOGI, 10/05/1996. 
449
450   Float_t hole, dmax, dbox;
451   Int_t nhol;
452   Float_t dist;
453   Int_t nbox;
454   Float_t rlow;
455   Int_t i, j;
456   Float_t rhigh, rr, xx, yy, th1, th2;
457   
458   th1 = thmin*kPI/180;
459   th2 = thmax*kPI/180;
460   // ESTIMATES FOR OCTAGON 
461   dist = zdist * TMath::Tan(th2);
462   // ***  04.06.97 Fixed Module size of 24 cm, 3 mm boundary. 
463   // ***  variable pad sizes of 8 mm, 10 mm, 12mm and 15 mm 
464   dbox   = edge*2 + 24.;
465   maxbox = Int_t(dist / dbox + .5);
466   dmax   = maxbox*dbox;
467   // NOW GET THE HOLE SIZE ETC. 
468   hole = zdist * TMath::Tan(th1);
469   nhol = Int_t(hole / dbox + .5);
470   hole = nhol * dbox;
471   
472   rlow  = zdist * TMath::Tan(thlow*kPI/180);
473   rhigh = zdist * TMath::Tan(thhigh*kPI/180);
474   for (i = 0; i < 40; ++i) {
475     for (j = 0; j < 40; ++j) {
476       pindex[j][i] = 0;
477       xbox[j][i]   = 0;
478       ybox[j][i]   = 0;
479     }
480   }
481   
482   //  NOW START PLACING THE BOXES IN VARIOUS LAYERS, START FROM THE CENTRE 
483   yy   = dbox / 2;
484     nbox = 0;
485     for (i = 0; i < maxbox; ++i) {
486       xx = dbox / 2;
487       for (j = 0; j < maxbox; ++j) {
488         rr = TMath::Sqrt(xx*xx + yy*yy);
489         if (rr >= hole && rr <= dmax) {  //  BOX CAN BE FITTED 
490           pindex[j][i] = 2;
491           if (rr < rlow)  pindex[j][i] = 1;
492           if (rr > rhigh) pindex[j][i] = 3;
493           xbox[j][i] = xx;
494           ybox[j][i] = yy;
495           ++nbox;
496         }
497         xx += dbox;
498       }
499       yy += dbox;
500     }
501 }
502  
503 //_____________________________________________________________________________
504 void AliPMDv1::CreateGeometry()
505 {
506   //
507   // Create geometry for Photon Multiplicity Detector Version 1
508   //
509   //Begin_Html
510   /*
511     <img src="gif/AliPMDv1.gif">
512   */
513   //End_Html
514   //Begin_Html
515   /*
516     <img src="gif/AliPMDv1Tree.gif">
517   */
518   //End_Html
519   CreatePads();
520   CreateInside();
521 }
522  
523 //_____________________________________________________________________________
524 void AliPMDv1::CreateInside()
525 {
526   //
527   // Create inside of Pads
528   //
529   // -- Author :     Y.P. VIYOGI, 07/05/1996. 
530   // -- Modified:    P.V.K.S.Baba(JU), 15-12-97. 
531   
532   Float_t sipmd[3] = { 300.,300.,5. };
533   
534   Int_t i2;
535   
536   Float_t xiqa[4], yiqa[4];
537   Int_t inum2, inum3, inum4, i, j, k;
538   Float_t siqad[4];
539   Float_t zd, xd, yd, xp, yp, zp;
540   Int_t idrotm[100];
541   
542   Int_t *idtmed = gAlice->Idtmed();    
543   
544   //  VOLUMES Names : begining with D for all PMD volumes, 
545   // The names of SIZE variables begin with S and have more meaningful
546   // characters as shown below. 
547   
548   //            VOLUME  SIZE    MEDIUM  :       REMARKS 
549   //            ------  -----   ------  : --------------------------- 
550   
551   //            DPMD    SIPMD   AIR     : INSIDE PMD  and its SIZE 
552   
553   
554   
555   // *** Define the  DPMD   Volume and fill with air *** 
556
557   AliMC* pMC = AliMC::GetMC();
558   
559   pMC->Gsvolu("DPMD", "BOX ", idtmed[698], sipmd, 3);
560   
561   // *** Define DIQU Volume and fill with air 
562   siqad[0] = sipmd[0] / 2. - 1.;
563   siqad[1] = sipmd[1] / 2. - 1.;
564   siqad[2] = sipmd[2];
565   pMC->Gsvolu("DIQU","BOX ", idtmed[698], siqad, 3);
566   pMC->Gsatt("DIQU", "SEEN", 1);
567   
568   
569   // --- Place the modules in INSIDE PMD (DPMD) 
570   // --- FIRST CALCULATE THE COORDINATES OF THE MODULES WHICH CAN BE 
571   // --- ACCOMODATED. 
572   
573   kdet = 1;
574   Coordinates();
575   
576   //inum = 0;
577   zd   = 0.;
578   AliMatrix(idrotm[1], 90., 0.,   90.,  90., 0., 0.);
579   AliMatrix(idrotm[2], 90., 180., 90.,  90., 0., 0.);
580   AliMatrix(idrotm[3], 90., 180., 90., 270., 0., 0.);
581   AliMatrix(idrotm[4], 90., 0.,   90., 270., 0., 0.);
582   // ****  Filling the DIQU Vol. (One Quadrant) 
583   inum2 = 0;
584   inum3 = 0;
585     inum4 = 0;
586     for (i = 0; i < maxbox; ++i) {
587       i2 = maxbox;
588       for (j = 0; j < i2; ++j) {
589         if (xbox[j][i] <= 0 && ybox[j][i] <= 0) continue;
590         xd = xbox[j][i] - siqad[0];
591         yd = ybox[j][i] - siqad[1];
592         if (pindex[j][i] == 1) {
593           ++inum2;
594           pMC->Gsposp("DM11", inum2, "DIQU", xd, yd, zd, 0, "ONLY", smod2, 3);
595         }
596         if (pindex[j][i] == 2) {
597           ++inum3;
598           pMC->Gsposp("DM12", inum3, "DIQU", xd, yd, zd, 0, "ONLY", smod3, 3);
599         }
600         if (pindex[j][i] == 3) {
601           ++inum4;
602           pMC->Gsposp("DM13", inum4, "DIQU", xd, yd, zd, 0, "ONLY", smod4, 3);
603         }
604       }
605     }
606     xiqa[0] = siqad[0];
607     xiqa[1] = -siqad[0];
608     xiqa[2] = xiqa[1];
609     xiqa[3] = xiqa[0];
610     yiqa[0] = siqad[0];
611     yiqa[1] = yiqa[0];
612     yiqa[2] = -siqad[0];
613     yiqa[3] = yiqa[2];
614     i2      = numqu;
615     for (k = 1; k <= i2; ++k) {
616       pMC->Gsposp("DIQU", k, "DPMD", xiqa[k-1], yiqa[k-1], zd, idrotm[k], "ONLY", siqad, 3);
617     }
618     
619     // --- Place the DPMD in ALICE with front edge 6.0m from vertex  --- 
620     xp = 0.;
621     yp = 0.;
622     zp = zdist;
623     pMC->Gspos("DPMD", 1, "ALIC", xp, yp, zp, 0, "ONLY");
624     
625 }
626
627 //_____________________________________________________________________________
628 void AliPMDv1::CreatePads()
629 {
630   //
631   // Create the geometry of the pads
632   // *** DEFINITION OF THE GEOMETRY OF THE PMD  *** 
633   // *** DIFFERENT PADS WITH SIZES 8 MM, 10 MM, 12 MM AND 15 MM SQUARE 
634   // -- Author :     Y.P. VIYOGI, 04/06/1997. 
635   // -- Modified:    P.V.K.S.Baba(JU), 13-12-97. 
636   
637   AliMC* pMC = AliMC::GetMC();
638   
639   Int_t npad1, npad2, npad3, npad4;
640   Float_t spad1[3], spad2[3], spad3[3], spad4[3];
641   Float_t scpv1[3], scpv2[3], scpv3[3], scpv4[3];
642   Int_t i, j;
643   Float_t sstr1[3], spsw1[3], sstr2[3], spsw2[3], sstr3[3], spsw3[3],
644     sstr4[3], spsw4[3];
645   Float_t xa, ya, za, xb, yb, zb, xc, sw[3], yc, zc;
646   Float_t sfe[3];
647   Float_t spb[3], pad1, pad2, pad3, pad4;
648   //  VOLUMES Names : begining with D for all PMD volumes, 
649   //     DMO1 : MODULE TYPE 1 ( 8 MM PADS) 
650   //     DM11 : MODULE TYPE 2 (10 MM PADS) 
651   //     DM12 : MODULE TYPE 3 (12 MM PADS) 
652   //     DM13 : MODULE TYPE 4 (15 MM PADS) 
653   
654   // The names of SIZE variables begin with S and have more meaningful
655   // characters as shown below. 
656   
657   //            VOLUME  SIZE    MEDIUM  :       REMARKS 
658   //            ------  -----   ------  : --------------------------- 
659   
660   //            DPPB    SPB     PB      : PB Converter and its SIZE 
661   //            DPFE    SFE     FE      : FE Support Plate and its SIZE 
662   
663   //               DP11    SPAD2   GAS     : PAD TYPE 2 (10 MM) 
664   //               DP12    SPAD2   GAS     : PAD TYPE 2 FOR CPV(10 MM) 
665   //               DS11    SSTR2   FE      : STRIP OF IRON 
666   //               DW11    SPSW2   G10     : PRESHOWER 
667   //               DV11    SCPV2   G10     : CPV 
668   
669   //               DP13    SPAD3   GAS     : PAD TYPE 3 (12 MM) 
670   //               DP14    SPAD3   GAS     : PAD TYPE 3 FOR CPV(12 MM) 
671   //               DS12    SSTR3   FE      : STRIP OF IRON 
672   //               DW12    SPSW3   G10     : PRESHOWER 
673   //               DV12    SCPV3   G10     : CPV 
674   
675   //               DP15    SPAD4   GAS     : PAD TYPE 4 (15 MM) 
676   //               DP16    SPAD4   GAS     : PAD TYPE 4 FOR CPV(15 MM) 
677   //               DS13    SSTR4   FE      : STRIP OF IRON 
678   //               DW13    SPSW4   G10     : PRESHOWER 
679   //               DV13    SCPV4   G10     : CPV 
680   
681   //     ****************** VOLUME TREE ****************** 
682   
683   //                    DM11 (Module) 
684   //                           | 
685   //                           | 
686   //    ------------------------------------------------- 
687   //       |             |               |                 | 
688   //       |             |               |                 | 
689   //    DV11( CPV)      DPFE            DPPB              DW11(Preshower) 
690   //       |                                            | 
691   //    |                                               | 
692   //    DS12(Strip)                                    DS11(Strip) 
693   //       |                                               | 
694   //       |                                            | 
695   //    DP12(Pads)                                        DP11(Pads) 
696   
697   //    ************************************************************ 
698   
699   // --- The above  gives the Volume Tree. PAD is a gas cell of size 
700   // --- given by PADSIZE in the input cards.  STRIP is a collection of 
701   //--- PADs in a row.   STRIPs are positioned in the PRESHOWER BOX. This is
702   //--- then placed in the MODULE. The PSW and the MODULE have the same size
703   // --- ; Lead converter, Iron support plate are also placed 
704   // --- in the MODULE. 
705   
706   
707   //        DATA PAD1,PAD2,PAD3,PAD4/4*0.8/ 
708   //        DATA NPAD1,NPAD2,NPAD3,NPAD4/4*30/ 
709   
710   Int_t *idtmed = gAlice->Idtmed();
711   
712   // **** PAD SIZE 8 MM 
713   //  pmdin  = fPar[0];
714   //  pmdout = fPar[1];
715   thgas  = fPar[2];
716   thcell = fPar[3];
717   thmin  = fIn[0];
718   thmax  = fIn[1];
719   zdist  = fIn[2];
720   thlow  = fIn[3];
721   thhigh = fIn[4];
722   //  wafer  = fGeo[0];
723   edge   = fGeo[1];
724   numqu  = Int_t(fGeo[2]);
725   
726   
727   // *BABA 
728   pad1  = fPadSize[0];
729   pad2  = fPadSize[1];
730   pad3  = fPadSize[2];
731   pad4  = fPadSize[3];
732   npad1 = Int_t(24/fPadSize[0]);
733   npad2 = Int_t(24/fPadSize[1]);
734   npad3 = Int_t(24/fPadSize[2]);
735   npad4 = Int_t(24/fPadSize[3]);
736   // *BABA 
737   spad1[0] = (pad1 - thcell) / 2.;
738   spad1[1] = spad1[0];
739   spad1[2] = thgas / 2;
740   pMC->Gsvolu("DP21", "BOX ", idtmed[604], spad1, 3);
741   pMC->Gsatt("DP21", "SEEN", 1);
742   pMC->Gsvolu("DP22", "BOX ", idtmed[604], spad1, 3);
743   pMC->Gsatt("DP22", "SEEN", 1);
744   
745   sstr1[0] = npad1*pad1/2;
746   sstr1[1] = pad1/2;
747   sstr1[2] = thgas/2;
748   pMC->Gsvolu("DS21", "BOX ", idtmed[605], sstr1, 3);
749   pMC->Gsatt("DS21", "SEEN", 1);
750   pMC->Gsvolu("DS22", "BOX ", idtmed[605], sstr1, 3);
751   pMC->Gsatt("DS22", "SEEN", 1);
752   
753   spsw1[0] = sstr1[0] + edge;
754   spsw1[1] = spsw1[0];
755   spsw1[2] = (thgas + .4) / 2;
756   // 2 mm G10 Plate cover (NMATE = 808) 
757   scpv1[0] = spsw1[0];
758   scpv1[1] = spsw1[1];
759   scpv1[2] = spsw1[2];
760   pMC->Gsvolu("DW21", "BOX ", idtmed[607], spsw1, 3);
761   pMC->Gsatt("DW21", "SEEN", 1);
762   pMC->Gsvolu("DV21", "BOX ", idtmed[607], spsw1, 3);
763   pMC->Gsatt("DV21", "SEEN", 1);
764   
765   // --- place  pads in a strip 
766   xa = (-npad1 + 1.) * pad1 / 2.;
767   ya = 0.;
768   za = 0.;
769   for (i = 1; i <= npad1; ++i) {
770     pMC->Gsposp("DP21", i, "DS21", xa, ya, za, 0, "ONLY", spad1, 3);
771     pMC->Gsposp("DP22", i, "DS22", xa, ya, za, 0, "ONLY", spad1, 3);
772     xa += pad1;
773   }
774   // --- place  strips in the PRESHOWER AND CPV boxes 
775   xb = 0.;
776   yb = (-npad1 + 1.) * pad1 / 2.;
777   zb = 0.;
778   for (j = 1; j <= npad1; ++j) {
779     pMC->Gsposp("DS21", j, "DW21", xb, yb, zb, 0, "ONLY", sstr1, 3);
780     pMC->Gsposp("DS22", j, "DV21", xb, yb, zb, 0, "ONLY", sstr1, 3);
781     yb += pad1;
782   }
783   
784   // **** PAD SIZE 10 MM 
785   
786   spad2[0] = (pad2 - thcell) / 2.;
787   spad2[1] = spad2[0];
788   spad2[2] = thgas / 2;
789   pMC->Gsvolu("DP11", "BOX ", idtmed[604], spad2, 3);
790   pMC->Gsatt("DP11", "SEEN", 1);
791   pMC->Gsvolu("DP12", "BOX ", idtmed[604], spad2, 3);
792   pMC->Gsatt("DP12", "SEEN", 1);
793   
794   sstr2[0] = npad2 * pad2 / 2;
795   sstr2[1] = pad2 / 2;
796   sstr2[2] = thgas / 2;
797   pMC->Gsvolu("DS11", "BOX ", idtmed[605], sstr2, 3);
798   pMC->Gsatt("DS11", "SEEN", 1);
799   pMC->Gsvolu("DS12", "BOX ", idtmed[605], sstr2, 3);
800   pMC->Gsatt("DS12", "SEEN", 1);
801   
802   spsw2[0] = sstr2[0] + edge;
803   spsw2[1] = spsw2[0];
804   spsw2[2] = (thgas + .4) / 2;
805   // 2 mm G10 Plate cover (NMATE = 808) 
806   scpv2[0] = spsw2[0];
807   scpv2[1] = spsw2[1];
808   scpv2[2] = spsw2[2];
809   pMC->Gsvolu("DW11","BOX ", idtmed[607], spsw2, 3);
810   pMC->Gsatt("DW11", "SEEN", 1);
811   pMC->Gsvolu("DV11","BOX ", idtmed[607], spsw2, 3);
812   pMC->Gsatt("DV11", "SEEN", 1);
813   
814   // --- place  pads in a strip 
815   xa = (-npad2 + 1.) * pad2 / 2.;
816   ya = 0.;
817   za = 0.;
818   for (i = 1; i <= npad2; ++i) {
819     pMC->Gsposp("DP11", i, "DS11", xa, ya, za, 0, "ONLY", spad2, 3);
820     pMC->Gsposp("DP12", i, "DS12", xa, ya, za, 0, "ONLY", spad2, 3);
821     xa += pad2;
822   }
823   // --- place  strips in the PRESHOWER AND CPV boxes 
824   xb = 0.;
825   yb = (-npad2 + 1.) * pad2 / 2.;
826   zb = 0.;
827   for (j = 1; j <= npad2; ++j) {
828     pMC->Gsposp("DS11", j, "DW11", xb, yb, zb, 0, "ONLY", sstr2, 3);
829     pMC->Gsposp("DS12", j, "DV11", xb, yb, zb, 0, "ONLY", sstr2, 3);
830     yb += pad2;
831   }
832   
833   // **** PAD SIZE 12 MM 
834   
835   spad3[0] = (pad3 - thcell) / 2.;
836   spad3[1] = spad3[0];
837   spad3[2] = thgas / 2;
838   pMC->Gsvolu("DP13", "BOX ", idtmed[604], spad3, 3);
839   pMC->Gsatt("DP13", "SEEN", 1);
840   pMC->Gsvolu("DP14", "BOX ", idtmed[604], spad3, 3);
841   pMC->Gsatt("DP14", "SEEN", 1);
842   
843   sstr3[0] = npad3 * pad3 / 2;
844   sstr3[1] = pad3 / 2;
845   sstr3[2] = thgas / 2;
846   pMC->Gsvolu("DS13", "BOX ", idtmed[605], sstr3, 3);
847   pMC->Gsatt("DS13", "SEEN", 1);
848   pMC->Gsvolu("DS14", "BOX ", idtmed[605], sstr3, 3);
849   pMC->Gsatt("DS14", "SEEN", 1);
850   
851   spsw3[0] = sstr3[0] + edge;
852   spsw3[1] = spsw3[0];
853   spsw3[2] = (thgas + .4) / 2;
854   // 2 mm G10 Plate cover (NMATE = 808) 
855   scpv3[0] = spsw3[0];
856   scpv3[1] = spsw3[1];
857   scpv3[2] = spsw3[2];
858   pMC->Gsvolu("DW12","BOX ", idtmed[607], spsw3, 3);
859   pMC->Gsatt("DW12", "SEEN", 1);
860   pMC->Gsvolu("DV12","BOX ", idtmed[607], spsw3, 3);
861   pMC->Gsatt("DV12", "SEEN", 1);
862   
863   // --- place  pads in a strip 
864   xa = (-npad3 + 1.) * pad3 / 2.;
865   ya = 0.;
866   za = 0.;
867   for (i = 1; i <= npad3; ++i) {
868     pMC->Gsposp("DP13", i, "DS13", xa, ya, za, 0, "ONLY", spad3, 3);
869     pMC->Gsposp("DP14", i, "DS14", xa, ya, za, 0, "ONLY", spad3, 3);
870     xa += pad3;
871   }
872   // --- place  strips in the PRESHOWER AND CPV boxes 
873   xb = 0.;
874   yb = (-npad3 + 1.) * pad3 / 2.;
875   zb = 0.;
876   for (j = 1; j <= npad3; ++j) {
877     pMC->Gsposp("DS13", j, "DW12", xb, yb, zb, 0, "ONLY", sstr3, 3);
878     pMC->Gsposp("DS14", j, "DV12", xb, yb, zb, 0, "ONLY", sstr3, 3);
879     yb += pad3;
880   }
881   
882   // **** PAD SIZE 15 MM 
883   
884   spad4[0] = (pad4 - thcell) / 2.;
885   spad4[1] = spad4[0];
886   spad4[2] = thgas / 2;
887   pMC->Gsvolu("DP15","BOX ", idtmed[604], spad4, 3);
888   pMC->Gsatt("DP15", "SEEN", 1);
889   pMC->Gsvolu("DP16","BOX ", idtmed[604], spad4, 3);
890   pMC->Gsatt("DP16", "SEEN", 1);
891   
892   sstr4[0] = npad4 * pad4 / 2;
893   sstr4[1] = pad4 / 2;
894   sstr4[2] = thgas / 2;
895   pMC->Gsvolu("DS15","BOX ", idtmed[605], sstr4, 3);
896   pMC->Gsatt("DS15", "SEEN", 1);
897   pMC->Gsvolu("DS16","BOX ", idtmed[605], sstr4, 3);
898   pMC->Gsatt("DS16", "SEEN", 1);
899   
900   spsw4[0] = sstr4[0] + edge;
901   spsw4[1] = spsw4[0];
902   spsw4[2] = (thgas + .4) / 2;
903   // 2 mm G10 Plate cover (NMATE = 808) 
904   scpv4[0] = spsw4[0];
905   scpv4[1] = spsw4[1];
906   scpv4[2] = spsw4[2];
907   pMC->Gsvolu("DW13","BOX ", idtmed[607], spsw4, 3);
908   pMC->Gsatt("DW13", "SEEN", 1);
909   pMC->Gsvolu("DV13","BOX ", idtmed[607], spsw4, 3);
910   pMC->Gsatt("DV13", "SEEN", 1);
911   
912   // --- place  pads in a strip 
913   xa = (-npad4 + 1.) * pad4 / 2.;
914   ya = 0.;
915   za = 0.;
916   for (i = 1; i <= npad4; ++i) {
917     pMC->Gsposp("DP15", i, "DS15", xa, ya, za, 0, "ONLY", spad4, 3);
918     pMC->Gsposp("DP16", i, "DS16", xa, ya, za, 0, "ONLY", spad4, 3);
919     xa += pad4;
920   }
921   // --- place  strips in the PRESHOWER AND CPV boxes 
922   xb = 0.;
923   yb = (-npad4 + 1.) * pad4 / 2.;
924   zb = 0.;
925   for (j = 1; j <= npad4; ++j) {
926     pMC->Gsposp("DS15", j, "DW13", xb, yb, zb, 0, "ONLY", sstr4, 3);
927     pMC->Gsposp("DS16", j, "DV13", xb, yb, zb, 0, "ONLY", sstr4, 3);
928     yb += pad4;
929   }
930   
931   
932   // --- DEFINE MODULES, IRON, TUNGSTEN AND LEAD VOLUMES 
933   
934   
935   spb[0] = spsw1[0];
936   spb[1] = spsw1[1];
937   spb[2] = .75;
938   pMC->Gsvolu("DPPB","BOX ", idtmed[600], spb, 3);
939   pMC->Gsatt("DPPB", "SEEN", 1);
940   
941   sw[0] = spsw1[0];
942   sw[1] = spsw1[1];
943   sw[2] = 0.9/2.;
944   pMC->Gsvolu("DPW ","BOX ", idtmed[600], sw, 3);
945   pMC->Gsatt("DPW ", "SEEN", 1);
946   
947   sfe[0] = spsw1[0];
948   sfe[1] = spsw1[1];
949   sfe[2] = 0.6/2.;
950   pMC->Gsvolu("DPFE","BOX ", idtmed[605], sfe, 3);
951   pMC->Gsatt("DPFE", "SEEN", 1);
952   
953   smod1[0] = spsw1[0];
954   smod1[1] = smod1[0];
955   //    SMOD1(3)=SPSW1(3)+SFE(3)+SW (3)+SCPV1(3) 
956   smod1[2] = spsw1[2] + sfe[2] + spb[2] + scpv1[2];
957   pMC->Gsvolu("DM21", "BOX ", idtmed[698], smod1, 3);
958   
959   smod2[0] = spsw2[0];
960   smod2[1] = smod2[0];
961   smod2[2] = spsw2[2] + sfe[2] + spb[2] + scpv2[2];
962   pMC->Gsvolu("DM11", "BOX ", idtmed[698], smod2, 3);
963   
964   smod3[0] = spsw3[0];
965   smod3[1] = smod3[0];
966   smod3[2] = spsw3[2] + sfe[2] + spb[2] + scpv3[2];
967   pMC->Gsvolu("DM12", "BOX ", idtmed[698], smod3, 3);
968   
969   smod4[0] = spsw4[0];
970   smod4[1] = smod4[0];
971   smod4[2] = spsw4[2] + sfe[2] + spb[2] + scpv4[2];
972   pMC->Gsvolu("DM13", "BOX ", idtmed[698], smod4, 3);
973   
974   // **** MODULE TYPE 1 : ALWAYS WITH TUNSGTEN CONVERTER 
975   
976   // *** try with PB once 8.6.97 
977   
978   // ---  place gas box (as CPV), iron support, lead converter and gas box 
979   // ---  (preshower) in the module 
980   xc = 0.;
981   yc = 0.;
982   // --- First the CPV box 
983   zc = -(spsw1[2] + sfe[2] + spb[2] + spsw1[2]) + spsw1[2];
984   pMC->Gspos("DV21", 1, "DM21", xc, yc, zc, 0, "ONLY");
985   // --- Then iron support plate 
986   zc = zc + sfe[2] + spsw1[2];
987   pMC->Gspos("DPFE", 1, "DM21", xc, yc, zc, 0, "ONLY");
988   // --- Then  converter plate 
989   zc = zc + sfe[2] + spb[2];
990   pMC->Gspos("DPPB", 1, "DM21", xc, yc, zc, 0, "ONLY");
991   // --- Lastly the preshower box 
992   zc = zc + spb[2] + spsw1[2];
993   pMC->Gspos("DW21", 1, "DM21", xc, yc, zc, 0, "ONLY");
994   
995   // **** MODULE TYPE 2 
996   
997   // ---  place gas box (as CPV), iron support, lead converter and gas box 
998   // ---  (preshower) in the module 
999   xc = 0.;
1000   yc = 0.;
1001   // --- First the CPV box 
1002   zc = -(spsw2[2] + sfe[2] + spb[2] + spsw2[2]) + spsw2[2];
1003   pMC->Gspos("DV11", 1, "DM11", xc, yc, zc, 0, "ONLY");
1004   // --- Then iron support plate 
1005   zc = zc + sfe[2] + spsw2[2];
1006   pMC->Gspos("DPFE", 1, "DM11", xc, yc, zc, 0, "ONLY");
1007   // --- Then lead converter plate 
1008   zc = zc + sfe[2] + spb[2];
1009   pMC->Gspos("DPPB", 1, "DM11", xc, yc, zc, 0, "ONLY");
1010   // --- Lastly the preshower box 
1011   zc = zc + spb[2] + spsw2[2];
1012   pMC->Gspos("DW11", 1, "DM11", xc, yc, zc, 0, "ONLY");
1013   
1014   
1015   // **** MODULE TYPE 3 
1016   
1017   // ---  place gas box (as CPV), iron support, lead converter and gas box 
1018   // ---  (preshower) in the module 
1019   xc = 0.;
1020   yc = 0.;
1021   // --- First the CPV box 
1022   zc = -(spsw3[2] + sfe[2] + spb[2] + spsw3[2]) + spsw3[2];
1023   pMC->Gspos("DV12", 1, "DM12", xc, yc, zc, 0, "ONLY");
1024   // --- Then iron support plate 
1025   zc = zc + sfe[2] + spsw3[2];
1026   pMC->Gspos("DPFE", 1, "DM12", xc, yc, zc, 0, "ONLY");
1027   // --- Then lead converter plate 
1028   zc = zc + sfe[2] + spb[2];
1029   pMC->Gspos("DPPB", 1, "DM12", xc, yc, zc, 0, "ONLY");
1030   // --- Lastly the preshower box 
1031   zc = zc + spb[2] + spsw3[2];
1032   pMC->Gspos("DW12", 1, "DM12", xc, yc, zc, 0, "ONLY");
1033   
1034
1035   // **** MODULE TYPE 4 
1036   
1037   // ---  place gas box (as CPV), iron support, lead converter and gas box 
1038   // ---  (preshower) in the module 
1039   xc = 0.;
1040   yc = 0.;
1041   // --- First the CPV box 
1042   zc = -(spsw4[2] + sfe[2] + spb[2] + spsw4[2]) + spsw4[2];
1043   pMC->Gspos("DV13", 1, "DM13", xc, yc, zc, 0, "ONLY");
1044   // --- Then iron support plate 
1045   zc = zc + sfe[2] + spsw4[2];
1046   pMC->Gspos("DPFE", 1, "DM13", xc, yc, zc, 0, "ONLY");
1047   // --- Then lead converter plate 
1048   zc = zc + sfe[2] + spb[2];
1049   pMC->Gspos("DPPB", 1, "DM13", xc, yc, zc, 0, "ONLY");
1050   // --- Lastly the preshower box 
1051   zc = zc + spb[2] + spsw4[2];
1052   pMC->Gspos("DW13", 1, "DM13", xc, yc, zc, 0, "ONLY");
1053   
1054 }
1055  
1056 //_____________________________________________________________________________
1057 void AliPMDv1::DrawModule()
1058 {
1059   //
1060   // Draw a shaded view of the Photon Multiplicity Detector
1061   //
1062
1063   AliMC* pMC = AliMC::GetMC();
1064   
1065   pMC->Gsatt("*", "seen", -1);
1066   pMC->Gsatt("alic", "seen", 0);
1067   //
1068   // Set the visibility of the components
1069   // 
1070   pMC->Gsatt("DP21","seen",0);
1071   pMC->Gsatt("DP22","seen",0);
1072   pMC->Gsatt("DS21","seen",1);
1073   pMC->Gsatt("DS22","seen",1);
1074   pMC->Gsatt("DW21","seen",0);
1075   pMC->Gsatt("DV21","seen",0);
1076   pMC->Gsatt("DP11","seen",0);
1077   pMC->Gsatt("DP12","seen",0);
1078   pMC->Gsatt("DS11","seen",1);
1079   pMC->Gsatt("DS12","seen",1);
1080   pMC->Gsatt("DW11","seen",0);
1081   pMC->Gsatt("DV11","seen",0);
1082   pMC->Gsatt("DP13","seen",0);
1083   pMC->Gsatt("DP14","seen",0);
1084   pMC->Gsatt("DS13","seen",1);
1085   pMC->Gsatt("DS14","seen",1);
1086   pMC->Gsatt("DW12","seen",0); 
1087   pMC->Gsatt("DV12","seen",0);
1088   pMC->Gsatt("DP15","seen",0);
1089   pMC->Gsatt("DP16","seen",0);
1090   pMC->Gsatt("DS15","seen",1);
1091   pMC->Gsatt("DS16","seen",1);
1092   pMC->Gsatt("DW13","seen",0);
1093   pMC->Gsatt("DV13","seen",0);
1094   pMC->Gsatt("DPPB","seen",1);
1095   pMC->Gsatt("DPW ","seen",1); 
1096   pMC->Gsatt("DPFE","seen",1);
1097   pMC->Gsatt("DM21","seen",1);
1098   pMC->Gsatt("DM11","seen",1);
1099   pMC->Gsatt("DM12","seen",1);
1100   pMC->Gsatt("DM13","seen",1);
1101   pMC->Gsatt("DPMD","seen",0);
1102   pMC->Gsatt("DIQU","seen",0);
1103   //
1104   pMC->Gdopt("hide", "on");
1105   pMC->Gdopt("shad", "on");
1106   pMC->Gsatt("*", "fill", 7);
1107   pMC->SetClipBox(".");
1108   pMC->SetClipBox("*", 0, 3000, -3000, 3000, -6000, 6000);
1109   pMC->DefaultRange();
1110   pMC->Gdraw("alic", 40, 30, 0, 22, 15.5, .04, .04);
1111   pMC->Gdhead(1111, "Photon Multiplicity Detector Version 1");
1112   pMC->Gdman(17, 5, "MAN");
1113   pMC->Gdopt("hide", "off");
1114 }
1115
1116 //_____________________________________________________________________________
1117 void AliPMDv1::CreateMaterials()
1118 {
1119   //
1120   // Create materials for the PMD version 1
1121   //
1122   // ORIGIN    : Y. P. VIYOGI 
1123   //
1124   
1125   AliMC* pMC = AliMC::GetMC();
1126   
1127   // --- The Argon- CO2 mixture --- 
1128   Float_t ag[2] = { 39.95 };
1129   Float_t zg[2] = { 18. };
1130   Float_t wg[2] = { .8,.2 };
1131   Float_t dar   = .001782;   // --- Ar density in g/cm3 --- 
1132   // --- CO2 --- 
1133   Float_t ac[2] = { 12.,16. };
1134   Float_t zc[2] = { 6.,8. };
1135   Float_t wc[2] = { 1.,2. };
1136   Float_t dc    = .001977;
1137   Float_t dco   = .002;  // --- CO2 density in g/cm3 ---
1138   
1139   Float_t absl, radl, a, d, z;
1140   Float_t dg;
1141   Float_t x0ar;
1142   Float_t buf[1];
1143   Int_t nbuf;
1144   
1145   Int_t *idtmed = gAlice->Idtmed();
1146   Int_t isxfld = gAlice->Field()->Integ();
1147   Float_t sxmgmx = gAlice->Field()->Max();
1148   
1149   // --- Define the various materials for GEANT --- 
1150   AliMaterial(1, "Pb    $", 207.19, 82., 11.35, .56, 18.5);
1151   x0ar = 19.55 / dar;
1152   AliMaterial(2, "Argon$", 39.95, 18., dar, x0ar, 6.5e4);
1153   AliMixture(3, "CO2  $", ac, zc, dc, -2, wc);
1154   AliMaterial(4, "Al   $", 26.98, 13., 2.7, 8.9, 18.5);
1155   AliMaterial(6, "Fe   $", 55.85, 26., 7.87, 1.76, 18.5);
1156   AliMaterial(7, "W    $", 183.85, 74., 19.3, .35, 10.3);
1157   AliMaterial(8, "G10  $", 20., 10., 1.7, 19.4, 999);
1158   AliMaterial(9, "SILIC$", 28.09, 14., 2.33, 9.36, 45.);
1159   AliMaterial(10, "Be   $", 9.01, 4., 1.848, 35.3, 36.7);
1160   AliMaterial(15, "Cu   $", 63.54, 29., 8.96, 1.43, 15.);
1161   AliMaterial(16, "C    $", 12.01, 6., 2.265, 18.8, 49.9);
1162   
1163   AliMaterial(96, "MYLAR$", 8.73, 4.55, 1.39, 28.7, 62.);
1164   AliMaterial(97, "CONCR$", 20., 10., 2.5, 10.7, 40.);
1165   AliMaterial(98, "Vacum$", 1e-9, 1e-9, 1e-9, 1e16, 1e16);
1166   AliMaterial(99, "Air  $", 14.61, 7.3, .0012, 30420., 67500.);
1167   
1168   //    define gas-mixtures 
1169   
1170   char namate[21];
1171   pMC->Gfmate((*fIdmate)[3], namate, a, z, d, radl, absl, buf, nbuf);
1172   ag[1] = a;
1173   zg[1] = z;
1174   dg = (dar * 4 + dco) / 5;
1175   AliMixture(5, "ArCO2$", ag, zg, dg, 2, wg);
1176   
1177   // Define tracking media 
1178   AliMedium(601, "Pb conv.$", 1,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
1179   AliMedium(607, "W  conv.$", 7,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
1180   AliMedium(608, "G10plate$", 8,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
1181   AliMedium(604, "Al      $", 4,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
1182   AliMedium(606, "Fe      $", 6,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
1183   AliMedium(605, "ArCO2   $", 5,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
1184   AliMedium(609, "SILICON $", 9,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
1185   AliMedium(610, "Be      $", 10, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
1186   AliMedium(698, "Vacuum  $", 98, 0, 0, isxfld, sxmgmx, 1., .1, .1,  10);
1187   AliMedium(699, "Air gaps$", 99, 0, 0, isxfld, sxmgmx, 1., .1, .1,  .1);
1188   AliMedium(615, "Cu      $", 15, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
1189   AliMedium(616, "C       $", 16, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
1190   
1191   // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
1192   pMC->Gstpar(idtmed[600], "LOSS", 3.);
1193   pMC->Gstpar(idtmed[600], "DRAY", 1.);
1194   
1195   pMC->Gstpar(idtmed[603], "LOSS", 3.);
1196   pMC->Gstpar(idtmed[603], "DRAY", 1.);
1197   
1198   pMC->Gstpar(idtmed[604], "LOSS", 3.);
1199   pMC->Gstpar(idtmed[604], "DRAY", 1.);
1200   
1201   pMC->Gstpar(idtmed[605], "LOSS", 3.);
1202   pMC->Gstpar(idtmed[605], "DRAY", 1.);
1203   
1204   pMC->Gstpar(idtmed[606], "LOSS", 3.);
1205   pMC->Gstpar(idtmed[606], "DRAY", 1.);
1206   
1207   pMC->Gstpar(idtmed[607], "LOSS", 3.);
1208   pMC->Gstpar(idtmed[607], "DRAY", 1.);
1209   
1210   // --- Energy cut-offs in the Pb and Al to gain time in tracking --- 
1211   // --- without affecting the hit patterns --- 
1212   pMC->Gstpar(idtmed[600], "CUTGAM", 1e-4);
1213   pMC->Gstpar(idtmed[600], "CUTELE", 1e-4);
1214   pMC->Gstpar(idtmed[600], "CUTNEU", 1e-4);
1215   pMC->Gstpar(idtmed[600], "CUTHAD", 1e-4);
1216   pMC->Gstpar(idtmed[605], "CUTGAM", 1e-4);
1217   pMC->Gstpar(idtmed[605], "CUTELE", 1e-4);
1218   pMC->Gstpar(idtmed[605], "CUTNEU", 1e-4);
1219   pMC->Gstpar(idtmed[605], "CUTHAD", 1e-4);
1220   pMC->Gstpar(idtmed[606], "CUTGAM", 1e-4);
1221   pMC->Gstpar(idtmed[606], "CUTELE", 1e-4);
1222   pMC->Gstpar(idtmed[606], "CUTNEU", 1e-4);
1223   pMC->Gstpar(idtmed[606], "CUTHAD", 1e-4);
1224   pMC->Gstpar(idtmed[603], "CUTGAM", 1e-4);
1225   pMC->Gstpar(idtmed[603], "CUTELE", 1e-4);
1226   pMC->Gstpar(idtmed[603], "CUTNEU", 1e-4);
1227   pMC->Gstpar(idtmed[603], "CUTHAD", 1e-4);
1228   pMC->Gstpar(idtmed[609], "CUTGAM", 1e-4);
1229   pMC->Gstpar(idtmed[609], "CUTELE", 1e-4);
1230   pMC->Gstpar(idtmed[609], "CUTNEU", 1e-4);
1231   pMC->Gstpar(idtmed[609], "CUTHAD", 1e-4);
1232   
1233   // --- Prevent particles stopping in the gas due to energy cut-off --- 
1234   pMC->Gstpar(idtmed[604], "CUTGAM", 1e-5);
1235   pMC->Gstpar(idtmed[604], "CUTELE", 1e-5);
1236   pMC->Gstpar(idtmed[604], "CUTNEU", 1e-5);
1237   pMC->Gstpar(idtmed[604], "CUTHAD", 1e-5);
1238   pMC->Gstpar(idtmed[604], "CUTMUO", 1e-5);
1239 }
1240
1241 //_____________________________________________________________________________
1242 void AliPMDv1::Init()
1243 {
1244   //
1245   // Initialises PMD detector after it has been built
1246   //
1247   Int_t i;
1248   kdet=1;
1249   //
1250   printf("\n");
1251   for(i=0;i<35;i++) printf("*");
1252   printf(" PMD_INIT ");
1253   for(i=0;i<35;i++) printf("*");
1254   printf("\n");
1255   printf("                 PMD simulation package initialised\n");
1256   printf(" parameters of pmd\n");
1257   printf("%6d %10.2f %10.2f %10.2f %10.2f %10.2f\n",kdet,thmin,thmax,zdist,thlow,thhigh);
1258   //
1259   for(i=0;i<80;i++) printf("*");
1260   printf("\n");
1261   //
1262   Int_t *idtmed = gAlice->Idtmed();
1263   fMedSens=idtmed[605-1];
1264 }
1265
1266 //_____________________________________________________________________________
1267 void AliPMDv1::StepManager()
1268 {
1269   //
1270   // Called at each step in the PMD
1271   //
1272   Int_t   copy;
1273   Float_t hits[4], destep;
1274   Float_t center[3] = {0,0,0};
1275   Int_t   vol[4];
1276   
1277   AliMC* pMC=AliMC::GetMC();
1278   if(pMC->GetMedium() == fMedSens && (destep = pMC->Edep())) {
1279     
1280     // THIS PART MUST BE CHECKED
1281     pMC->CurrentVol(0, copy);
1282     vol[0]=copy;
1283     pMC->CurrentVolOff(1,0,copy);
1284     vol[1]=copy;
1285     pMC->CurrentVolOff(2,0,copy);
1286     vol[2]=copy;
1287     pMC->CurrentVolOff(1,0,copy);
1288     vol[3]=copy;
1289     pMC->Gdtom(center,hits,1);
1290     hits[3] = destep*1e9; //Number in eV
1291     AddHit(gAlice->CurrentTrack(), vol, hits);
1292   }
1293 }
1294
1295 ClassImp(AliPMDhit)
1296   
1297 //_____________________________________________________________________________
1298 AliPMDhit::AliPMDhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
1299   AliHit(shunt, track)
1300 {
1301   //
1302   // Add a PMD hit
1303   //
1304   Int_t i;
1305   for (i=0;i<4;i++) fVolume[i] = vol[i];
1306   fX=hits[0];
1307   fY=hits[1];
1308   fZ=hits[2];
1309   fEnergy=hits[3];
1310 }