]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALv0.cxx
correct the size of volumes XEN1 and XUi to have all the volumes inside mothers
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv0.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id$ */
16
17 //_________________________________________________________________________
18 // Implementation version v0 of EMCAL Manager class 
19 // An object of this class does not produce hits nor digits
20 // It is the one to use if you do not want to produce outputs in TREEH or TREED
21 // This class places a Geometry of the EMCAL in the ALICE Detector as defined in AliEMCALGeometry.cxx                 
22 //*-- Author: Yves Schutz (SUBATECH)
23 //*-- and   : Sahal Yacoob (LBL / UCT)
24
25 // This Version of AliEMCALv0 reduces the number of volumes placed in XEN1 (the envelope) to less than five hundred
26 // The Envelope is Placed in Alice, And the Aluminium layer. Mini envelopes (XU) are then placed in XEN1.
27 // Each mini envelope contains 2 scintillator, and 2 lead layers, except the last one which contains just one scintillator layer.
28 // At the moment I cannot place the 36 and above layers in the mini envelopes so all layers are still placed in XEN1
29
30
31 // --- ROOT system ---
32
33 #include "TPGON.h"
34 #include "TTUBS.h"
35 #include "TNode.h"
36 #include "TRandom.h"
37 #include "TGeometry.h"
38
39 // --- Standard library ---
40
41 #include <stdio.h>
42 #include <string.h>
43 #include <stdlib.h>
44 #include <Rstrstream.h>
45 #include <Riostream.h>
46
47 // --- AliRoot header files ---
48
49 #include "AliEMCALv0.h"
50 #include "AliEMCALGeometry.h"
51 #include "AliConst.h"
52 #include "AliRun.h"
53
54 ClassImp(AliEMCALv0)
55
56 //______________________________________________________________________
57 AliEMCALv0::AliEMCALv0(const char *name, const char *title):
58   AliEMCAL(name,title)
59 {
60   // ctor : title is used to identify the layout
61   GetGeometry() ; 
62
63 }
64
65 //______________________________________________________________________
66 void AliEMCALv0::BuildGeometry()
67 {
68     // Display Geometry for display.C
69
70     const Int_t kColorArm1   = kBlue ;
71
72     AliEMCALGeometry * geom = GetGeometry() ; 
73
74     // Define the shape of the Calorimeter 
75     TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
76     new TTUBS("Envelop1", "Tubs that contains arm 1", "void", 
77               geom->GetEnvelop(0),     // rmin 
78               geom->GetEnvelop(1) +30 ,     // rmax
79               geom->GetEnvelop(2)/2.0, // half length in Z
80               geom->GetArm1PhiMin(),   // minimun phi angle
81               geom->GetArm1PhiMax()    // maximun phi angle
82         );
83
84     // Place the Node
85     top->cd();
86     TNode * envelop1node = new TNode("Envelop1", "Arm1 Envelop", "Envelop1"
87                                      ,0., 0., 0., "") ;
88     envelop1node->SetLineColor(kColorArm1) ;
89     fNodes->Add(envelop1node) ;
90 }
91
92 //______________________________________________________________________
93 void AliEMCALv0::CreateGeometry()
94 {
95   // Create the EMCAL geometry for Geant
96   // Geometry of a tower
97   //|-----------------------------------------------------| XEN1
98   //| |                                                 | |
99   //| |    Al thickness = GetAlFrontThickness()         | |
100   //| |                                                 | |
101   //| |                                                 | |
102   //| |                                                 | |
103   //|  -------------------------------------------------  |
104   //| |    Air Gap = GetGap2Active()                    | |
105   //| |                                                 | |
106   //|  -------------------------------------------------  |
107   //| |    XU0 : XPST (PreShower e = GetPreSintThick() )| |
108   //|  -------------------------------------------------  |
109   //| |    XU0 : XPBX (PreShower e = GetPbRadThick() )  | |
110   //|  -------------------------------------------------  |
111   //| |    XU0 : XPST (PreShower e = GetPreSintThick() )| |
112   //|  -------------------------------------------------  |
113   //| |    XU0 : XPBX (PreShower e = GetPbRadThick() )  | |
114   //|  -------------------------------------------------  |
115   //| |    XU1 : XPST (Tower e = GetFullSintThick() )   | |
116   //|  -------------------------------------------------  |
117   //| |    XU1 : XPBX (Tower e = GetPbRadThick() )      | |
118   //|  -------------------------------------------------  |
119   //| |    XU1 : XPST (Tower e = GetFullSintThick()     | |
120   //|  -------------------------------------------------  |
121   //| |    XU1 : XPBX (Tower e = GetPbRadThick() )      | |
122   //|  -------------------------------------------------  |
123   //|    etc .....                                        |
124   //|  -------------------------------------------------  |
125   //| |    XU10 : XPST (Tower e = GetFullSintThick() )  | |
126   //|-----------------------------------------------------|
127  
128     Float_t etamin,etamax;
129     Float_t *dum=0;
130
131     AliEMCALGeometry * geom = GetGeometry() ; 
132
133     if(!(geom->IsInitialized())){
134         Error("CreateGeometry","EMCAL Geometry class has not been set up.");
135     } // end if
136
137     // Get pointer to the array containing media indices
138     Int_t *idtmed = fIdtmed->GetArray() - 1599 ;
139
140     Int_t idrotm = 1;
141     AliMatrix(idrotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
142
143
144
145     // Create the EMCAL Mother Volume (a polygone) within which to place the Detector and named XEN1 
146
147     Float_t envelopA[10];
148     envelopA[0] = geom->GetArm1PhiMin();                         // minimum phi angle
149     envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
150     envelopA[2] = geom->GetNPhi();                               // number of sections in phi
151     envelopA[3] = 2;                                             // 2 z coordinates
152     envelopA[4] = geom->ZFromEtaR(geom->GetEnvelop(1),
153                                    geom->GetArm1EtaMin());       // z coordinate 1
154     envelopA[5] = geom->GetEnvelop(0) ;                          // rmin at z1
155     envelopA[6] = geom->GetEnvelop(1) ;                          // rmax at z1
156     envelopA[7] = geom->ZFromEtaR(geom->GetEnvelop(1),
157                                   geom->GetArm1EtaMax());        // z coordinate 2
158     envelopA[8] = envelopA[5] ;                                  // radii are the same.
159     envelopA[9] = envelopA[6] ;                                  // radii are the same.
160
161     gMC->Gsvolu("XEN1", "PGON ", idtmed[1599], envelopA, 10) ;   // Polygone filled with air 
162
163     // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)  
164
165     gMC->Gspos("XEN1", 1, "ALIC", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
166     
167     if (gDebug==2) 
168       Info("CreateGeometry","rXEN1 = %f, %f\n", envelopA[5], envelopA[6]); 
169
170     // Create mini-envelopes which will contain the PreShower scintillator-Lead-scintillator-lead  
171    
172     if (gDebug==2) 
173       Info("CreateGeometry","XU0 = %f, %f\n", envelopA[5], envelopA[6]); 
174
175     // Create mini-envelopes which will contain the Tower scintillator-radiator-scintillator-radiator 
176     
177     TString label ;
178
179     envelopA[5] = envelopA[5] + geom->GetGap2Active() // we are at the first scintllator
180       + geom->GetAlFrontThickness();                  // rmin at z1
181     envelopA[6] = envelopA[5] ;
182
183
184     Int_t i ; 
185
186     Int_t nLayers = geom->GetNPRLayers() + geom->GetNECLayers() + geom->GetNHCLayers() ;
187
188     for (i = 0; i < nLayers/2 ; i++ ){
189         label = "XU" ;
190         label += i ;
191         Float_t tseg ; 
192         if (i == 0 ) 
193           tseg = 2 *(geom->GetPreSintThick()+geom->GetPbRadThick()); // thickness of 2 * scintillator+Pb in pre shower
194         else if ( i <= geom->GetNECLayers()/2) 
195           tseg = 2* (geom->GetFullSintThick()+geom->GetPbRadThick()); // thickness of 2 * scintillator+Pb in E Cal
196         else 
197           tseg = 2* (geom->GetFullSintThick()+geom->GetCuRadThick()); // thickness of 2 * scintillator+Cu in H Cal 
198         envelopA[5] = envelopA[6] ;                                   // rmin at z1
199         envelopA[4] = geom->ZFromEtaR(envelopA[5] + tseg,
200                                       geom->GetArm1EtaMin());         // z coordinate 1
201         envelopA[7] = geom->ZFromEtaR(envelopA[5] + tseg,
202                                       geom->GetArm1EtaMax());         // z coordinate 2
203         envelopA[6] = envelopA[5] + tseg ;                            // rmax at z1
204         envelopA[8] = envelopA[5] ;                                   // radii are the same.
205         envelopA[9] = envelopA[6] ;                                   // radii are the same.
206  
207         gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10);// Polygone filled with air 
208
209         // Position XUi in XEN1
210         
211         gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
212
213         if (gDebug == 2)
214           Info("CreateGeometry","XU%d = %f, %f\n", i, envelopA[5], envelopA[6]); 
215
216     } // end  i
217  
218   
219     // Create one mini-envelope which will contain the last Tower scintillator (XU(nlayers-1)/2)
220
221     label = "XU" ;
222     label += i ;
223     envelopA[5] = envelopA[6] ;                                   // rmin at z1
224     envelopA[4] = geom->ZFromEtaR(envelopA[5],
225                                   geom->GetArm1EtaMin());         // z coordinate 1
226     envelopA[7] = geom->ZFromEtaR(envelopA[5],
227                                   geom->GetArm1EtaMax());         // z coordinate 2
228     envelopA[6] = envelopA[5] + geom->GetFullSintThick() ;        // rmax at z1
229     envelopA[8] = envelopA[5] ;                                   // radii are the same.
230     envelopA[9] = envelopA[6] ;                                   // radii are the same.
231
232     gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10); // Polygone filled with air
233
234     // Position the last minienvelope in XEN1
235   
236     gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
237   
238     if(gDebug == 2) 
239       Info("CreateGeometry","XEN%d = %f, %f\n", i, envelopA[5], envelopA[6]); 
240   
241     // Create the shapes of active material (LEAD/Aluminium/Scintillator)
242     // to be placed
243     Float_t envelopB[10]; // First Layer of Aluminium
244     Float_t envelopC[10]; // Scintillator Layers
245     Float_t envelopD[10]; // Lead Layers
246
247     envelopC[0] = envelopD[0] = envelopB[0] = envelopA[0] ;  // starting position in Phi
248     envelopC[1] = envelopD[1] = envelopB[1] = envelopA[1] ;  // angular range in phi          
249     envelopC[2] = envelopD[2] = envelopB[2] = envelopA[2] ;  // number of sections in Phi
250     envelopD[3] = envelopC[3] = envelopB[3] = envelopA[3] ;  // 2 z coordinates
251
252     Float_t dist = geom->GetEnvelop(0) + geom->GetAlFrontThickness() + geom->GetGap2Active() ; 
253     envelopB[4] = geom->ZFromEtaR(dist,
254                                   geom->GetArm1EtaMin());   // z co-ordinate 1
255     envelopB[5] = geom->GetEnvelop(0) ;                     // rmin at z1
256     envelopB[6] = envelopB[5] + geom->GetAlFrontThickness();// rmax at z1
257     envelopB[7] = geom->ZFromEtaR(dist,
258                                   geom->GetArm1EtaMax());   // z co-ordinate 2
259     envelopB[8] = envelopB[5] ;                             // radii are the same.
260     envelopB[9] = envelopB[6] ;                             // radii are the same.
261
262     // Define active volumes completely
263     
264     gMC->Gsvolu("XALU", "PGON", idtmed[1602], envelopB, 10); // PGON filled with Al
265     
266     gMC->Gspos("XALU", 1, "XEN1", 0.0, 0.0, 0.0 , idrotm, "ONLY") ; // Position Aluminium Layer in XEN1
267
268     gMC->Gsvolu("XPST", "PGON", idtmed[1601], dum, 0);      // PGON filled with Scintillator (shape to be defined by GSPOSP)
269   
270     gMC->Gsvolu("XPBX", "PGON", idtmed[1600], dum, 0);      // PGON filled with Lead (shape to be defined by GSPOSP)
271   
272     gMC->Gsvolu("XCUX", "PGON", idtmed[1603], dum, 0);      // PGON filled with Copper (shape to be defined by GSPOSP)
273
274     gMC->Gsdvn("XPHI", "XPST", geom->GetNPhi(), 2);         // Divide eta section of scintillators into phi segments.
275  
276     // Position alternatively scintillator and  Lead Layers in XUi.
277
278     envelopD[6] = envelopB[6] + geom->GetGap2Active() ;// gap between Al layer and XU0
279     
280     for (int i = 0; i < nLayers; i++ ){
281       label = "XU" ;
282       label += static_cast<Int_t> (i/2)  ; // we will place two layers (i = one layer) in each mini envelope)   
283
284       Float_t scthick ; // scintillator thickness 
285       if ( i <  geom->GetNPRLayers() ) // its a preshower
286         scthick = geom->GetPreSintThick() ;
287       else if( i < geom->GetNPRLayers() + geom->GetNECLayers() ) // its an EMCAL section
288         scthick = geom->GetFullSintThick() ;
289       else  // its an HCAL section
290         scthick = geom->GetFullSintThick() ;
291
292       envelopC[5] = envelopD[6] ;           //rmin
293       envelopC[6] = envelopC[5] + scthick ; //rmax
294       envelopC[8] = envelopC[5] ;           //rmin
295       envelopC[9] = envelopC[6] ;           //rmax
296
297
298       //        envelopC[6] = envelopD[6] + ((i > 1)  ? geom->GetFullSintThick() : geom->GetPreSintThick());//rmax larger for first two layers (preshower)
299       //        envelopC[9] = envelopD[6] + ((i > 1 ) ? geom->GetFullSintThick() :geom->GetPreSintThick());//rmax larger for first two layers (preshower)
300
301       if(gDebug == 2 ) 
302         Info("CreateGeometry", "volume = %s, name = XPST thickness = %f deb = %f/%f fin = %f/%f", label.Data(), scthick, envelopC[5], envelopC[8], envelopC[6], envelopC[9]) ; 
303
304       for (int j =0; j < (geom->GetNEta()) ; j++){
305         etamin = geom->GetArm1EtaMin()+
306           (j*geom->GetDeltaEta());
307         etamax = geom->GetArm1EtaMin()+
308           ((j+1)*geom->GetDeltaEta());
309         envelopC[4] = geom->ZFromEtaR(envelopC[5],etamin); //z begin  
310         envelopC[7] = geom->ZFromEtaR(envelopC[5],etamax);// z end 
311         
312         gMC->Gsposp("XPST",1+j+i*(geom->GetNEta()), label.Data(), 
313                     0.0, 0.0, 0.0 , idrotm, "ONLY", envelopC, 10); // Position and define layer
314       } // end for j
315       
316       if (i < nLayers){ 
317         Float_t radthick ; // radiator thickness 
318         TString radname ;  // radiator name
319         if ( i <= 1 ) { // its a preshower
320           radthick =  geom->GetPbRadThick();
321           radname  =  "XPBX" ; 
322         }
323         else if( i <= geom->GetNECLayers()) {// its an EMCAL section
324           radthick = geom->GetPbRadThick();
325           radname  =  "XPBX" ; 
326         }
327         else {  // its an HCAL section
328           radthick = geom->GetCuRadThick();
329           radname  =  "XCUX" ; 
330         }
331
332         if ( i < nLayers -1 ) { // except for the last XU which contains only one scintillator layer 
333
334           envelopD[5] = envelopC[6] ; //rmin
335           envelopD[8] = envelopD[5] ; //rmin
336           envelopD[6] = envelopD[5] + radthick ; // rmax
337           //  envelopD[6] = envelopC[6] + geom->GetPbRadThick();  //rmax
338           envelopD[9] = envelopD[6] ; //rmax
339           // envelopD[9] = envelopC[6] + geom->GetPbRadThick();  //rmax
340           
341           if(gDebug == 2 ) 
342             Info("CreateGeometry", "volume = %s, name = %s thickness = %f deb = %f/%f fin = %f/%f", label.Data(), radname.Data(), radthick, envelopD[5], envelopD[8], envelopD[6], envelopD[9]) ; 
343
344           for (int j =0; j < (geom->GetNEta()) ; j++){
345             etamin = geom->GetArm1EtaMin()+
346               (j*geom->GetDeltaEta());
347             etamax = geom->GetArm1EtaMin()+
348               ((j+1)*geom->GetDeltaEta());
349             envelopD[4] = geom->ZFromEtaR(envelopD[5],etamin);//z begin  
350             envelopD[7] = geom->ZFromEtaR(envelopD[5],etamax);// z end
351             
352             // Position and Define Layer
353             
354             gMC->Gsposp(radname.Data(),1+j+i*(geom->GetNEta()), label.Data(), 
355                         0.0, 0.0, 0.0 , idrotm, "ONLY", envelopD, 10);
356           } // end for j
357         } // if not last layer
358       } // end if i
359     }  // for i
360 }
361
362 //______________________________________________________________________
363 void AliEMCALv0::Init(void)
364 {
365     // Just prints an information message
366   
367   if(fDebug) { 
368     TString message("\n") ; 
369     message += "*****************************************\n" ;
370     
371     // Here the EMCAL initialisation code (if any!)
372     
373     AliEMCALGeometry * geom = GetGeometry() ; 
374     
375     if (geom!=0) {   
376       message += "AliEMCAL " ; 
377       message += Version() ; 
378       message += "EMCAL geometry initialized for " ; 
379       message += geom->GetName()  ;
380     }
381     else {
382       message += "AliEMCAL " ; 
383       message += Version() ;  
384       message += "EMCAL geometry initialization failed !" ; 
385     }
386     message += "\n*****************************************" ;
387     Info("Init", message.Data() ) ; 
388   }
389 }