]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALv0.cxx
In BuildGeometry(): cd to the top volume before defining the node.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv0.cxx
1 /**************************************************************************
2
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4
5  *                                                                        *
6
7  * Author: The ALICE Off-line Project.                                    *
8
9  * Contributors are mentioned in the code where appropriate.              *
10
11  *                                                                        *
12
13  * Permission to use, copy, modify and distribute this software and its   *
14
15  * documentation strictly for non-commercial purposes is hereby granted   *
16
17  * without fee, provided that the above copyright notice appears in all   *
18
19  * copies and that both the copyright notice and this permission notice   *
20
21  * appear in the supporting documentation. The authors make no claims     *
22
23  * about the suitability of this software for any purpose. It is          *
24
25  * provided "as is" without express or implied warranty.                  *
26
27  **************************************************************************/
28
29
30
31 /* $Id$ */
32
33
34
35 //_________________________________________________________________________
36
37 // Implementation version v0 of EMCAL Manager class 
38
39 // An object of this class does not produce hits nor digits
40
41 // It is the one to use if you do not want to produce outputs in TREEH or TREED
42
43 // This class places a Geometry of the EMCAL in the ALICE Detector as defined in AliEMCALGeometry.cxx                 
44
45 //*-- Author: Yves Schutz (SUBATECH)
46
47 //*-- and   : Sahal Yacoob (LBL / UCT)
48
49
50
51 // This Version of AliEMCALv0 reduces the number of volumes placed in XEN1 (the envelope) to less than five hundred
52
53 // The Envelope is Placed in Alice, And the Aluminium layer. Mini envelopes (XU) are then placed in XEN1.
54
55 // Each mini envelope contains 2 scintillator, and 2 lead layers, except the last one which contains just one scintillator layer.
56
57 // At the moment I cannot place the 36 and above layers in the mini envelopes so all layers are still placed in XEN1
58
59
60
61
62
63 // --- ROOT system ---
64
65 #include "TPGON.h"
66
67 #include "TTUBS.h"
68
69 #include "TNode.h"
70
71 #include "TRandom.h"
72
73 #include "TGeometry.h"
74
75 //#include "Tstring.h"
76
77
78
79 // --- Standard library ---
80
81
82
83 #include <stdio.h>
84
85 #include <string.h>
86
87 #include <stdlib.h>
88
89 #include <strstream.h>
90
91 #include <iostream.h>
92
93
94
95 // --- AliRoot header files ---
96
97
98
99 #include "AliEMCALv0.h"
100
101 #include "AliEMCALGeometry.h"
102
103 #include "AliConst.h"
104
105 #include "AliRun.h"
106
107 #include "AliMC.h"
108
109
110
111 ClassImp(AliEMCALv0)
112
113
114
115 //______________________________________________________________________
116
117 AliEMCALv0::AliEMCALv0(const char *name, const char *title):
118
119     AliEMCAL(name,title){
120
121     // Standard Constructor
122
123
124
125     if (strcmp(GetTitle(),"") != 0 )
126
127         fGeom =  AliEMCALGeometry::GetInstance(GetTitle(), "") ;
128
129
130
131 }
132
133 //______________________________________________________________________
134
135 void AliEMCALv0::BuildGeometry(){
136
137     // Display Geometry for display.C
138
139
140
141     const Int_t kColorArm1   = kBlue ;
142
143
144
145     // Difine the shape of the Calorimeter 
146
147   
148     TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
149
150     new TTUBS("Envelop1", "Tubs that contains arm 1", "void", 
151
152               fGeom->GetEnvelop(0),     // rmin 
153
154               fGeom->GetEnvelop(1) +30 ,     // rmax
155
156               fGeom->GetEnvelop(2)/2.0, // half length in Z
157
158               fGeom->GetArm1PhiMin(),   // minimun phi angle
159
160               fGeom->GetArm1PhiMax()    // maximun phi angle
161
162         );
163
164     // Place the Node
165     top->cd();
166     
167     TNode * envelop1node = new TNode("Envelop1", "Arm1 Envelop", "Envelop1"
168                                      ,0., 0., 0., "") ;
169
170     envelop1node->SetLineColor(kColorArm1) ;
171
172     fNodes->Add(envelop1node) ;
173
174 }
175
176 //______________________________________________________________________
177
178 void AliEMCALv0::CreateGeometry(){
179
180     // Create the EMCAL geometry for Geant
181
182     Float_t etamin,etamax;
183
184     Float_t *dum=0;
185
186
187
188     if(!(fGeom->IsInitialized())){
189
190         Error("CreateGeometry","EMCAL Geometry class has not been set up.");
191
192     } // end if
193
194     // Get pointer to the array containing media indices
195
196     Int_t *idtmed = fIdtmed->GetArray() - 1599 ;
197
198
199
200     // Create an Envelope within which to place the Detector 
201
202  
203
204     Float_t envelopA[5];
205
206     envelopA[0] = fGeom->GetEnvelop(0);     // rmin
207
208     envelopA[1] = fGeom->GetEnvelop(1);     // rmax
209
210     envelopA[2] = fGeom->GetEnvelop(2)/2.0; // dz
211
212     envelopA[3] = fGeom->GetArm1PhiMin();   // minimun phi angle
213
214     envelopA[4] = fGeom->GetArm1PhiMax();   // maximun phi angle
215
216
217
218     // create XEN1
219
220     gMC->Gsvolu("XEN1", "TUBS ", idtmed[1599], envelopA, 5) ; //filled with air
221
222
223
224     Int_t idrotm = 1;
225
226     AliMatrix(idrotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
227
228
229
230     // Position the EMCAL Mother Volume in Alice  
231
232     gMC->Gspos("XEN1", 1, "ALIC", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
233
234
235
236     //  
237
238     TString label = "XU0";
239
240
241
242     //rmin Start mini envelopes after the aluminium layer
243
244     envelopA[0] = fGeom->GetEnvelop(0) + fGeom->GetGap2Active() + 
245
246                   fGeom->GetAlFrontThickness();
247
248     //rmax larger for first two layers (preshower);
249
250     Float_t tseg = fGeom->GetPreSintThick()+fGeom->GetPbRadThick();
251
252     envelopA[1] = envelopA[0] + 2.0*tseg;
253
254     envelopA[2] = fGeom->GetEnvelop(2)/2.0; // dz
255
256     envelopA[3] = fGeom->GetArm1PhiMin();   // minimun phi angle
257
258     envelopA[4] = fGeom->GetArm1PhiMax();   // maximun phi angle
259
260     //filled with air
261
262     gMC->Gsvolu(label.Data(), "TUBS ", idtmed[1599], envelopA, 5);
263
264     // Place XU0 in to XEN1
265
266     gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY");
267
268
269
270     tseg = fGeom->GetFullSintThick()+fGeom->GetPbRadThick();
271
272     for (int i = 1; i < ((fGeom->GetNLayers()-1)/2) + 1 ; i++ ){
273
274         label = "XU" ;
275
276         label += i ;
277
278         envelopA[0] = envelopA[1]; //rmin
279
280         envelopA[1] = envelopA[0] + 2.0*tseg;  //rmax
281
282          //filled with air
283
284         gMC->Gsvolu(label.Data(), "TUBS ", idtmed[1599], envelopA, 5);
285
286         gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
287
288     } // end  i
289
290
291
292     // Create the shapes of active material (LEAD/Aluminium/Scintillator)
293
294     // to be placed
295
296     Float_t envelopB[10]; // First Layer of Aluminium
297
298     Float_t envelopC[10]; // Scintillator Layers
299
300     Float_t envelopD[10]; // Lead Layers
301
302     //starting position in Phi
303
304     envelopC[0] = envelopD[0] =  envelopB[0] = fGeom->GetArm1PhiMin();
305
306     // Angular size of the Detector in Phi
307
308     envelopB[1] = fGeom->GetArm1PhiMax() - fGeom->GetArm1PhiMin();
309
310     envelopC[1] = envelopD[1] = envelopB[1];
311
312     // Number of Section in Phi
313
314     envelopC[2] = envelopD[2] = envelopB[2] = fGeom->GetNPhi();
315
316     // each section will be passed 2 z coordinates    
317
318     envelopD[3] = envelopC[3] = envelopB[3] = 2;
319
320     envelopB[4] = fGeom->ZFromEtaR(fGeom->GetEnvelop(0)+fGeom->GetGap2Active(),
321
322                                    fGeom->GetArm1EtaMin());// z co-ordinate 1
323
324     envelopB[5] = fGeom->GetEnvelop(0) + fGeom->GetGap2Active(); //rmin at z1
325
326     envelopB[6] = envelopB[5] + fGeom->GetAlFrontThickness();//rmax at z1
327
328     envelopD[6] = envelopB[6];
329
330     envelopB[7] =fGeom->ZFromEtaR(fGeom->GetEnvelop(0)+fGeom->GetGap2Active(),
331
332                                   fGeom->GetArm1EtaMax()); // z co-ordinate 2
333
334     envelopB[8] = envelopB[5] ; //
335
336     envelopB[9] = envelopB[6] ; // radii are the same.
337
338
339
340     // filled shapes wit hactive material 
341
342     // Define Aluminium volume completely
343
344     gMC->Gsvolu("XALU", "PGON", idtmed[1602], envelopB, 10);
345
346     // The polystyrene layers will be defined when placed 
347
348     gMC->Gsvolu("XPST", "PGON", idtmed[1601], dum, 0);
349
350     gMC->Gsvolu("XPBX", "PGON", idtmed[1600], dum, 0);//  as will the lead layers
351
352     //  Dividind eta polystyrene divisions into phi segments.
353
354     gMC->Gsdvn("XPHI", "XPST", fGeom->GetNPhi(), 2);
355
356     // Position Aluminium Layer in the Envelope 
357
358     gMC->Gspos("XALU", 1, "XEN1", 0.0, 0.0, 0.0 , idrotm, "ONLY") ;
359
360
361
362     // The loop below places the scintillator in Lead Layers alternately.
363
364     for (int i = 0; i < fGeom->GetNLayers() ; i++ ){
365
366         label = "XU" ;
367
368         label += (int) i/2  ; // we will place two layers (i = one layer) in each mini envelope)        
369
370         envelopC[5] = envelopD[6] ; //rmin
371
372         envelopC[6] = envelopD[6] + ((i > 1)  ? fGeom->GetFullSintThick() : 
373
374                                      fGeom->GetPreSintThick());//rmax larger for first two layers (preshower)
375
376         envelopC[8] = envelopD[6] ; //rmin
377
378         envelopC[9] = envelopD[6] + ((i > 1 ) ? fGeom->GetFullSintThick() :
379
380                                      fGeom->GetPreSintThick());//rmax larger for first two layers (preshower)
381
382         for (int j =0; j < (fGeom->GetNEta()) ; j++){
383
384             
385
386             etamin = fGeom->GetArm1EtaMin()+
387
388                 (j*fGeom->GetDeltaEta());
389
390             etamax = fGeom->GetArm1EtaMin()+
391
392                 ((j+1)*fGeom->GetDeltaEta());
393
394             envelopC[4] = fGeom->ZFromEtaR(envelopD[6],etamin); //z begin  
395
396             envelopC[7] = fGeom->ZFromEtaR(envelopD[6],etamax);// z end 
397
398             gMC->Gsposp("XPST",1+j+i*(fGeom->GetNEta()), label.Data(), // should be used but there's a weird crash above i = 18, 
399
400                         0.0, 0.0, 0.0 , idrotm, "ONLY", envelopC, 10); // Position and define layer
401
402         } // end for j
403
404         if (i < (fGeom->GetNLayers()-1)){
405
406             envelopD[5] = envelopC[6] ; //rmin
407
408             envelopD[6] = envelopC[6] + fGeom->GetPbRadThick();  //rmax
409
410             envelopD[8] = envelopC[6] ; //rmin
411
412             envelopD[9] = envelopC[6] + fGeom->GetPbRadThick();  //rmax
413
414             for (int j =0; j < (fGeom->GetNEta()) ; j++){
415
416                 etamin = fGeom->GetArm1EtaMin()+
417
418                     (j*fGeom->GetDeltaEta());
419
420                 etamax = fGeom->GetArm1EtaMin()+
421
422                     ((j+1)*fGeom->GetDeltaEta());
423
424                 envelopD[4] = fGeom->ZFromEtaR(envelopC[6],etamin);//z begin  
425
426                 envelopD[7] = fGeom->ZFromEtaR(envelopC[6],etamax);// z end
427
428                 // Position and Define Layer
429
430                 gMC->Gsposp("XPBX",1+ j+i*(fGeom->GetNEta()), label.Data(), 
431
432                             0.0, 0.0, 0.0 , idrotm, "ONLY", envelopD, 10);
433
434             } // end for j
435
436         } // end if i
437
438     }  // for i
439 }
440
441 //______________________________________________________________________
442
443 void AliEMCALv0::Init(void){
444
445     // Just prints an information message
446
447     Int_t i;
448
449
450
451     cout << endl;
452
453     for(i=0;i<35;i++) cout <<"*";
454
455     cout << " EMCAL_INIT ";
456
457     for(i=0;i<35;i++) cout << "*";
458
459     cout << endl;
460
461
462
463     // Here the EMCAL initialisation code (if any!)
464
465
466
467     if (fGeom!=0)  
468
469         cout << "AliEMCAL" << Version() << " : EMCAL geometry intialized for "
470
471              << fGeom->GetName() << endl ;
472
473     else
474
475         cout << "AliEMCAL" << Version() << 
476
477             " : EMCAL geometry initialization failed !" << endl ;
478
479     for(i=0;i<80;i++) printf("*");
480
481     cout << endl;
482
483 }
484