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