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