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