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