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