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