]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv0.cxx
removed constant parameters
[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 /* $Id$ */
16
17 /* History of cvs commits:
18  *
19  * $Log$
20  * Revision 1.79  2005/05/28 14:19:05  schutz
21  * Compilation warnings fixed by T.P.
22  *
23  */
24
25 //_________________________________________________________________________
26 // Implementation version v0 of PHOS Manager class 
27 // An object of this class does not produce hits nor digits
28 // It is the one to use if you do not want to produce outputs in TREEH or TREED
29 //                  
30 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
31
32
33 // --- ROOT system ---
34
35 #include <TBRIK.h>
36 #include <TFolder.h>
37 #include <TGeometry.h>
38 #include <TNode.h>
39 #include <TROOT.h>
40 #include <TRandom.h>
41 #include <TTRD1.h>
42 #include <TTree.h>
43 #include <TVirtualMC.h>
44
45 // --- Standard library ---
46
47 #include <string.h>
48 #include <stdlib.h>
49
50 // --- AliRoot header files ---
51
52 #include "AliConst.h"
53 #include "AliPHOSGeometry.h"
54 #include "AliPHOSLoader.h"
55 #include "AliPHOSv0.h"
56 #include "AliRun.h"
57 #include "AliLog.h"
58
59 ClassImp(AliPHOSv0)
60
61 //____________________________________________________________________________
62 AliPHOSv0::AliPHOSv0(const char *name, const char *title):
63   AliPHOS(name,title)
64 {
65   // ctor : title is used to identify the layout
66   GetGeometry() ; 
67 }
68
69 //____________________________________________________________________________
70 void AliPHOSv0::Copy(TObject & phos) const
71 {
72   TObject::Copy(phos) ; 
73   AliPHOS::Copy(phos) ; 
74 }
75
76 //____________________________________________________________________________
77 void AliPHOSv0::BuildGeometry()
78 {
79   // Build the PHOS geometry for the ROOT display
80   //BEGIN_HTML
81   /*
82     <H2>
83      PHOS in ALICE displayed by root
84     </H2>
85     <UL>
86     <LI> All Views
87     <P>
88     <CENTER>
89     <IMG Align=BOTTOM ALT="All Views" SRC="../images/AliPHOSv0AllViews.gif"> 
90     </CENTER></P></LI>
91     <LI> Front View
92     <P>
93     <CENTER>
94     <IMG Align=BOTTOM ALT="Front View" SRC="../images/AliPHOSv0FrontView.gif"> 
95     </CENTER></P></LI>
96      <LI> 3D View 1
97     <P>
98     <CENTER>
99     <IMG Align=BOTTOM ALT="3D View 1" SRC="../images/AliPHOSv03DView1.gif"> 
100     </CENTER></P></LI>
101     <LI> 3D View 2
102     <P>
103     <CENTER>
104     <IMG Align=BOTTOM ALT="3D View 2" SRC="../images/AliPHOSv03DView2.gif"> 
105     </CENTER></P></LI>
106     </UL>
107   */
108   //END_HTML  
109   
110   this->BuildGeometryforEMC() ; 
111   this->BuildGeometryforCPV() ;
112   
113 }
114
115 //____________________________________________________________________________
116 void AliPHOSv0:: BuildGeometryforEMC(void)
117 {
118   // Build the PHOS-EMC geometry for the ROOT display
119   
120   const Int_t kColorPHOS = kRed ;
121   const Int_t kColorXTAL = kBlue ;
122   
123   Double_t const kRADDEG = 180.0 / TMath::Pi() ;
124   
125   AliPHOSGeometry * geom = GetGeometry() ; 
126   AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ;
127   Float_t * boxparams = emcg->GetEMCParams() ;
128
129   new TTRD1("OuterBox", "PHOS box", "void",boxparams[0],boxparams[1],boxparams[2], boxparams[3] );
130   
131   
132   // Crystals Box
133   
134   Float_t * cribox = emcg->GetInnerThermoHalfSize() ;  
135   new TBRIK( "CrystalsBox", "PHOS crystals box", "void", cribox[0], cribox[2], cribox[1] ) ;
136   
137   // position PHOS into ALICE
138   
139   Float_t r = geom->GetIPtoOuterCoverDistance() + boxparams[3] ;
140   Int_t number = 988 ; 
141   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
142   
143   char * nodename = new char[20] ;  
144   char * rotname  = new char[20] ; 
145
146   new TRotMatrix("cribox", "cribox", 90, 0, 90, 90, 0, 0);  
147
148   for( Int_t i = 1; i <= geom->GetNModules(); i++ ) { 
149
150     Float_t angle = geom->GetPHOSAngle(i) ;
151     sprintf(rotname, "%s%d", "rot", number++) ;
152     new TRotMatrix(rotname, rotname, 90, angle, 0,  0,  90,  270 + angle);
153
154     top->cd();
155     sprintf(nodename,"%s%d", "Module", i) ;    
156     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
157     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
158     TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ;
159     outerboxnode->SetLineColor(kColorPHOS) ;
160     fNodes->Add(outerboxnode) ;
161     outerboxnode->cd() ; 
162
163     Float_t z = -boxparams[3] - geom->GetIPtoOuterCoverDistance() + 
164                  cribox[1] +  geom->GetIPtoCrystalSurface() ;
165     TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, 0, z) ;    
166     crystalsboxnode->SetLineColor(kColorXTAL) ; 
167     fNodes->Add(crystalsboxnode) ; 
168   }
169
170   delete[] rotname ;  
171   delete[] nodename ;
172 }
173
174
175 //____________________________________________________________________________
176 void AliPHOSv0:: BuildGeometryforCPV(void)
177 {
178   //  Build the PHOS-CPV geometry for the ROOT display
179   //  Author: Yuri Kharlov 11 September 2000
180   //
181   //BEGIN_HTML
182   /*
183     <H2>
184     CPV displayed by root
185     </H2>
186     <table width=700>
187
188     <tr>
189          <td>CPV perspective view</td>
190          <td>CPV front view      </td>
191     </tr>
192
193     <tr>
194          <td> <img height=300 width=290 src="../images/CPVRootPersp.gif"> </td>
195          <td> <img height=300 width=290 src="../images/CPVRootFront.gif"> </td>
196     </tr>
197
198     </table>
199
200   */
201   //END_HTML  
202
203   const Double_t kRADDEG         = 180.0 / TMath::Pi() ;
204   const Int_t    kColorCPV       = kGreen ;
205   const Int_t    kColorFrame     = kYellow ;
206   const Int_t    kColorGassiplex = kRed;
207   const Int_t    kColorPCB       = kCyan;
208
209   AliPHOSGeometry * geom = GetGeometry() ; 
210
211   // Box for a full PHOS module
212
213   new TBRIK ("CPVBox", "CPV box", "void",                   geom->GetCPVBoxSize(0)/2,
214                                                             geom->GetCPVBoxSize(1)/2,
215                                                             geom->GetCPVBoxSize(2)/2 );
216   new TBRIK ("CPVFrameLR", "CPV frame Left-Right", "void",  geom->GetCPVFrameSize(0)/2,
217                                                             geom->GetCPVFrameSize(1)/2,
218                                                             geom->GetCPVBoxSize(2)/2 );
219   new TBRIK ("CPVFrameUD", "CPV frame Up-Down",    "void",  geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0),
220                                                             geom->GetCPVFrameSize(1)/2,
221                                                             geom->GetCPVFrameSize(2)/2);
222   new TBRIK ("CPVPCB",    "CPV PCB",               "void",  geom->GetCPVActiveSize(0)/2,
223                                                             geom->GetCPVTextoliteThickness()/2,
224                                                             geom->GetCPVActiveSize(1)/2);
225   new TBRIK ("CPVGassiplex", "CPV Gassiplex PCB",  "void",  geom->GetGassiplexChipSize(0)/2,
226                                                             geom->GetGassiplexChipSize(1)/2,
227                                                             geom->GetGassiplexChipSize(2)/2);
228
229   // position CPV into ALICE
230
231   char * nodename = new char[25] ;
232   char * rotname  = new char[25] ;
233   
234   Float_t r = geom->GetIPtoCPVDistance() + geom->GetCPVBoxSize(1) / 2.0 ;
235   Int_t number = 988 ; 
236   TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
237
238   Int_t lastModule = 0 ;
239   lastModule = geom->GetNModules();
240   
241   for( Int_t i = 1; i <= lastModule; i++ ) { // the number of PHOS modules
242     
243     // One CPV module
244     
245     Float_t angle = geom->GetPHOSAngle(i) ;
246     sprintf(rotname, "%s%d", "rotg", number+i) ;
247     new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
248     top->cd();
249     sprintf(nodename, "%s%d", "CPVModule", i) ;    
250     Float_t x =  r * TMath::Sin( angle / kRADDEG ) ;
251     Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
252     Float_t z;
253     TNode * cpvBoxNode = new TNode(nodename , nodename ,"CPVBox", x, y, 0, rotname ) ;
254     cpvBoxNode->SetLineColor(kColorCPV) ;
255     fNodes->Add(cpvBoxNode) ;
256     cpvBoxNode->cd() ;
257
258     // inside each CPV box:
259
260     // Frame around CPV
261     Int_t j;
262     for (j=0; j<=1; j++) {
263       sprintf(nodename, "CPVModule%d Frame%d", i, j+1) ;
264       x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
265       TNode * cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameLR", x, 0, 0) ;
266       cpvFrameNode->SetLineColor(kColorFrame) ;
267       fNodes->Add(cpvFrameNode) ;
268
269       sprintf(nodename, "CPVModule%d Frame%d", i, j+3) ;
270       z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
271       cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameUD", 0, 0, z) ;
272       cpvFrameNode->SetLineColor(kColorFrame) ;
273       fNodes->Add(cpvFrameNode) ;
274     }
275
276     // 4 printed circuit boards
277     for (j=0; j<4; j++) {
278       sprintf(nodename, "CPVModule%d PCB%d", i, j+1) ;
279       y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(j) + geom->GetCPVTextoliteThickness()/2;
280       TNode * cpvPCBNode = new TNode(nodename , nodename ,"CPVPCB", 0, y, 0) ;
281       cpvPCBNode->SetLineColor(kColorPCB) ;
282       fNodes->Add(cpvPCBNode) ;
283     }
284
285     // Gassiplex chips
286     Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
287     Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
288     y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
289         geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
290     for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
291       x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
292       for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
293         z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
294         sprintf(nodename, "CPVModule%d Chip(%dx%d)", i, ix+1,iz+1) ;
295         TNode * cpvGassiplexNode = new TNode(nodename , nodename ,"CPVGassiplex", x, y, z) ;
296         cpvGassiplexNode->SetLineColor(kColorGassiplex) ;
297         fNodes->Add(cpvGassiplexNode) ;
298       }
299     }
300
301   } // PHOS modules
302  
303   delete[] rotname ;  
304   delete[] nodename ; 
305 }
306
307 //____________________________________________________________________________
308 void AliPHOSv0::CreateGeometry()
309 {
310   // Create the PHOS geometry for Geant
311
312   AliPHOSv0 *phostmp = dynamic_cast<AliPHOSv0*>(gAlice->GetModule("PHOS")) ;
313
314   if ( phostmp == NULL ) {
315     
316     fprintf(stderr, "PHOS detector not found!\n") ;
317     return;
318     
319   }
320
321   AliPHOSGeometry * geom = GetGeometry() ; 
322
323   // Get pointer to the array containing media indeces
324   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
325
326   // Create a PHOS module.
327   
328   gMC->Gsvolu("PHOS", "TRD1", idtmed[798], geom->GetPHOSParams(), 4) ;        
329   
330   this->CreateGeometryforEMC() ; 
331
332   this->CreateGeometryforCPV() ;
333   
334   this->CreateGeometryforSupport() ; 
335   
336   // --- Position  PHOS mdules in ALICE setup ---
337   
338   Int_t idrotm[99] ;
339   Double_t const kRADDEG = 180.0 / TMath::Pi() ;
340   Float_t * phosParams = geom->GetPHOSParams() ;
341
342   Float_t r = geom->GetIPtoOuterCoverDistance() + phosParams[3] - geom->GetCPVBoxSize(1) ;
343   Int_t i;
344   for( i = 1; i <= geom->GetNModules()  ; i++ ) {
345     
346     Float_t angle = geom->GetPHOSAngle(i) ;
347     AliMatrix(idrotm[i-1], 90.,angle, 0., 0., 90., 270. +angle) ;
348     
349     Float_t xP1 =  r * TMath::Sin( angle / kRADDEG ) ;
350     Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
351     
352     gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
353     
354   } 
355
356 }
357
358 //____________________________________________________________________________
359 void AliPHOSv0::CreateGeometryforEMC()
360 {
361   // Create the PHOS-EMC geometry for GEANT
362   // Author: Dmitri Peressounko August 2001
363   // The used coordinate system: 
364   //   1. in Module: X along longer side, Y out of beam, Z along shorter side (along beam)
365   //   2. In Strip the same: X along longer side, Y out of beam, Z along shorter side (along beam)
366
367
368     //BEGIN_HTML
369   /*
370     <H2>
371     Geant3 geometry tree of PHOS-EMC in ALICE
372     </H2>
373     <P><CENTER>
374     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif"> 
375     </CENTER><P>
376   */
377   //END_HTML  
378   
379   // Get pointer to the array containing media indexes
380   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
381
382   AliPHOSGeometry * geom = GetGeometry() ; 
383   AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ;
384
385   // ======= Define the strip ===============
386
387   gMC->Gsvolu("PSTR", "BOX ", idtmed[716], emcg->GetStripHalfSize(), 3) ;  //Made of stell
388    
389       // --- define air volume (cell of the honeycomb)
390       gMC->Gsvolu("PCEL", "BOX ", idtmed[798], emcg->GetAirCellHalfSize(), 3);
391
392       // --- define wrapped crystal and put it into AirCell
393
394       gMC->Gsvolu("PWRA", "BOX ", idtmed[702], emcg->GetWrappedHalfSize(), 3);
395       Float_t * pin = emcg->GetAPDHalfSize() ; 
396       Float_t * preamp = emcg->GetPreampHalfSize() ;
397       Float_t y = (emcg->GetAirGapLed()-2*pin[1]-2*preamp[1])/2;
398       gMC->Gspos("PWRA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;
399     
400       // --- Define crystall and put it into wrapped crystall ---
401       gMC->Gsvolu("PXTL", "BOX ", idtmed[699], emcg->GetCrystalHalfSize(), 3) ;
402       gMC->Gspos("PXTL", 1, "PWRA", 0.0, 0.0, 0.0, 0, "ONLY") ;
403       
404       // --- define APD/PIN preamp and put it into AirCell
405  
406       gMC->Gsvolu("PPIN", "BOX ", idtmed[705], emcg->GetAPDHalfSize(), 3) ;
407       Float_t * crystal = emcg->GetCrystalHalfSize() ;
408       y = crystal[1] + emcg->GetAirGapLed() /2 - preamp[1]; 
409       gMC->Gspos("PPIN", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;
410
411       gMC->Gsvolu("PREA", "BOX ", idtmed[711], emcg->GetPreampHalfSize(), 3) ;   // Here I assumed preamp
412                                                                                  // as a printed Circuit
413       y = crystal[1] + emcg->GetAirGapLed() /2 + pin[1]  ;                  // May it should be changed
414       gMC->Gspos("PREA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ;                    // to ceramics?
415    
416
417       // --- Fill strip with wrapped cristalls in Air Cells
418
419       Float_t* splate = emcg->GetSupportPlateHalfSize();  
420       y = -splate[1] ;
421       Float_t* acel = emcg->GetAirCellHalfSize() ;
422       Int_t icel ;
423       for(icel = 1; icel <= emcg->GetNCellsInStrip(); icel++){
424         Float_t x = (2*icel - 1 - emcg->GetNCellsInStrip())* acel[0] ;
425         gMC->Gspos("PCEL", icel, "PSTR", x, y, 0.0, 0, "ONLY") ;
426       }
427
428       // --- define the support plate, hole in it and position it in strip ----
429       gMC->Gsvolu("PSUP", "BOX ", idtmed[701], emcg->GetSupportPlateHalfSize(), 3) ;
430
431       gMC->Gsvolu("PSHO", "BOX ", idtmed[798], emcg->GetSupportPlateInHalfSize(), 3) ;
432       Float_t z = emcg->GetSupportPlateThickness()/2 ;
433       gMC->Gspos("PSHO", 1, "PSUP", 0.0, 0.0, z, 0, "ONLY") ;
434
435       y = acel[1] ;
436       gMC->Gspos("PSUP", 1, "PSTR", 0.0, y, 0.0, 0, "ONLY") ;
437
438
439     // ========== Fill module with strips and put them into inner thermoinsulation=============
440       gMC->Gsvolu("PTII", "BOX ", idtmed[706], emcg->GetInnerThermoHalfSize(), 3) ;     
441
442       Float_t * inthermo = emcg->GetInnerThermoHalfSize() ;
443       Float_t * strip = emcg->GetStripHalfSize() ;
444       y = inthermo[1] - strip[1] ;
445       Int_t irow;
446       Int_t nr = 1 ;
447       Int_t icol ;
448
449       for(irow = 0; irow < emcg->GetNStripX(); irow ++){
450         Float_t x = (2*irow + 1 - emcg->GetNStripX())* strip[0] ;
451         for(icol = 0; icol < emcg->GetNStripZ(); icol ++){
452           z = (2*icol + 1 - emcg->GetNStripZ()) * strip[2] ;
453           gMC->Gspos("PSTR", nr, "PTII", x, y, z, 0, "ONLY") ;
454           nr++ ;
455         }
456       }
457           
458
459    // ------- define the air gap between thermoinsulation and cooler
460       gMC->Gsvolu("PAGA", "BOX ", idtmed[798], emcg->GetAirGapHalfSize(), 3) ;   
461       Float_t * agap = emcg->GetAirGapHalfSize() ;
462       y = agap[1] - inthermo[1]  ;
463       
464       gMC->Gspos("PTII", 1, "PAGA", 0.0, y, 0.0, 0, "ONLY") ;
465
466
467
468    // ------- define the Al passive cooler 
469       gMC->Gsvolu("PCOR", "BOX ", idtmed[701], emcg->GetCoolerHalfSize(), 3) ;   
470       Float_t * cooler = emcg->GetCoolerHalfSize() ;
471       y = cooler[1] - agap[1]  ;
472       
473       gMC->Gspos("PAGA", 1, "PCOR", 0.0, y, 0.0, 0, "ONLY") ;
474
475    // ------- define the outer thermoinsulating cover
476       gMC->Gsvolu("PTIO", "TRD1", idtmed[706], emcg->GetOuterThermoParams(), 4) ;        
477       Float_t * outparams = emcg->GetOuterThermoParams() ; 
478
479       Int_t idrotm[99] ;
480       AliMatrix(idrotm[1], 90.0, 0.0, 0.0, 0.0, 90.0, 270.0) ;
481       // Frame in outer thermoinsulation and so on: z out of beam, y along beam, x across beam
482  
483       z = outparams[3] - cooler[1] ;
484       gMC->Gspos("PCOR", 1, "PTIO", 0., 0.0, z, idrotm[1], "ONLY") ;
485        
486   // -------- Define the outer Aluminium cover -----
487       gMC->Gsvolu("PCOL", "TRD1", idtmed[701], emcg->GetAlCoverParams(), 4) ;        
488       Float_t * covparams = emcg->GetAlCoverParams() ; 
489       z = covparams[3] - outparams[3] ;
490       gMC->Gspos("PTIO", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ;
491
492  // --------- Define front fiberglass cover -----------
493       gMC->Gsvolu("PFGC", "BOX ", idtmed[717], emcg->GetFiberGlassHalfSize(), 3) ;  
494       z = - outparams[3] ;
495       gMC->Gspos("PFGC", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ;
496
497  //=============This is all with cold section==============
498
499
500       //------ Warm Section --------------
501       gMC->Gsvolu("PWAR", "BOX ", idtmed[701], emcg->GetWarmAlCoverHalfSize(), 3) ; 
502       Float_t * warmcov = emcg->GetWarmAlCoverHalfSize() ;
503
504       // --- Define the outer thermoinsulation ---
505       gMC->Gsvolu("PWTI", "BOX ", idtmed[706], emcg->GetWarmThermoHalfSize(), 3) ; 
506       Float_t * warmthermo = emcg->GetWarmThermoHalfSize() ;
507       z = -warmcov[2] + warmthermo[2] ;
508
509       gMC->Gspos("PWTI", 1, "PWAR", 0., 0.0, z, 0, "ONLY") ;     
510
511       // --- Define cables area and put in it T-supports ---- 
512       gMC->Gsvolu("PCA1", "BOX ", idtmed[718], emcg->GetTCables1HalfSize(), 3) ; 
513       Float_t * cbox = emcg->GetTCables1HalfSize() ;
514
515       gMC->Gsvolu("PBE1", "BOX ", idtmed[701], emcg->GetTSupport1HalfSize(), 3) ;
516       Float_t * beams = emcg->GetTSupport1HalfSize() ;
517       Int_t isup ;
518       for(isup = 0; isup < emcg->GetNTSuppots(); isup++){
519         Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ;
520         gMC->Gspos("PBE1", isup, "PCA1", x, 0.0, 0.0, 0, "ONLY") ;
521       }
522
523       z = -warmthermo[2] + cbox[2] ;
524       gMC->Gspos("PCA1", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ;     
525
526       gMC->Gsvolu("PCA2", "BOX ", idtmed[718], emcg->GetTCables2HalfSize(), 3) ; 
527       Float_t * cbox2 = emcg->GetTCables2HalfSize() ;
528
529       gMC->Gsvolu("PBE2", "BOX ", idtmed[701], emcg->GetTSupport2HalfSize(), 3) ;
530       for(isup = 0; isup < emcg->GetNTSuppots(); isup++){
531         Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ;
532         gMC->Gspos("PBE2", isup, "PCA2", x, 0.0, 0.0, 0, "ONLY") ;
533       }
534
535       z = -warmthermo[2] + 2*cbox[2] + cbox2[2];
536       gMC->Gspos("PCA2", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ;     
537
538
539   // --- Define frame ---
540       gMC->Gsvolu("PFRX", "BOX ", idtmed[716], emcg->GetFrameXHalfSize(), 3) ; 
541       Float_t * posit = emcg->GetFrameXPosition() ;
542       gMC->Gspos("PFRX", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
543       gMC->Gspos("PFRX", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
544
545       gMC->Gsvolu("PFRZ", "BOX ", idtmed[716], emcg->GetFrameZHalfSize(), 3) ; 
546       posit = emcg->GetFrameZPosition() ;
547       gMC->Gspos("PFRZ", 1, "PWTI", posit[0], posit[1],  posit[2], 0, "ONLY") ;
548       gMC->Gspos("PFRZ", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
549
550  // --- Define Fiber Glass support ---
551       gMC->Gsvolu("PFG1", "BOX ", idtmed[717], emcg->GetFGupXHalfSize(), 3) ; 
552       posit = emcg->GetFGupXPosition() ;
553       gMC->Gspos("PFG1", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
554       gMC->Gspos("PFG1", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
555
556       gMC->Gsvolu("PFG2", "BOX ", idtmed[717], emcg->GetFGupZHalfSize(), 3) ; 
557       posit = emcg->GetFGupZPosition() ;
558       gMC->Gspos("PFG2", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
559       gMC->Gspos("PFG2", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
560
561       gMC->Gsvolu("PFG3", "BOX ", idtmed[717], emcg->GetFGlowXHalfSize(), 3) ; 
562       posit = emcg->GetFGlowXPosition() ;
563       gMC->Gspos("PFG3", 1, "PWTI", posit[0],  posit[1], posit[2], 0, "ONLY") ;
564       gMC->Gspos("PFG3", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
565
566       gMC->Gsvolu("PFG4", "BOX ", idtmed[717], emcg->GetFGlowZHalfSize(), 3) ; 
567       posit = emcg->GetFGlowZPosition() ;
568       gMC->Gspos("PFG4", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
569       gMC->Gspos("PFG4", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
570
571       // --- Define Air Gap for FEE electronics ----- 
572
573       gMC->Gsvolu("PAFE", "BOX ", idtmed[798], emcg->GetFEEAirHalfSize(), 3) ; 
574       posit = emcg->GetFEEAirPosition() ;
575       gMC->Gspos("PAFE", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
576
577       // Define the EMC module volume and combine Cool and Warm sections
578
579       gMC->Gsvolu("PEMC", "TRD1", idtmed[798], emcg->GetEMCParams(), 4) ;        
580
581       z =  - warmcov[2] ;
582       gMC->Gspos("PCOL", 1, "PEMC",  0., 0., z, 0, "ONLY") ;
583       z = covparams[3] ;
584       gMC->Gspos("PWAR", 1, "PEMC",  0., 0., z, 0, "ONLY") ;
585
586
587       // Put created EMC geometry into PHOS volume
588       
589       z = geom->GetCPVBoxSize(1) / 2. ;
590       gMC->Gspos("PEMC", 1, "PHOS", 0., 0., z, 0, "ONLY") ; 
591             
592 }
593
594 //____________________________________________________________________________
595 void AliPHOSv0::CreateGeometryforCPV()
596 {
597   // Create the PHOS-CPV geometry for GEANT
598   // Author: Yuri Kharlov 11 September 2000
599   //BEGIN_HTML
600   /*
601     <H2>
602     Geant3 geometry of PHOS-CPV in ALICE
603     </H2>
604     <table width=700>
605
606     <tr>
607          <td>CPV perspective view</td>
608          <td>CPV front view      </td>
609     </tr>
610
611     <tr>
612          <td> <img height=300 width=290 src="../images/CPVallPersp.gif"> </td>
613          <td> <img height=300 width=290 src="../images/CPVallFront.gif"> </td>
614     </tr>
615
616     <tr>
617          <td>One CPV module, perspective view                            </td>
618          <td>One CPV module, front view (extended in vertical direction) </td>
619     </tr>
620
621     <tr>
622          <td><img height=300 width=290 src="../images/CPVmodulePers.gif"></td>
623          <td><img height=300 width=290 src="../images/CPVmoduleSide.gif"></td>
624     </tr>
625
626     </table>
627
628     <H2>
629     Geant3 geometry tree of PHOS-CPV in ALICE
630     </H2>
631     <center>
632     <img height=300 width=290 src="../images/CPVtree.gif">
633     </center>
634   */
635   //END_HTML  
636
637   Float_t par[3], x,y,z;
638
639   // Get pointer to the array containing media indexes
640   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
641
642   AliPHOSGeometry * geom = GetGeometry() ; 
643
644   // The box containing all CPV for one PHOS module filled with air 
645   par[0] = geom->GetCPVBoxSize(0) / 2.0 ;  
646   par[1] = geom->GetCPVBoxSize(1) / 2.0 ; 
647   par[2] = geom->GetCPVBoxSize(2) / 2.0 ;
648   gMC->Gsvolu("PCPV", "BOX ", idtmed[798], par, 3) ;
649
650   Float_t * emcParams = geom->GetEMCAGeometry()->GetEMCParams() ;
651   z = - emcParams[3] ;
652   Int_t rotm ;
653   AliMatrix(rotm, 90.,0., 0., 0., 90., 90.) ;
654
655   gMC->Gspos("PCPV", 1, "PHOS", 0.0, 0.0, z, rotm, "ONLY") ; 
656   
657   // Gassiplex board
658   
659   par[0] = geom->GetGassiplexChipSize(0)/2.;
660   par[1] = geom->GetGassiplexChipSize(1)/2.;
661   par[2] = geom->GetGassiplexChipSize(2)/2.;
662   gMC->Gsvolu("PCPC","BOX ",idtmed[707],par,3);
663   
664   // Cu+Ni foil covers Gassiplex board
665
666   par[1] = geom->GetCPVCuNiFoilThickness()/2;
667   gMC->Gsvolu("PCPD","BOX ",idtmed[710],par,3);
668   y      = -(geom->GetGassiplexChipSize(1)/2 - par[1]);
669   gMC->Gspos("PCPD",1,"PCPC",0,y,0,0,"ONLY");
670
671   // Position of the chip inside CPV
672
673   Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1);
674   Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ()   + 1);
675   Int_t   copy  = 0;
676   y = geom->GetCPVFrameSize(1)/2           - geom->GetFTPosition(0) +
677     geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1;
678   for (Int_t ix=0; ix<geom->GetNumberOfCPVChipsPhi(); ix++) {
679     x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2;
680     for (Int_t iz=0; iz<geom->GetNumberOfCPVChipsZ(); iz++) {
681       copy++;
682       z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2;
683       gMC->Gspos("PCPC",copy,"PCPV",x,y,z,0,"ONLY");
684     }
685   }
686
687   // Foiled textolite (1 mm of textolite + 50 mkm of Cu + 6 mkm of Ni)
688   
689   par[0] = geom->GetCPVActiveSize(0)        / 2;
690   par[1] = geom->GetCPVTextoliteThickness() / 2;
691   par[2] = geom->GetCPVActiveSize(1)        / 2;
692   gMC->Gsvolu("PCPF","BOX ",idtmed[707],par,3);
693
694   // Argon gas volume
695
696   par[1] = (geom->GetFTPosition(2) - geom->GetFTPosition(1) - geom->GetCPVTextoliteThickness()) / 2;
697   gMC->Gsvolu("PCPG","BOX ",idtmed[715],par,3);
698
699   for (Int_t i=0; i<4; i++) {
700     y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(i) + geom->GetCPVTextoliteThickness()/2;
701     gMC->Gspos("PCPF",i+1,"PCPV",0,y,0,0,"ONLY");
702     if(i==1){
703       y-= (geom->GetFTPosition(2) - geom->GetFTPosition(1)) / 2;
704       gMC->Gspos("PCPG",1,"PCPV ",0,y,0,0,"ONLY");
705     }
706   }
707
708   // Dummy sensitive plane in the middle of argone gas volume
709
710   par[1]=0.001;
711   gMC->Gsvolu("PCPQ","BOX ",idtmed[715],par,3);
712   gMC->Gspos ("PCPQ",1,"PCPG",0,0,0,0,"ONLY");
713
714   // Cu+Ni foil covers textolite
715
716   par[1] = geom->GetCPVCuNiFoilThickness() / 2;
717   gMC->Gsvolu("PCP1","BOX ",idtmed[710],par,3);
718   y = geom->GetCPVTextoliteThickness()/2 - par[1];
719   gMC->Gspos ("PCP1",1,"PCPF",0,y,0,0,"ONLY");
720
721   // Aluminum frame around CPV
722
723   par[0] = geom->GetCPVFrameSize(0)/2;
724   par[1] = geom->GetCPVFrameSize(1)/2;
725   par[2] = geom->GetCPVBoxSize(2)  /2;
726   gMC->Gsvolu("PCF1","BOX ",idtmed[701],par,3);
727
728   par[0] = geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0);
729   par[1] = geom->GetCPVFrameSize(1)/2;
730   par[2] = geom->GetCPVFrameSize(2)/2;
731   gMC->Gsvolu("PCF2","BOX ",idtmed[701],par,3);
732
733   for (Int_t j=0; j<=1; j++) {
734     x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2;
735     gMC->Gspos("PCF1",j+1,"PCPV", x,0,0,0,"ONLY");
736     z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2;
737     gMC->Gspos("PCF2",j+1,"PCPV",0, 0,z,0,"ONLY");
738   }
739
740 }
741
742
743 //____________________________________________________________________________
744 void AliPHOSv0::CreateGeometryforSupport()
745 {
746   // Create the PHOS' support geometry for GEANT
747     //BEGIN_HTML
748   /*
749     <H2>
750     Geant3 geometry of the PHOS's support
751     </H2>
752     <P><CENTER>
753     <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/PHOS_support.gif"> 
754     </CENTER><P>
755   */
756   //END_HTML  
757   
758   Float_t par[5], x0,y0,z0 ; 
759   Int_t   i,j,copy;
760
761   // Get pointer to the array containing media indexes
762   Int_t *idtmed = fIdtmed->GetArray() - 699 ;
763
764   AliPHOSGeometry * geom = GetGeometry() ; 
765
766   // --- Dummy box containing two rails on which PHOS support moves
767   // --- Put these rails to the bottom of the L3 magnet
768
769   par[0] =  geom->GetRailRoadSize(0) / 2.0 ;
770   par[1] =  geom->GetRailRoadSize(1) / 2.0 ;
771   par[2] =  geom->GetRailRoadSize(2) / 2.0 ;
772   gMC->Gsvolu("PRRD", "BOX ", idtmed[798], par, 3) ;
773
774   y0     = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) / 2.0) ;
775   gMC->Gspos("PRRD", 1, "ALIC", 0.0, y0, 0.0, 0, "ONLY") ; 
776
777   // --- Dummy box containing one rail
778
779   par[0] =  geom->GetRailOuterSize(0) / 2.0 ;
780   par[1] =  geom->GetRailOuterSize(1) / 2.0 ;
781   par[2] =  geom->GetRailOuterSize(2) / 2.0 ;
782   gMC->Gsvolu("PRAI", "BOX ", idtmed[798], par, 3) ;
783
784   for (i=0; i<2; i++) {
785     x0     = (2*i-1) * geom->GetDistanceBetwRails()  / 2.0 ;
786     gMC->Gspos("PRAI", i, "PRRD", x0, 0.0, 0.0, 0, "ONLY") ; 
787   }
788
789   // --- Upper and bottom steel parts of the rail
790
791   par[0] =  geom->GetRailPart1(0) / 2.0 ;
792   par[1] =  geom->GetRailPart1(1) / 2.0 ;
793   par[2] =  geom->GetRailPart1(2) / 2.0 ;
794   gMC->Gsvolu("PRP1", "BOX ", idtmed[716], par, 3) ;
795
796   y0     = - (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 ;
797   gMC->Gspos("PRP1", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
798   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart1(1))  / 2.0 - geom->GetRailPart3(1);
799   gMC->Gspos("PRP1", 2, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ;
800
801   // --- The middle vertical steel parts of the rail
802
803   par[0] =  geom->GetRailPart2(0) / 2.0 ;
804   par[1] =  geom->GetRailPart2(1) / 2.0 ;
805   par[2] =  geom->GetRailPart2(2) / 2.0 ;
806   gMC->Gsvolu("PRP2", "BOX ", idtmed[716], par, 3) ;
807
808   y0     =   - geom->GetRailPart3(1) / 2.0 ;
809   gMC->Gspos("PRP2", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
810
811   // --- The most upper steel parts of the rail
812
813   par[0] =  geom->GetRailPart3(0) / 2.0 ;
814   par[1] =  geom->GetRailPart3(1) / 2.0 ;
815   par[2] =  geom->GetRailPart3(2) / 2.0 ;
816   gMC->Gsvolu("PRP3", "BOX ", idtmed[716], par, 3) ;
817
818   y0     =   (geom->GetRailOuterSize(1) - geom->GetRailPart3(1))  / 2.0 ;
819   gMC->Gspos("PRP3", 1, "PRAI", 0.0, y0, 0.0, 0, "ONLY") ; 
820
821   // --- The wall of the cradle
822   // --- The wall is empty: steel thin walls and air inside
823
824   par[1] =  TMath::Sqrt(TMath::Power((geom->GetIPtoCPVDistance() + geom->GetOuterBoxSize(3)),2) +
825                         TMath::Power((geom->GetOuterBoxSize(1)/2),2))+10. ;
826   par[0] =  par[1] - geom->GetCradleWall(1) ;
827   par[2] =  geom->GetCradleWall(2) / 2.0 ;
828   par[3] =  geom->GetCradleWall(3) ;
829   par[4] =  geom->GetCradleWall(4) ;
830   gMC->Gsvolu("PCRA", "TUBS", idtmed[716], par, 5) ;
831
832   par[0] +=  geom->GetCradleWallThickness() ;
833   par[1] -=  geom->GetCradleWallThickness() ;
834   par[2] -=  geom->GetCradleWallThickness() ;
835   gMC->Gsvolu("PCRE", "TUBS", idtmed[798], par, 5) ;
836   gMC->Gspos ("PCRE", 1, "PCRA", 0.0, 0.0, 0.0, 0, "ONLY") ; 
837
838   for (i=0; i<2; i++) {
839     z0 = (2*i-1) * (geom->GetOuterBoxSize(2) + geom->GetCradleWall(2) )/ 2.0  ;
840         gMC->Gspos("PCRA", i, "ALIC", 0.0, 0.0, z0, 0, "ONLY") ; 
841   }
842
843   // --- The "wheels" of the cradle
844   
845   par[0] = geom->GetCradleWheel(0) / 2;
846   par[1] = geom->GetCradleWheel(1) / 2;
847   par[2] = geom->GetCradleWheel(2) / 2;
848   gMC->Gsvolu("PWHE", "BOX ", idtmed[716], par, 3) ;
849
850   y0 = -(geom->GetRailsDistanceFromIP() - geom->GetRailRoadSize(1) -
851          geom->GetCradleWheel(1)/2) ;
852   for (i=0; i<2; i++) {
853     z0 = (2*i-1) * ((geom->GetOuterBoxSize(2) + geom->GetCradleWheel(2))/ 2.0 +
854                     geom->GetCradleWall(2));
855     for (j=0; j<2; j++) {
856       copy = 2*i + j;
857       x0 = (2*j-1) * geom->GetDistanceBetwRails()  / 2.0 ;
858       gMC->Gspos("PWHE", copy, "ALIC", x0, y0, z0, 0, "ONLY") ; 
859     }
860   }
861
862 }
863
864 //____________________________________________________________________________
865 Float_t AliPHOSv0::ZMin(void) const
866 {
867   // Overall dimension of the PHOS (min)
868
869   AliPHOSGeometry * geom = GetGeometry() ; 
870
871   return -geom->GetOuterBoxSize(2)/2.;
872 }
873
874 //____________________________________________________________________________
875 Float_t AliPHOSv0::ZMax(void) const
876 {
877   // Overall dimension of the PHOS (max)
878
879   AliPHOSGeometry * geom = GetGeometry() ; 
880
881   return  geom->GetOuterBoxSize(2)/2.;
882 }
883
884 //____________________________________________________________________________
885 void AliPHOSv0::Init(void)
886 {
887   // Just prints an information message
888   
889   Int_t i;
890
891   if(AliLog::GetGlobalDebugLevel()>0) {
892     TString st ; 
893     for(i=0;i<35;i++) 
894       st += "*";
895     Info("Init", "%s", st.Data()) ;  
896     // Here the PHOS initialisation code (if any!)
897     
898     AliPHOSGeometry * geom = GetGeometry() ; 
899
900     if (geom!=0)  
901       Info("Init", "AliPHOS%s: PHOS geometry intialized for %s", Version().Data(), geom->GetName()) ;
902     else
903       Info("Init", "AliPHOS%s: PHOS geometry initialization failed !", Version().Data()) ;       
904
905     Info("Init", "%s", st.Data()) ;  
906   }
907 }