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