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