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