]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv0.cxx
Added virtual IsVersion. Print of version defered to Init in AliPHOS
[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 // An object of this class does not produce hits nor digits
22 // It is the one to use if you do not want to produce outputs in TREEH or TREED
23 //                  
24 //*-- Author: Yves Schutz (SUBATECH)
25
26
27 // --- ROOT system ---
28
29 #include "TBRIK.h"
30 #include "TNode.h"
31 #include "TRandom.h"
32
33
34 // --- Standard library ---
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <stdlib.h>
39 #include <strstream.h>
40
41 // --- AliRoot header files ---
42
43 #include "AliPHOSv0.h"
44 #include "AliRun.h"
45 #include "AliConst.h"
46
47 ClassImp(AliPHOSv0)
48
49 //____________________________________________________________________________
50 AliPHOSv0::AliPHOSv0(const char *name, const char *title):
51   AliPHOS(name,title)
52 {
53   // ctor : title is used to identify the layout
54   //        GPS2 = 5 modules (EMC + PPSD)   
55  
56   // gets an instance of the geometry parameters class  
57
58   if (strcmp(GetTitle(),"") != 0 ) 
59     fGeom =  AliPHOSGeometry::GetInstance(GetTitle(), "") ; 
60
61 }
62
63 //____________________________________________________________________________
64 void AliPHOSv0::BuildGeometry()
65 {
66   // Build the PHOS geometry for the ROOT display
67   //BEGIN_HTML
68   /*
69     <H2>
70      PHOS in ALICE displayed by root
71     </H2>
72     <UL>
73     <LI> All Views
74     <P>
75     <CENTER>
76     <IMG Align=BOTTOM ALT="All Views" SRC="../images/AliPHOSv0AllViews.gif"> 
77     </CENTER></P></LI>
78     <LI> Front View
79     <P>
80     <CENTER>
81     <IMG Align=BOTTOM ALT="Front View" SRC="../images/AliPHOSv0FrontView.gif"> 
82     </CENTER></P></LI>
83      <LI> 3D View 1
84     <P>
85     <CENTER>
86     <IMG Align=BOTTOM ALT="3D View 1" SRC="../images/AliPHOSv03DView1.gif"> 
87     </CENTER></P></LI>
88     <LI> 3D View 2
89     <P>
90     <CENTER>
91     <IMG Align=BOTTOM ALT="3D View 2" SRC="../images/AliPHOSv03DView2.gif"> 
92     </CENTER></P></LI>
93     </UL>
94   */
95   //END_HTML  
96
97   this->BuildGeometryforPHOS() ; 
98   if ( ( strcmp(fGeom->GetName(), "GPS2" ) == 0 ) ) 
99     this->BuildGeometryforPPSD() ;
100   else
101     cout << "AliPHOSv0::BuildGeometry : no charged particle identification system installed" << endl; 
102
103 }
104
105 //____________________________________________________________________________
106 void AliPHOSv0:: BuildGeometryforPHOS(void)
107 {
108  // Build the PHOS-EMC geometry for the ROOT display
109
110   const Int_t kColorPHOS = kRed ;
111   const Int_t kColorXTAL = kBlue ;
112
113   Double_t const kRADDEG = 180.0 / kPI ;
114  
115   new TBRIK( "OuterBox", "PHOS box", "void", fGeom->GetOuterBoxSize(0)/2, 
116                                              fGeom->GetOuterBoxSize(1)/2, 
117                                              fGeom->GetOuterBoxSize(2)/2 );
118
119   // Textolit Wall box, position inside PHOS 
120   
121   new TBRIK( "TextolitBox", "PHOS Textolit box ", "void", fGeom->GetTextolitBoxSize(0)/2, 
122                                                           fGeom->GetTextolitBoxSize(1)/2, 
123                                                           fGeom->GetTextolitBoxSize(2)/2);
124
125   // Polystyrene Foam Plate
126
127   new TBRIK( "UpperFoamPlate", "PHOS Upper foam plate", "void", fGeom->GetTextolitBoxSize(0)/2, 
128                                                                 fGeom->GetSecondUpperPlateThickness()/2, 
129                                                                 fGeom->GetTextolitBoxSize(2)/2 ) ; 
130
131   // Air Filled Box
132  
133   new TBRIK( "AirFilledBox", "PHOS air filled box", "void", fGeom->GetAirFilledBoxSize(0)/2, 
134                                                             fGeom->GetAirFilledBoxSize(1)/2, 
135                                                             fGeom->GetAirFilledBoxSize(2)/2 );
136
137   // Crystals Box
138
139   Float_t xtlX = fGeom->GetCrystalSize(0) ; 
140   Float_t xtlY = fGeom->GetCrystalSize(1) ; 
141   Float_t xtlZ = fGeom->GetCrystalSize(2) ; 
142
143   Float_t xl =  fGeom->GetNPhi() * ( xtlX + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
144   Float_t yl =  ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 
145              + fGeom->GetModuleBoxThickness() / 2.0 ;
146   Float_t zl =  fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 +  fGeom->GetModuleBoxThickness() ;
147   
148   new TBRIK( "CrystalsBox", "PHOS crystals box", "void", xl, yl, zl ) ;
149
150 // position PHOS into ALICE
151
152   Float_t r = fGeom->GetIPtoOuterCoverDistance() + fGeom->GetOuterBoxSize(1) / 2.0 ;
153   Int_t number = 988 ; 
154   Float_t pphi =  TMath::ATan( fGeom->GetOuterBoxSize(0)  / ( 2.0 * fGeom->GetIPtoOuterCoverDistance() ) ) ;
155   pphi *= kRADDEG ;
156   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
157  
158   char * nodename = new char[20] ;  
159   char * rotname  = new char[20] ; 
160
161   for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) { 
162    Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
163    sprintf(rotname, "%s%d", "rot", number++) ;
164    new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
165    top->cd();
166    sprintf(nodename,"%s%d", "Module", i) ;    
167    Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
168    Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
169    TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ;
170    outerboxnode->SetLineColor(kColorPHOS) ;
171    fNodes->Add(outerboxnode) ;
172    outerboxnode->cd() ; 
173    // now inside the outer box the textolit box
174    y = ( fGeom->GetOuterBoxThickness(1) -  fGeom->GetUpperPlateThickness() ) / 2.  ;
175    sprintf(nodename,"%s%d", "TexBox", i) ;  
176    TNode * textolitboxnode = new TNode(nodename, nodename, "TextolitBox", 0, y, 0) ; 
177    textolitboxnode->SetLineColor(kColorPHOS) ;
178    fNodes->Add(textolitboxnode) ;
179    // upper foam plate inside outre box
180    outerboxnode->cd() ; 
181    sprintf(nodename, "%s%d", "UFPlate", i) ;
182    y =  ( fGeom->GetTextolitBoxSize(1) - fGeom->GetSecondUpperPlateThickness() ) / 2.0 ;
183    TNode * upperfoamplatenode = new TNode(nodename, nodename, "UpperFoamPlate", 0, y, 0) ; 
184    upperfoamplatenode->SetLineColor(kColorPHOS) ;
185    fNodes->Add(upperfoamplatenode) ;  
186    // air filled box inside textolit box (not drawn)
187    textolitboxnode->cd();
188    y = ( fGeom->GetTextolitBoxSize(1) - fGeom->GetAirFilledBoxSize(1) ) / 2.0 -  fGeom->GetSecondUpperPlateThickness() ;
189    sprintf(nodename, "%s%d", "AFBox", i) ;
190    TNode * airfilledboxnode = new TNode(nodename, nodename, "AirFilledBox", 0, y, 0) ; 
191    fNodes->Add(airfilledboxnode) ; 
192    // crystals box inside air filled box
193    airfilledboxnode->cd() ; 
194    y = fGeom->GetAirFilledBoxSize(1) / 2.0 - yl 
195        - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness() 
196        -  fGeom->GetUpperPlateThickness() -  fGeom->GetSecondUpperPlateThickness() ) ; 
197    sprintf(nodename, "%s%d", "XTBox", i) ; 
198    TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, y, 0) ;    
199    crystalsboxnode->SetLineColor(kColorXTAL) ; 
200    fNodes->Add(crystalsboxnode) ; 
201   }
202
203   delete[] rotname ;  
204   delete[] nodename ;
205 }
206
207 //____________________________________________________________________________
208 void AliPHOSv0:: BuildGeometryforPPSD(void)
209 {
210  //  Build the PHOS-PPSD geometry for the ROOT display
211  //BEGIN_HTML
212   /*
213     <H2>
214      PPSD displayed by root
215     </H2>
216     <UL>
217     <LI> Zoom on PPSD: Front View
218     <P>
219     <CENTER>
220     <IMG Align=BOTTOM ALT="PPSD Front View" SRC="../images/AliPHOSv0PPSDFrontView.gif"> 
221     </CENTER></P></LI>
222     <LI> Zoom on PPSD: Perspective View
223     <P>
224     <CENTER>
225     <IMG Align=BOTTOM ALT="PPSD Prespective View" SRC="../images/AliPHOSv0PPSDPerspectiveView.gif"> 
226     </CENTER></P></LI>
227     </UL>
228   */
229   //END_HTML  
230   Double_t const kRADDEG = 180.0 / kPI ;
231
232   const Int_t kColorPHOS = kRed ;
233   const Int_t kColorPPSD = kGreen ;
234   const Int_t kColorGas  = kBlue ;  
235   const Int_t kColorAir  = kYellow ; 
236
237   // Box for a full PHOS module
238
239   new TBRIK( "PPSDBox", "PPSD box", "void",  fGeom->GetPPSDBoxSize(0)/2, 
240                                              fGeom->GetPPSDBoxSize(1)/2, 
241                                              fGeom->GetPPSDBoxSize(2)/2 );
242
243   // Box containing one micromegas module 
244
245   new TBRIK( "PPSDModule", "PPSD module", "void",  fGeom->GetPPSDModuleSize(0)/2, 
246                                                    fGeom->GetPPSDModuleSize(1)/2, 
247                                                    fGeom->GetPPSDModuleSize(2)/2 );
248  // top lid
249
250   new TBRIK ( "TopLid", "Micromegas top lid", "void",  fGeom->GetPPSDModuleSize(0)/2,
251                                                        fGeom->GetLidThickness()/2,
252                                                        fGeom->GetPPSDModuleSize(2)/2 ) ; 
253  // composite panel (top and bottom)
254
255   new TBRIK ( "TopPanel", "Composite top panel", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
256                                                             fGeom->GetCompositeThickness()/2,
257                                                           ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;  
258   
259   new TBRIK ( "BottomPanel", "Composite bottom panel", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
260                                                                   fGeom->GetCompositeThickness()/2,
261                                                                 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ; 
262  // gas gap (conversion and avalanche)
263
264   new TBRIK ( "GasGap", "gas gap", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
265                                             ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() )/2,
266                                             ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ; 
267
268  // anode and cathode 
269
270   new TBRIK ( "Anode", "Anode", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
271                                            fGeom->GetAnodeThickness()/2,
272                                          ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ; 
273
274   new TBRIK ( "Cathode", "Cathode", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
275                                                fGeom->GetCathodeThickness()/2,
276                                              ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ; 
277  // PC  
278
279   new TBRIK ( "PCBoard", "Printed Circuit", "void",  ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
280                                                        fGeom->GetPCThickness()/2,
281                                                      ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ; 
282  // Gap between Lead and top micromegas
283
284   new TBRIK ( "LeadToM", "Air Gap top", "void", fGeom->GetPPSDBoxSize(0)/2,
285                                                 fGeom->GetMicro1ToLeadGap()/2,
286                                                 fGeom->GetPPSDBoxSize(2)/2  ) ;  
287  
288 // Gap between Lead and bottom micromegas
289
290   new TBRIK ( "MToLead", "Air Gap bottom", "void", fGeom->GetPPSDBoxSize(0)/2,
291                                                    fGeom->GetLeadToMicro2Gap()/2,
292                                                    fGeom->GetPPSDBoxSize(2)/2  ) ; 
293  // Lead converter
294    
295   new TBRIK ( "Lead", "Lead converter", "void", fGeom->GetPPSDBoxSize(0)/2,
296                                                 fGeom->GetLeadConverterThickness()/2,
297                                                 fGeom->GetPPSDBoxSize(2)/2  ) ; 
298
299      // position PPSD into ALICE
300
301   char * nodename = new char[20] ;  
302   char * rotname  = new char[20] ; 
303
304   Float_t r = fGeom->GetIPtoTopLidDistance() + fGeom->GetPPSDBoxSize(1) / 2.0 ;
305   Int_t number = 988 ; 
306   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
307  
308   for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) { // the number of PHOS modules
309     Float_t angle = fGeom->GetPHOSAngle(i) ;
310     sprintf(rotname, "%s%d", "rotg", number++) ;
311     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
312     top->cd();
313     sprintf(nodename, "%s%d", "Moduleg", i) ;    
314     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
315     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
316     TNode * ppsdboxnode = new TNode(nodename , nodename ,"PPSDBox", x, y, 0, rotname ) ;
317     ppsdboxnode->SetLineColor(kColorPPSD) ;
318     fNodes->Add(ppsdboxnode) ;
319     ppsdboxnode->cd() ;
320     // inside the PPSD box: 
321     //   1.   fNumberOfModulesPhi x fNumberOfModulesZ top micromegas
322     x = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. ;  
323     {
324       for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
325         Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2. ;
326         TNode * micro1node ; 
327         for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
328           y = ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas1Thickness() ) / 2. ; 
329           sprintf(nodename, "%s%d%d%d", "Mic1", i, iphi, iz) ;
330           micro1node  = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
331           micro1node->SetLineColor(kColorPPSD) ;  
332           fNodes->Add(micro1node) ; 
333           // inside top micromegas
334           micro1node->cd() ; 
335           //      a. top lid
336           y = ( fGeom->GetMicromegas1Thickness() - fGeom->GetLidThickness() ) / 2. ; 
337           sprintf(nodename, "%s%d%d%d", "Lid", i, iphi, iz) ;
338           TNode * toplidnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
339           toplidnode->SetLineColor(kColorPPSD) ;  
340           fNodes->Add(toplidnode) ; 
341           //      b. composite panel
342           y = y - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ; 
343           sprintf(nodename, "%s%d%d%d", "CompU", i, iphi, iz) ;
344           TNode * compupnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
345           compupnode->SetLineColor(kColorPPSD) ;  
346           fNodes->Add(compupnode) ; 
347           //      c. anode
348           y = y - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness()  / 2. ; 
349           sprintf(nodename, "%s%d%d%d", "Ano", i, iphi, iz) ;
350           TNode * anodenode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
351           anodenode->SetLineColor(kColorPHOS) ;  
352           fNodes->Add(anodenode) ; 
353           //      d.  gas 
354           y = y - fGeom->GetAnodeThickness() / 2. - ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() ) / 2. ; 
355           sprintf(nodename, "%s%d%d%d", "GGap", i, iphi, iz) ;
356           TNode * ggapnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
357           ggapnode->SetLineColor(kColorGas) ;  
358           fNodes->Add(ggapnode) ;          
359           //      f. cathode
360           y = y - ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness()  / 2. ; 
361           sprintf(nodename, "%s%d%d%d", "Cathode", i, iphi, iz) ;
362           TNode * cathodenode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
363           cathodenode->SetLineColor(kColorPHOS) ;  
364           fNodes->Add(cathodenode) ;        
365           //      g. printed circuit
366           y = y - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness()  / 2. ; 
367           sprintf(nodename, "%s%d%d%d", "PC", i, iphi, iz) ;
368           TNode * pcnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
369           pcnode->SetLineColor(kColorPPSD) ;  
370           fNodes->Add(pcnode) ;        
371           //      h. composite panel
372           y = y - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness()  / 2. ; 
373           sprintf(nodename, "%s%d%d%d", "CompDown", i, iphi, iz) ;
374           TNode * compdownnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
375           compdownnode->SetLineColor(kColorPPSD) ;  
376           fNodes->Add(compdownnode) ;   
377           z = z - fGeom->GetPPSDModuleSize(2) ;
378           ppsdboxnode->cd() ;
379         } // end of Z module loop     
380         x = x -  fGeom->GetPPSDModuleSize(0) ; 
381         ppsdboxnode->cd() ;
382       } // end of phi module loop
383     }
384     //   2. air gap      
385     ppsdboxnode->cd() ;
386     y = ( fGeom->GetPPSDBoxSize(1) - 2 * fGeom->GetMicromegas1Thickness() - fGeom->GetMicro1ToLeadGap() ) / 2. ; 
387     sprintf(nodename, "%s%d", "GapUp", i) ;
388     TNode * gapupnode = new TNode(nodename, nodename, "LeadToM", 0, y, 0) ;
389     gapupnode->SetLineColor(kColorAir) ;  
390     fNodes->Add(gapupnode) ;        
391     //   3. lead converter
392     y = y - fGeom->GetMicro1ToLeadGap() / 2. - fGeom->GetLeadConverterThickness() / 2. ; 
393     sprintf(nodename, "%s%d", "LeadC", i) ;
394     TNode * leadcnode = new TNode(nodename, nodename, "Lead", 0, y, 0) ;
395     leadcnode->SetLineColor(kColorPPSD) ;  
396     fNodes->Add(leadcnode) ;        
397     //   4. air gap
398     y = y - fGeom->GetLeadConverterThickness() / 2. - fGeom->GetLeadToMicro2Gap()  / 2. ; 
399     sprintf(nodename, "%s%d", "GapDown", i) ;
400     TNode * gapdownnode = new TNode(nodename, nodename, "MToLead", 0, y, 0) ;
401     gapdownnode->SetLineColor(kColorAir) ;  
402     fNodes->Add(gapdownnode) ;        
403     //    5.  fNumberOfModulesPhi x fNumberOfModulesZ bottom micromegas
404     x = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. - fGeom->GetPhiDisplacement() ;  
405     {
406       for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) { 
407         Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2.  - fGeom->GetZDisplacement() ;;
408         TNode * micro2node ; 
409         for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) { 
410           y = - ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas2Thickness() ) / 2. ; 
411           sprintf(nodename, "%s%d%d%d", "Mic2", i, iphi, iz) ;
412           micro2node  = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
413           micro2node->SetLineColor(kColorPPSD) ;  
414           fNodes->Add(micro2node) ; 
415           // inside bottom micromegas
416           micro2node->cd() ; 
417           //      a. top lid
418           y = ( fGeom->GetMicromegas2Thickness() - fGeom->GetLidThickness() ) / 2. ; 
419           sprintf(nodename, "%s%d", "Lidb", i) ;
420           TNode * toplidbnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
421           toplidbnode->SetLineColor(kColorPPSD) ;  
422           fNodes->Add(toplidbnode) ; 
423           //      b. composite panel
424           y = y - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ; 
425           sprintf(nodename, "%s%d", "CompUb", i) ;
426           TNode * compupbnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
427           compupbnode->SetLineColor(kColorPPSD) ;  
428           fNodes->Add(compupbnode) ; 
429           //      c. anode
430           y = y - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness()  / 2. ; 
431           sprintf(nodename, "%s%d", "Anob", i) ;
432           TNode * anodebnode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
433           anodebnode->SetLineColor(kColorPPSD) ;  
434           fNodes->Add(anodebnode) ; 
435           //      d. conversion gas
436           y = y - fGeom->GetAnodeThickness() / 2. - ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() )  / 2. ; 
437           sprintf(nodename, "%s%d", "GGapb", i) ;
438           TNode * ggapbnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
439           ggapbnode->SetLineColor(kColorGas) ;  
440           fNodes->Add(ggapbnode) ;           
441           //      f. cathode
442           y = y - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness()  / 2. ; 
443           sprintf(nodename, "%s%d", "Cathodeb", i) ;
444           TNode * cathodebnode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
445           cathodebnode->SetLineColor(kColorPPSD) ;  
446           fNodes->Add(cathodebnode) ;        
447           //      g. printed circuit
448           y = y - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness()  / 2. ; 
449           sprintf(nodename, "%s%d", "PCb", i) ;
450           TNode * pcbnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
451           pcbnode->SetLineColor(kColorPPSD) ;  
452           fNodes->Add(pcbnode) ;        
453           //      h. composite pane
454           y = y - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness()  / 2. ; 
455           sprintf(nodename, "%s%d", "CompDownb", i) ;
456           TNode * compdownbnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
457           compdownbnode->SetLineColor(kColorPPSD) ;  
458           fNodes->Add(compdownbnode) ;        
459           z = z - fGeom->GetPPSDModuleSize(2) ;
460           ppsdboxnode->cd() ;
461         } // end of Z module loop     
462         x = x -  fGeom->GetPPSDModuleSize(0) ; 
463         ppsdboxnode->cd() ;
464       } // end of phi module loop
465     }
466   } // PHOS modules
467  
468   delete[] rotname ;  
469   delete[] nodename ; 
470
471 }
472
473 //____________________________________________________________________________
474 void AliPHOSv0::CreateGeometry()
475 {
476   // Create the PHOS geometry for Geant
477
478   AliPHOSv0 *phostmp = (AliPHOSv0*)gAlice->GetModule("PHOS") ;
479
480   if ( phostmp == NULL ) {
481     
482     fprintf(stderr, "PHOS detector not found!\n") ;
483     return;
484     
485   }
486   // Get pointer to the array containing media indeces
487   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
488
489   Float_t bigbox[3] ; 
490   bigbox[0] =   fGeom->GetOuterBoxSize(0) / 2.0 ;
491   bigbox[1] = ( fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) / 2.0 ;
492   bigbox[2] =   fGeom->GetOuterBoxSize(2) / 2.0 ;
493   
494   gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
495   
496   this->CreateGeometryforPHOS() ; 
497   if ( strcmp( fGeom->GetName(), "GPS2") == 0  ) 
498     this->CreateGeometryforPPSD() ;
499   else
500     cout << "AliPHOSv0::CreateGeometry : no charged particle identification system installed" << endl; 
501   
502   // --- Position  PHOS mdules in ALICE setup ---
503   
504   Int_t idrotm[99] ;
505   Double_t const kRADDEG = 180.0 / kPI ;
506   
507   for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
508     
509     Float_t angle = fGeom->GetPHOSAngle(i) ;
510     AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
511  
512     Float_t r = fGeom->GetIPtoOuterCoverDistance() + ( fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) / 2.0 ;
513
514     Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
515     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
516
517     gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
518  
519   } // for GetNModules
520
521 }
522
523 //____________________________________________________________________________
524 void AliPHOSv0::CreateGeometryforPHOS()
525 {
526   // Create the PHOS-EMC geometry for GEANT
527     //BEGIN_HTML
528   /*
529     <H2>
530     Geant3 geometry tree of PHOS-EMC in ALICE
531     </H2>
532     <P><CENTER>
533     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif"> 
534     </CENTER><P>
535   */
536   //END_HTML  
537   
538   // Get pointer to the array containing media indexes
539   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
540
541   // ---
542   // --- Define PHOS box volume, fPUFPill with thermo insulating foam ---
543   // --- Foam Thermo Insulating outer cover dimensions ---
544   // --- Put it in bigbox = PHOS
545
546   Float_t dphos[3] ; 
547   dphos[0] =  fGeom->GetOuterBoxSize(0) / 2.0 ;
548   dphos[1] =  fGeom->GetOuterBoxSize(1) / 2.0 ;
549   dphos[2] =  fGeom->GetOuterBoxSize(2) / 2.0 ;
550
551   gMC->Gsvolu("EMCA", "BOX ", idtmed[706], dphos, 3) ;
552
553   Float_t yO =  - fGeom->GetPPSDBoxSize(1)  / 2.0 ;
554
555   gMC->Gspos("EMCA", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
556
557   // ---
558   // --- Define Textolit Wall box, position inside EMCA ---
559   // --- Textolit Wall box dimentions ---
560  
561  
562   Float_t dptxw[3];
563   dptxw[0] = fGeom->GetTextolitBoxSize(0) / 2.0 ;
564   dptxw[1] = fGeom->GetTextolitBoxSize(1) / 2.0 ;
565   dptxw[2] = fGeom->GetTextolitBoxSize(2) / 2.0 ;
566
567   gMC->Gsvolu("PTXW", "BOX ", idtmed[707], dptxw, 3);
568
569   yO =   (  fGeom->GetOuterBoxThickness(1) -   fGeom->GetUpperPlateThickness() ) / 2.  ;
570    
571   gMC->Gspos("PTXW", 1, "EMCA", 0.0, yO, 0.0, 0, "ONLY") ;
572
573   // --- 
574   // --- Define Upper Polystyrene Foam Plate, place inside PTXW ---
575   // --- immediately below Foam Thermo Insulation Upper plate ---
576
577   // --- Upper Polystyrene Foam plate thickness ---
578  
579   Float_t  dpufp[3] ;
580   dpufp[0] = fGeom->GetTextolitBoxSize(0) / 2.0 ; 
581   dpufp[1] = fGeom->GetSecondUpperPlateThickness() / 2. ;
582   dpufp[2] = fGeom->GetTextolitBoxSize(2) /2.0 ; 
583
584   gMC->Gsvolu("PUFP", "BOX ", idtmed[703], dpufp, 3) ;
585   
586   yO = ( fGeom->GetTextolitBoxSize(1) -  fGeom->GetSecondUpperPlateThickness() ) / 2.0 ;
587   
588   gMC->Gspos("PUFP", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
589   
590   // ---
591   // --- Define air-filled box, place inside PTXW ---
592   // --- Inner AIR volume dimensions ---
593  
594
595   Float_t  dpair[3] ;
596   dpair[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
597   dpair[1] = fGeom->GetAirFilledBoxSize(1) / 2.0 ;
598   dpair[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
599
600   gMC->Gsvolu("PAIR", "BOX ", idtmed[798], dpair, 3) ;
601   
602   yO = ( fGeom->GetTextolitBoxSize(1) -  fGeom->GetAirFilledBoxSize(1) ) / 2.0 -   fGeom->GetSecondUpperPlateThickness() ;
603   
604   gMC->Gspos("PAIR", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
605
606 // --- Dimensions of PbWO4 crystal ---
607
608   Float_t xtlX =  fGeom->GetCrystalSize(0) ; 
609   Float_t xtlY =  fGeom->GetCrystalSize(1) ; 
610   Float_t xtlZ =  fGeom->GetCrystalSize(2) ; 
611
612   Float_t dptcb[3] ;  
613   dptcb[0] =  fGeom->GetNPhi() * ( xtlX + 2 *  fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
614   dptcb[1] = ( xtlY +  fGeom->GetCrystalSupportHeight() +  fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 
615              + fGeom->GetModuleBoxThickness() / 2.0 ;
616   dptcb[2] = fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 +  fGeom->GetModuleBoxThickness() ;
617   
618   gMC->Gsvolu("PTCB", "BOX ", idtmed[706], dptcb, 3) ;
619
620   yO =  fGeom->GetAirFilledBoxSize(1) / 2.0 - dptcb[1] 
621        - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness() 
622        -  fGeom->GetUpperPlateThickness() -  fGeom->GetSecondUpperPlateThickness() ) ;
623   
624   gMC->Gspos("PTCB", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
625
626   // ---
627   // --- Define Crystal BLock filled with air, position it inside PTCB ---
628   Float_t dpcbl[3] ; 
629   
630   dpcbl[0] = fGeom->GetNPhi() * ( xtlX + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 ;
631   dpcbl[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
632   dpcbl[2] = fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 ;
633   
634   gMC->Gsvolu("PCBL", "BOX ", idtmed[798], dpcbl, 3) ;
635   
636   // --- Divide PCBL in X (phi) and Z directions --
637   gMC->Gsdvn("PROW", "PCBL", Int_t (fGeom->GetNPhi()), 1) ;
638   gMC->Gsdvn("PCEL", "PROW", Int_t (fGeom->GetNZ()), 3) ;
639
640   yO = -fGeom->GetModuleBoxThickness() / 2.0 ;
641   
642   gMC->Gspos("PCBL", 1, "PTCB", 0.0, yO, 0.0, 0, "ONLY") ;
643
644   // ---
645   // --- Define STeel (actually, it's titanium) Cover volume, place inside PCEL
646   Float_t  dpstc[3] ; 
647   
648   dpstc[0] = ( xtlX + 2 * fGeom->GetCrystalWrapThickness() ) / 2.0 ;
649   dpstc[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
650   dpstc[2] = ( xtlZ + 2 * fGeom->GetCrystalWrapThickness()  + 2 *  fGeom->GetCrystalHolderThickness() ) / 2.0 ;
651   
652   gMC->Gsvolu("PSTC", "BOX ", idtmed[704], dpstc, 3) ;
653
654   gMC->Gspos("PSTC", 1, "PCEL", 0.0, 0.0, 0.0, 0, "ONLY") ;
655
656   // ---
657   // --- Define Tyvek volume, place inside PSTC ---
658   Float_t  dppap[3] ;
659
660   dppap[0] = xtlX / 2.0 + fGeom->GetCrystalWrapThickness() ;
661   dppap[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 ;
662   dppap[2] = xtlZ / 2.0 + fGeom->GetCrystalWrapThickness() ;
663   
664   gMC->Gsvolu("PPAP", "BOX ", idtmed[702], dppap, 3) ;
665   
666   yO = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 
667               - ( xtlY +  fGeom->GetCrystalSupportHeight() +  fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
668    
669   gMC->Gspos("PPAP", 1, "PSTC", 0.0, yO, 0.0, 0, "ONLY") ;
670
671   // ---
672   // --- Define PbWO4 crystal volume, place inside PPAP ---
673   Float_t  dpxtl[3] ; 
674
675   dpxtl[0] = xtlX / 2.0 ;
676   dpxtl[1] = xtlY / 2.0 ;
677   dpxtl[2] = xtlZ / 2.0 ;
678   
679   gMC->Gsvolu("PXTL", "BOX ", idtmed[699], dpxtl, 3) ;
680
681   yO = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 - xtlY / 2.0 - fGeom->GetCrystalWrapThickness() ;
682   
683   gMC->Gspos("PXTL", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
684
685   // ---
686   // --- Define crystal support volume, place inside PPAP ---
687   Float_t dpsup[3] ; 
688
689   dpsup[0] = xtlX / 2.0 + fGeom->GetCrystalWrapThickness()  ;
690   dpsup[1] = fGeom->GetCrystalSupportHeight() / 2.0 ;
691   dpsup[2] = xtlZ / 2.0 +  fGeom->GetCrystalWrapThickness() ;
692
693   gMC->Gsvolu("PSUP", "BOX ", idtmed[798], dpsup, 3) ;
694
695   yO =  fGeom->GetCrystalSupportHeight() / 2.0 - ( xtlY +  fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 ;
696
697   gMC->Gspos("PSUP", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
698
699   // ---
700   // --- Define PIN-diode volume and position it inside crystal support ---
701   // --- right behind PbWO4 crystal
702
703   // --- PIN-diode dimensions ---
704
705  
706   Float_t dppin[3] ;
707   dppin[0] = fGeom->GetPinDiodeSize(0) / 2.0 ;
708   dppin[1] = fGeom->GetPinDiodeSize(1) / 2.0 ;
709   dppin[2] = fGeom->GetPinDiodeSize(2) / 2.0 ;
710  
711   gMC->Gsvolu("PPIN", "BOX ", idtmed[705], dppin, 3) ;
712  
713   yO = fGeom->GetCrystalSupportHeight() / 2.0 - fGeom->GetPinDiodeSize(1) / 2.0 ;
714  
715   gMC->Gspos("PPIN", 1, "PSUP", 0.0, yO, 0.0, 0, "ONLY") ;
716
717   // ---
718   // --- Define Upper Cooling Panel, place it on top of PTCB ---
719   Float_t dpucp[3] ;
720  // --- Upper Cooling Plate thickness ---
721  
722   dpucp[0] = dptcb[0] ;
723   dpucp[1] = fGeom->GetUpperCoolingPlateThickness() ;
724   dpucp[2] = dptcb[2] ;
725   
726   gMC->Gsvolu("PUCP", "BOX ", idtmed[701], dpucp,3) ;
727   
728   yO = (  fGeom->GetAirFilledBoxSize(1) -  fGeom->GetUpperCoolingPlateThickness() ) / 2. 
729        - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness()
730            - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() - fGeom->GetUpperCoolingPlateThickness() ) ; 
731   
732   gMC->Gspos("PUCP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
733
734   // ---
735   // --- Define Al Support Plate, position it inside PAIR ---
736   // --- right beneath PTCB ---
737  // --- Al Support Plate thickness ---
738  
739   Float_t dpasp[3] ;
740   dpasp[0] =  fGeom->GetAirFilledBoxSize(0) / 2.0 ;
741   dpasp[1] = fGeom->GetSupportPlateThickness() / 2.0 ;
742   dpasp[2] =  fGeom->GetAirFilledBoxSize(2) / 2.0 ;
743   
744   gMC->Gsvolu("PASP", "BOX ", idtmed[701], dpasp, 3) ;
745   
746   yO = (  fGeom->GetAirFilledBoxSize(1) - fGeom->GetSupportPlateThickness() ) / 2. 
747        -  ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance()
748            - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 ) ;
749   
750   gMC->Gspos("PASP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
751
752   // ---
753   // --- Define Thermo Insulating Plate, position it inside PAIR ---
754   // --- right beneath PASP ---
755   // --- Lower Thermo Insulating Plate thickness ---
756   
757   Float_t dptip[3] ;
758   dptip[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
759   dptip[1] = fGeom->GetLowerThermoPlateThickness() / 2.0 ;
760   dptip[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
761
762   gMC->Gsvolu("PTIP", "BOX ", idtmed[706], dptip, 3) ;
763
764   yO =  ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetLowerThermoPlateThickness() ) / 2. 
765        -  ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetUpperPlateThickness() 
766             - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + fGeom->GetSupportPlateThickness() ) ;
767
768   gMC->Gspos("PTIP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
769
770   // ---
771   // --- Define Textolit Plate, position it inside PAIR ---
772   // --- right beneath PTIP ---
773   // --- Lower Textolit Plate thickness ---
774  
775   Float_t dptxp[3] ;
776   dptxp[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
777   dptxp[1] = fGeom->GetLowerTextolitPlateThickness() / 2.0 ;
778   dptxp[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
779
780   gMC->Gsvolu("PTXP", "BOX ", idtmed[707], dptxp, 3) ;
781
782   yO =  ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetLowerTextolitPlateThickness() ) / 2. 
783        -  ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetUpperPlateThickness() 
784             - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + fGeom->GetSupportPlateThickness() 
785             +  fGeom->GetLowerThermoPlateThickness() ) ;
786
787   gMC->Gspos("PTXP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
788
789 }
790
791 //____________________________________________________________________________
792 void AliPHOSv0::CreateGeometryforPPSD()
793 {
794   // Create the PHOS-PPSD geometry for GEANT
795
796   //BEGIN_HTML
797   /*
798     <H2>
799     Geant3 geometry tree of PHOS-PPSD in ALICE
800     </H2>
801     <P><CENTER>
802     <IMG Align=BOTTOM ALT="PPSD geant tree" SRC="../images/PPSDinAlice.gif"> 
803     </CENTER><P>
804   */
805   //END_HTML  
806
807   // Get pointer to the array containing media indexes
808   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
809   
810   // The box containing all ppsd's for one PHOS module filled with air 
811   Float_t ppsd[3] ; 
812   ppsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;  
813   ppsd[1] = fGeom->GetPPSDBoxSize(1) / 2.0 ; 
814   ppsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
815
816   gMC->Gsvolu("PPSD", "BOX ", idtmed[798], ppsd, 3) ;
817
818   Float_t yO =  fGeom->GetOuterBoxSize(1) / 2.0 ;
819
820   gMC->Gspos("PPSD", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ; 
821
822   // Now we build a micromegas module
823   // The box containing the whole module filled with epoxy (FR4)
824
825   Float_t mppsd[3] ;  
826   mppsd[0] = fGeom->GetPPSDModuleSize(0) / 2.0 ;  
827   mppsd[1] = fGeom->GetPPSDModuleSize(1) / 2.0 ;  
828   mppsd[2] = fGeom->GetPPSDModuleSize(2) / 2.0 ;
829
830   gMC->Gsvolu("MPPS", "BOX ", idtmed[708], mppsd, 3) ;  
831  
832   // Inside mppsd :
833   // 1. The Top Lid made of epoxy (FR4) 
834
835   Float_t tlppsd[3] ; 
836   tlppsd[0] = fGeom->GetPPSDModuleSize(0) / 2.0 ; 
837   tlppsd[1] = fGeom->GetLidThickness() / 2.0 ;
838   tlppsd[2] = fGeom->GetPPSDModuleSize(2) / 2.0 ;
839
840   gMC->Gsvolu("TLPS", "BOX ", idtmed[708], tlppsd, 3) ; 
841
842   Float_t  y0 = ( fGeom->GetMicromegas1Thickness() - fGeom->GetLidThickness() ) / 2. ; 
843
844   gMC->Gspos("TLPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
845  
846   // 2. the upper panel made of composite material
847
848   Float_t upppsd[3] ; 
849   upppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
850   upppsd[1] = fGeom->GetCompositeThickness() / 2.0 ;
851   upppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
852  
853   gMC->Gsvolu("UPPS", "BOX ", idtmed[709], upppsd, 3) ; 
854   
855   y0 = y0 - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ; 
856
857   gMC->Gspos("UPPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
858
859   // 3. the anode made of Copper
860   
861   Float_t anppsd[3] ; 
862   anppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ; 
863   anppsd[1] = fGeom->GetAnodeThickness() / 2.0 ; 
864   anppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0  ; 
865
866   gMC->Gsvolu("ANPS", "BOX ", idtmed[710], anppsd, 3) ; 
867   
868   y0 = y0 - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness()  / 2. ; 
869   
870   gMC->Gspos("ANPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
871
872   // 4. the conversion gap + avalanche gap filled with gas
873
874   Float_t ggppsd[3] ; 
875   ggppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
876   ggppsd[1] = ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() ) / 2.0 ; 
877   ggppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
878
879   gMC->Gsvolu("GGPS", "BOX ", idtmed[715], ggppsd, 3) ; 
880   
881   // --- Divide GGPP in X (phi) and Z directions --
882   gMC->Gsdvn("GROW", "GGPS", fGeom->GetNumberOfPadsPhi(), 1) ;
883   gMC->Gsdvn("GCEL", "GROW", fGeom->GetNumberOfPadsZ() , 3) ;
884
885   y0 = y0 - fGeom->GetAnodeThickness() / 2.  - ( fGeom->GetConversionGap() +  fGeom->GetAvalancheGap() ) / 2. ; 
886
887   gMC->Gspos("GGPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
888
889
890   // 6. the cathode made of Copper
891
892   Float_t cappsd[3] ;
893   cappsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
894   cappsd[1] = fGeom->GetCathodeThickness() / 2.0 ; 
895   cappsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0  ;
896
897   gMC->Gsvolu("CAPS", "BOX ", idtmed[710], cappsd, 3) ; 
898
899   y0 = y0 - ( fGeom->GetAvalancheGap() +  fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness()  / 2. ; 
900
901   gMC->Gspos("CAPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
902
903   // 7. the printed circuit made of G10       
904
905   Float_t pcppsd[3] ; 
906   pcppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2,.0 ; 
907   pcppsd[1] = fGeom->GetPCThickness() / 2.0 ; 
908   pcppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
909
910   gMC->Gsvolu("PCPS", "BOX ", idtmed[711], cappsd, 3) ; 
911
912   y0 = y0 - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness()  / 2. ; 
913
914   gMC->Gspos("PCPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
915
916   // 8. the lower panel made of composite material
917                                                     
918   Float_t lpppsd[3] ; 
919   lpppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ; 
920   lpppsd[1] = fGeom->GetCompositeThickness() / 2.0 ; 
921   lpppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
922
923   gMC->Gsvolu("LPPS", "BOX ", idtmed[709], lpppsd, 3) ; 
924  
925   y0 = y0 - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness()  / 2. ; 
926
927   gMC->Gspos("LPPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ; 
928
929   // Position the  fNumberOfModulesPhi x fNumberOfModulesZ modules (mppsd) inside PPSD to cover a PHOS module
930   // the top and bottom one's (which are assumed identical) :
931
932    Float_t yt = ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas1Thickness() ) / 2. ; 
933    Float_t yb = - ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas2Thickness() ) / 2. ; 
934
935    Int_t copyNumbertop = 0 ; 
936    Int_t copyNumberbot = fGeom->GetNumberOfModulesPhi() *  fGeom->GetNumberOfModulesZ() ; 
937
938    Float_t x  = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. ;  
939
940    for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
941       Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2. ;
942
943       for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
944         gMC->Gspos("MPPS", ++copyNumbertop, "PPSD", x, yt, z, 0, "ONLY") ;
945         gMC->Gspos("MPPS", ++copyNumberbot, "PPSD", x, yb, z, 0, "ONLY") ; 
946         z = z - fGeom->GetPPSDModuleSize(2) ;
947       } // end of Z module loop   
948       x = x -  fGeom->GetPPSDModuleSize(0) ; 
949     } // end of phi module loop
950
951    // The Lead converter between two air gaps
952    // 1. Upper air gap
953
954    Float_t uappsd[3] ;
955    uappsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
956    uappsd[1] = fGeom->GetMicro1ToLeadGap() / 2.0 ; 
957    uappsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
958
959   gMC->Gsvolu("UAPPSD", "BOX ", idtmed[798], uappsd, 3) ; 
960
961   y0 = ( fGeom->GetPPSDBoxSize(1) - 2 * fGeom->GetMicromegas1Thickness() - fGeom->GetMicro1ToLeadGap() ) / 2. ; 
962
963   gMC->Gspos("UAPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
964
965    // 2. Lead converter
966  
967   Float_t lcppsd[3] ; 
968   lcppsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
969   lcppsd[1] = fGeom->GetLeadConverterThickness() / 2.0 ; 
970   lcppsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
971  
972   gMC->Gsvolu("LCPPSD", "BOX ", idtmed[712], lcppsd, 3) ; 
973   
974   y0 = y0 - fGeom->GetMicro1ToLeadGap() / 2. - fGeom->GetLeadConverterThickness() / 2. ; 
975
976   gMC->Gspos("LCPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
977
978   // 3. Lower air gap
979
980   Float_t lappsd[3] ; 
981   lappsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ; 
982   lappsd[1] = fGeom->GetLeadToMicro2Gap() / 2.0 ; 
983   lappsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
984
985   gMC->Gsvolu("LAPPSD", "BOX ", idtmed[798], lappsd, 3) ; 
986     
987   y0 = y0 - fGeom->GetLeadConverterThickness() / 2. - fGeom->GetLeadToMicro2Gap()  / 2. ; 
988   
989   gMC->Gspos("LAPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ; 
990    
991 }
992
993
994 //____________________________________________________________________________
995 void AliPHOSv0::Init(void)
996 {
997   // Just prints an information message
998   
999   Int_t i;
1000
1001   printf("\n");
1002   for(i=0;i<35;i++) printf("*");
1003   printf(" PHOS_INIT ");
1004   for(i=0;i<35;i++) printf("*");
1005   printf("\n");
1006
1007   // Here the PHOS initialisation code (if any!)
1008
1009   if (fGeom!=0)  
1010     cout << "AliPHOS" << Version() << " : PHOS geometry intialized for " << fGeom->GetName() << endl ;
1011   else
1012     cout << "AliPHOS" << Version() << " : PHOS geometry initialization failed !" << endl ;   
1013   
1014   for(i=0;i<80;i++) printf("*");
1015   printf("\n");
1016   
1017 }
1018