]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv0.cxx
Consistence with new AliPHOSGetter interface
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv0.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id$ */
16
17
18 //_________________________________________________________________________
19 // Implementation version v0 of PHOS Manager class 
20 // 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 #include "TTree.h"
37
38
39 // --- Standard library ---
40
41 #include <stdio.h>
42 #include <string.h>
43 #include <stdlib.h>
44 #include <strstream.h>
45
46 // --- AliRoot header files ---
47
48 #include "AliPHOSv0.h"
49 #include "AliRun.h"
50 #include "AliConst.h"
51 #include "AliMC.h"
52 #include "AliPHOSGeometry.h"
53 #include "AliPHOSGetter.h"
54
55 ClassImp(AliPHOSv0)
56
57 //____________________________________________________________________________
58 AliPHOSv0::AliPHOSv0(const char *name, const char *title):
59   AliPHOS(name,title)
60 {
61   // ctor : title is used to identify the layout
62   //        GPS2 = 5 modules (EMC + PPSD)
63   //        IHEP = 5 modules (EMC + CPV)
64   //        MIXT = 4 modules (EMC + CPV) and 1 module (EMC + PPSD)
65  
66   // create the geometry parameters object  
67   // and post it to a folder (Post retrieves the correct geometry)
68   AliPHOSGetter::GetInstance(gDirectory->GetName(), 0)->PostGeometry() ; 
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
447           y = ( geom->GetMicromegas2Thickness() - geom->GetLidThickness() ) / 2. ; 
448           sprintf(nodename, "%s%d%d%d", "Lidb", i, iphi, iz) ;
449
450           TNode * toplidbnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
451           toplidbnode->SetLineColor(kColorPPSD) ;  
452           fNodes->Add(toplidbnode) ; 
453           //      b. composite panel
454
455           y = y - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; 
456           sprintf(nodename, "%s%d%d%d", "CompUb", i, iphi, iz) ;
457
458           TNode * compupbnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
459           compupbnode->SetLineColor(kColorPPSD) ;  
460           fNodes->Add(compupbnode) ; 
461           //      c. anode
462
463           y = y - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness()  / 2. ; 
464           sprintf(nodename, "%s%d%d%d", "Anob", i, iphi, iz) ;
465
466           TNode * anodebnode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
467           anodebnode->SetLineColor(kColorPPSD) ;  
468           fNodes->Add(anodebnode) ; 
469           //      d. conversion gas
470
471           y = y - geom->GetAnodeThickness() / 2. - ( geom->GetConversionGap() +  geom->GetAvalancheGap() )  / 2. ; 
472           sprintf(nodename, "%s%d%d%d", "GGapb", i, iphi, iz) ;
473
474           TNode * ggapbnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
475           ggapbnode->SetLineColor(kColorGas) ;  
476           fNodes->Add(ggapbnode) ;           
477           //      f. cathode
478
479           y = y - ( geom->GetConversionGap() + geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness()  / 2. ; 
480           sprintf(nodename, "%s%d%d%d", "Cathodeb", i, iphi, iz) ;
481
482           TNode * cathodebnode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
483           cathodebnode->SetLineColor(kColorPPSD) ;  
484           fNodes->Add(cathodebnode) ;        
485           //      g. printed circuit
486           y = y - geom->GetCathodeThickness() / 2. - geom->GetPCThickness()  / 2. ; 
487           sprintf(nodename, "%s%d%d%d", "PCb", i, iphi, iz) ;
488           TNode * pcbnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
489           pcbnode->SetLineColor(kColorPPSD) ;  
490           fNodes->Add(pcbnode) ;        
491           //      h. composite pane
492           y = y - geom->GetPCThickness() / 2. - geom->GetCompositeThickness()  / 2. ; 
493           sprintf(nodename, "%s%d%d%d", "CompDownb", i, iphi, iz) ;
494           TNode * compdownbnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
495           compdownbnode->SetLineColor(kColorPPSD) ;  
496           fNodes->Add(compdownbnode) ;        
497           z = z - geom->GetPPSDModuleSize(2) ;
498           ppsdboxnode->cd() ;
499         } // end of Z module loop     
500         x = x -  geom->GetPPSDModuleSize(0) ; 
501         ppsdboxnode->cd() ;
502       } // end of phi module loop
503     }
504   } // PHOS modules
505  
506   delete[] rotname ;  
507   delete[] nodename ; 
508
509 }
510
511 //____________________________________________________________________________
512 void AliPHOSv0:: BuildGeometryforCPV(void)
513 {
514   //  Build the PHOS-CPV geometry for the ROOT display
515   //  Author: Yuri Kharlov 11 September 2000
516   //
517   //BEGIN_HTML
518   /*
519     <H2>
520     CPV displayed by root
521     </H2>
522     <table width=700>
523
524     <tr>
525          <td>CPV perspective view</td>
526          <td>CPV front view      </td>
527     </tr>
528
529     <tr>
530          <td> <img height=300 width=290 src="../images/CPVRootPersp.gif"> </td>
531          <td> <img height=300 width=290 src="../images/CPVRootFront.gif"> </td>
532     </tr>
533
534     </table>
535
536   */
537   //END_HTML  
538
539   const Double_t kRADDEG         = 180.0 / kPI ;
540   const Int_t    kColorCPV       = kGreen ;
541   const Int_t    kColorFrame     = kYellow ;
542   const Int_t    kColorGassiplex = kRed;
543   const Int_t    kColorPCB       = kCyan;
544
545   AliPHOSGeometry * geom = GetGeometry() ; 
546
547   // Box for a full PHOS module
548
549   new TBRIK ("CPVBox", "CPV box", "void",                   geom->GetCPVBoxSize(0)/2,
550                                                             geom->GetCPVBoxSize(1)/2,
551                                                             geom->GetCPVBoxSize(2)/2 );
552   new TBRIK ("CPVFrameLR", "CPV frame Left-Right", "void",  geom->GetCPVFrameSize(0)/2,
553                                                             geom->GetCPVFrameSize(1)/2,
554                                                             geom->GetCPVBoxSize(2)/2 );
555   new TBRIK ("CPVFrameUD", "CPV frame Up-Down",    "void",  geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0),
556                                                             geom->GetCPVFrameSize(1)/2,
557                                                             geom->GetCPVFrameSize(2)/2);
558   new TBRIK ("CPVPCB",    "CPV PCB",               "void",  geom->GetCPVActiveSize(0)/2,
559                                                             geom->GetCPVTextoliteThickness()/2,
560                                                             geom->GetCPVActiveSize(1)/2);
561   new TBRIK ("CPVGassiplex", "CPV Gassiplex PCB",  "void",  geom->GetGassiplexChipSize(0)/2,
562                                                             geom->GetGassiplexChipSize(1)/2,
563                                                             geom->GetGassiplexChipSize(2)/2);
564
565   // position CPV into ALICE
566
567   char * nodename = new char[25] ;
568   char * rotname  = new char[25] ;
569   
570   Float_t r = geom->GetIPtoCPVDistance() + geom->GetCPVBoxSize(1) / 2.0 ;
571   Int_t number = 988 ; 
572   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
573
574   Int_t lastModule = 0 ;
575   if      (strcmp(geom->GetName(),"IHEP") == 0) 
576     lastModule = geom->GetNModules();
577   else if (strcmp(geom->GetName(),"MIXT") == 0) 
578     lastModule = geom->GetNModules() - geom->GetNPPSDModules();
579   
580   for( Int_t i = 1; i <= lastModule; i++ ) { // the number of PHOS modules
581
582     // One CPV module
583
584     Float_t angle = geom->GetPHOSAngle(i) ;
585     sprintf(rotname, "%s%d", "rotg", number+i) ;
586     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
587     top->cd();
588     sprintf(nodename, "%s%d", "CPVModule", i) ;    
589     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
590     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
591     Float_t z;
592     TNode * cpvBoxNode = new TNode(nodename , nodename ,"CPVBox", x, y, 0, rotname ) ;
593     cpvBoxNode->SetLineColor(kColorCPV) ;
594     fNodes->Add(cpvBoxNode) ;
595     cpvBoxNode->cd() ;
596
597     // inside each CPV box:
598
599     // Frame around CPV
600     Int_t j;
601     for (j=0; j<=1; j++) {
602       sprintf(nodename, "CPVModule%d Frame%d", i, j+1) ;
603       x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
604       TNode * cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameLR", x, 0, 0) ;
605       cpvFrameNode->SetLineColor(kColorFrame) ;
606       fNodes->Add(cpvFrameNode) ;
607
608       sprintf(nodename, "CPVModule%d Frame%d", i, j+3) ;
609       z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
610       cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameUD", 0, 0, z) ;
611       cpvFrameNode->SetLineColor(kColorFrame) ;
612       fNodes->Add(cpvFrameNode) ;
613     }
614
615     // 4 printed circuit boards
616     for (j=0; j<4; j++) {
617       sprintf(nodename, "CPVModule%d PCB%d", i, j+1) ;
618       y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(j) + geom->GetCPVTextoliteThickness()/2;
619       TNode * cpvPCBNode = new TNode(nodename , nodename ,"CPVPCB", 0, y, 0) ;
620       cpvPCBNode->SetLineColor(kColorPCB) ;
621       fNodes->Add(cpvPCBNode) ;
622     }
623
624     // Gassiplex chips
625     Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
626     Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
627     y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
628         geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
629     for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
630       x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
631       for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
632         z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
633         sprintf(nodename, "CPVModule%d Chip(%dx%d)", i, ix+1,iz+1) ;
634         TNode * cpvGassiplexNode = new TNode(nodename , nodename ,"CPVGassiplex", x, y, z) ;
635         cpvGassiplexNode->SetLineColor(kColorGassiplex) ;
636         fNodes->Add(cpvGassiplexNode) ;
637       }
638     }
639
640   } // PHOS modules
641  
642   delete[] rotname ;  
643   delete[] nodename ; 
644 }
645
646 //____________________________________________________________________________
647 void AliPHOSv0::CreateGeometry()
648 {
649   // Create the PHOS geometry for Geant
650
651   AliPHOSv0 *phostmp = (AliPHOSv0*)gAlice->GetModule("PHOS") ;
652
653   if ( phostmp == NULL ) {
654     
655     fprintf(stderr, "PHOS detector not found!\n") ;
656     return;
657     
658   }
659
660   AliPHOSGeometry * geom = GetGeometry() ; 
661
662   // Get pointer to the array containing media indeces
663   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
664
665   // Create a box a PHOS module.
666   // In case of MIXT geometry 2 different boxes are needed
667
668   Float_t bigbox[3] ; 
669   bigbox[0] =   geom->GetOuterBoxSize(0) / 2.0 ;
670   bigbox[1] = ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
671   bigbox[2] =   geom->GetOuterBoxSize(2) / 2.0 ;
672   
673     gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
674
675   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
676     gMC->Gsvolu("PHO1", "BOX ", idtmed[798], bigbox, 3) ;
677   
678     this->CreateGeometryforPHOS() ; 
679   if      ( strcmp( geom->GetName(), "GPS2") == 0  ) 
680     this->CreateGeometryforPPSD() ;
681   else if ( strcmp( geom->GetName(), "IHEP") == 0  ) 
682     this->CreateGeometryforCPV() ;
683   else if ( strcmp( geom->GetName(), "MIXT") == 0  ) {
684     this->CreateGeometryforPPSD() ;
685     this->CreateGeometryforCPV() ;
686   }
687   else
688     cout << "AliPHOSv0::CreateGeometry : no charged particle identification system installed" << endl; 
689
690   this->CreateGeometryforSupport() ; 
691   
692   // --- Position  PHOS mdules in ALICE setup ---
693   
694   Int_t idrotm[99] ;
695   Double_t const kRADDEG = 180.0 / kPI ;
696   
697   Int_t lastModule;
698   if (strcmp(geom->GetName(),"MIXT") == 0) 
699     lastModule = geom->GetNModules() - geom->GetNPPSDModules();
700   else
701     lastModule = geom->GetNModules();
702
703   Int_t i;
704   for( i = 1; i <= lastModule ; i++ ) {
705     
706     Float_t angle = geom->GetPHOSAngle(i) ;
707     AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
708  
709     Float_t r = geom->GetIPtoOuterCoverDistance() + ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
710
711     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
712     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
713
714     gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
715  
716   } // for GetNModules
717
718   for( i = lastModule+1; i <= geom->GetNModules(); i++ ) {
719     
720     Float_t angle = geom->GetPHOSAngle(i) ;
721     AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
722  
723     Float_t r = geom->GetIPtoOuterCoverDistance() + ( geom->GetOuterBoxSize(1) + geom->GetCPVBoxSize(1) ) / 2.0 ;
724
725     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
726     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
727
728     gMC->Gspos("PHO1", i-lastModule, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
729  
730   } // for GetNModules
731
732 }
733
734 //____________________________________________________________________________
735 void AliPHOSv0::CreateGeometryforPHOS()
736 {
737   // Create the PHOS-EMC geometry for GEANT
738     //BEGIN_HTML
739   /*
740     <H2>
741     Geant3 geometry tree of PHOS-EMC in ALICE
742     </H2>
743     <P><CENTER>
744     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif"> 
745     </CENTER><P>
746   */
747   //END_HTML  
748   
749   // Get pointer to the array containing media indexes
750   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
751
752   AliPHOSGeometry * geom = GetGeometry() ; 
753
754   // ---
755   // --- Define PHOS box volume, fPUFPill with thermo insulating foam ---
756   // --- Foam Thermo Insulating outer cover dimensions ---
757   // --- Put it in bigbox = PHOS
758
759   Float_t dphos[3] ; 
760   dphos[0] =  geom->GetOuterBoxSize(0) / 2.0 ;
761   dphos[1] =  geom->GetOuterBoxSize(1) / 2.0 ;
762   dphos[2] =  geom->GetOuterBoxSize(2) / 2.0 ;
763
764   gMC->Gsvolu("PEMC", "BOX ", idtmed[706], dphos, 3) ;
765
766   Float_t yO =  - geom->GetCPVBoxSize(1)  / 2.0 ;
767
768     gMC->Gspos("PEMC", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
769   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
770     gMC->Gspos("PEMC", 1, "PHO1", 0.0, yO, 0.0, 0, "ONLY") ; 
771
772   // ---
773   // --- Define Textolit Wall box, position inside PEMC ---
774   // --- Textolit Wall box dimentions ---
775  
776  
777   Float_t dptxw[3];
778   dptxw[0] = geom->GetTextolitBoxSize(0) / 2.0 ;
779   dptxw[1] = geom->GetTextolitBoxSize(1) / 2.0 ;
780   dptxw[2] = geom->GetTextolitBoxSize(2) / 2.0 ;
781
782   gMC->Gsvolu("PTXW", "BOX ", idtmed[707], dptxw, 3);
783
784   yO =   (  geom->GetOuterBoxThickness(1) -   geom->GetUpperPlateThickness() ) / 2.  ;
785    
786   gMC->Gspos("PTXW", 1, "PEMC", 0.0, yO, 0.0, 0, "ONLY") ;
787
788   // --- 
789   // --- Define Upper Polystyrene Foam Plate, place inside PTXW ---
790   // --- immediately below Foam Thermo Insulation Upper plate ---
791
792   // --- Upper Polystyrene Foam plate thickness ---
793  
794   Float_t  dpufp[3] ;
795   dpufp[0] = geom->GetTextolitBoxSize(0) / 2.0 ; 
796   dpufp[1] = geom->GetSecondUpperPlateThickness() / 2. ;
797   dpufp[2] = geom->GetTextolitBoxSize(2) /2.0 ; 
798
799   gMC->Gsvolu("PUFP", "BOX ", idtmed[703], dpufp, 3) ;
800   
801   yO = ( geom->GetTextolitBoxSize(1) -  geom->GetSecondUpperPlateThickness() ) / 2.0 ;
802   
803   gMC->Gspos("PUFP", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
804   
805   // ---
806   // --- Define air-filled box, place inside PTXW ---
807   // --- Inner AIR volume dimensions ---
808  
809
810   Float_t  dpair[3] ;
811   dpair[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
812   dpair[1] = geom->GetAirFilledBoxSize(1) / 2.0 ;
813   dpair[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
814
815   gMC->Gsvolu("PAIR", "BOX ", idtmed[798], dpair, 3) ;
816   
817   yO = ( geom->GetTextolitBoxSize(1) -  geom->GetAirFilledBoxSize(1) ) / 2.0 -   geom->GetSecondUpperPlateThickness() ;
818   
819   gMC->Gspos("PAIR", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
820
821 // --- Dimensions of PbWO4 crystal ---
822
823   Float_t xtlX =  geom->GetCrystalSize(0) ; 
824   Float_t xtlY =  geom->GetCrystalSize(1) ; 
825   Float_t xtlZ =  geom->GetCrystalSize(2) ; 
826
827   Float_t dptcb[3] ;  
828   dptcb[0] =  geom->GetNPhi() * ( xtlX + 2 *  geom->GetGapBetweenCrystals() ) / 2.0 + geom->GetModuleBoxThickness() ;
829   dptcb[1] = ( xtlY +  geom->GetCrystalSupportHeight() +  geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 
830              + geom->GetModuleBoxThickness() / 2.0 ;
831   dptcb[2] = geom->GetNZ() * ( xtlZ + 2 * geom->GetGapBetweenCrystals() ) / 2.0 +  geom->GetModuleBoxThickness() ;
832   
833   gMC->Gsvolu("PTCB", "BOX ", idtmed[706], dptcb, 3) ;
834
835   yO =  geom->GetAirFilledBoxSize(1) / 2.0 - dptcb[1] 
836        - ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetModuleBoxThickness() 
837        -  geom->GetUpperPlateThickness() -  geom->GetSecondUpperPlateThickness() ) ;
838   
839   gMC->Gspos("PTCB", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
840
841   // ---
842   // --- Define Crystal BLock filled with air, position it inside PTCB ---
843   Float_t dpcbl[3] ; 
844   
845   dpcbl[0] = geom->GetNPhi() * ( xtlX + 2 * geom->GetGapBetweenCrystals() ) / 2.0 ;
846   dpcbl[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
847   dpcbl[2] = geom->GetNZ() * ( xtlZ + 2 * geom->GetGapBetweenCrystals() ) / 2.0 ;
848   
849   gMC->Gsvolu("PCBL", "BOX ", idtmed[798], dpcbl, 3) ;
850   
851   // --- Divide PCBL in X (phi) and Z directions --
852   gMC->Gsdvn("PROW", "PCBL", Int_t (geom->GetNPhi()), 1) ;
853   gMC->Gsdvn("PCEL", "PROW", Int_t (geom->GetNZ()), 3) ;
854
855   yO = -geom->GetModuleBoxThickness() / 2.0 ;
856   
857   gMC->Gspos("PCBL", 1, "PTCB", 0.0, yO, 0.0, 0, "ONLY") ;
858
859   // ---
860   // --- Define STeel (actually, it's titanium) Cover volume, place inside PCEL
861   Float_t  dpstc[3] ; 
862   
863   dpstc[0] = ( xtlX + 2 * geom->GetCrystalWrapThickness() ) / 2.0 ;
864   dpstc[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
865   dpstc[2] = ( xtlZ + 2 * geom->GetCrystalWrapThickness()  + 2 *  geom->GetCrystalHolderThickness() ) / 2.0 ;
866   
867   gMC->Gsvolu("PSTC", "BOX ", idtmed[704], dpstc, 3) ;
868
869   gMC->Gspos("PSTC", 1, "PCEL", 0.0, 0.0, 0.0, 0, "ONLY") ;
870
871   // ---
872   // --- Define Tyvek volume, place inside PSTC ---
873   Float_t  dppap[3] ;
874
875   dppap[0] = xtlX / 2.0 + geom->GetCrystalWrapThickness() ;
876   dppap[1] = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 ;
877   dppap[2] = xtlZ / 2.0 + geom->GetCrystalWrapThickness() ;
878   
879   gMC->Gsvolu("PPAP", "BOX ", idtmed[702], dppap, 3) ;
880   
881   yO = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 
882               - ( xtlY +  geom->GetCrystalSupportHeight() +  geom->GetCrystalWrapThickness() + geom->GetCrystalHolderThickness() ) / 2.0 ;
883    
884   gMC->Gspos("PPAP", 1, "PSTC", 0.0, yO, 0.0, 0, "ONLY") ;
885
886   // ---
887   // --- Define PbWO4 crystal volume, place inside PPAP ---
888   Float_t  dpxtl[3] ; 
889
890   dpxtl[0] = xtlX / 2.0 ;
891   dpxtl[1] = xtlY / 2.0 ;
892   dpxtl[2] = xtlZ / 2.0 ;
893   
894   gMC->Gsvolu("PXTL", "BOX ", idtmed[699], dpxtl, 3) ;
895
896   yO = ( xtlY + geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 - xtlY / 2.0 - geom->GetCrystalWrapThickness() ;
897   
898   gMC->Gspos("PXTL", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
899
900   // ---
901   // --- Define crystal support volume, place inside PPAP ---
902   Float_t dpsup[3] ; 
903
904   dpsup[0] = xtlX / 2.0 + geom->GetCrystalWrapThickness()  ;
905   dpsup[1] = geom->GetCrystalSupportHeight() / 2.0 ;
906   dpsup[2] = xtlZ / 2.0 +  geom->GetCrystalWrapThickness() ;
907
908   gMC->Gsvolu("PSUP", "BOX ", idtmed[798], dpsup, 3) ;
909
910   yO =  geom->GetCrystalSupportHeight() / 2.0 - ( xtlY +  geom->GetCrystalSupportHeight() + geom->GetCrystalWrapThickness() ) / 2.0 ;
911
912   gMC->Gspos("PSUP", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
913
914   // ---
915   // --- Define PIN-diode volume and position it inside crystal support ---
916   // --- right behind PbWO4 crystal
917
918   // --- PIN-diode dimensions ---
919
920  
921   Float_t dppin[3] ;
922   dppin[0] = geom->GetPinDiodeSize(0) / 2.0 ;
923   dppin[1] = geom->GetPinDiodeSize(1) / 2.0 ;
924   dppin[2] = geom->GetPinDiodeSize(2) / 2.0 ;
925  
926   gMC->Gsvolu("PPIN", "BOX ", idtmed[705], dppin, 3) ;
927  
928   yO = geom->GetCrystalSupportHeight() / 2.0 - geom->GetPinDiodeSize(1) / 2.0 ;
929  
930   gMC->Gspos("PPIN", 1, "PSUP", 0.0, yO, 0.0, 0, "ONLY") ;
931
932   // ---
933   // --- Define Upper Cooling Panel, place it on top of PTCB ---
934   Float_t dpucp[3] ;
935  // --- Upper Cooling Plate thickness ---
936  
937   dpucp[0] = dptcb[0] ;
938   dpucp[1] = geom->GetUpperCoolingPlateThickness() ;
939   dpucp[2] = dptcb[2] ;
940   
941   gMC->Gsvolu("PUCP", "BOX ", idtmed[701], dpucp,3) ;
942   
943   yO = geom->GetAirFilledBoxSize(1) / 2. 
944     -( geom->GetIPtoCrystalSurface()  - geom->GetIPtoOuterCoverDistance()    - geom->GetModuleBoxThickness()
945       -geom->GetUpperPlateThickness() - geom->GetSecondUpperPlateThickness() - geom->GetUpperCoolingPlateThickness() ) ; 
946   
947   gMC->Gspos("PUCP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
948
949   // ---
950   // --- Define Al Support Plate, position it inside PAIR ---
951   // --- right beneath PTCB ---
952  // --- Al Support Plate thickness ---
953  
954   Float_t dpasp[3] ;
955   dpasp[0] =  geom->GetAirFilledBoxSize(0) / 2.0 ;
956   dpasp[1] = geom->GetSupportPlateThickness() / 2.0 ;
957   dpasp[2] =  geom->GetAirFilledBoxSize(2) / 2.0 ;
958   
959   gMC->Gsvolu("PASP", "BOX ", idtmed[701], dpasp, 3) ;
960   
961   yO = (  geom->GetAirFilledBoxSize(1) - geom->GetSupportPlateThickness() ) / 2. 
962        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance()
963            - geom->GetUpperPlateThickness() - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 ) ;
964   
965   gMC->Gspos("PASP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
966
967   // ---
968   // --- Define Thermo Insulating Plate, position it inside PAIR ---
969   // --- right beneath PASP ---
970   // --- Lower Thermo Insulating Plate thickness ---
971   
972   Float_t dptip[3] ;
973   dptip[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
974   dptip[1] = geom->GetLowerThermoPlateThickness() / 2.0 ;
975   dptip[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
976
977   gMC->Gsvolu("PTIP", "BOX ", idtmed[706], dptip, 3) ;
978
979   yO =  ( geom->GetAirFilledBoxSize(1) - geom->GetLowerThermoPlateThickness() ) / 2. 
980        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetUpperPlateThickness() 
981             - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + geom->GetSupportPlateThickness() ) ;
982
983   gMC->Gspos("PTIP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
984
985   // ---
986   // --- Define Textolit Plate, position it inside PAIR ---
987   // --- right beneath PTIP ---
988   // --- Lower Textolit Plate thickness ---
989  
990   Float_t dptxp[3] ;
991   dptxp[0] = geom->GetAirFilledBoxSize(0) / 2.0 ;
992   dptxp[1] = geom->GetLowerTextolitPlateThickness() / 2.0 ;
993   dptxp[2] = geom->GetAirFilledBoxSize(2) / 2.0 ;
994
995   gMC->Gsvolu("PTXP", "BOX ", idtmed[707], dptxp, 3) ;
996
997   yO =  ( geom->GetAirFilledBoxSize(1) - geom->GetLowerTextolitPlateThickness() ) / 2. 
998        -  ( geom->GetIPtoCrystalSurface() - geom->GetIPtoOuterCoverDistance() - geom->GetUpperPlateThickness() 
999             - geom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + geom->GetSupportPlateThickness() 
1000             +  geom->GetLowerThermoPlateThickness() ) ;
1001
1002   gMC->Gspos("PTXP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
1003
1004 }
1005
1006 //____________________________________________________________________________
1007 void AliPHOSv0::CreateGeometryforPPSD()
1008 {
1009   // Create the PHOS-PPSD geometry for GEANT
1010   //BEGIN_HTML
1011   /*
1012     <H2>
1013     Geant3 geometry tree of PHOS-PPSD in ALICE
1014     </H2>
1015     <P><CENTER>
1016     <IMG Align=BOTTOM ALT="PPSD geant tree" SRC="../images/PPSDinAlice.gif"> 
1017     </CENTER><P>
1018   */
1019   //END_HTML  
1020
1021   // Get pointer to the array containing media indexes
1022   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1023
1024   AliPHOSGeometry * geom = GetGeometry() ; 
1025
1026   // The box containing all ppsd's for one PHOS module filled with air 
1027   Float_t ppsd[3] ; 
1028   ppsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
1029   ppsd[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
1030   ppsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1031
1032   gMC->Gsvolu("PPSD", "BOX ", idtmed[798], ppsd, 3) ;
1033
1034   Float_t yO =  geom->GetOuterBoxSize(1) / 2.0 ;
1035
1036   if ( strcmp( geom->GetName(),"MIXT") == 0 && geom->GetNPPSDModules() > 0) 
1037     gMC->Gspos("PPSD", 1, "PHO1", 0.0, yO, 0.0, 0, "ONLY") ; 
1038   else
1039     gMC->Gspos("PPSD", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
1040
1041   // Now we build a micromegas module
1042   // The box containing the whole module filled with epoxy (FR4)
1043
1044   Float_t mppsd[3] ;  
1045   mppsd[0] = geom->GetPPSDModuleSize(0) / 2.0 ;  
1046   mppsd[1] = geom->GetPPSDModuleSize(1) / 2.0 ;  
1047   mppsd[2] = geom->GetPPSDModuleSize(2) / 2.0 ;
1048
1049   gMC->Gsvolu("PMPP", "BOX ", idtmed[708], mppsd, 3) ;  
1050  
1051   // Inside mppsd :
1052   // 1. The Top Lid made of epoxy (FR4) 
1053
1054   Float_t tlppsd[3] ; 
1055   tlppsd[0] = geom->GetPPSDModuleSize(0) / 2.0 ; 
1056   tlppsd[1] = geom->GetLidThickness() / 2.0 ;
1057   tlppsd[2] = geom->GetPPSDModuleSize(2) / 2.0 ;
1058
1059   gMC->Gsvolu("PTLP", "BOX ", idtmed[708], tlppsd, 3) ; 
1060
1061   Float_t  y0 = ( geom->GetMicromegas1Thickness() - geom->GetLidThickness() ) / 2. ; 
1062
1063   gMC->Gspos("PTLP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1064  
1065   // 2. the upper panel made of composite material
1066
1067   Float_t upppsd[3] ; 
1068   upppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1069   upppsd[1] = geom->GetCompositeThickness() / 2.0 ;
1070   upppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1071  
1072   gMC->Gsvolu("PUPP", "BOX ", idtmed[709], upppsd, 3) ; 
1073   
1074   y0 = y0 - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; 
1075
1076   gMC->Gspos("PUPP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1077
1078   // 3. the anode made of Copper
1079   
1080   Float_t anppsd[3] ; 
1081   anppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ; 
1082   anppsd[1] = geom->GetAnodeThickness() / 2.0 ; 
1083   anppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0  ; 
1084
1085   gMC->Gsvolu("PANP", "BOX ", idtmed[710], anppsd, 3) ; 
1086   
1087   y0 = y0 - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness()  / 2. ; 
1088   
1089   gMC->Gspos("PANP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1090
1091   // 4. the conversion gap + avalanche gap filled with gas
1092
1093   Float_t ggppsd[3] ; 
1094   ggppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1095   ggppsd[1] = ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2.0 ; 
1096   ggppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1097
1098   gMC->Gsvolu("PGGP", "BOX ", idtmed[715], ggppsd, 3) ; 
1099   
1100   // --- Divide GGPP in X (phi) and Z directions --
1101   gMC->Gsdvn("PPRO", "PGGP", geom->GetNumberOfPadsPhi(), 1) ;
1102   gMC->Gsdvn("PPCE", "PPRO", geom->GetNumberOfPadsZ() ,  3) ;
1103
1104   y0 = y0 - geom->GetAnodeThickness() / 2.  - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. ; 
1105
1106   gMC->Gspos("PGGP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1107
1108
1109   // 6. the cathode made of Copper
1110
1111   Float_t cappsd[3] ;
1112   cappsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1113   cappsd[1] = geom->GetCathodeThickness() / 2.0 ; 
1114   cappsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0  ;
1115
1116   gMC->Gsvolu("PCAP", "BOX ", idtmed[710], cappsd, 3) ; 
1117
1118   y0 = y0 - ( geom->GetConversionGap() +  geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness()  / 2. ; 
1119
1120   gMC->Gspos("PCAP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1121
1122   // 7. the printed circuit made of G10       
1123
1124   Float_t pcppsd[3] ; 
1125   pcppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2,.0 ; 
1126   pcppsd[1] = geom->GetPCThickness() / 2.0 ; 
1127   pcppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1128
1129   gMC->Gsvolu("PCPS", "BOX ", idtmed[711], cappsd, 3) ; 
1130
1131   y0 = y0 - geom->GetCathodeThickness() / 2. - geom->GetPCThickness()  / 2. ; 
1132
1133   gMC->Gspos("PCPS", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1134
1135   // 8. the lower panel made of composite material
1136                                                     
1137   Float_t lpppsd[3] ; 
1138   lpppsd[0] = ( geom->GetPPSDModuleSize(0) - geom->GetMicromegasWallThickness() ) / 2.0 ; 
1139   lpppsd[1] = geom->GetCompositeThickness() / 2.0 ; 
1140   lpppsd[2] = ( geom->GetPPSDModuleSize(2) - geom->GetMicromegasWallThickness() ) / 2.0 ;
1141
1142   gMC->Gsvolu("PLPP", "BOX ", idtmed[709], lpppsd, 3) ; 
1143  
1144   y0 = y0 - geom->GetPCThickness() / 2. - geom->GetCompositeThickness()  / 2. ; 
1145
1146   gMC->Gspos("PLPP", 1, "PMPP", 0.0, y0, 0.0, 0, "ONLY") ; 
1147
1148   // Position the  fNumberOfModulesPhi x fNumberOfModulesZ modules (mppsd) inside PPSD to cover a PHOS module
1149   // the top and bottom one's (which are assumed identical) :
1150
1151    Float_t yt = ( geom->GetCPVBoxSize(1) - geom->GetMicromegas1Thickness() ) / 2. ; 
1152    Float_t yb = - ( geom->GetCPVBoxSize(1) - geom->GetMicromegas2Thickness() ) / 2. ; 
1153
1154    Int_t copyNumbertop = 0 ; 
1155    Int_t copyNumberbot = geom->GetNumberOfModulesPhi() *  geom->GetNumberOfModulesZ() ; 
1156
1157    Float_t x  = ( geom->GetCPVBoxSize(0) - geom->GetPPSDModuleSize(0) ) / 2. ;  
1158
1159    for ( Int_t iphi = 1; iphi <= geom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
1160       Float_t z = ( geom->GetCPVBoxSize(2) - geom->GetPPSDModuleSize(2) ) / 2. ;
1161
1162       for ( Int_t iz = 1; iz <= geom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
1163         gMC->Gspos("PMPP", ++copyNumbertop, "PPSD", x, yt, z, 0, "ONLY") ;
1164         gMC->Gspos("PMPP", ++copyNumberbot, "PPSD", x, yb, z, 0, "ONLY") ; 
1165         z = z - geom->GetPPSDModuleSize(2) ;
1166       } // end of Z module loop   
1167       x = x -  geom->GetPPSDModuleSize(0) ; 
1168     } // end of phi module loop
1169
1170    // The Lead converter between two air gaps
1171    // 1. Upper air gap
1172
1173    Float_t uappsd[3] ;
1174    uappsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;
1175    uappsd[1] = geom->GetMicro1ToLeadGap() / 2.0 ; 
1176    uappsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1177
1178   gMC->Gsvolu("PUAPPS", "BOX ", idtmed[798], uappsd, 3) ; 
1179
1180   y0 = ( geom->GetCPVBoxSize(1) - 2 * geom->GetMicromegas1Thickness() - geom->GetMicro1ToLeadGap() ) / 2. ; 
1181
1182   gMC->Gspos("PUAPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1183
1184    // 2. Lead converter
1185  
1186   Float_t lcppsd[3] ; 
1187   lcppsd[0] = geom->GetCPVBoxSize(0) / 2.0 ;
1188   lcppsd[1] = geom->GetLeadConverterThickness() / 2.0 ; 
1189   lcppsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1190  
1191   gMC->Gsvolu("PLCPPS", "BOX ", idtmed[712], lcppsd, 3) ; 
1192   
1193   y0 = y0 - geom->GetMicro1ToLeadGap() / 2. - geom->GetLeadConverterThickness() / 2. ; 
1194
1195   gMC->Gspos("PLCPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1196
1197   // 3. Lower air gap
1198
1199   Float_t lappsd[3] ; 
1200   lappsd[0] = geom->GetCPVBoxSize(0) / 2.0 ; 
1201   lappsd[1] = geom->GetLeadToMicro2Gap() / 2.0 ; 
1202   lappsd[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1203
1204   gMC->Gsvolu("PLAPPS", "BOX ", idtmed[798], lappsd, 3) ; 
1205     
1206   y0 = y0 - geom->GetLeadConverterThickness() / 2. - geom->GetLeadToMicro2Gap()  / 2. ; 
1207   
1208   gMC->Gspos("PLAPPS", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
1209    
1210 }
1211
1212
1213 //____________________________________________________________________________
1214 void AliPHOSv0::CreateGeometryforCPV()
1215 {
1216   // Create the PHOS-CPV geometry for GEANT
1217   // Author: Yuri Kharlov 11 September 2000
1218   //BEGIN_HTML
1219   /*
1220     <H2>
1221     Geant3 geometry of PHOS-CPV in ALICE
1222     </H2>
1223     <table width=700>
1224
1225     <tr>
1226          <td>CPV perspective view</td>
1227          <td>CPV front view      </td>
1228     </tr>
1229
1230     <tr>
1231          <td> <img height=300 width=290 src="../images/CPVallPersp.gif"> </td>
1232          <td> <img height=300 width=290 src="../images/CPVallFront.gif"> </td>
1233     </tr>
1234
1235     <tr>
1236          <td>One CPV module, perspective view                            </td>
1237          <td>One CPV module, front view (extended in vertical direction) </td>
1238     </tr>
1239
1240     <tr>
1241          <td><img height=300 width=290 src="../images/CPVmodulePers.gif"></td>
1242          <td><img height=300 width=290 src="../images/CPVmoduleSide.gif"></td>
1243     </tr>
1244
1245     </table>
1246
1247     <H2>
1248     Geant3 geometry tree of PHOS-CPV in ALICE
1249     </H2>
1250     <center>
1251     <img height=300 width=290 src="../images/CPVtree.gif">
1252     </center>
1253   */
1254   //END_HTML  
1255
1256   Float_t par[3], x,y,z;
1257
1258   // Get pointer to the array containing media indexes
1259   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1260
1261   AliPHOSGeometry * geom = GetGeometry() ; 
1262
1263   // The box containing all CPV for one PHOS module filled with air 
1264   par[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
1265   par[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
1266   par[2] = geom->GetCPVBoxSize(2) / 2.0 ;
1267   gMC->Gsvolu("PCPV", "BOX ", idtmed[798], par, 3) ;
1268   
1269   y = geom->GetOuterBoxSize(1) / 2.0 ;
1270   gMC->Gspos("PCPV", 1, "PHOS", 0.0, y, 0.0, 0, "ONLY") ; 
1271   
1272   // Gassiplex board
1273   
1274   par[0] = geom->GetGassiplexChipSize(0)/2.;
1275   par[1] = geom->GetGassiplexChipSize(1)/2.;
1276   par[2] = geom->GetGassiplexChipSize(2)/2.;
1277   gMC->Gsvolu("PCPC","BOX ",idtmed[707],par,3);
1278   
1279   // Cu+Ni foil covers Gassiplex board
1280
1281   par[1] = geom->GetCPVCuNiFoilThickness()/2;
1282   gMC->Gsvolu("PCPD","BOX ",idtmed[710],par,3);
1283   y      = -(geom->GetGassiplexChipSize(1)/2 - par[1]);
1284   gMC->Gspos("PCPD",1,"PCPC",0,y,0,0,"ONLY");
1285
1286   // Position of the chip inside CPV
1287
1288   Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
1289   Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
1290   Int_t   copy  = 0;
1291   y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
1292     geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
1293   for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
1294     x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
1295     for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
1296       copy++;
1297       z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
1298       gMC->Gspos("PCPC",copy,"PCPV",x,y,z,0,"ONLY");
1299     }
1300   }
1301
1302   // Foiled textolite (1 mm of textolite + 50 mkm of Cu + 6 mkm of Ni)
1303   
1304   par[0] = geom->GetCPVActiveSize(0)        / 2;
1305   par[1] = geom->GetCPVTextoliteThickness() / 2;
1306   par[2] = geom->GetCPVActiveSize(1)        / 2;
1307   gMC->Gsvolu("PCPF","BOX ",idtmed[707],par,3);
1308
1309   // Argon gas volume
1310
1311   par[1] = (geom->GetFTPosition(2) - geom->GetFTPosition(1) - geom->GetCPVTextoliteThickness()) / 2;
1312   gMC->Gsvolu("PCPG","BOX ",idtmed[715],par,3);
1313
1314   for (Int_t i=0; i<4; i++) {
1315     y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(i) + geom->GetCPVTextoliteThickness()/2;
1316     gMC->Gspos("PCPF",i+1,"PCPV",0,y,0,0,"ONLY");
1317     if(i==1){
1318       y-= (geom->GetFTPosition(2) - geom->GetFTPosition(1)) / 2;
1319       gMC->Gspos("PCPG",1,"PCPV ",0,y,0,0,"ONLY");
1320     }
1321   }
1322
1323   // Dummy sensitive plane in the middle of argone gas volume
1324
1325   par[1]=0.001;
1326   gMC->Gsvolu("PCPQ","BOX ",idtmed[715],par,3);
1327   gMC->Gspos ("PCPQ",1,"PCPG",0,0,0,0,"ONLY");
1328
1329   // Cu+Ni foil covers textolite
1330
1331   par[1] = geom->GetCPVCuNiFoilThickness() / 2;
1332   gMC->Gsvolu("PCP1","BOX ",idtmed[710],par,3);
1333   y = geom->GetCPVTextoliteThickness()/2 - par[1];
1334   gMC->Gspos ("PCP1",1,"PCPF",0,y,0,0,"ONLY");
1335
1336   // Aluminum frame around CPV
1337
1338   par[0] = geom->GetCPVFrameSize(0)/2;
1339   par[1] = geom->GetCPVFrameSize(1)/2;
1340   par[2] = geom->GetCPVBoxSize(2)  /2;
1341   gMC->Gsvolu("PCF1","BOX ",idtmed[701],par,3);
1342
1343   par[0] = geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0);
1344   par[1] = geom->GetCPVFrameSize(1)/2;
1345   par[2] = geom->GetCPVFrameSize(2)/2;
1346   gMC->Gsvolu("PCF2","BOX ",idtmed[701],par,3);
1347
1348   for (Int_t j=0; j<=1; j++) {
1349     x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
1350     gMC->Gspos("PCF1",j+1,"PCPV", x,0,0,0,"ONLY");
1351     z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
1352     gMC->Gspos("PCF2",j+1,"PCPV",0, 0,z,0,"ONLY");
1353   }
1354
1355 }
1356
1357
1358 //____________________________________________________________________________
1359 void AliPHOSv0::CreateGeometryforSupport()
1360 {
1361   // Create the PHOS' support geometry for GEANT
1362     //BEGIN_HTML
1363   /*
1364     <H2>
1365     Geant3 geometry of the PHOS's support
1366     </H2>
1367     <P><CENTER>
1368     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/PHOS_support.gif"> 
1369     </CENTER><P>
1370   */
1371   //END_HTML  
1372   
1373   Float_t par[5], x0,y0,z0 ; 
1374   Int_t   i,j,copy;
1375
1376   // Get pointer to the array containing media indexes
1377   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
1378
1379   AliPHOSGeometry * geom = GetGeometry() ; 
1380
1381   // --- Dummy box containing two rails on which PHOS support moves
1382   // --- Put these rails to the bottom of the L3 magnet
1383
1384   par[0] =  geom->GetRailRoadSize(0) / 2.0 ;
1385   par[1] =  geom->GetRailRoadSize(1) / 2.0 ;
1386   par[2] =  geom->GetRailRoadSize(2) / 2.0 ;
1387   gMC->Gsvolu("PRRD", "BOX ", idtmed[798], par, 3) ;
1388
1389   y0     = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) / 2.0) ;
1390   gMC->Gspos("PRRD", 1, "ALIC", 0.0, y0, 0.0, 0, "ONLY") ; 
1391
1392   // --- Dummy box containing one rail
1393
1394   par[0] =  geom->GetRailOuterSize(0) / 2.0 ;
1395   par[1] =  geom->GetRailOuterSize(1) / 2.0 ;
1396   par[2] =  geom->GetRailOuterSize(2) / 2.0 ;
1397   gMC->Gsvolu("PRAI", "BOX ", idtmed[798], par, 3) ;
1398
1399   for (i=0; i<2; i++) {
1400     x0     = (2*i-1) * geom->GetDistanceBetwRails()  / 2.0 ;
1401     gMC->Gspos("PRAI", i, "PRRD", x0, 0.0, 0.0, 0, "ONLY") ; 
1402   }
1403
1404   // --- Upper and bottom steel parts of the rail
1405
1406   par[0] =  geom->GetRailPart1(0) / 2.0 ;
1407   par[1] =  geom->GetRailPart1(1) / 2.0 ;
1408   par[2] =  geom->GetRailPart1(2) / 2.0 ;
1409   gMC->Gsvolu("PRP1", "BOX ", idtmed[716], par, 3) ;
1410
1411   y0     = - (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 ;
1412   gMC->Gspos("PRP1", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
1413   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 - geom->GetRailPart3(1);
1414   gMC->Gspos("PRP1", 2, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
1415
1416   // --- The middle vertical steel parts of the rail
1417
1418   par[0] =  geom->GetRailPart2(0) / 2.0 ;
1419   par[1] =  geom->GetRailPart2(1) / 2.0 ;
1420   par[2] =  geom->GetRailPart2(2) / 2.0 ;
1421   gMC->Gsvolu("PRP2", "BOX ", idtmed[716], par, 3) ;
1422
1423   y0     =   - geom->GetRailPart3(1) / 2.0 ;
1424   gMC->Gspos("PRP2", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
1425
1426   // --- The most upper steel parts of the rail
1427
1428   par[0] =  geom->GetRailPart3(0) / 2.0 ;
1429   par[1] =  geom->GetRailPart3(1) / 2.0 ;
1430   par[2] =  geom->GetRailPart3(2) / 2.0 ;
1431   gMC->Gsvolu("PRP3", "BOX ", idtmed[716], par, 3) ;
1432
1433   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart3(1))  / 2.0 ;
1434   gMC->Gspos("PRP3", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
1435
1436   // --- The wall of the cradle
1437   // --- The wall is empty: steel thin walls and air inside
1438
1439   par[1] =  TMath::Sqrt(
1440                         TMath::Power((geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1)),2) +
1441                         TMath::Power((geom->GetOuterBoxSize(0)/2),2)) + 10.;
1442   par[0] =  par[1] - geom->GetCradleWall(1) ;
1443   par[2] =  geom->GetCradleWall(2) / 2.0 ;
1444   par[3] =  geom->GetCradleWall(3) ;
1445   par[4] =  geom->GetCradleWall(4) ;
1446   gMC->Gsvolu("PCRA", "TUBS", idtmed[716], par, 5) ;
1447
1448   par[0] -=  geom->GetCradleWallThickness() ;
1449   par[1] -=  geom->GetCradleWallThickness() ;
1450   par[2] -=  geom->GetCradleWallThickness() ;
1451   gMC->Gsvolu("PCRE", "TUBS", idtmed[798], par, 5) ;
1452   gMC->Gspos ("PCRE", 1, "PCRA", 0.0, 0.0, 0.0, 0, "ONLY") ; 
1453
1454   for (i=0; i<2; i++) {
1455     z0 = (2*i-1) * (geom->GetOuterBoxSize(2) + geom->GetCradleWall(2)) / 2.0 ;
1456     gMC->Gspos("PCRA", i, "ALIC", 0.0, 0.0, z0, 0, "ONLY") ; 
1457   }
1458
1459   // --- The "wheels" of the cradle
1460   
1461   par[0] = geom->GetCradleWheel(0) / 2;
1462   par[1] = geom->GetCradleWheel(1) / 2;
1463   par[2] = geom->GetCradleWheel(2) / 2;
1464   gMC->Gsvolu("PWHE", "BOX ", idtmed[716], par, 3) ;
1465
1466   y0 = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) -
1467          geom->GetCradleWheel(1)/2) ;
1468   for (i=0; i<2; i++) {
1469     z0 = (2*i-1) * ((geom->GetOuterBoxSize(2) + geom->GetCradleWheel(2)) / 2.0 +
1470                     geom->GetCradleWall(2));
1471     for (j=0; j<2; j++) {
1472       copy = 2*i + j;
1473       x0 = (2*j-1) * geom->GetDistanceBetwRails()  / 2.0 ;
1474       gMC->Gspos("PWHE", copy, "ALIC", x0, y0, z0, 0, "ONLY") ; 
1475     }
1476   }
1477
1478 }
1479
1480 //____________________________________________________________________________
1481 Float_t AliPHOSv0::ZMin(void) const
1482 {
1483   // Overall dimension of the PHOS (min)
1484   // Take it twice more than the PHOS module size
1485
1486   AliPHOSGeometry * geom = GetGeometry() ; 
1487
1488   return -geom->GetOuterBoxSize(2);
1489 }
1490
1491 //____________________________________________________________________________
1492 Float_t AliPHOSv0::ZMax(void) const
1493 {
1494   // Overall dimension of the PHOS (max)
1495   // Take it twice more than the PHOS module size
1496
1497   AliPHOSGeometry * geom = GetGeometry() ; 
1498
1499   return  geom->GetOuterBoxSize(2);
1500 }
1501
1502 //____________________________________________________________________________
1503 void AliPHOSv0::Init(void)
1504 {
1505   // Just prints an information message
1506   
1507   Int_t i;
1508
1509   if(fDebug) {
1510     printf("\n%s: ",ClassName());
1511     for(i=0;i<35;i++) printf("*");
1512     printf(" PHOS_INIT ");
1513     for(i=0;i<35;i++) printf("*");
1514     printf("\n%s: ",ClassName());
1515     
1516     
1517     // Here the PHOS initialisation code (if any!)
1518
1519     AliPHOSGeometry * geom = GetGeometry() ; 
1520
1521     if (geom!=0)  
1522       cout << "AliPHOS" << Version() << " : PHOS geometry intialized for " << geom->GetName() << endl ;
1523     else
1524       cout << "AliPHOS" << Version() << " : PHOS geometry initialization failed !" << endl ;   
1525     
1526     for(i=0;i<80;i++) printf("*");
1527     printf("\n");
1528   }  
1529 }
1530
1531