]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALv0.cxx
bugfix
[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 "TGeometry.h"
37 #include "TVirtualMC.h"
38 #include "TArrayI.h"
39
40 // --- Standard library ---
41
42 //#include <stdio.h>
43
44 // --- AliRoot header files ---
45
46 #include "AliEMCALv0.h"
47 #include "AliEMCALGeometry.h"
48 #include "AliRun.h"
49
50 ClassImp(AliEMCALv0)
51
52 //______________________________________________________________________
53 AliEMCALv0::AliEMCALv0(const char *name, const char *title):
54   AliEMCAL(name,title)
55 {
56   // ctor : title is used to identify the layout
57   GetGeometry() ; 
58
59 }
60
61 //______________________________________________________________________
62 void AliEMCALv0::BuildGeometry()
63 {
64     // Display Geometry for display.C
65
66     const Int_t kColorArm1   = kBlue ;
67
68     AliEMCALGeometry * geom = GetGeometry() ; 
69
70     // Define the shape of the Calorimeter 
71     TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
72     new TTUBS("Envelop1", "Tubs that contains arm 1", "void", 
73               geom->GetEnvelop(0),     // rmin 
74               geom->GetEnvelop(1) +30 ,     // rmax
75               geom->GetEnvelop(2)/2.0, // half length in Z
76               geom->GetArm1PhiMin(),   // minimun phi angle
77               geom->GetArm1PhiMax()    // maximun phi angle
78         );
79
80     // Place the Node
81     top->cd();
82     TNode * envelop1node = new TNode("Envelop1", "Arm1 Envelop", "Envelop1"
83                                      ,0., 0., 0., "") ;
84     envelop1node->SetLineColor(kColorArm1) ;
85     fNodes->Add(envelop1node) ;
86 }
87
88 //______________________________________________________________________
89 void AliEMCALv0::CreateGeometry()
90 {
91   // Create the EMCAL geometry for Geant
92   // Geometry of a tower
93   //|-----------------------------------------------------| XEN1
94   //| |                                                 | |
95   //| |    Al thickness = GetAlFrontThickness()         | |
96   //| |                                                 | |
97   //| |                                                 | |
98   //| |                                                 | |
99   //|  -------------------------------------------------  |
100   //| |    Air Gap = GetGap2Active()                    | |
101   //| |                                                 | |
102   //|  -------------------------------------------------  |
103   //| |    XU0 : XPST (PreShower e = GetPRScintThick() )| |
104   //|  -------------------------------------------------  |
105   //| |    XU0 : XPBX (PreShower e = GetPRPbRadThick() )| |
106   //|  -------------------------------------------------  |
107   //| |    XU0 : XPST (PreShower e = GetPEScintThick() )| |
108   //|  -------------------------------------------------  |
109   //| |    XU0 : XPBX (PreShower e = GetPRPbRadThick() )| |
110   //|  -------------------------------------------------  |
111   //|    etc ..... GetNPRLayers() times                   |
112   //|  -------------------------------------------------  |
113   //| |    XU1 : XPST (ECAL e = GetECScintThick() )     | |
114   //|  -------------------------------------------------  |
115   //| |    XU1 : XPBX (ECAL e = GetECPbRadThick() )     | |
116   //|  -------------------------------------------------  |
117   //| |    XU1 : XPST (ECAL e = GetECScintThick()       | |
118   //|  -------------------------------------------------  |
119   //| |    XU1 : XPBX (ECAL e = GetECPbRadThick() )     | |
120   //|  -------------------------------------------------  |
121   //|    etc ..... GetNECLayers() times                   |
122   //|  -------------------------------------------------  |
123   //| |    XU1 : XPST (ECAL e = GetHCScintThick() )     | |
124   //|  -------------------------------------------------  |
125   //| |    XU1 : XPBX (ECAL e = GetHCPbRadThick() )     | |
126   //|  -------------------------------------------------  |
127   //| |    XU1 : XPST (ECAL e = GetHCScintThick()       | |
128   //|  -------------------------------------------------  |
129   //| |    XU1 : XPBX (ECAL e = GetHCPbRadThick() )     | |
130   //|  -------------------------------------------------  |
131   //|    etc ..... GetNHCLayers() times                   |
132   //|  -------------------------------------------------  |
133   //| |    XU10 : XPST (HCAL e = GetHCScintThick() )    | |
134   //|-----------------------------------------------------|
135  
136     Float_t etamin,etamax;
137     Float_t *dum=0;
138
139     AliEMCALGeometry * geom = GetGeometry() ; 
140
141     if(!(geom->IsInitialized())){
142         Error("CreateGeometry","EMCAL Geometry class has not been set up.");
143     } // end if
144
145     // Get pointer to the array containing media indices
146     Int_t *idtmed = fIdtmed->GetArray() - 1599 ;
147
148     Int_t idrotm = 1;
149     AliMatrix(idrotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
150
151
152
153     // Create the EMCAL Mother Volume (a polygone) within which to place the Detector and named XEN1 
154
155     Float_t envelopA[10];
156     envelopA[0] = geom->GetArm1PhiMin();                         // minimum phi angle
157     envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
158     envelopA[2] = geom->GetNPhi();                               // number of sections in phi
159     envelopA[3] = 2;                                             // 2 z coordinates
160     envelopA[4] = geom->ZFromEtaR(geom->GetEnvelop(1),
161                                    geom->GetArm1EtaMin());       // z coordinate 1
162     envelopA[5] = geom->GetEnvelop(0) ;                          // rmin at z1
163     envelopA[6] = geom->GetEnvelop(1) ;                          // rmax at z1
164     envelopA[7] = geom->ZFromEtaR(geom->GetEnvelop(1),
165                                   geom->GetArm1EtaMax());        // z coordinate 2
166     envelopA[8] = envelopA[5] ;                                  // radii are the same.
167     envelopA[9] = envelopA[6] ;                                  // radii are the same.
168
169     gMC->Gsvolu("XEN1", "PGON ", idtmed[1599], envelopA, 10) ;   // Polygone filled with air 
170
171     // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)  
172
173     gMC->Gspos("XEN1", 1, "ALIC", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
174     
175     if (gDebug==2) 
176       Info("CreateGeometry","rXEN1 = %f, %f\n", envelopA[5], envelopA[6]); 
177
178     // Create mini-envelopes which will contain the PreShower scintillator-Lead-scintillator-lead  
179    
180     if (gDebug==2) 
181       Info("CreateGeometry","XU0 = %f, %f\n", envelopA[5], envelopA[6]); 
182
183     // Create mini-envelopes which will contain the Tower scintillator-radiator-scintillator-radiator 
184     
185     TString label ;
186
187     envelopA[5] = envelopA[5] + geom->GetGap2Active() // we are at the first scintllator
188       + geom->GetAlFrontThickness();                  // rmin at z1
189     envelopA[6] = envelopA[5] ;
190
191
192     Int_t i ; 
193
194     Int_t nLayers = geom->GetNPRLayers() + geom->GetNECLayers() + geom->GetNHCLayers() ;
195
196     for (i = 0; i < nLayers/2 ; i++ ){
197         label = "XU" ;
198         label += i ;
199         Float_t tseg ; 
200         if (i == 0 ) 
201           tseg = 2 *(geom->GetPRScintThick()+geom->GetPRPbRadThick()); // thickness of 2 * scintillator+Pb in pre shower
202         else if ( i <= geom->GetNECLayers()/2) 
203           tseg = 2* (geom->GetECScintThick()+geom->GetECPbRadThick()); // thickness of 2 * scintillator+Pb in E Cal
204         else 
205           tseg = 2* (geom->GetHCScintThick()+geom->GetHCCuRadThick()); // thickness of 2 * scintillator+Cu in H Cal 
206         envelopA[5] = envelopA[6] ;                                   // rmin at z1
207         envelopA[4] = geom->ZFromEtaR(envelopA[5] + tseg,
208                                       geom->GetArm1EtaMin());         // z coordinate 1
209         envelopA[7] = geom->ZFromEtaR(envelopA[5] + tseg,
210                                       geom->GetArm1EtaMax());         // z coordinate 2
211         envelopA[6] = envelopA[5] + tseg ;                            // rmax at z1
212         envelopA[8] = envelopA[5] ;                                   // radii are the same.
213         envelopA[9] = envelopA[6] ;                                   // radii are the same.
214  
215         gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10);// Polygone filled with air 
216
217         // Position XUi in XEN1
218         
219         gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
220
221         if (gDebug == 2)
222           Info("CreateGeometry","XU%d = %f, %f\n", i, envelopA[5], envelopA[6]); 
223
224     } // end  i
225  
226   
227     // Create one mini-envelope which will contain the last Tower scintillator (XU(nlayers-1)/2)
228
229     label = "XU" ;
230     label += i ;
231     envelopA[5] = envelopA[6] ;                                   // rmin at z1
232     envelopA[4] = geom->ZFromEtaR(envelopA[5],
233                                   geom->GetArm1EtaMin());         // z coordinate 1
234     envelopA[7] = geom->ZFromEtaR(envelopA[5],
235                                   geom->GetArm1EtaMax());         // z coordinate 2
236     if (geom->GetNHCLayers() == 0)                                // last scintillator is in ECAL
237       envelopA[6] = envelopA[5] + geom->GetECScintThick() ;       // rmax at z1
238     else                                                          // last scintillator is in HCAL
239       envelopA[6] = envelopA[5] + geom->GetECScintThick() ;       // rmax at z1
240     envelopA[8] = envelopA[5] ;                                   // radii are the same.
241     envelopA[9] = envelopA[6] ;                                   // radii are the same.
242
243     gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10); // Polygone filled with air
244
245     // Position the last minienvelope in XEN1
246   
247     gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
248   
249     if(gDebug == 2) 
250       Info("CreateGeometry","XEN%d = %f, %f\n", i, envelopA[5], envelopA[6]); 
251   
252     // Create the shapes of active material (LEAD/Aluminium/Scintillator)
253     // to be placed
254     Float_t envelopB[10]; // First Layer of Aluminium
255     Float_t envelopC[10]; // Scintillator Layers
256     Float_t envelopD[10]; // Lead Layers
257
258     envelopC[0] = envelopD[0] = envelopB[0] = envelopA[0] ;  // starting position in Phi
259     envelopC[1] = envelopD[1] = envelopB[1] = envelopA[1] ;  // angular range in phi          
260     envelopC[2] = envelopD[2] = envelopB[2] = envelopA[2] ;  // number of sections in Phi
261     envelopD[3] = envelopC[3] = envelopB[3] = envelopA[3] ;  // 2 z coordinates
262
263     Float_t dist = geom->GetEnvelop(0) + geom->GetAlFrontThickness() + geom->GetGap2Active() ; 
264     envelopB[4] = geom->ZFromEtaR(dist,
265                                   geom->GetArm1EtaMin());   // z co-ordinate 1
266     envelopB[5] = geom->GetEnvelop(0) ;                     // rmin at z1
267     envelopB[6] = envelopB[5] + geom->GetAlFrontThickness();// rmax at z1
268     envelopB[7] = geom->ZFromEtaR(dist,
269                                   geom->GetArm1EtaMax());   // z co-ordinate 2
270     envelopB[8] = envelopB[5] ;                             // radii are the same.
271     envelopB[9] = envelopB[6] ;                             // radii are the same.
272
273     // Define active volumes completely
274     
275     gMC->Gsvolu("XALU", "PGON", idtmed[1602], envelopB, 10); // PGON filled with Al
276     
277     gMC->Gspos("XALU", 1, "XEN1", 0.0, 0.0, 0.0 , idrotm, "ONLY") ; // Position Aluminium Layer in XEN1
278
279     gMC->Gsvolu("XPST", "PGON", idtmed[1601], dum, 0);      // PGON filled with Scintillator (shape to be defined by GSPOSP)
280   
281     gMC->Gsvolu("XPBX", "PGON", idtmed[1600], dum, 0);      // PGON filled with Lead (shape to be defined by GSPOSP)
282   
283     gMC->Gsvolu("XCUX", "PGON", idtmed[1603], dum, 0);      // PGON filled with Copper (shape to be defined by GSPOSP)
284
285     gMC->Gsdvn("XPHI", "XPST", geom->GetNPhi(), 2);         // Divide eta section of scintillators into phi segments.
286  
287     // Position alternatively scintillator and  Lead Layers in XUi.
288
289     envelopD[6] = envelopB[6] + geom->GetGap2Active() ;// gap between Al layer and XU0
290     
291     for (int i = 0; i < nLayers; i++ ){
292       label = "XU" ;
293       label += static_cast<Int_t> (i/2)  ; // we will place two layers (i = one layer) in each mini envelope)   
294
295       Float_t scthick ; // scintillator thickness 
296       if ( i <  geom->GetNPRLayers() ) // its a preshower
297         scthick = geom->GetPRScintThick() ;
298       else if( i < geom->GetNPRLayers() + geom->GetNECLayers() ) // its an EMCAL section
299         scthick = geom->GetECScintThick() ;
300       else  // its an HCAL section
301         scthick = geom->GetHCScintThick() ;
302
303       envelopC[5] = envelopD[6] ;           //rmin
304       envelopC[6] = envelopC[5] + scthick ; //rmax
305       envelopC[8] = envelopC[5] ;           //rmin
306       envelopC[9] = envelopC[6] ;           //rmax
307
308
309       //        envelopC[6] = envelopD[6] + ((i > 1)  ? geom->GetFullSintThick() : geom->GetPreSintThick());//rmax larger for first two layers (preshower)
310       //        envelopC[9] = envelopD[6] + ((i > 1 ) ? geom->GetFullSintThick() :geom->GetPreSintThick());//rmax larger for first two layers (preshower)
311
312       if(gDebug == 2 ) 
313         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]) ; 
314
315       for (int j =0; j < (geom->GetNEta()) ; j++){
316         etamin = geom->GetArm1EtaMin()+
317           (j*geom->GetDeltaEta());
318         etamax = geom->GetArm1EtaMin()+
319           ((j+1)*geom->GetDeltaEta());
320         envelopC[4] = geom->ZFromEtaR(envelopC[5],etamin); //z begin  
321         envelopC[7] = geom->ZFromEtaR(envelopC[5],etamax);// z end 
322         
323         gMC->Gsposp("XPST",1+j+i*(geom->GetNEta()), label.Data(), 
324                     0.0, 0.0, 0.0 , idrotm, "ONLY", envelopC, 10); // Position and define layer
325       } // end for j
326       
327       if (i < nLayers){ 
328         Float_t radthick ; // radiator thickness 
329         TString radname ;  // radiator name
330         if ( i <= 1 ) { // its a preshower
331           radthick =  geom->GetPRPbRadThick();
332           radname  =  "XPBX" ; 
333         }
334         else if( i <= geom->GetNECLayers()) {// its an EMCAL section
335           radthick = geom->GetECPbRadThick();
336           radname  =  "XPBX" ; 
337         }
338         else {  // its an HCAL section
339           radthick = geom->GetHCCuRadThick();
340           radname  =  "XCUX" ; 
341         }
342
343         if ( i < nLayers -1 ) { // except for the last XU which contains only one scintillator layer 
344
345           envelopD[5] = envelopC[6] ; //rmin
346           envelopD[8] = envelopD[5] ; //rmin
347           envelopD[6] = envelopD[5] + radthick ; // rmax
348           //  envelopD[6] = envelopC[6] + geom->GetPbRadThick();  //rmax
349           envelopD[9] = envelopD[6] ; //rmax
350           // envelopD[9] = envelopC[6] + geom->GetPbRadThick();  //rmax
351           
352           if(gDebug == 2 ) 
353             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]) ; 
354
355           for (int j =0; j < (geom->GetNEta()) ; j++){
356             etamin = geom->GetArm1EtaMin()+
357               (j*geom->GetDeltaEta());
358             etamax = geom->GetArm1EtaMin()+
359               ((j+1)*geom->GetDeltaEta());
360             envelopD[4] = geom->ZFromEtaR(envelopD[5],etamin);//z begin  
361             envelopD[7] = geom->ZFromEtaR(envelopD[5],etamax);// z end
362             
363             // Position and Define Layer
364             
365             gMC->Gsposp(radname.Data(),1+j+i*(geom->GetNEta()), label.Data(), 
366                         0.0, 0.0, 0.0 , idrotm, "ONLY", envelopD, 10);
367           } // end for j
368         } // if not last layer
369       } // end if i
370     }  // for i
371 }
372
373 //______________________________________________________________________
374 void AliEMCALv0::Init(void)
375 {
376     // Just prints an information message
377   
378   if(fDebug) { 
379     TString message("\n") ; 
380     message += "*****************************************\n" ;
381     
382     // Here the EMCAL initialisation code (if any!)
383     
384     AliEMCALGeometry * geom = GetGeometry() ; 
385     
386     if (geom!=0) {   
387       message += "AliEMCAL " ; 
388       message += Version() ; 
389       message += "EMCAL geometry initialized for " ; 
390       message += geom->GetName()  ;
391     }
392     else {
393       message += "AliEMCAL " ; 
394       message += Version() ;  
395       message += "EMCAL geometry initialization failed !" ; 
396     }
397     message += "\n*****************************************" ;
398     Info("Init", message.Data() ) ; 
399   }
400 }