]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv0.cxx
repaired a screwup in commit: overwrites previous version
[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
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 // Implementation version v0 of PHOS Manager class 
20 // Layout EMC + PPSD has name GPS2  
21 // Layout EMC + CPV  has name IHEP
22 // An object of this class does not produce hits nor digits
23 // It is the one to use if you do not want to produce outputs in TREEH or TREED
24 //                  
25 //*-- Author: Yves Schutz (SUBATECH)
26
27
28 // --- ROOT system ---
29
30 #include "TBRIK.h"
31 #include "TNode.h"
32 #include "TRandom.h"
33 #include "TGeometry.h"
34 #include "TFolder.h"
35 #include "TROOT.h"
36
37
38 // --- Standard library ---
39
40 #include <stdio.h>
41 #include <string.h>
42 #include <stdlib.h>
43 #include <strstream.h>
44
45 // --- AliRoot header files ---
46
47 #include "AliPHOSv0.h"
48 #include "AliRun.h"
49 #include "AliConst.h"
50 #include "AliMC.h"
51 #include "AliPHOSGeometry.h"
52
53 ClassImp(AliPHOSv0)
54
55 //____________________________________________________________________________
56 AliPHOSv0::AliPHOSv0(const char *name, const char *title):
57   AliPHOS(name,title)
58 {
59   // ctor : title is used to identify the layout
60   //        GPS2 = 5 modules (EMC + PPSD)
61   //        IHEP = 5 modules (EMC + CPV)
62   //        MIXT = 4 modules (EMC + CPV) and 1 module (EMC + PPSD)
63  
64   // create the geometry parameters object  
65   // it will posted to a folder
66
67   if (strcmp(GetTitle(),"") != 0 ) 
68     fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ; 
69
70 }
71
72 //____________________________________________________________________________
73 void AliPHOSv0::BuildGeometry()
74 {
75   // Build the PHOS geometry for the ROOT display
76   //BEGIN_HTML
77   /*
78     <H2>
79      PHOS in ALICE displayed by root
80     </H2>
81     <UL>
82     <LI> All Views
83     <P>
84     <CENTER>
85     <IMG Align=BOTTOM ALT="All Views" SRC="../images/AliPHOSv0AllViews.gif"> 
86     </CENTER></P></LI>
87     <LI> Front View
88     <P>
89     <CENTER>
90     <IMG Align=BOTTOM ALT="Front View" SRC="../images/AliPHOSv0FrontView.gif"> 
91     </CENTER></P></LI>
92      <LI> 3D View 1
93     <P>
94     <CENTER>
95     <IMG Align=BOTTOM ALT="3D View 1" SRC="../images/AliPHOSv03DView1.gif"> 
96     </CENTER></P></LI>
97     <LI> 3D View 2
98     <P>
99     <CENTER>
100     <IMG Align=BOTTOM ALT="3D View 2" SRC="../images/AliPHOSv03DView2.gif"> 
101     </CENTER></P></LI>
102     </UL>
103   */
104   //END_HTML  
105   
106   AliPHOSGeometry * geom = GetGeometry() ; 
107
108   this->BuildGeometryforPHOS() ; 
109   if      (strcmp(geom->GetName(),"GPS2") == 0)
110     this->BuildGeometryforPPSD() ;
111   else if (strcmp(geom->GetName(),"IHEP") == 0)
112     this->BuildGeometryforCPV() ;
113   else if (strcmp(geom->GetName(),"MIXT") == 0) {
114     this->BuildGeometryforPPSD() ;
115     this->BuildGeometryforCPV() ;
116   }
117   else
118     cout << "AliPHOSv0::BuildGeometry : no charged particle identification system installed: "
119          << "Geometry name = " << geom->GetName() << endl; 
120
121 }
122
123 //____________________________________________________________________________
124 void AliPHOSv0:: BuildGeometryforPHOS(void)
125 {
126  // Build the PHOS-EMC geometry for the ROOT display
127
128   const Int_t kColorPHOS = kRed ;
129   const Int_t kColorXTAL = kBlue ;
130
131   Double_t const kRADDEG = 180.0 / kPI ;
132
133   AliPHOSGeometry * geom = GetGeometry() ; 
134
135   new TBRIK( "OuterBox", "PHOS box", "void", geom->GetOuterBoxSize(0)/2, 
136                                              geom->GetOuterBoxSize(1)/2, 
137                                              geom->GetOuterBoxSize(2)/2 );
138
139   // Textolit Wall box, position inside PHOS 
140   
141   new TBRIK( "TextolitBox", "PHOS Textolit box ", "void", geom->GetTextolitBoxSize(0)/2, 
142                                                           geom->GetTextolitBoxSize(1)/2, 
143                                                           geom->GetTextolitBoxSize(2)/2);
144
145   // Polystyrene Foam Plate
146
147   new TBRIK( "UpperFoamPlate", "PHOS Upper foam plate", "void", geom->GetTextolitBoxSize(0)/2, 
148                                                                 geom->GetSecondUpperPlateThickness()/2, 
149                                                                 geom->GetTextolitBoxSize(2)/2 ) ; 
150
151   // Air Filled Box
152  
153   new TBRIK( "AirFilledBox", "PHOS air filled box", "void", geom->GetAirFilledBoxSize(0)/2, 
154                                                             geom->GetAirFilledBoxSize(1)/2, 
155                                                             geom->GetAirFilledBoxSize(2)/2 );
156
157   // Crystals Box
158
159   Float_t xtlX = geom->GetCrystalSize(0) ; 
160   Float_t xtlY = geom->GetCrystalSize(1) ; 
161   Float_t xtlZ = geom->GetCrystalSize(2) ; 
162
163   Float_t xl =  geom->GetNPhi() * ( xtlX + 2 * geom->GetGapBetweenCrystals() ) / 2.0 + geom->GetModuleBoxThickness() ;
164   Float_t yl =  ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 
165              + geom->GetModuleBoxThickness() / 2.0 ;
166   Float_t zl =  geom->GetNZ() * ( xtlZ + 2 * geom->GetGapBetweenCrystals() ) / 2.0 +  geom->GetModuleBoxThickness() ;
167   
168   new TBRIK( "CrystalsBox", "PHOS crystals box", "void", xl, yl, zl ) ;
169
170 // position PHOS into ALICE
171
172   Float_t r = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) / 2.0 ;
173   Int_t number = 988 ; 
174   Float_t pphi =  TMath::ATan( geom->GetOuterBoxSize(0)  / ( 2.0 * geom->GetIPtoOuterCoverDistance() ) ) ;
175   pphi *= kRADDEG ;
176   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
177  
178   char * nodename = new char[20] ;  
179   char * rotname  = new char[20] ; 
180
181   for( Int_t i = 1; i <= geom->GetNModules(); i++ ) { 
182    Float_t angle = pphi * 2 * ( i - geom->GetNModules() / 2.0 - 0.5 ) ;
183    sprintf(rotname, "%s%d", "rot", number++) ;
184    new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
185    top->cd();
186    sprintf(nodename,"%s%d", "Module", i) ;    
187    Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
188    Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
189    TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ;
190    outerboxnode->SetLineColor(kColorPHOS) ;
191    fNodes->Add(outerboxnode) ;
192    outerboxnode->cd() ; 
193    // now inside the outer box the textolit box
194    y = ( geom->GetOuterBoxThickness(1) -  geom->GetUpperPlateThickness() ) / 2.  ;
195    sprintf(nodename,"%s%d", "TexBox", i) ;  
196    TNode * textolitboxnode = new TNode(nodename, nodename, "TextolitBox", 0, y, 0) ; 
197    textolitboxnode->SetLineColor(kColorPHOS) ;
198    fNodes->Add(textolitboxnode) ;
199    // upper foam plate inside outre box
200    outerboxnode->cd() ; 
201    sprintf(nodename, "%s%d", "UFPlate", i) ;
202    y =  ( geom->GetTextolitBoxSize(1) - geom->GetSecondUpperPlateThickness() ) / 2.0 ;
203    TNode * upperfoamplatenode = new TNode(nodename, nodename, "UpperFoamPlate", 0, y, 0) ; 
204    upperfoamplatenode->SetLineColor(kColorPHOS) ;
205    fNodes->Add(upperfoamplatenode) ;  
206    // air filled box inside textolit box (not drawn)
207    textolitboxnode->cd();
208    y = ( geom->GetTextolitBoxSize(1) - geom->GetAirFilledBoxSize(1) ) / 2.0 -  geom->GetSecondUpperPlateThickness() ;
209    sprintf(nodename, "%s%d", "AFBox", i) ;
210    TNode * airfilledboxnode = new TNode(nodename, nodename, "AirFilledBox", 0, y, 0) ; 
211    fNodes->Add(airfilledboxnode) ; 
212    // crystals box inside air filled box
213    airfilledboxnode->cd() ; 
214    y = geom->GetAirFilledBoxSize(1) / 2.0 - yl 
215        - ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetModuleBoxThickness() 
216        -  geom->GetUpperPlateThickness() -  geom->GetSecondUpperPlateThickness() ) ; 
217    sprintf(nodename, "%s%d", "XTBox", i) ; 
218    TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, y, 0) ;    
219    crystalsboxnode->SetLineColor(kColorXTAL) ; 
220    fNodes->Add(crystalsboxnode) ; 
221   }
222
223   delete[] rotname ;  
224   delete[] nodename ;
225 }
226
227 //____________________________________________________________________________
228 void AliPHOSv0:: BuildGeometryforPPSD(void)
229 {
230  //  Build the PHOS-PPSD geometry for the ROOT display
231  //BEGIN_HTML
232   /*
233     <H2>
234      PPSD displayed by root
235     </H2>
236     <UL>
237     <LI> Zoom on PPSD: Front View
238     <P>
239     <CENTER>
240     <IMG Align=BOTTOM ALT="PPSD Front View" SRC="../images/AliPHOSv0PPSDFrontView.gif"> 
241     </CENTER></P></LI>
242     <LI> Zoom on PPSD: Perspective View
243     <P>
244     <CENTER>
245     <IMG Align=BOTTOM ALT="PPSD Prespective View" SRC="../images/AliPHOSv0PPSDPerspectiveView.gif"> 
246     </CENTER></P></LI>
247     </UL>
248   */
249   //END_HTML  
250   Double_t const kRADDEG = 180.0 / kPI ;
251
252   const Int_t kColorPHOS = kRed ;
253   const Int_t kColorPPSD = kGreen ;
254   const Int_t kColorGas  = kBlue ;  
255   const Int_t kColorAir  = kYellow ; 
256
257   AliPHOSGeometry * geom = GetGeometry() ; 
258
259   // Box for a full PHOS module
260
261   new TBRIK( "PPSDBox", "PPSD box", "void",  geom->GetCPVBoxSize(0)/2, 
262                                              geom->GetCPVBoxSize(1)/2, 
263                                              geom->GetCPVBoxSize(2)/2 );
264
265   // Box containing one micromegas module 
266
267   new TBRIK( "PPSDModule", "PPSD module", "void",  geom->GetPPSDModuleSize(0)/2, 
268                                                    geom->GetPPSDModuleSize(1)/2, 
269                                                    geom->GetPPSDModuleSize(2)/2 );
270  // top lid
271
272   new TBRIK ( "TopLid", "Micromegas top lid", "void",  geom->GetPPSDModuleSize(0)/2,
273                                                        geom->GetLidThickness()/2,
274                                                        geom->GetPPSDModuleSize(2)/2 ) ; 
275  // composite panel (top and bottom)
276
277   new TBRIK ( "TopPanel", "Composite top panel", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
278                                                             geom->GetCompositeThickness()/2,
279                                                           ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ;  
280   
281   new TBRIK ( "BottomPanel", "Composite bottom panel", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
282                                                                   geom->GetCompositeThickness()/2,
283                                                                 ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ; 
284  // gas gap (conversion and avalanche)
285
286   new TBRIK ( "GasGap", "gas gap", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
287                                             ( geom->GetConversionGap() +  geom->GetAvalancheGap() )/2,
288                                             ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ; 
289
290  // anode and cathode 
291
292   new TBRIK ( "Anode", "Anode", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
293                                            geom->GetAnodeThickness()/2,
294                                          ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ; 
295
296   new TBRIK ( "Cathode", "Cathode", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
297                                                geom->GetCathodeThickness()/2,
298                                              ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ; 
299  // PC  
300
301   new TBRIK ( "PCBoard", "Printed Circuit", "void",  ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() )/2,
302                                                        geom->GetPCThickness()/2,
303                                                      ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() )/2 ) ; 
304  // Gap between Lead and top micromegas
305
306   new TBRIK ( "LeadToM", "Air Gap top", "void", geom->GetCPVBoxSize(0)/2,
307                                                 geom->GetMicro1ToLeadGap()/2,
308                                                 geom->GetCPVBoxSize(2)/2  ) ;  
309  
310 // Gap between Lead and bottom micromegas
311
312   new TBRIK ( "MToLead", "Air Gap bottom", "void", geom->GetCPVBoxSize(0)/2,
313                                                    geom->GetLeadToMicro2Gap()/2,
314                                                    geom->GetCPVBoxSize(2)/2  ) ; 
315  // Lead converter
316    
317   new TBRIK ( "Lead", "Lead converter", "void", geom->GetCPVBoxSize(0)/2,
318                                                 geom->GetLeadConverterThickness()/2,
319                                                 geom->GetCPVBoxSize(2)/2  ) ; 
320
321      // position PPSD into ALICE
322
323   char * nodename = new char[20] ;  
324   char * rotname  = new char[20] ; 
325
326   Float_t r = geom->GetIPtoTopLidDistance() + geom->GetCPVBoxSize(1) / 2.0 ;
327   Int_t number = 988 ; 
328   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
329  
330   Int_t firstModule = 0 ; 
331   if      (strcmp(geom->GetName(),"GPS2") == 0) 
332     firstModule = 1;
333   else if (strcmp(geom->GetName(),"MIXT") == 0) 
334     firstModule = geom->GetNModules() - geom->GetNPPSDModules() + 1;
335   
336   for( Int_t i = firstModule; i <= geom->GetNModules(); i++ ) { // the number of PHOS modules
337     Float_t angle = geom->GetPHOSAngle(i) ;
338     sprintf(rotname, "%s%d", "rotg", number+i) ;
339     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
340     top->cd();
341     sprintf(nodename, "%s%d", "Moduleg", i) ;    
342     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
343     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
344     TNode * ppsdboxnode = new TNode(nodename , nodename ,"PPSDBox", x, y, 0, rotname ) ;
345     ppsdboxnode->SetLineColor(kColorPPSD) ;
346     fNodes->Add(ppsdboxnode) ;
347     ppsdboxnode->cd() ;
348     // inside the PPSD box: 
349     //   1.   fNumberOfModulesPhi x fNumberOfModulesZ top micromegas
350     x = ( geom->GetCPVBoxSize(0) - geom->GetPPSDModuleSize(0) ) / 2. ;  
351     {
352       for ( Int_t iphi = 1; iphi <= geom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
353         Float_t z = ( geom->GetCPVBoxSize(2) - geom->GetPPSDModuleSize(2) ) / 2. ;
354         TNode * micro1node ; 
355         for ( Int_t iz = 1; iz <= geom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
356           y = ( geom->GetCPVBoxSize(1) - geom->GetMicromegas1Thickness() ) / 2. ; 
357           sprintf(nodename, "%s%d%d%d", "Mic1", i, iphi, iz) ;
358           micro1node  = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
359           micro1node->SetLineColor(kColorPPSD) ;  
360           fNodes->Add(micro1node) ; 
361           // inside top micromegas
362           micro1node->cd() ; 
363           //      a. top lid
364           y = ( geom->GetMicromegas1Thickness() - geom->GetLidThickness() ) / 2. ; 
365           sprintf(nodename, "%s%d%d%d", "Lid", i, iphi, iz) ;
366           TNode * toplidnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
367           toplidnode->SetLineColor(kColorPPSD) ;  
368           fNodes->Add(toplidnode) ; 
369           //      b. composite panel
370           y = y - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; 
371           sprintf(nodename, "%s%d%d%d", "CompU", i, iphi, iz) ;
372           TNode * compupnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
373           compupnode->SetLineColor(kColorPPSD) ;  
374           fNodes->Add(compupnode) ; 
375           //      c. anode
376           y = y - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness()  / 2. ; 
377           sprintf(nodename, "%s%d%d%d", "Ano", i, iphi, iz) ;
378           TNode * anodenode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
379           anodenode->SetLineColor(kColorPHOS) ;  
380           fNodes->Add(anodenode) ; 
381           //      d.  gas 
382           y = y - geom->GetAnodeThickness() / 2. - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. ; 
383           sprintf(nodename, "%s%d%d%d", "GGap", i, iphi, iz) ;
384           TNode * ggapnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
385           ggapnode->SetLineColor(kColorGas) ;  
386           fNodes->Add(ggapnode) ;          
387           //      f. cathode
388           y = y - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness()  / 2. ; 
389           sprintf(nodename, "%s%d%d%d", "Cathode", i, iphi, iz) ;
390           TNode * cathodenode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
391           cathodenode->SetLineColor(kColorPHOS) ;  
392           fNodes->Add(cathodenode) ;        
393           //      g. printed circuit
394           y = y - geom->GetCathodeThickness() / 2. - geom->GetPCThickness()  / 2. ; 
395           sprintf(nodename, "%s%d%d%d", "PC", i, iphi, iz) ;
396           TNode * pcnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
397           pcnode->SetLineColor(kColorPPSD) ;  
398           fNodes->Add(pcnode) ;        
399           //      h. composite panel
400           y = y - geom->GetPCThickness() / 2. - geom->GetCompositeThickness()  / 2. ; 
401           sprintf(nodename, "%s%d%d%d", "CompDown", i, iphi, iz) ;
402           TNode * compdownnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
403           compdownnode->SetLineColor(kColorPPSD) ;  
404           fNodes->Add(compdownnode) ;   
405           z = z - geom->GetPPSDModuleSize(2) ;
406           ppsdboxnode->cd() ;
407         } // end of Z module loop     
408         x = x -  geom->GetPPSDModuleSize(0) ; 
409         ppsdboxnode->cd() ;
410       } // end of phi module loop
411     }
412     //   2. air gap      
413     ppsdboxnode->cd() ;
414     y = ( geom->GetCPVBoxSize(1) - 2 * geom->GetMicromegas1Thickness() - geom->GetMicro1ToLeadGap() ) / 2. ; 
415     sprintf(nodename, "%s%d", "GapUp", i) ;
416     TNode * gapupnode = new TNode(nodename, nodename, "LeadToM", 0, y, 0) ;
417     gapupnode->SetLineColor(kColorAir) ;  
418     fNodes->Add(gapupnode) ;        
419     //   3. lead converter
420     y = y - geom->GetMicro1ToLeadGap() / 2. - geom->GetLeadConverterThickness() / 2. ; 
421     sprintf(nodename, "%s%d", "LeadC", i) ;
422     TNode * leadcnode = new TNode(nodename, nodename, "Lead", 0, y, 0) ;
423     leadcnode->SetLineColor(kColorPPSD) ;  
424     fNodes->Add(leadcnode) ;        
425     //   4. air gap
426     y = y - geom->GetLeadConverterThickness() / 2. - geom->GetLeadToMicro2Gap()  / 2. ; 
427     sprintf(nodename, "%s%d", "GapDown", i) ;
428     TNode * gapdownnode = new TNode(nodename, nodename, "MToLead", 0, y, 0) ;
429     gapdownnode->SetLineColor(kColorAir) ;  
430     fNodes->Add(gapdownnode) ;        
431     //    5.  fNumberOfModulesPhi x fNumberOfModulesZ bottom micromegas
432     x = ( geom->GetCPVBoxSize(0) - geom->GetPPSDModuleSize(0) ) / 2. - geom->GetPhiDisplacement() ;  
433     {
434       for ( Int_t iphi = 1; iphi <= geom->GetNumberOfModulesPhi(); iphi++ ) { 
435         Float_t z = ( geom->GetCPVBoxSize(2) - geom->GetPPSDModuleSize(2) ) / 2.  - geom->GetZDisplacement() ;;
436         TNode * micro2node ; 
437         for ( Int_t iz = 1; iz <= geom->GetNumberOfModulesZ(); iz++ ) { 
438           y = - ( geom->GetCPVBoxSize(1) - geom->GetMicromegas2Thickness() ) / 2. ; 
439           sprintf(nodename, "%s%d%d%d", "Mic2", i, iphi, iz) ;
440           micro2node  = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
441           micro2node->SetLineColor(kColorPPSD) ;  
442           fNodes->Add(micro2node) ; 
443           // inside bottom micromegas
444           micro2node->cd() ; 
445           //      a. top lid
446           y = ( geom->GetMicromegas2Thickness() - geom->GetLidThickness() ) / 2. ; 
447           sprintf(nodename, "%s%d%d%d", "Lidb", i, iphi, iz) ;
448           TNode * toplidbnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
449           toplidbnode->SetLineColor(kColorPPSD) ;  
450           fNodes->Add(toplidbnode) ; 
451           //      b. composite panel
452           y = y - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; 
453           sprintf(nodename, "%s%d%d%d", "CompUb", i, iphi, iz) ;
454           TNode * compupbnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
455           compupbnode->SetLineColor(kColorPPSD) ;  
456           fNodes->Add(compupbnode) ; 
457           //      c. anode
458           y = y - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness()  / 2. ; 
459           sprintf(nodename, "%s%d%d%d", "Anob", i, iphi, iz) ;
460           TNode * anodebnode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
461           anodebnode->SetLineColor(kColorPPSD) ;  
462           fNodes->Add(anodebnode) ; 
463           //      d. conversion gas
464           y = y - geom->GetAnodeThickness() / 2. - ( geom->GetConversionGap() +  geom->GetAvalancheGap() )  / 2. ; 
465           sprintf(nodename, "%s%d%d%d", "GGapb", i, iphi, iz) ;
466           TNode * ggapbnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
467           ggapbnode->SetLineColor(kColorGas) ;  
468           fNodes->Add(ggapbnode) ;           
469           //      f. cathode
470           y = y - ( geom->GetConversionGap() + geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness()  / 2. ; 
471           sprintf(nodename, "%s%d%d%d", "Cathodeb", i, iphi, iz) ;
472           TNode * cathodebnode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
473           cathodebnode->SetLineColor(kColorPPSD) ;  
474           fNodes->Add(cathodebnode) ;        
475           //      g. printed circuit
476           y = y - geom->GetCathodeThickness() / 2. - geom->GetPCThickness()  / 2. ; 
477           sprintf(nodename, "%s%d%d%d", "PCb", i, iphi, iz) ;
478           TNode * pcbnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
479           pcbnode->SetLineColor(kColorPPSD) ;  
480           fNodes->Add(pcbnode) ;        
481           //      h. composite pane
482           y = y - geom->GetPCThickness() / 2. - geom->GetCompositeThickness()  / 2. ; 
483           sprintf(nodename, "%s%d%d%d", "CompDownb", i, iphi, iz) ;
484           TNode * compdownbnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
485           compdownbnode->SetLineColor(kColorPPSD) ;  
486           fNodes->Add(compdownbnode) ;        
487           z = z - geom->GetPPSDModuleSize(2) ;
488           ppsdboxnode->cd() ;
489         } // end of Z module loop     
490         x = x -  geom->GetPPSDModuleSize(0) ; 
491         ppsdboxnode->cd() ;
492       } // end of phi module loop
493     }
494   } // PHOS modules
495  
496   delete[] rotname ;  
497   delete[] nodename ; 
498
499 }
500
501 //____________________________________________________________________________
502 void AliPHOSv0:: BuildGeometryforCPV(void)
503 {
504   //  Build the PHOS-CPV geometry for the ROOT display
505   //  Author: Yuri Kharlov 11 September 2000
506   //
507   //BEGIN_HTML
508   /*
509     <H2>
510     CPV displayed by root
511     </H2>
512     <table width=700>
513
514     <tr>
515          <td>CPV perspective view</td>
516          <td>CPV front view      </td>
517     </tr>
518
519     <tr>
520          <td> <img height=300 width=290 src="../images/CPVRootPersp.gif"> </td>
521          <td> <img height=300 width=290 src="../images/CPVRootFront.gif"> </td>
522     </tr>
523
524     </table>
525
526   */
527   //END_HTML  
528
529   const Double_t kRADDEG         = 180.0 / kPI ;
530   const Int_t    kColorCPV       = kGreen ;
531   const Int_t    kColorFrame     = kYellow ;
532   const Int_t    kColorGassiplex = kRed;
533   const Int_t    kColorPCB       = kCyan;
534
535   AliPHOSGeometry * geom = GetGeometry() ; 
536
537   // Box for a full PHOS module
538
539   new TBRIK ("CPVBox", "CPV box", "void",                   geom->GetCPVBoxSize(0)/2,
540                                                             geom->GetCPVBoxSize(1)/2,
541                                                             geom->GetCPVBoxSize(2)/2 );
542   new TBRIK ("CPVFrameLR", "CPV frame Left-Right", "void",  geom->GetCPVFrameSize(0)/2,
543                                                             geom->GetCPVFrameSize(1)/2,
544                                                             geom->GetCPVBoxSize(2)/2 );
545   new TBRIK ("CPVFrameUD", "CPV frame Up-Down",    "void",  geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0),
546                                                             geom->GetCPVFrameSize(1)/2,
547                                                             geom->GetCPVFrameSize(2)/2);
548   new TBRIK ("CPVPCB",    "CPV PCB",               "void",  geom->GetCPVActiveSize(0)/2,
549                                                             geom->GetCPVTextoliteThickness()/2,
550                                                             geom->GetCPVActiveSize(1)/2);
551   new TBRIK ("CPVGassiplex", "CPV Gassiplex PCB",  "void",  geom->GetGassiplexChipSize(0)/2,
552                                                             geom->GetGassiplexChipSize(1)/2,
553                                                             geom->GetGassiplexChipSize(2)/2);
554
555   // position CPV into ALICE
556
557   char * nodename = new char[25] ;
558   char * rotname  = new char[25] ;
559   
560   Float_t r = geom->GetIPtoCPVDistance() + geom->GetCPVBoxSize(1) / 2.0 ;
561   Int_t number = 988 ; 
562   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
563
564   Int_t lastModule = 0 ;
565   if      (strcmp(geom->GetName(),"IHEP") == 0) 
566     lastModule = geom->GetNModules();
567   else if (strcmp(geom->GetName(),"MIXT") == 0) 
568     lastModule = geom->GetNModules() - geom->GetNPPSDModules();
569   
570   for( Int_t i = 1; i <= lastModule; i++ ) { // the number of PHOS modules
571
572     // One CPV module
573
574     Float_t angle = geom->GetPHOSAngle(i) ;
575     sprintf(rotname, "%s%d", "rotg", number+i) ;
576     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
577     top->cd();
578     sprintf(nodename, "%s%d", "CPVModule", i) ;    
579     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
580     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
581     Float_t z;
582     TNode * cpvBoxNode = new TNode(nodename , nodename ,"CPVBox", x, y, 0, rotname ) ;
583     cpvBoxNode->SetLineColor(kColorCPV) ;
584     fNodes->Add(cpvBoxNode) ;
585     cpvBoxNode->cd() ;
586
587     // inside each CPV box:
588
589     // Frame around CPV
590     Int_t j;
591     for (j=0; j<=1; j++) {
592       sprintf(nodename, "CPVModule%d Frame%d", i, j+1) ;
593       x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
594       TNode * cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameLR", x, 0, 0) ;
595       cpvFrameNode->SetLineColor(kColorFrame) ;
596       fNodes->Add(cpvFrameNode) ;
597
598       sprintf(nodename, "CPVModule%d Frame%d", i, j+3) ;
599       z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
600       cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameUD", 0, 0, z) ;
601       cpvFrameNode->SetLineColor(kColorFrame) ;
602       fNodes->Add(cpvFrameNode) ;
603     }
604
605     // 4 printed circuit boards
606     for (j=0; j<4; j++) {
607       sprintf(nodename, "CPVModule%d PCB%d", i, j+1) ;
608       y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(j) + geom->GetCPVTextoliteThickness()/2;
609       TNode * cpvPCBNode = new TNode(nodename , nodename ,"CPVPCB", 0, y, 0) ;
610       cpvPCBNode->SetLineColor(kColorPCB) ;
611       fNodes->Add(cpvPCBNode) ;
612     }
613
614     // Gassiplex chips
615     Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
616     Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
617     y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
618         geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
619     for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
620       x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
621       for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
622         z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
623         sprintf(nodename, "CPVModule%d Chip(%dx%d)", i, ix+1,iz+1) ;
624         TNode * cpvGassiplexNode = new TNode(nodename , nodename ,"CPVGassiplex", x, y, z) ;
625         cpvGassiplexNode->SetLineColor(kColorGassiplex) ;
626         fNodes->Add(cpvGassiplexNode) ;
627       }
628     }
629
630   } // PHOS modules
631  
632   delete[] rotname ;  
633   delete[] nodename ; 
634 }
635
636 //____________________________________________________________________________
637 void AliPHOSv0::CreateGeometry()
638 {
639   // Create the PHOS geometry for Geant
640
641   AliPHOSv0 *phostmp = (AliPHOSv0*)gAlice->GetModule("PHOS") ;
642
643   if ( phostmp == NULL ) {
644     
645     fprintf(stderr, "PHOS detector not found!\n") ;
646     return;
647     
648   }
649
650   AliPHOSGeometry * geom = GetGeometry() ; 
651
652   // Get pointer to the array containing media indeces
653   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
654
655   // Create a box a PHOS module.
656   // In case of MIXT geometry 2 different boxes are needed
657
658   Float_t bigbox[3] ; 
659   bigbox[0] =   geom->GetOuterBoxSize(0) / 2.0 ;
660   bigbox[1] = ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
661   bigbox[2] =   geom->GetOuterBoxSize(2) / 2.0 ;
662   
663     gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
664
665   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
666     gMC->Gsvolu("PHO1", "BOX ", idtmed[798], bigbox, 3) ;
667   
668     this->CreateGeometryforPHOS() ; 
669   if      ( strcmp( geom->GetName(), "GPS2") == 0  ) 
670     this->CreateGeometryforPPSD() ;
671   else if ( strcmp( geom->GetName(), "IHEP") == 0  ) 
672     this->CreateGeometryforCPV() ;
673   else if ( strcmp( geom->GetName(), "MIXT") == 0  ) {
674     this->CreateGeometryforPPSD() ;
675     this->CreateGeometryforCPV() ;
676   }
677   else
678     cout << "AliPHOSv0::CreateGeometry : no charged particle identification system installed" << endl; 
679
680   this->CreateGeometryforSupport() ; 
681   
682   // --- Position  PHOS mdules in ALICE setup ---
683   
684   Int_t idrotm[99] ;
685   Double_t const kRADDEG = 180.0 / kPI ;
686   
687   Int_t lastModule;
688   if (strcmp(geom->GetName(),"MIXT") == 0) 
689     lastModule = geom->GetNModules() - geom->GetNPPSDModules();
690   else
691     lastModule = geom->GetNModules();
692
693   Int_t i;
694   for( i = 1; i <= lastModule ; i++ ) {
695     
696     Float_t angle = geom->GetPHOSAngle(i) ;
697     AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
698  
699     Float_t r = geom->GetIPtoOuterCoverDistance() + ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
700
701     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
702     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
703
704     gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
705  
706   } // for GetNModules
707
708   for( i = lastModule+1; i <= geom->GetNModules(); i++ ) {
709     
710     Float_t angle = geom->GetPHOSAngle(i) ;
711     AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
712  
713     Float_t r = geom->GetIPtoOuterCoverDistance() + ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
714
715     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
716     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
717
718     gMC->Gspos("PHO1", i-lastModule, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
719  
720   } // for GetNModules
721
722 }
723
724 //____________________________________________________________________________
725 void AliPHOSv0::CreateGeometryforPHOS()
726 {
727   // Create the PHOS-EMC geometry for GEANT
728     //BEGIN_HTML
729   /*
730     <H2>
731     Geant3 geometry tree of PHOS-EMC in ALICE
732     </H2>
733     <P><CENTER>
734     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif"> 
735     </CENTER><P>
736   */
737   //END_HTML  
738   
739   // Get pointer to the array containing media indexes
740   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
741
742   AliPHOSGeometry * geom = GetGeometry() ; 
743
744   // ---
745   // --- Define PHOS box volume, fPUFPill with thermo insulating foam ---
746   // --- Foam Thermo Insulating outer cover dimensions ---
747   // --- Put it in bigbox = PHOS
748
749   Float_t dphos[3] ; 
750   dphos[0] =  geom->GetOuterBoxSize(0) / 2.0 ;
751   dphos[1] =  geom->GetOuterBoxSize(1) / 2.0 ;
752   dphos[2] =  geom->GetOuterBoxSize(2) / 2.0 ;
753
754   gMC->Gsvolu("PEMC", "BOX ", idtmed[706], dphos, 3) ;
755
756   Float_t yO =  - geom->GetCPVBoxSize(1)  / 2.0 ;
757
758     gMC->Gspos("PEMC", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
759   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
760     gMC->Gspos("PEMC", 1, "PHO1", 0.0, yO, 0.0, 0, "ONLY") ; 
761
762   // ---
763   // --- Define Textolit Wall box, position inside PEMC ---
764   // --- Textolit Wall box dimentions ---
765  
766  
767   Float_t dptxw[3];
768   dptxw[0] = geom->GetTextolitBoxSize(0) / 2.0 ;
769   dptxw[1] = geom->GetTextolitBoxSize(1) / 2.0 ;
770   dptxw[2] = geom->GetTextolitBoxSize(2) / 2.0 ;
771
772   gMC->Gsvolu("PTXW", "BOX ", idtmed[707], dptxw, 3);
773
774   yO =   (  geom->GetOuterBoxThickness(1) -   geom->GetUpperPlateThickness() ) / 2.  ;
775    
776   gMC->Gspos("PTXW", 1, "PEMC", 0.0, yO, 0.0, 0, "ONLY") ;
777
778   // --- 
779   // --- Define Upper Polystyrene Foam Plate, place inside PTXW ---
780   // --- immediately below Foam Thermo Insulation Upper plate ---
781
782   // --- Upper Polystyrene Foam plate thickness ---
783  
784   Float_t  dpufp[3] ;
785   dpufp[0] = geom->GetTextolitBoxSize(0) / 2.0 ; 
786   dpufp[1] = geom->GetSecondUpperPlateThickness() / 2. ;
787   dpufp[2] = geom->GetTextolitBoxSize(2) /2.0 ; 
788
789   gMC->Gsvolu("PUFP", "BOX ", idtmed[703], dpufp, 3) ;
790   
791   yO = ( geom->GetTextolitBoxSize(1) -  geom->GetSecondUpperPlateThickness() ) / 2.0 ;
792   
793   gMC->Gspos("PUFP", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
794   
795   // ---
796   // --- Define air-filled box, place inside PTXW ---
797   // --- Inner AIR volume dimensions ---
798  
799
800   Float_t  dpair[3] ;
801   dpair[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
802   dpair[1] = geom->GetAirFilledBoxSize(1) / 2.0 ;
803   dpair[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
804
805   gMC->Gsvolu("PAIR", "BOX ", idtmed[798], dpair, 3) ;
806   
807   yO = ( geom->GetTextolitBoxSize(1) -  geom->GetAirFilledBoxSize(1) ) / 2.0 -   geom->GetSecondUpperPlateThickness() ;
808   
809   gMC->Gspos("PAIR", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
810
811 // --- Dimensions of PbWO4 crystal ---
812
813   Float_t xtlX =  geom->GetCrystalSize(0) ; 
814   Float_t xtlY =  geom->GetCrystalSize(1) ; 
815   Float_t xtlZ =  geom->GetCrystalSize(2) ; 
816
817   Float_t dptcb[3] ;  
818   dptcb[0] =  geom->GetNPhi() * ( xtlX + 2 *  geom->GetGapBetweenCrystals() ) / 2.0 + geom->GetModuleBoxThickness() ;
819   dptcb[1] = ( xtlY +  geom->GetCrystalSupportHeight() +  geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 
820              + geom->GetModuleBoxThickness() / 2.0 ;
821   dptcb[2] = geom->GetNZ() * ( xtlZ + 2 * geom->GetGapBetweenCrystals() ) / 2.0 +  geom->GetModuleBoxThickness() ;
822   
823   gMC->Gsvolu("PTCB", "BOX ", idtmed[706], dptcb, 3) ;
824
825   yO =  geom->GetAirFilledBoxSize(1) / 2.0 - dptcb[1] 
826        - ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetModuleBoxThickness() 
827        -  geom->GetUpperPlateThickness() -  geom->GetSecondUpperPlateThickness() ) ;
828   
829   gMC->Gspos("PTCB", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
830
831   // ---
832   // --- Define Crystal BLock filled with air, position it inside PTCB ---
833   Float_t dpcbl[3] ; 
834   
835   dpcbl[0] = geom->GetNPhi() * ( xtlX + 2 * geom->GetGapBetweenCrystals() ) / 2.0 ;
836   dpcbl[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
837   dpcbl[2] = geom->GetNZ() * ( xtlZ + 2 * geom->GetGapBetweenCrystals() ) / 2.0 ;
838   
839   gMC->Gsvolu("PCBL", "BOX ", idtmed[798], dpcbl, 3) ;
840   
841   // --- Divide PCBL in X (phi) and Z directions --
842   gMC->Gsdvn("PROW", "PCBL", Int_t (geom->GetNPhi()), 1) ;
843   gMC->Gsdvn("PCEL", "PROW", Int_t (geom->GetNZ()), 3) ;
844
845   yO = -geom->GetModuleBoxThickness() / 2.0 ;
846   
847   gMC->Gspos("PCBL", 1, "PTCB", 0.0, yO, 0.0, 0, "ONLY") ;
848
849   // ---
850   // --- Define STeel (actually, it's titanium) Cover volume, place inside PCEL
851   Float_t  dpstc[3] ; 
852   
853   dpstc[0] = ( xtlX + 2 * geom->GetCrystalWrapThickness() ) / 2.0 ;
854   dpstc[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
855   dpstc[2] = ( xtlZ + 2 * geom->GetCrystalWrapThickness()  + 2 *  geom->GetCrystalHolderThickness() ) / 2.0 ;
856   
857   gMC->Gsvolu("PSTC", "BOX ", idtmed[704], dpstc, 3) ;
858
859   gMC->Gspos("PSTC", 1, "PCEL", 0.0, 0.0, 0.0, 0, "ONLY") ;
860
861   // ---
862   // --- Define Tyvek volume, place inside PSTC ---
863   Float_t  dppap[3] ;
864
865   dppap[0] = xtlX / 2.0 + geom->GetCrystalWrapThickness() ;
866   dppap[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 ;
867   dppap[2] = xtlZ / 2.0 + geom->GetCrystalWrapThickness() ;
868   
869   gMC->Gsvolu("PPAP", "BOX ", idtmed[702], dppap, 3) ;
870   
871   yO = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 
872               - ( xtlY +  geom->GetCrystalSupportHeight() +  geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
873    
874   gMC->Gspos("PPAP", 1, "PSTC", 0.0, yO, 0.0, 0, "ONLY") ;
875
876   // ---
877   // --- Define PbWO4 crystal volume, place inside PPAP ---
878   Float_t  dpxtl[3] ; 
879
880   dpxtl[0] = xtlX / 2.0 ;
881   dpxtl[1] = xtlY / 2.0 ;
882   dpxtl[2] = xtlZ / 2.0 ;
883   
884   gMC->Gsvolu("PXTL", "BOX ", idtmed[699], dpxtl, 3) ;
885
886   yO = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 - xtlY / 2.0 - geom->GetCrystalWrapThickness() ;
887   
888   gMC->Gspos("PXTL", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
889
890   // ---
891   // --- Define crystal support volume, place inside PPAP ---
892   Float_t dpsup[3] ; 
893
894   dpsup[0] = xtlX / 2.0 + geom->GetCrystalWrapThickness()  ;
895   dpsup[1] = geom->GetCrystalSupportHeight() / 2.0 ;
896   dpsup[2] = xtlZ / 2.0 +  geom->GetCrystalWrapThickness() ;
897
898   gMC->Gsvolu("PSUP", "BOX ", idtmed[798], dpsup, 3) ;
899
900   yO =  geom->GetCrystalSupportHeight() / 2.0 - ( xtlY +  geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 ;
901
902   gMC->Gspos("PSUP", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
903
904   // ---
905   // --- Define PIN-diode volume and position it inside crystal support ---
906   // --- right behind PbWO4 crystal
907
908   // --- PIN-diode dimensions ---
909
910  
911   Float_t dppin[3] ;
912   dppin[0] = geom->GetPinDiodeSize(0) / 2.0 ;
913   dppin[1] = geom->GetPinDiodeSize(1) / 2.0 ;
914   dppin[2] = geom->GetPinDiodeSize(2) / 2.0 ;
915  
916   gMC->Gsvolu("PPIN", "BOX ", idtmed[705], dppin, 3) ;
917  
918   yO = geom->GetCrystalSupportHeight() / 2.0 - geom->GetPinDiodeSize(1) / 2.0 ;
919  
920   gMC->Gspos("PPIN", 1, "PSUP", 0.0, yO, 0.0, 0, "ONLY") ;
921
922   // ---
923   // --- Define Upper Cooling Panel, place it on top of PTCB ---
924   Float_t dpucp[3] ;
925  // --- Upper Cooling Plate thickness ---
926  
927   dpucp[0] = dptcb[0] ;
928   dpucp[1] = geom->GetUpperCoolingPlateThickness() ;
929   dpucp[2] = dptcb[2] ;
930   
931   gMC->Gsvolu("PUCP", "BOX ", idtmed[701], dpucp,3) ;
932   
933   yO = geom->GetAirFilledBoxSize(1) / 2. 
934     -( geom->GetIPtoCrystalSurface()  - geom->GetIPtoOuterCoverDistance()    - geom->GetModuleBoxThickness()
935       -geom->GetUpperPlateThickness() - geom->GetSecondUpperPlateThickness() - geom->GetUpperCoolingPlateThickness() ) ; 
936   
937   gMC->Gspos("PUCP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
938
939   // ---
940   // --- Define Al Support Plate, position it inside PAIR ---
941   // --- right beneath PTCB ---
942  // --- Al Support Plate thickness ---
943  
944   Float_t dpasp[3] ;
945   dpasp[0] =  geom->GetAirFilledBoxSize(0) / 2.0 ;
946   dpasp[1] = geom->GetSupportPlateThickness() / 2.0 ;
947   dpasp[2] =  geom->GetAirFilledBoxSize(2) / 2.0 ;
948   
949   gMC->Gsvolu("PASP", "BOX ", idtmed[701], dpasp, 3) ;
950   
951   yO = (  geom->GetAirFilledBoxSize(1) - geom->GetSupportPlateThickness() ) / 2. 
952        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance()
953            - geom->GetUpperPlateThickness() - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 ) ;
954   
955   gMC->Gspos("PASP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
956
957   // ---
958   // --- Define Thermo Insulating Plate, position it inside PAIR ---
959   // --- right beneath PASP ---
960   // --- Lower Thermo Insulating Plate thickness ---
961   
962   Float_t dptip[3] ;
963   dptip[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
964   dptip[1] = geom->GetLowerThermoPlateThickness() / 2.0 ;
965   dptip[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
966
967   gMC->Gsvolu("PTIP", "BOX ", idtmed[706], dptip, 3) ;
968
969   yO =  ( geom->GetAirFilledBoxSize(1) - geom->GetLowerThermoPlateThickness() ) / 2. 
970        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetUpperPlateThickness() 
971             - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + geom->GetSupportPlateThickness() ) ;
972
973   gMC->Gspos("PTIP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
974
975   // ---
976   // --- Define Textolit Plate, position it inside PAIR ---
977   // --- right beneath PTIP ---
978   // --- Lower Textolit Plate thickness ---
979  
980   Float_t dptxp[3] ;
981   dptxp[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
982   dptxp[1] = geom->GetLowerTextolitPlateThickness() / 2.0 ;
983   dptxp[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
984
985   gMC->Gsvolu("PTXP", "BOX ", idtmed[707], dptxp, 3) ;
986
987   yO =  ( geom->GetAirFilledBoxSize(1) - geom->GetLowerTextolitPlateThickness() ) / 2. 
988        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetUpperPlateThickness() 
989             - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + geom->GetSupportPlateThickness() 
990             +  geom->GetLowerThermoPlateThickness() ) ;
991
992   gMC->Gspos("PTXP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
993
994 }
995
996 //____________________________________________________________________________
997 void AliPHOSv0::CreateGeometryforPPSD()
998 {
999   // Create the PHOS-PPSD geometry for GEANT
1000   //BEGIN_HTML
1001   /*
1002     <H2>
1003     Geant3 geometry tree of PHOS-PPSD in ALICE
1004     </H2>
1005     <P><CENTER>
1006     <IMG Align=BOTTOM ALT="PPSD geant tree" SRC="../images/PPSDinAlice.gif"> 
1007     </CENTER><P>
1008   */
1009   //END_HTML  
1010
1011   // Get pointer to the array containing media indexes
1012   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1013
1014   AliPHOSGeometry * geom = GetGeometry() ; 
1015
1016   // The box containing all ppsd's for one PHOS module filled with air 
1017   Float_t ppsd[3] ; 
1018   ppsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
1019   ppsd[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
1020   ppsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1021
1022   gMC->Gsvolu("PPSD", "BOX ", idtmed[798], ppsd, 3) ;
1023
1024   Float_t yO =  geom->GetOuterBoxSize(1) / 2.0 ;
1025
1026   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
1027     gMC->Gspos("PPSD", 1, "PHO1", 0.0, yO, 0.0, 0, "ONLY") ; 
1028   else
1029     gMC->Gspos("PPSD", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
1030
1031   // Now we build a micromegas module
1032   // The box containing the whole module filled with epoxy (FR4)
1033
1034   Float_t mppsd[3] ;  
1035   mppsd[0] = geom->GetPPSDModuleSize(0) / 2.0 ;  
1036   mppsd[1] = geom->GetPPSDModuleSize(1) / 2.0 ;  
1037   mppsd[2] = geom->GetPPSDModuleSize(2) / 2.0 ;
1038
1039   gMC->Gsvolu("PMPP", "BOX ", idtmed[708], mppsd, 3) ;  
1040  
1041   // Inside mppsd :
1042   // 1. The Top Lid made of epoxy (FR4) 
1043
1044   Float_t tlppsd[3] ; 
1045   tlppsd[0] = geom->GetPPSDModuleSize(0) / 2.0 ; 
1046   tlppsd[1] = geom->GetLidThickness() / 2.0 ;
1047   tlppsd[2] = geom->GetPPSDModuleSize(2) / 2.0 ;
1048
1049   gMC->Gsvolu("PTLP", "BOX ", idtmed[708], tlppsd, 3) ; 
1050
1051   Float_t  y0 = ( geom->GetMicromegas1Thickness() - geom->GetLidThickness() ) / 2. ; 
1052
1053   gMC->Gspos("PTLP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1054  
1055   // 2. the upper panel made of composite material
1056
1057   Float_t upppsd[3] ; 
1058   upppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1059   upppsd[1] = geom->GetCompositeThickness() / 2.0 ;
1060   upppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1061  
1062   gMC->Gsvolu("PUPP", "BOX ", idtmed[709], upppsd, 3) ; 
1063   
1064   y0 = y0 - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; 
1065
1066   gMC->Gspos("PUPP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1067
1068   // 3. the anode made of Copper
1069   
1070   Float_t anppsd[3] ; 
1071   anppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ; 
1072   anppsd[1] = geom->GetAnodeThickness() / 2.0 ; 
1073   anppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0  ; 
1074
1075   gMC->Gsvolu("PANP", "BOX ", idtmed[710], anppsd, 3) ; 
1076   
1077   y0 = y0 - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness()  / 2. ; 
1078   
1079   gMC->Gspos("PANP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1080
1081   // 4. the conversion gap + avalanche gap filled with gas
1082
1083   Float_t ggppsd[3] ; 
1084   ggppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1085   ggppsd[1] = ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2.0 ; 
1086   ggppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1087
1088   gMC->Gsvolu("PGGP", "BOX ", idtmed[715], ggppsd, 3) ; 
1089   
1090   // --- Divide GGPP in X (phi) and Z directions --
1091   gMC->Gsdvn("PPRO", "PGGP", geom->GetNumberOfPadsPhi(), 1) ;
1092   gMC->Gsdvn("PPCE", "PPRO", geom->GetNumberOfPadsZ() ,  3) ;
1093
1094   y0 = y0 - geom->GetAnodeThickness() / 2.  - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. ; 
1095
1096   gMC->Gspos("PGGP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1097
1098
1099   // 6. the cathode made of Copper
1100
1101   Float_t cappsd[3] ;
1102   cappsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1103   cappsd[1] = geom->GetCathodeThickness() / 2.0 ; 
1104   cappsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0  ;
1105
1106   gMC->Gsvolu("PCAP", "BOX ", idtmed[710], cappsd, 3) ; 
1107
1108   y0 = y0 - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness()  / 2. ; 
1109
1110   gMC->Gspos("PCAP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1111
1112   // 7. the printed circuit made of G10       
1113
1114   Float_t pcppsd[3] ; 
1115   pcppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2,.0 ; 
1116   pcppsd[1] = geom->GetPCThickness() / 2.0 ; 
1117   pcppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1118
1119   gMC->Gsvolu("PCPS", "BOX ", idtmed[711], cappsd, 3) ; 
1120
1121   y0 = y0 - geom->GetCathodeThickness() / 2. - geom->GetPCThickness()  / 2. ; 
1122
1123   gMC->Gspos("PCPS", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1124
1125   // 8. the lower panel made of composite material
1126                                                     
1127   Float_t lpppsd[3] ; 
1128   lpppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ; 
1129   lpppsd[1] = geom->GetCompositeThickness() / 2.0 ; 
1130   lpppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1131
1132   gMC->Gsvolu("PLPP", "BOX ", idtmed[709], lpppsd, 3) ; 
1133  
1134   y0 = y0 - geom->GetPCThickness() / 2. - geom->GetCompositeThickness()  / 2. ; 
1135
1136   gMC->Gspos("PLPP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1137
1138   // Position the  fNumberOfModulesPhi x fNumberOfModulesZ modules (mppsd) inside PPSD to cover a PHOS module
1139   // the top and bottom one's (which are assumed identical) :
1140
1141    Float_t yt = ( geom->GetCPVBoxSize(1) - geom->GetMicromegas1Thickness() ) / 2. ; 
1142    Float_t yb = - ( geom->GetCPVBoxSize(1) - geom->GetMicromegas2Thickness() ) / 2. ; 
1143
1144    Int_t copyNumbertop = 0 ; 
1145    Int_t copyNumberbot = geom->GetNumberOfModulesPhi() *  geom->GetNumberOfModulesZ() ; 
1146
1147    Float_t x  = ( geom->GetCPVBoxSize(0) - geom->GetPPSDModuleSize(0) ) / 2. ;  
1148
1149    for ( Int_t iphi = 1; iphi <= geom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
1150       Float_t z = ( geom->GetCPVBoxSize(2) - geom->GetPPSDModuleSize(2) ) / 2. ;
1151
1152       for ( Int_t iz = 1; iz <= geom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
1153         gMC->Gspos("PMPP", ++copyNumbertop, "PPSD", x, yt, z, 0, "ONLY") ;
1154         gMC->Gspos("PMPP", ++copyNumberbot, "PPSD", x, yb, z, 0, "ONLY") ; 
1155         z = z - geom->GetPPSDModuleSize(2) ;
1156       } // end of Z module loop   
1157       x = x -  geom->GetPPSDModuleSize(0) ; 
1158     } // end of phi module loop
1159
1160    // The Lead converter between two air gaps
1161    // 1. Upper air gap
1162
1163    Float_t uappsd[3] ;
1164    uappsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;
1165    uappsd[1] = geom->GetMicro1ToLeadGap() / 2.0 ; 
1166    uappsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1167
1168   gMC->Gsvolu("PUAPPS", "BOX ", idtmed[798], uappsd, 3) ; 
1169
1170   y0 = ( geom->GetCPVBoxSize(1) - 2 * geom->GetMicromegas1Thickness() - geom->GetMicro1ToLeadGap() ) / 2. ; 
1171
1172   gMC->Gspos("PUAPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1173
1174    // 2. Lead converter
1175  
1176   Float_t lcppsd[3] ; 
1177   lcppsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;
1178   lcppsd[1] = geom->GetLeadConverterThickness() / 2.0 ; 
1179   lcppsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1180  
1181   gMC->Gsvolu("PLCPPS", "BOX ", idtmed[712], lcppsd, 3) ; 
1182   
1183   y0 = y0 - geom->GetMicro1ToLeadGap() / 2. - geom->GetLeadConverterThickness() / 2. ; 
1184
1185   gMC->Gspos("PLCPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1186
1187   // 3. Lower air gap
1188
1189   Float_t lappsd[3] ; 
1190   lappsd[0] = geom->GetCPVBoxSize(0) / 2.0 ; 
1191   lappsd[1] = geom->GetLeadToMicro2Gap() / 2.0 ; 
1192   lappsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1193
1194   gMC->Gsvolu("PLAPPS", "BOX ", idtmed[798], lappsd, 3) ; 
1195     
1196   y0 = y0 - geom->GetLeadConverterThickness() / 2. - geom->GetLeadToMicro2Gap()  / 2. ; 
1197   
1198   gMC->Gspos("PLAPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1199    
1200 }
1201
1202
1203 //____________________________________________________________________________
1204 void AliPHOSv0::CreateGeometryforCPV()
1205 {
1206   // Create the PHOS-CPV geometry for GEANT
1207   // Author: Yuri Kharlov 11 September 2000
1208   //BEGIN_HTML
1209   /*
1210     <H2>
1211     Geant3 geometry of PHOS-CPV in ALICE
1212     </H2>
1213     <table width=700>
1214
1215     <tr>
1216          <td>CPV perspective view</td>
1217          <td>CPV front view      </td>
1218     </tr>
1219
1220     <tr>
1221          <td> <img height=300 width=290 src="../images/CPVallPersp.gif"> </td>
1222          <td> <img height=300 width=290 src="../images/CPVallFront.gif"> </td>
1223     </tr>
1224
1225     <tr>
1226          <td>One CPV module, perspective view                            </td>
1227          <td>One CPV module, front view (extended in vertical direction) </td>
1228     </tr>
1229
1230     <tr>
1231          <td><img height=300 width=290 src="../images/CPVmodulePers.gif"></td>
1232          <td><img height=300 width=290 src="../images/CPVmoduleSide.gif"></td>
1233     </tr>
1234
1235     </table>
1236
1237     <H2>
1238     Geant3 geometry tree of PHOS-CPV in ALICE
1239     </H2>
1240     <center>
1241     <img height=300 width=290 src="../images/CPVtree.gif">
1242     </center>
1243   */
1244   //END_HTML  
1245
1246   Float_t par[3], x,y,z;
1247
1248   // Get pointer to the array containing media indexes
1249   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1250
1251   AliPHOSGeometry * geom = GetGeometry() ; 
1252
1253   // The box containing all CPV for one PHOS module filled with air 
1254   par[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
1255   par[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
1256   par[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1257   gMC->Gsvolu("PCPV", "BOX ", idtmed[798], par, 3) ;
1258   
1259   y = geom->GetOuterBoxSize(1) / 2.0 ;
1260   gMC->Gspos("PCPV", 1, "PHOS", 0.0, y, 0.0, 0, "ONLY") ; 
1261   
1262   // Gassiplex board
1263   
1264   par[0] = geom->GetGassiplexChipSize(0)/2.;
1265   par[1] = geom->GetGassiplexChipSize(1)/2.;
1266   par[2] = geom->GetGassiplexChipSize(2)/2.;
1267   gMC->Gsvolu("PCPC","BOX ",idtmed[707],par,3);
1268   
1269   // Cu+Ni foil covers Gassiplex board
1270
1271   par[1] = geom->GetCPVCuNiFoilThickness()/2;
1272   gMC->Gsvolu("PCPD","BOX ",idtmed[710],par,3);
1273   y      = -(geom->GetGassiplexChipSize(1)/2 - par[1]);
1274   gMC->Gspos("PCPD",1,"PCPC",0,y,0,0,"ONLY");
1275
1276   // Position of the chip inside CPV
1277
1278   Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
1279   Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
1280   Int_t   copy  = 0;
1281   y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
1282     geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
1283   for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
1284     x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
1285     for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
1286       copy++;
1287       z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
1288       gMC->Gspos("PCPC",copy,"PCPV",x,y,z,0,"ONLY");
1289     }
1290   }
1291
1292   // Foiled textolite (1 mm of textolite + 50 mkm of Cu + 6 mkm of Ni)
1293   
1294   par[0] = geom->GetCPVActiveSize(0)        / 2;
1295   par[1] = geom->GetCPVTextoliteThickness() / 2;
1296   par[2] = geom->GetCPVActiveSize(1)        / 2;
1297   gMC->Gsvolu("PCPF","BOX ",idtmed[707],par,3);
1298
1299   // Argon gas volume
1300
1301   par[1] = (geom->GetFTPosition(2) - geom->GetFTPosition(1) - geom->GetCPVTextoliteThickness()) / 2;
1302   gMC->Gsvolu("PCPG","BOX ",idtmed[715],par,3);
1303
1304   for (Int_t i=0; i<4; i++) {
1305     y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(i) + geom->GetCPVTextoliteThickness()/2;
1306     gMC->Gspos("PCPF",i+1,"PCPV",0,y,0,0,"ONLY");
1307     if(i==1){
1308       y-= (geom->GetFTPosition(2) - geom->GetFTPosition(1)) / 2;
1309       gMC->Gspos("PCPG",1,"PCPV ",0,y,0,0,"ONLY");
1310     }
1311   }
1312
1313   // Dummy sensitive plane in the middle of argone gas volume
1314
1315   par[1]=0.001;
1316   gMC->Gsvolu("PCPQ","BOX ",idtmed[715],par,3);
1317   gMC->Gspos ("PCPQ",1,"PCPG",0,0,0,0,"ONLY");
1318
1319   // Cu+Ni foil covers textolite
1320
1321   par[1] = geom->GetCPVCuNiFoilThickness() / 2;
1322   gMC->Gsvolu("PCP1","BOX ",idtmed[710],par,3);
1323   y = geom->GetCPVTextoliteThickness()/2 - par[1];
1324   gMC->Gspos ("PCP1",1,"PCPF",0,y,0,0,"ONLY");
1325
1326   // Aluminum frame around CPV
1327
1328   par[0] = geom->GetCPVFrameSize(0)/2;
1329   par[1] = geom->GetCPVFrameSize(1)/2;
1330   par[2] = geom->GetCPVBoxSize(2)  /2;
1331   gMC->Gsvolu("PCF1","BOX ",idtmed[701],par,3);
1332
1333   par[0] = geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0);
1334   par[1] = geom->GetCPVFrameSize(1)/2;
1335   par[2] = geom->GetCPVFrameSize(2)/2;
1336   gMC->Gsvolu("PCF2","BOX ",idtmed[701],par,3);
1337
1338   for (Int_t j=0; j<=1; j++) {
1339     x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
1340     gMC->Gspos("PCF1",j+1,"PCPV", x,0,0,0,"ONLY");
1341     z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
1342     gMC->Gspos("PCF2",j+1,"PCPV",0, 0,z,0,"ONLY");
1343   }
1344
1345 }
1346
1347
1348 //____________________________________________________________________________
1349 void AliPHOSv0::CreateGeometryforSupport()
1350 {
1351   // Create the PHOS' support geometry for GEANT
1352     //BEGIN_HTML
1353   /*
1354     <H2>
1355     Geant3 geometry of the PHOS's support
1356     </H2>
1357     <P><CENTER>
1358     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/PHOS_support.gif"> 
1359     </CENTER><P>
1360   */
1361   //END_HTML  
1362   
1363   Float_t par[5], x0,y0,z0 ; 
1364   Int_t   i,j,copy;
1365
1366   // Get pointer to the array containing media indexes
1367   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1368
1369   AliPHOSGeometry * geom = GetGeometry() ; 
1370
1371   // --- Dummy box containing two rails on which PHOS support moves
1372   // --- Put these rails to the bottom of the L3 magnet
1373
1374   par[0] =  geom->GetRailRoadSize(0) / 2.0 ;
1375   par[1] =  geom->GetRailRoadSize(1) / 2.0 ;
1376   par[2] =  geom->GetRailRoadSize(2) / 2.0 ;
1377   gMC->Gsvolu("PRRD", "BOX ", idtmed[798], par, 3) ;
1378
1379   y0     = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) / 2.0) ;
1380   gMC->Gspos("PRRD", 1, "ALIC", 0.0, y0, 0.0, 0, "ONLY") ; 
1381
1382   // --- Dummy box containing one rail
1383
1384   par[0] =  geom->GetRailOuterSize(0) / 2.0 ;
1385   par[1] =  geom->GetRailOuterSize(1) / 2.0 ;
1386   par[2] =  geom->GetRailOuterSize(2) / 2.0 ;
1387   gMC->Gsvolu("PRAI", "BOX ", idtmed[798], par, 3) ;
1388
1389   for (i=0; i<2; i++) {
1390     x0     = (2*i-1) * geom->GetDistanceBetwRails()  / 2.0 ;
1391     gMC->Gspos("PRAI", i, "PRRD", x0, 0.0, 0.0, 0, "ONLY") ; 
1392   }
1393
1394   // --- Upper and bottom steel parts of the rail
1395
1396   par[0] =  geom->GetRailPart1(0) / 2.0 ;
1397   par[1] =  geom->GetRailPart1(1) / 2.0 ;
1398   par[2] =  geom->GetRailPart1(2) / 2.0 ;
1399   gMC->Gsvolu("PRP1", "BOX ", idtmed[716], par, 3) ;
1400
1401   y0     = - (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 ;
1402   gMC->Gspos("PRP1", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
1403   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 - geom->GetRailPart3(1);
1404   gMC->Gspos("PRP1", 2, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
1405
1406   // --- The middle vertical steel parts of the rail
1407
1408   par[0] =  geom->GetRailPart2(0) / 2.0 ;
1409   par[1] =  geom->GetRailPart2(1) / 2.0 ;
1410   par[2] =  geom->GetRailPart2(2) / 2.0 ;
1411   gMC->Gsvolu("PRP2", "BOX ", idtmed[716], par, 3) ;
1412
1413   y0     =   - geom->GetRailPart3(1) / 2.0 ;
1414   gMC->Gspos("PRP2", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
1415
1416   // --- The most upper steel parts of the rail
1417
1418   par[0] =  geom->GetRailPart3(0) / 2.0 ;
1419   par[1] =  geom->GetRailPart3(1) / 2.0 ;
1420   par[2] =  geom->GetRailPart3(2) / 2.0 ;
1421   gMC->Gsvolu("PRP3", "BOX ", idtmed[716], par, 3) ;
1422
1423   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart3(1))  / 2.0 ;
1424   gMC->Gspos("PRP3", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
1425
1426   // --- The wall of the cradle
1427   // --- The wall is empty: steel thin walls and air inside
1428
1429   par[1] =  TMath::Sqrt(
1430                         TMath::Power((geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1)),2) +
1431                         TMath::Power((geom->GetOuterBoxSize(0)/2),2)) + 10.;
1432   par[0] =  par[1] - geom->GetCradleWall(1) ;
1433   par[2] =  geom->GetCradleWall(2) / 2.0 ;
1434   par[3] =  geom->GetCradleWall(3) ;
1435   par[4] =  geom->GetCradleWall(4) ;
1436   gMC->Gsvolu("PCRA", "TUBS", idtmed[716], par, 5) ;
1437
1438   par[0] -=  geom->GetCradleWallThickness() ;
1439   par[1] -=  geom->GetCradleWallThickness() ;
1440   par[2] -=  geom->GetCradleWallThickness() ;
1441   gMC->Gsvolu("PCRE", "TUBS", idtmed[798], par, 5) ;
1442   gMC->Gspos ("PCRE", 1, "PCRA", 0.0, 0.0, 0.0, 0, "ONLY") ; 
1443
1444   for (i=0; i<2; i++) {
1445     z0 = (2*i-1) * (geom->GetOuterBoxSize(2) + geom->GetCradleWall(2)) / 2.0 ;
1446     gMC->Gspos("PCRA", i, "ALIC", 0.0, 0.0, z0, 0, "ONLY") ; 
1447   }
1448
1449   // --- The "wheels" of the cradle
1450   
1451   par[0] = geom->GetCradleWheel(0) / 2;
1452   par[1] = geom->GetCradleWheel(1) / 2;
1453   par[2] = geom->GetCradleWheel(2) / 2;
1454   gMC->Gsvolu("PWHE", "BOX ", idtmed[716], par, 3) ;
1455
1456   y0 = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) -
1457          geom->GetCradleWheel(1)/2) ;
1458   for (i=0; i<2; i++) {
1459     z0 = (2*i-1) * ((geom->GetOuterBoxSize(2) + geom->GetCradleWheel(2)) / 2.0 +
1460                     geom->GetCradleWall(2));
1461     for (j=0; j<2; j++) {
1462       copy = 2*i + j;
1463       x0 = (2*j-1) * geom->GetDistanceBetwRails()  / 2.0 ;
1464       gMC->Gspos("PWHE", copy, "ALIC", x0, y0, z0, 0, "ONLY") ; 
1465     }
1466   }
1467
1468 }
1469
1470 //____________________________________________________________________________
1471 Float_t AliPHOSv0::ZMin(void) const
1472 {
1473   // Overall dimension of the PHOS (min)
1474   // Take it twice more than the PHOS module size
1475
1476   AliPHOSGeometry * geom = GetGeometry() ; 
1477
1478   return -geom->GetOuterBoxSize(2);
1479 }
1480
1481 //____________________________________________________________________________
1482 Float_t AliPHOSv0::ZMax(void) const
1483 {
1484   // Overall dimension of the PHOS (max)
1485   // Take it twice more than the PHOS module size
1486
1487   AliPHOSGeometry * geom = GetGeometry() ; 
1488
1489   return  geom->GetOuterBoxSize(2);
1490 }
1491
1492 //____________________________________________________________________________
1493 void AliPHOSv0::Init(void)
1494 {
1495   // Just prints an information message
1496   
1497   Int_t i;
1498
1499   if(fDebug) {
1500     printf("\n%s: ",ClassName());
1501     for(i=0;i<35;i++) printf("*");
1502     printf(" PHOS_INIT ");
1503     for(i=0;i<35;i++) printf("*");
1504     printf("\n%s: ",ClassName());
1505     
1506     
1507     // Here the PHOS initialisation code (if any!)
1508
1509     AliPHOSGeometry * geom = GetGeometry() ; 
1510
1511     if (geom!=0)  
1512       cout << "AliPHOS" << Version() << " : PHOS geometry intialized for " << geom->GetName() << endl ;
1513     else
1514       cout << "AliPHOS" << Version() << " : PHOS geometry initialization failed !" << endl ;   
1515     
1516     for(i=0;i<80;i++) printf("*");
1517     printf("\n");
1518   }  
1519 }
1520