]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv0.cxx
coding conventions corrections
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv0.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 /* $Id$ */
16
17
18 //_________________________________________________________________________
19 // Implementation version v0 of PHOS Manager class 
20 // An object of this class does not produce hits nor digits
21 // It is the one to use if you do not want to produce outputs in TREEH or TREED
22 //...                  
23 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
24
25
26 // --- ROOT system ---
27
28 #include "TBRIK.h"
29 #include "TTRD1.h"
30 #include "TNode.h"
31 #include "TArrayI.h"
32 #include "TRandom.h"
33 #include "TGeometry.h"
34   //#include "TFolder.h"
35 #include "TROOT.h"
36   //#include "TTree.h"
37
38
39 // --- Standard library ---
40
41 //#include <string.h>
42 //#include <stdlib.h>
43
44 // --- AliRoot header files ---
45
46 #include "AliPHOSv0.h"
47 #include "AliRun.h"
48   //#include "AliConst.h"
49 #include "AliPHOSGeometry.h"
50   //#include "AliPHOSGetter.h"
51
52 ClassImp(AliPHOSv0)
53
54 //____________________________________________________________________________
55 AliPHOSv0::AliPHOSv0(const char *name, const char *title):
56   AliPHOS(name,title)
57 {
58   // ctor : title is used to identify the layout
59   GetGeometry() ; 
60 }
61
62 //____________________________________________________________________________
63 void AliPHOSv0::BuildGeometry()
64 {
65   // Build the PHOS geometry for the ROOT display
66   //BEGIN_HTML
67   /*
68     <H2>
69      PHOS in ALICE displayed by root
70     </H2>
71     <UL>
72     <LI> All Views
73     <P>
74     <CENTER>
75     <IMG Align=BOTTOM ALT="All Views" SRC="../images/AliPHOSv0AllViews.gif"> 
76     </CENTER></P></LI>
77     <LI> Front View
78     <P>
79     <CENTER>
80     <IMG Align=BOTTOM ALT="Front View" SRC="../images/AliPHOSv0FrontView.gif"> 
81     </CENTER></P></LI>
82      <LI> 3D View 1
83     <P>
84     <CENTER>
85     <IMG Align=BOTTOM ALT="3D View 1" SRC="../images/AliPHOSv03DView1.gif"> 
86     </CENTER></P></LI>
87     <LI> 3D View 2
88     <P>
89     <CENTER>
90     <IMG Align=BOTTOM ALT="3D View 2" SRC="../images/AliPHOSv03DView2.gif"> 
91     </CENTER></P></LI>
92     </UL>
93   */
94   //END_HTML  
95   
96   this->BuildGeometryforEMC() ; 
97   this->BuildGeometryforCPV() ;
98   
99 }
100
101 //____________________________________________________________________________
102 void AliPHOSv0:: BuildGeometryforEMC(void)
103 {
104   // Build the PHOS-EMC geometry for the ROOT display
105   
106   const Int_t kColorPHOS = kRed ;
107   const Int_t kColorXTAL = kBlue ;
108   
109   Double_t const kRADDEG = 180.0 / kPI ;
110   
111   AliPHOSGeometry * geom = GetGeometry() ; 
112   AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ;
113   Float_t * boxparams = emcg->GetEMCParams() ;
114
115   new TTRD1("OuterBox", "PHOS box", "void",boxparams[0],boxparams[1],boxparams[2], boxparams[3] );
116   
117   
118   // Crystals Box
119   
120   Float_t * cribox = emcg->GetInnerThermoHalfSize() ;  
121   new TBRIK( "CrystalsBox", "PHOS crystals box", "void", cribox[0], cribox[2], cribox[1] ) ;
122   
123   // position PHOS into ALICE
124   
125   Float_t r = geom->GetIPtoOuterCoverDistance() + boxparams[3] ;
126   Int_t number = 988 ; 
127   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
128   
129   char * nodename = new char[20] ;  
130   char * rotname  = new char[20] ; 
131
132   new TRotMatrix("cribox", "cribox", 90, 0, 90, 90, 0, 0);  
133
134   for( Int_t i = 1; i <= geom->GetNModules(); i++ ) { 
135
136     Float_t angle = geom->GetPHOSAngle(i) ;
137     sprintf(rotname, "%s%d", "rot", number++) ;
138     new TRotMatrix(rotname, rotname, 90, angle, 0,  0,  90,  270 + angle);
139
140     top->cd();
141     sprintf(nodename,"%s%d", "Module", i) ;    
142     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
143     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
144     TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ;
145     outerboxnode->SetLineColor(kColorPHOS) ;
146     fNodes->Add(outerboxnode) ;
147     outerboxnode->cd() ; 
148
149     Float_t z = -boxparams[3] - geom->GetIPtoOuterCoverDistance() + 
150                  cribox[1] +  geom->GetIPtoCrystalSurface() ;
151     TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, 0, z) ;    
152     crystalsboxnode->SetLineColor(kColorXTAL) ; 
153     fNodes->Add(crystalsboxnode) ; 
154   }
155
156   delete[] rotname ;  
157   delete[] nodename ;
158 }
159
160
161 //____________________________________________________________________________
162 void AliPHOSv0:: BuildGeometryforCPV(void)
163 {
164   //  Build the PHOS-CPV geometry for the ROOT display
165   //  Author: Yuri Kharlov 11 September 2000
166   //
167   //BEGIN_HTML
168   /*
169     <H2>
170     CPV displayed by root
171     </H2>
172     <table width=700>
173
174     <tr>
175          <td>CPV perspective view</td>
176          <td>CPV front view      </td>
177     </tr>
178
179     <tr>
180          <td> <img height=300 width=290 src="../images/CPVRootPersp.gif"> </td>
181          <td> <img height=300 width=290 src="../images/CPVRootFront.gif"> </td>
182     </tr>
183
184     </table>
185
186   */
187   //END_HTML  
188
189   const Double_t kRADDEG         = 180.0 / kPI ;
190   const Int_t    kColorCPV       = kGreen ;
191   const Int_t    kColorFrame     = kYellow ;
192   const Int_t    kColorGassiplex = kRed;
193   const Int_t    kColorPCB       = kCyan;
194
195   AliPHOSGeometry * geom = GetGeometry() ; 
196
197   // Box for a full PHOS module
198
199   new TBRIK ("CPVBox", "CPV box", "void",                   geom->GetCPVBoxSize(0)/2,
200                                                             geom->GetCPVBoxSize(1)/2,
201                                                             geom->GetCPVBoxSize(2)/2 );
202   new TBRIK ("CPVFrameLR", "CPV frame Left-Right", "void",  geom->GetCPVFrameSize(0)/2,
203                                                             geom->GetCPVFrameSize(1)/2,
204                                                             geom->GetCPVBoxSize(2)/2 );
205   new TBRIK ("CPVFrameUD", "CPV frame Up-Down",    "void",  geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0),
206                                                             geom->GetCPVFrameSize(1)/2,
207                                                             geom->GetCPVFrameSize(2)/2);
208   new TBRIK ("CPVPCB",    "CPV PCB",               "void",  geom->GetCPVActiveSize(0)/2,
209                                                             geom->GetCPVTextoliteThickness()/2,
210                                                             geom->GetCPVActiveSize(1)/2);
211   new TBRIK ("CPVGassiplex", "CPV Gassiplex PCB",  "void",  geom->GetGassiplexChipSize(0)/2,
212                                                             geom->GetGassiplexChipSize(1)/2,
213                                                             geom->GetGassiplexChipSize(2)/2);
214
215   // position CPV into ALICE
216
217   char * nodename = new char[25] ;
218   char * rotname  = new char[25] ;
219   
220   Float_t r = geom->GetIPtoCPVDistance() + geom->GetCPVBoxSize(1) / 2.0 ;
221   Int_t number = 988 ; 
222   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
223
224   Int_t lastModule = 0 ;
225   lastModule = geom->GetNModules();
226   
227   for( Int_t i = 1; i <= lastModule; i++ ) { // the number of PHOS modules
228     
229     // One CPV module
230     
231     Float_t angle = geom->GetPHOSAngle(i) ;
232     sprintf(rotname, "%s%d", "rotg", number+i) ;
233     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
234     top->cd();
235     sprintf(nodename, "%s%d", "CPVModule", i) ;    
236     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
237     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
238     Float_t z;
239     TNode * cpvBoxNode = new TNode(nodename , nodename ,"CPVBox", x, y, 0, rotname ) ;
240     cpvBoxNode->SetLineColor(kColorCPV) ;
241     fNodes->Add(cpvBoxNode) ;
242     cpvBoxNode->cd() ;
243
244     // inside each CPV box:
245
246     // Frame around CPV
247     Int_t j;
248     for (j=0; j<=1; j++) {
249       sprintf(nodename, "CPVModule%d Frame%d", i, j+1) ;
250       x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
251       TNode * cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameLR", x, 0, 0) ;
252       cpvFrameNode->SetLineColor(kColorFrame) ;
253       fNodes->Add(cpvFrameNode) ;
254
255       sprintf(nodename, "CPVModule%d Frame%d", i, j+3) ;
256       z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
257       cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameUD", 0, 0, z) ;
258       cpvFrameNode->SetLineColor(kColorFrame) ;
259       fNodes->Add(cpvFrameNode) ;
260     }
261
262     // 4 printed circuit boards
263     for (j=0; j<4; j++) {
264       sprintf(nodename, "CPVModule%d PCB%d", i, j+1) ;
265       y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(j) + geom->GetCPVTextoliteThickness()/2;
266       TNode * cpvPCBNode = new TNode(nodename , nodename ,"CPVPCB", 0, y, 0) ;
267       cpvPCBNode->SetLineColor(kColorPCB) ;
268       fNodes->Add(cpvPCBNode) ;
269     }
270
271     // Gassiplex chips
272     Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
273     Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
274     y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
275         geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
276     for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
277       x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
278       for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
279         z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
280         sprintf(nodename, "CPVModule%d Chip(%dx%d)", i, ix+1,iz+1) ;
281         TNode * cpvGassiplexNode = new TNode(nodename , nodename ,"CPVGassiplex", x, y, z) ;
282         cpvGassiplexNode->SetLineColor(kColorGassiplex) ;
283         fNodes->Add(cpvGassiplexNode) ;
284       }
285     }
286
287   } // PHOS modules
288  
289   delete[] rotname ;  
290   delete[] nodename ; 
291 }
292
293 //____________________________________________________________________________
294 void AliPHOSv0::CreateGeometry()
295 {
296   // Create the PHOS geometry for Geant
297
298   AliPHOSv0 *phostmp = dynamic_cast<AliPHOSv0*>(gAlice->GetModule("PHOS")) ;
299
300   if ( phostmp == NULL ) {
301     
302     fprintf(stderr, "PHOS detector not found!\n") ;
303     return;
304     
305   }
306
307   AliPHOSGeometry * geom = GetGeometry() ; 
308
309   // Get pointer to the array containing media indeces
310   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
311
312   // Create a PHOS module.
313   
314   gMC->Gsvolu("PHOS", "TRD1", idtmed[798], geom->GetPHOSParams(), 4) ;        
315   
316   this->CreateGeometryforEMC() ; 
317
318   this->CreateGeometryforCPV() ;
319   
320   this->CreateGeometryforSupport() ; 
321   
322   // --- Position  PHOS mdules in ALICE setup ---
323   
324   Int_t idrotm[99] ;
325   Double_t const kRADDEG = 180.0 / kPI ;
326   Float_t * phosParams = geom->GetPHOSParams() ;
327
328   Float_t r = geom->GetIPtoOuterCoverDistance() + phosParams[3] - geom->GetCPVBoxSize(1) ;
329   Int_t i;
330   for( i = 1; i <= geom->GetNModules()  ; i++ ) {
331     
332     Float_t angle = geom->GetPHOSAngle(i) ;
333     AliMatrix(idrotm[i-1], 90.,angle, 0., 0., 90., 270. +angle) ;
334     
335     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
336     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
337     
338     gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
339     
340   } 
341
342 }
343
344 //____________________________________________________________________________
345 void AliPHOSv0::CreateGeometryforEMC()
346 {
347   // Create the PHOS-EMC geometry for GEANT
348   // Author: Dmitri Peressounko August 2001
349   // The used coordinate system: 
350   //   1. in Module: X along longer side, Y out of beam, Z along shorter side (along beam)
351   //   2. In Strip the same: X along longer side, Y out of beam, Z along shorter side (along beam)
352
353
354     //BEGIN_HTML
355   /*
356     <H2>
357     Geant3 geometry tree of PHOS-EMC in ALICE
358     </H2>
359     <P><CENTER>
360     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif"> 
361     </CENTER><P>
362   */
363   //END_HTML  
364   
365   // Get pointer to the array containing media indexes
366   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
367
368   AliPHOSGeometry * geom = GetGeometry() ; 
369   AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ;
370
371   // ======= Define the strip ===============
372
373   gMC->Gsvolu("PSTR", "BOX ", idtmed[716], emcg->GetStripHalfSize(), 3) ;  //Made of stell
374    
375       // --- define air volume (cell of the honeycomb)
376       gMC->Gsvolu("PCEL", "BOX ", idtmed[798], emcg->GetAirCellHalfSize(), 3);
377
378       // --- define wrapped crystal and put it into AirCell
379
380       gMC->Gsvolu("PWRA", "BOX ", idtmed[702], emcg->GetWrappedHalfSize(), 3);
381       Float_t * pin = emcg->GetAPDHalfSize() ; 
382       Float_t * preamp = emcg->GetPreampHalfSize() ;
383       Float_t y = (emcg->GetAirGapLed()-2*pin[1]-2*preamp[1])/2;
384       gMC->Gspos("PWRA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;
385     
386       // --- Define crystall and put it into wrapped crystall ---
387       gMC->Gsvolu("PXTL", "BOX ", idtmed[699], emcg->GetCrystalHalfSize(), 3) ;
388       gMC->Gspos("PXTL", 1, "PWRA", 0.0, 0.0, 0.0, 0, "ONLY") ;
389       
390       // --- define APD/PIN preamp and put it into AirCell
391  
392       gMC->Gsvolu("PPIN", "BOX ", idtmed[705], emcg->GetAPDHalfSize(), 3) ;
393       Float_t * crystal = emcg->GetCrystalHalfSize() ;
394       y = crystal[1] + emcg->GetAirGapLed() /2 - preamp[1]; 
395       gMC->Gspos("PPIN", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;
396
397       gMC->Gsvolu("PREA", "BOX ", idtmed[711], emcg->GetPreampHalfSize(), 3) ;   // Here I assumed preamp
398                                                                                  // as a printed Circuit
399       y = crystal[1] + emcg->GetAirGapLed() /2 + pin[1]  ;                  // May it should be changed
400       gMC->Gspos("PREA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;                    // to ceramics?
401    
402
403       // --- Fill strip with wrapped cristalls in Air Cells
404
405       Float_t* splate = emcg->GetSupportPlateHalfSize();  
406       y = -splate[1] ;
407       Float_t* acel = emcg->GetAirCellHalfSize() ;
408       Int_t icel ;
409       for(icel = 1; icel <= emcg->GetNCellsInStrip(); icel++){
410         Float_t x = (2*icel - 1 - emcg->GetNCellsInStrip())* acel[0] ;
411         gMC->Gspos("PCEL", icel, "PSTR", x, y, 0.0, 0, "ONLY") ;
412       }
413
414       // --- define the support plate, hole in it and position it in strip ----
415       gMC->Gsvolu("PSUP", "BOX ", idtmed[701], emcg->GetSupportPlateHalfSize(), 3) ;
416
417       gMC->Gsvolu("PSHO", "BOX ", idtmed[798], emcg->GetSupportPlateInHalfSize(), 3) ;
418       Float_t z = emcg->GetSupportPlateThickness()/2 ;
419       gMC->Gspos("PSHO", 1, "PSUP", 0.0, 0.0, z, 0, "ONLY") ;
420
421       y = acel[1] ;
422       gMC->Gspos("PSUP", 1, "PSTR", 0.0, y, 0.0, 0, "ONLY") ;
423
424
425     // ========== Fill module with strips and put them into inner thermoinsulation=============
426       gMC->Gsvolu("PTII", "BOX ", idtmed[706], emcg->GetInnerThermoHalfSize(), 3) ;     
427
428       Float_t * inthermo = emcg->GetInnerThermoHalfSize() ;
429       Float_t * strip = emcg->GetStripHalfSize() ;
430       y = inthermo[1] - strip[1] ;
431       Int_t irow;
432       Int_t nr = 1 ;
433       Int_t icol ;
434
435       for(irow = 0; irow < emcg->GetNStripX(); irow ++){
436         Float_t x = (2*irow + 1 - emcg->GetNStripX())* strip[0] ;
437         for(icol = 0; icol < emcg->GetNStripZ(); icol ++){
438           z = (2*icol + 1 - emcg->GetNStripZ()) * strip[2] ;
439           gMC->Gspos("PSTR", nr, "PTII", x, y, z, 0, "ONLY") ;
440           nr++ ;
441         }
442       }
443           
444
445    // ------- define the air gap between thermoinsulation and cooler
446       gMC->Gsvolu("PAGA", "BOX ", idtmed[798], emcg->GetAirGapHalfSize(), 3) ;   
447       Float_t * agap = emcg->GetAirGapHalfSize() ;
448       y = agap[1] - inthermo[1]  ;
449       
450       gMC->Gspos("PTII", 1, "PAGA", 0.0, y, 0.0, 0, "ONLY") ;
451
452
453
454    // ------- define the Al passive cooler 
455       gMC->Gsvolu("PCOR", "BOX ", idtmed[701], emcg->GetCoolerHalfSize(), 3) ;   
456       Float_t * cooler = emcg->GetCoolerHalfSize() ;
457       y = cooler[1] - agap[1]  ;
458       
459       gMC->Gspos("PAGA", 1, "PCOR", 0.0, y, 0.0, 0, "ONLY") ;
460
461    // ------- define the outer thermoinsulating cover
462       gMC->Gsvolu("PTIO", "TRD1", idtmed[706], emcg->GetOuterThermoParams(), 4) ;        
463       Float_t * outparams = emcg->GetOuterThermoParams() ; 
464
465       Int_t idrotm[99] ;
466       AliMatrix(idrotm[1], 90.0, 0.0, 0.0, 0.0, 90.0, 270.0) ;
467       // Frame in outer thermoinsulation and so on: z out of beam, y along beam, x across beam
468  
469       z = outparams[3] - cooler[1] ;
470       gMC->Gspos("PCOR", 1, "PTIO", 0., 0.0, z, idrotm[1], "ONLY") ;
471        
472   // -------- Define the outer Aluminium cover -----
473       gMC->Gsvolu("PCOL", "TRD1", idtmed[701], emcg->GetAlCoverParams(), 4) ;        
474       Float_t * covparams = emcg->GetAlCoverParams() ; 
475       z = covparams[3] - outparams[3] ;
476       gMC->Gspos("PTIO", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ;
477
478  // --------- Define front fiberglass cover -----------
479       gMC->Gsvolu("PFGC", "BOX ", idtmed[717], emcg->GetFiberGlassHalfSize(), 3) ;  
480       z = - outparams[3] ;
481       gMC->Gspos("PFGC", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ;
482
483  //=============This is all with cold section==============
484
485
486       //------ Warm Section --------------
487       gMC->Gsvolu("PWAR", "BOX ", idtmed[701], emcg->GetWarmAlCoverHalfSize(), 3) ; 
488       Float_t * warmcov = emcg->GetWarmAlCoverHalfSize() ;
489
490       // --- Define the outer thermoinsulation ---
491       gMC->Gsvolu("PWTI", "BOX ", idtmed[706], emcg->GetWarmThermoHalfSize(), 3) ; 
492       Float_t * warmthermo = emcg->GetWarmThermoHalfSize() ;
493       z = -warmcov[2] + warmthermo[2] ;
494
495       gMC->Gspos("PWTI", 1, "PWAR", 0., 0.0, z, 0, "ONLY") ;     
496
497       // --- Define cables area and put in it T-supports ---- 
498       gMC->Gsvolu("PCA1", "BOX ", idtmed[718], emcg->GetTCables1HalfSize(), 3) ; 
499       Float_t * cbox = emcg->GetTCables1HalfSize() ;
500
501       gMC->Gsvolu("PBE1", "BOX ", idtmed[701], emcg->GetTSupport1HalfSize(), 3) ;
502       Float_t * beams = emcg->GetTSupport1HalfSize() ;
503       Int_t isup ;
504       for(isup = 0; isup < emcg->GetNTSuppots(); isup++){
505         Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ;
506         gMC->Gspos("PBE1", isup, "PCA1", x, 0.0, 0.0, 0, "ONLY") ;
507       }
508
509       z = -warmthermo[2] + cbox[2] ;
510       gMC->Gspos("PCA1", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ;     
511
512       gMC->Gsvolu("PCA2", "BOX ", idtmed[718], emcg->GetTCables2HalfSize(), 3) ; 
513       Float_t * cbox2 = emcg->GetTCables2HalfSize() ;
514
515       gMC->Gsvolu("PBE2", "BOX ", idtmed[701], emcg->GetTSupport2HalfSize(), 3) ;
516       for(isup = 0; isup < emcg->GetNTSuppots(); isup++){
517         Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ;
518         gMC->Gspos("PBE2", isup, "PCA2", x, 0.0, 0.0, 0, "ONLY") ;
519       }
520
521       z = -warmthermo[2] + 2*cbox[2] + cbox2[2];
522       gMC->Gspos("PCA2", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ;     
523
524
525   // --- Define frame ---
526       gMC->Gsvolu("PFRX", "BOX ", idtmed[716], emcg->GetFrameXHalfSize(), 3) ; 
527       Float_t * posit = emcg->GetFrameXPosition() ;
528       gMC->Gspos("PFRX", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
529       gMC->Gspos("PFRX", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
530
531       gMC->Gsvolu("PFRZ", "BOX ", idtmed[716], emcg->GetFrameZHalfSize(), 3) ; 
532       posit = emcg->GetFrameZPosition() ;
533       gMC->Gspos("PFRZ", 1, "PWTI", posit[0], posit[1],  posit[2], 0, "ONLY") ;
534       gMC->Gspos("PFRZ", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
535
536  // --- Define Fiber Glass support ---
537       gMC->Gsvolu("PFG1", "BOX ", idtmed[717], emcg->GetFGupXHalfSize(), 3) ; 
538       posit = emcg->GetFGupXPosition() ;
539       gMC->Gspos("PFG1", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
540       gMC->Gspos("PFG1", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
541
542       gMC->Gsvolu("PFG2", "BOX ", idtmed[717], emcg->GetFGupZHalfSize(), 3) ; 
543       posit = emcg->GetFGupZPosition() ;
544       gMC->Gspos("PFG2", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
545       gMC->Gspos("PFG2", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
546
547       gMC->Gsvolu("PFG3", "BOX ", idtmed[717], emcg->GetFGlowXHalfSize(), 3) ; 
548       posit = emcg->GetFGlowXPosition() ;
549       gMC->Gspos("PFG3", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
550       gMC->Gspos("PFG3", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
551
552       gMC->Gsvolu("PFG4", "BOX ", idtmed[717], emcg->GetFGlowZHalfSize(), 3) ; 
553       posit = emcg->GetFGlowZPosition() ;
554       gMC->Gspos("PFG4", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
555       gMC->Gspos("PFG4", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
556
557       // --- Define Air Gap for FEE electronics ----- 
558
559       gMC->Gsvolu("PAFE", "BOX ", idtmed[798], emcg->GetFEEAirHalfSize(), 3) ; 
560       posit = emcg->GetFEEAirPosition() ;
561       gMC->Gspos("PAFE", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
562
563       // Define the EMC module volume and combine Cool and Warm sections
564
565       gMC->Gsvolu("PEMC", "TRD1", idtmed[798], emcg->GetEMCParams(), 4) ;        
566
567       z =  - warmcov[2] ;
568       gMC->Gspos("PCOL", 1, "PEMC",  0., 0., z, 0, "ONLY") ;
569       z = covparams[3] ;
570       gMC->Gspos("PWAR", 1, "PEMC",  0., 0., z, 0, "ONLY") ;
571
572
573       // Put created EMC geometry into PHOS volume
574       
575       z = geom->GetCPVBoxSize(1) / 2. ;
576       gMC->Gspos("PEMC", 1, "PHOS", 0., 0., z, 0, "ONLY") ; 
577             
578 }
579
580 //____________________________________________________________________________
581 void AliPHOSv0::CreateGeometryforCPV()
582 {
583   // Create the PHOS-CPV geometry for GEANT
584   // Author: Yuri Kharlov 11 September 2000
585   //BEGIN_HTML
586   /*
587     <H2>
588     Geant3 geometry of PHOS-CPV in ALICE
589     </H2>
590     <table width=700>
591
592     <tr>
593          <td>CPV perspective view</td>
594          <td>CPV front view      </td>
595     </tr>
596
597     <tr>
598          <td> <img height=300 width=290 src="../images/CPVallPersp.gif"> </td>
599          <td> <img height=300 width=290 src="../images/CPVallFront.gif"> </td>
600     </tr>
601
602     <tr>
603          <td>One CPV module, perspective view                            </td>
604          <td>One CPV module, front view (extended in vertical direction) </td>
605     </tr>
606
607     <tr>
608          <td><img height=300 width=290 src="../images/CPVmodulePers.gif"></td>
609          <td><img height=300 width=290 src="../images/CPVmoduleSide.gif"></td>
610     </tr>
611
612     </table>
613
614     <H2>
615     Geant3 geometry tree of PHOS-CPV in ALICE
616     </H2>
617     <center>
618     <img height=300 width=290 src="../images/CPVtree.gif">
619     </center>
620   */
621   //END_HTML  
622
623   Float_t par[3], x,y,z;
624
625   // Get pointer to the array containing media indexes
626   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
627
628   AliPHOSGeometry * geom = GetGeometry() ; 
629
630   // The box containing all CPV for one PHOS module filled with air 
631   par[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
632   par[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
633   par[2] = geom->GetCPVBoxSize(2) / 2.0 ;
634   gMC->Gsvolu("PCPV", "BOX ", idtmed[798], par, 3) ;
635
636   Float_t * emcParams = geom->GetEMCAGeometry()->GetEMCParams() ;
637   z = - emcParams[3] ;
638   Int_t rotm ;
639   AliMatrix(rotm, 90.,0., 0., 0., 90., 90.) ;
640
641   gMC->Gspos("PCPV", 1, "PHOS", 0.0, 0.0, z, rotm, "ONLY") ; 
642   
643   // Gassiplex board
644   
645   par[0] = geom->GetGassiplexChipSize(0)/2.;
646   par[1] = geom->GetGassiplexChipSize(1)/2.;
647   par[2] = geom->GetGassiplexChipSize(2)/2.;
648   gMC->Gsvolu("PCPC","BOX ",idtmed[707],par,3);
649   
650   // Cu+Ni foil covers Gassiplex board
651
652   par[1] = geom->GetCPVCuNiFoilThickness()/2;
653   gMC->Gsvolu("PCPD","BOX ",idtmed[710],par,3);
654   y      = -(geom->GetGassiplexChipSize(1)/2 - par[1]);
655   gMC->Gspos("PCPD",1,"PCPC",0,y,0,0,"ONLY");
656
657   // Position of the chip inside CPV
658
659   Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
660   Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
661   Int_t   copy  = 0;
662   y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
663     geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
664   for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
665     x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
666     for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
667       copy++;
668       z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
669       gMC->Gspos("PCPC",copy,"PCPV",x,y,z,0,"ONLY");
670     }
671   }
672
673   // Foiled textolite (1 mm of textolite + 50 mkm of Cu + 6 mkm of Ni)
674   
675   par[0] = geom->GetCPVActiveSize(0)        / 2;
676   par[1] = geom->GetCPVTextoliteThickness() / 2;
677   par[2] = geom->GetCPVActiveSize(1)        / 2;
678   gMC->Gsvolu("PCPF","BOX ",idtmed[707],par,3);
679
680   // Argon gas volume
681
682   par[1] = (geom->GetFTPosition(2) - geom->GetFTPosition(1) - geom->GetCPVTextoliteThickness()) / 2;
683   gMC->Gsvolu("PCPG","BOX ",idtmed[715],par,3);
684
685   for (Int_t i=0; i<4; i++) {
686     y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(i) + geom->GetCPVTextoliteThickness()/2;
687     gMC->Gspos("PCPF",i+1,"PCPV",0,y,0,0,"ONLY");
688     if(i==1){
689       y-= (geom->GetFTPosition(2) - geom->GetFTPosition(1)) / 2;
690       gMC->Gspos("PCPG",1,"PCPV ",0,y,0,0,"ONLY");
691     }
692   }
693
694   // Dummy sensitive plane in the middle of argone gas volume
695
696   par[1]=0.001;
697   gMC->Gsvolu("PCPQ","BOX ",idtmed[715],par,3);
698   gMC->Gspos ("PCPQ",1,"PCPG",0,0,0,0,"ONLY");
699
700   // Cu+Ni foil covers textolite
701
702   par[1] = geom->GetCPVCuNiFoilThickness() / 2;
703   gMC->Gsvolu("PCP1","BOX ",idtmed[710],par,3);
704   y = geom->GetCPVTextoliteThickness()/2 - par[1];
705   gMC->Gspos ("PCP1",1,"PCPF",0,y,0,0,"ONLY");
706
707   // Aluminum frame around CPV
708
709   par[0] = geom->GetCPVFrameSize(0)/2;
710   par[1] = geom->GetCPVFrameSize(1)/2;
711   par[2] = geom->GetCPVBoxSize(2)  /2;
712   gMC->Gsvolu("PCF1","BOX ",idtmed[701],par,3);
713
714   par[0] = geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0);
715   par[1] = geom->GetCPVFrameSize(1)/2;
716   par[2] = geom->GetCPVFrameSize(2)/2;
717   gMC->Gsvolu("PCF2","BOX ",idtmed[701],par,3);
718
719   for (Int_t j=0; j<=1; j++) {
720     x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
721     gMC->Gspos("PCF1",j+1,"PCPV", x,0,0,0,"ONLY");
722     z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
723     gMC->Gspos("PCF2",j+1,"PCPV",0, 0,z,0,"ONLY");
724   }
725
726 }
727
728
729 //____________________________________________________________________________
730 void AliPHOSv0::CreateGeometryforSupport()
731 {
732   // Create the PHOS' support geometry for GEANT
733     //BEGIN_HTML
734   /*
735     <H2>
736     Geant3 geometry of the PHOS's support
737     </H2>
738     <P><CENTER>
739     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/PHOS_support.gif"> 
740     </CENTER><P>
741   */
742   //END_HTML  
743   
744   Float_t par[5], x0,y0,z0 ; 
745   Int_t   i,j,copy;
746
747   // Get pointer to the array containing media indexes
748   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
749
750   AliPHOSGeometry * geom = GetGeometry() ; 
751
752   // --- Dummy box containing two rails on which PHOS support moves
753   // --- Put these rails to the bottom of the L3 magnet
754
755   par[0] =  geom->GetRailRoadSize(0) / 2.0 ;
756   par[1] =  geom->GetRailRoadSize(1) / 2.0 ;
757   par[2] =  geom->GetRailRoadSize(2) / 2.0 ;
758   gMC->Gsvolu("PRRD", "BOX ", idtmed[798], par, 3) ;
759
760   y0     = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) / 2.0) ;
761   gMC->Gspos("PRRD", 1, "ALIC", 0.0, y0, 0.0, 0, "ONLY") ; 
762
763   // --- Dummy box containing one rail
764
765   par[0] =  geom->GetRailOuterSize(0) / 2.0 ;
766   par[1] =  geom->GetRailOuterSize(1) / 2.0 ;
767   par[2] =  geom->GetRailOuterSize(2) / 2.0 ;
768   gMC->Gsvolu("PRAI", "BOX ", idtmed[798], par, 3) ;
769
770   for (i=0; i<2; i++) {
771     x0     = (2*i-1) * geom->GetDistanceBetwRails()  / 2.0 ;
772     gMC->Gspos("PRAI", i, "PRRD", x0, 0.0, 0.0, 0, "ONLY") ; 
773   }
774
775   // --- Upper and bottom steel parts of the rail
776
777   par[0] =  geom->GetRailPart1(0) / 2.0 ;
778   par[1] =  geom->GetRailPart1(1) / 2.0 ;
779   par[2] =  geom->GetRailPart1(2) / 2.0 ;
780   gMC->Gsvolu("PRP1", "BOX ", idtmed[716], par, 3) ;
781
782   y0     = - (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 ;
783   gMC->Gspos("PRP1", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
784   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 - geom->GetRailPart3(1);
785   gMC->Gspos("PRP1", 2, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
786
787   // --- The middle vertical steel parts of the rail
788
789   par[0] =  geom->GetRailPart2(0) / 2.0 ;
790   par[1] =  geom->GetRailPart2(1) / 2.0 ;
791   par[2] =  geom->GetRailPart2(2) / 2.0 ;
792   gMC->Gsvolu("PRP2", "BOX ", idtmed[716], par, 3) ;
793
794   y0     =   - geom->GetRailPart3(1) / 2.0 ;
795   gMC->Gspos("PRP2", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
796
797   // --- The most upper steel parts of the rail
798
799   par[0] =  geom->GetRailPart3(0) / 2.0 ;
800   par[1] =  geom->GetRailPart3(1) / 2.0 ;
801   par[2] =  geom->GetRailPart3(2) / 2.0 ;
802   gMC->Gsvolu("PRP3", "BOX ", idtmed[716], par, 3) ;
803
804   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart3(1))  / 2.0 ;
805   gMC->Gspos("PRP3", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
806
807   // --- The wall of the cradle
808   // --- The wall is empty: steel thin walls and air inside
809
810   par[1] =  TMath::Sqrt(TMath::Power((geom->GetIPtoCPVDistance() + geom->GetOuterBoxSize(3)),2) +
811                         TMath::Power((geom->GetOuterBoxSize(1)/2),2))+10. ;
812   par[0] =  par[1] - geom->GetCradleWall(1) ;
813   par[2] =  geom->GetCradleWall(2) / 2.0 ;
814   par[3] =  geom->GetCradleWall(3) ;
815   par[4] =  geom->GetCradleWall(4) ;
816   gMC->Gsvolu("PCRA", "TUBS", idtmed[716], par, 5) ;
817
818   par[0] -=  geom->GetCradleWallThickness() ;
819   par[1] -=  geom->GetCradleWallThickness() ;
820   par[2] -=  geom->GetCradleWallThickness() ;
821   gMC->Gsvolu("PCRE", "TUBS", idtmed[798], par, 5) ;
822   gMC->Gspos ("PCRE", 1, "PCRA", 0.0, 0.0, 0.0, 0, "ONLY") ; 
823
824   for (i=0; i<2; i++) {
825     z0 = (2*i-1) * (geom->GetOuterBoxSize(2) + geom->GetCradleWall(2) )/ 2.0  ;
826         gMC->Gspos("PCRA", i, "ALIC", 0.0, 0.0, z0, 0, "ONLY") ; 
827   }
828
829   // --- The "wheels" of the cradle
830   
831   par[0] = geom->GetCradleWheel(0) / 2;
832   par[1] = geom->GetCradleWheel(1) / 2;
833   par[2] = geom->GetCradleWheel(2) / 2;
834   gMC->Gsvolu("PWHE", "BOX ", idtmed[716], par, 3) ;
835
836   y0 = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) -
837          geom->GetCradleWheel(1)/2) ;
838   for (i=0; i<2; i++) {
839     z0 = (2*i-1) * ((geom->GetOuterBoxSize(2) + geom->GetCradleWheel(2))/ 2.0 +
840                     geom->GetCradleWall(2));
841     for (j=0; j<2; j++) {
842       copy = 2*i + j;
843       x0 = (2*j-1) * geom->GetDistanceBetwRails()  / 2.0 ;
844       gMC->Gspos("PWHE", copy, "ALIC", x0, y0, z0, 0, "ONLY") ; 
845     }
846   }
847
848 }
849
850 //____________________________________________________________________________
851 Float_t AliPHOSv0::ZMin(void) const
852 {
853   // Overall dimension of the PHOS (min)
854
855   AliPHOSGeometry * geom = GetGeometry() ; 
856
857   return -geom->GetOuterBoxSize(2)/2.;
858 }
859
860 //____________________________________________________________________________
861 Float_t AliPHOSv0::ZMax(void) const
862 {
863   // Overall dimension of the PHOS (max)
864
865   AliPHOSGeometry * geom = GetGeometry() ; 
866
867   return  geom->GetOuterBoxSize(2)/2.;
868 }
869
870 //____________________________________________________________________________
871 void AliPHOSv0::Init(void)
872 {
873   // Just prints an information message
874   
875   Int_t i;
876
877   if(fDebug) {
878     TString st ; 
879     for(i=0;i<35;i++) 
880       st += "*";
881     Info("Init", "%s", st.Data()) ;  
882     // Here the PHOS initialisation code (if any!)
883     
884     AliPHOSGeometry * geom = GetGeometry() ; 
885
886     if (geom!=0)  
887       Info("Init", "AliPHOS%s: PHOS geometry intialized for %s", Version().Data(), geom->GetName()) ;
888     else
889       Info("Init", "AliPHOS%s: PHOS geometry initialization failed !", Version().Data()) ;       
890
891     Info("Init", "%s", st.Data()) ;  
892   }
893 }