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