cleaning before reading new data added in ReadTreeR
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv0.cxx
CommitLineData
2012850d 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 **************************************************************************/
2012850d 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
ffa6d63b 21// This class places a Geometry of the EMCAL in the ALICE Detector as defined in AliEMCALGeometry.cxx
2012850d 22//*-- Author: Yves Schutz (SUBATECH)
b13bbe81 23//*-- and : Sahal Yacoob (LBL / UCT)
2012850d 24
09641ef5 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
2012850d 31// --- ROOT system ---
a1469a24 32
b13bbe81 33#include "TPGON.h"
2012850d 34#include "TTUBS.h"
35#include "TNode.h"
36#include "TRandom.h"
37#include "TGeometry.h"
a1469a24 38
2012850d 39// --- Standard library ---
40
b13bbe81 41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
70479d0e 44#include <Rstrstream.h>
45#include <Riostream.h>
2012850d 46
47// --- AliRoot header files ---
48
49#include "AliEMCALv0.h"
50#include "AliEMCALGeometry.h"
b13bbe81 51#include "AliConst.h"
2012850d 52#include "AliRun.h"
2012850d 53
54ClassImp(AliEMCALv0)
55
b13bbe81 56//______________________________________________________________________
2012850d 57AliEMCALv0::AliEMCALv0(const char *name, const char *title):
05a92d59 58 AliEMCAL(name,title)
59{
60 // ctor : title is used to identify the layout
61 GetGeometry() ;
a1469a24 62
2012850d 63}
a1469a24 64
b13bbe81 65//______________________________________________________________________
05a92d59 66void AliEMCALv0::BuildGeometry()
67{
b13bbe81 68 // Display Geometry for display.C
2012850d 69
b13bbe81 70 const Int_t kColorArm1 = kBlue ;
91e9918b 71
05a92d59 72 AliEMCALGeometry * geom = GetGeometry() ;
a1469a24 73
05a92d59 74 // Define the shape of the Calorimeter
5502a765 75 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
b13bbe81 76 new TTUBS("Envelop1", "Tubs that contains arm 1", "void",
05a92d59 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
b13bbe81 82 );
a1469a24 83
ffa6d63b 84 // Place the Node
5502a765 85 top->cd();
5502a765 86 TNode * envelop1node = new TNode("Envelop1", "Arm1 Envelop", "Envelop1"
87 ,0., 0., 0., "") ;
b13bbe81 88 envelop1node->SetLineColor(kColorArm1) ;
89 fNodes->Add(envelop1node) ;
2012850d 90}
a1469a24 91
b13bbe81 92//______________________________________________________________________
05a92d59 93void AliEMCALv0::CreateGeometry()
94{
f590bb15 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
a1469a24 128 Float_t etamin,etamax;
3ca04a8a 129 Float_t *dum=0;
130
05a92d59 131 AliEMCALGeometry * geom = GetGeometry() ;
a1469a24 132
05a92d59 133 if(!(geom->IsInitialized())){
a1469a24 134 Error("CreateGeometry","EMCAL Geometry class has not been set up.");
b13bbe81 135 } // end if
a1469a24 136
b13bbe81 137 // Get pointer to the array containing media indices
138 Int_t *idtmed = fIdtmed->GetArray() - 1599 ;
e13bd4f0 139
09641ef5 140 Int_t idrotm = 1;
141 AliMatrix(idrotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
142
a1469a24 143
c13b5a7c 144 // Create the EMCAL Mother Volume (a polygone) within which to place the Detector and named XEN1
145
146 Float_t envelopA[10];
147 envelopA[0] = geom->GetArm1PhiMin(); // minimum phi angle
148 envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
149 envelopA[2] = geom->GetNPhi(); // number of sections in phi
150 envelopA[3] = 2; // 2 z coordinates
151 envelopA[4] = geom->ZFromEtaR(geom->GetEnvelop(0),
152 geom->GetArm1EtaMin()); // z coordinate 1
153 envelopA[5] = geom->GetEnvelop(0) ; // rmin at z1
154 envelopA[6] = geom->GetEnvelop(1) ; // rmax at z1
155 envelopA[7] = geom->ZFromEtaR(geom->GetEnvelop(0),
156 geom->GetArm1EtaMax()); // z coordinate 2
157 envelopA[8] = envelopA[5] ; // radii are the same.
158 envelopA[9] = envelopA[6] ; // radii are the same.
159
160 gMC->Gsvolu("XEN1", "PGON ", idtmed[1599], envelopA, 10) ; // Polygone filled with air
09641ef5 161
c13b5a7c 162 // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)
09641ef5 163
c13b5a7c 164 gMC->Gspos("XEN1", 1, "ALIC", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
165
2f909c8d 166 if (fDebug==2)
c13b5a7c 167 Info("CreateGeometry","rXEN1 = %f, %f\n", envelopA[5], envelopA[6]);
a1469a24 168
c13b5a7c 169 // Create mini-envelopes which will contain the PreShower scintillator-Lead-scintillator-lead (XU0)
170
171 TString label = "XU0";
a1469a24 172
c13b5a7c 173 envelopA[5] = envelopA[5] + geom->GetGap2Active()
174 + geom->GetAlFrontThickness(); // rmin at z1
175 envelopA[4] = geom->ZFromEtaR(envelopA[5],
176 geom->GetArm1EtaMin()); // z coordinate 1
177 envelopA[7] = geom->ZFromEtaR(envelopA[5],
178 geom->GetArm1EtaMax()); // z coordinate 2
179 envelopA[6] = envelopA[5] + 2 * (geom->GetPreSintThick()
180 + geom->GetPbRadThick() ); // rmax at z1
181 envelopA[8] = envelopA[5] ; // radii are the same.
182 envelopA[9] = envelopA[6] ; // radii are the same.
183
184 gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10);// Polygone filled with air
185
186 // Position XU0 in XEN1
187
a1469a24 188 gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY");
189
2f909c8d 190 if (fDebug==2)
c13b5a7c 191 Info("CreateGeometry","rXU0 = %f, %f\n", envelopA[5], envelopA[6]);
192
193 // Create mini-envelopes which will contain the Tower scintillator-Lead-scintillator-lead (XU1 -> XU9)
194
195 Float_t tseg = geom->GetFullSintThick()+geom->GetPbRadThick(); // thickness of scintillator+Pb
196
f590bb15 197 Int_t i ;
198 for (i = 1; i < ((geom->GetNLayers()-2)/2) + 1 ; i++ ){
a1469a24 199 label = "XU" ;
a1469a24 200 label += i ;
c13b5a7c 201 envelopA[5] = envelopA[6] ; // rmin at z1
202 envelopA[4] = geom->ZFromEtaR(envelopA[5],
203 geom->GetArm1EtaMin()); // z coordinate 1
204 envelopA[7] = geom->ZFromEtaR(envelopA[5],
205 geom->GetArm1EtaMax()); // z coordinate 2
206 envelopA[6] = envelopA[5] + 2 * tseg ; // rmax at z1
207 envelopA[8] = envelopA[5] ; // radii are the same.
208 envelopA[9] = envelopA[6] ; // radii are the same.
209
210 gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10);// Polygone filled with air
a1469a24 211
c13b5a7c 212 // Position XUi in XEN1
213
a1469a24 214 gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
c13b5a7c 215
2f909c8d 216 if (fDebug==2)
c13b5a7c 217 Info("CreateGeometry","rXEN%d = %f, %f\n", i, envelopA[5], envelopA[6]);
218
a1469a24 219 } // end i
f590bb15 220
c13b5a7c 221
222 // Create one mini-envelope which will contain the last Tower scintillator (XU(nlayers-1)/2)
223
f590bb15 224 tseg = geom->GetFullSintThick() ;
225 label = "XU" ;
226 label += i ;
c13b5a7c 227 envelopA[5] = envelopA[6] ; // rmin at z1
228 envelopA[4] = geom->ZFromEtaR(envelopA[5],
229 geom->GetArm1EtaMin()); // z coordinate 1
230 envelopA[7] = geom->ZFromEtaR(envelopA[5],
231 geom->GetArm1EtaMax()); // z coordinate 2
232 envelopA[6] = envelopA[5] + tseg ; // rmax at z1
233 envelopA[8] = envelopA[5] ; // radii are the same.
234 envelopA[9] = envelopA[6] ; // radii are the same.
235
236 gMC->Gsvolu(label.Data(), "PGON", idtmed[1599], envelopA, 10); // Polygone filled with air
237
238 // Position XU10 in XEN1
239
f590bb15 240 gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
241
2f909c8d 242 if (fDebug==2)
243 Info("CreateGeometry","rXEN%d = %f, %f\n", i, envelopA[5], envelopA[6]);
f590bb15 244
a1469a24 245 // Create the shapes of active material (LEAD/Aluminium/Scintillator)
a1469a24 246 // to be placed
ffa6d63b 247 Float_t envelopB[10]; // First Layer of Aluminium
248 Float_t envelopC[10]; // Scintillator Layers
a1469a24 249 Float_t envelopD[10]; // Lead Layers
250
c13b5a7c 251 envelopC[0] = envelopD[0] = envelopB[0] = envelopA[0] ; // starting position in Phi
252 envelopC[1] = envelopD[1] = envelopB[1] = envelopA[1] ; // angular range in phi
253 envelopC[2] = envelopD[2] = envelopB[2] = envelopA[2] ; // number of sections in Phi
254 envelopD[3] = envelopC[3] = envelopB[3] = envelopA[3] ; // 2 z coordinates
a1469a24 255
c4edd8cd 256 envelopB[4] = geom->ZFromEtaR(geom->GetEnvelop(0),
c13b5a7c 257 geom->GetArm1EtaMin()); // z co-ordinate 1
258 envelopB[5] = geom->GetEnvelop(0) ; // rmin at z1
259 envelopB[6] = envelopB[5] + geom->GetAlFrontThickness();// rmax at z1
c4edd8cd 260 envelopB[7] = geom->ZFromEtaR(geom->GetEnvelop(0),
c13b5a7c 261 geom->GetArm1EtaMax()); // z co-ordinate 2
262 envelopB[8] = envelopB[5] ; // radii are the same.
263 envelopB[9] = envelopB[6] ; // radii are the same.
ffa6d63b 264
c13b5a7c 265 // Define active volumes completely
266
267 gMC->Gsvolu("XALU", "PGON", idtmed[1602], envelopB, 10); // PGON filled with Al
268
269 gMC->Gspos("XALU", 1, "XEN1", 0.0, 0.0, 0.0 , idrotm, "ONLY") ; // Position Aluminium Layer in XEN1
a1469a24 270
c13b5a7c 271 gMC->Gsvolu("XPST", "PGON", idtmed[1601], dum, 0); // PGON filled with Scintillator (shape to be defined by GSPOSP)
272
273 gMC->Gsvolu("XPBX", "PGON", idtmed[1600], dum, 0); // PGON filled with Lead (shape to be defined by GSPOSP)
274
275 gMC->Gsdvn("XPHI", "XPST", geom->GetNPhi(), 2); // Divide eta section of scintillators into phi segments.
276
277 // Position alternatively scintillator and Lead Layers in XUi.
a1469a24 278
c13b5a7c 279 envelopD[6] = envelopB[6] + geom->GetGap2Active() ;// gap between Al layer and XU0
b13bbe81 280
05a92d59 281 for (int i = 0; i < geom->GetNLayers() ; i++ ){
a1469a24 282 label = "XU" ;
f590bb15 283 label += static_cast<Int_t> (i/2) ; // we will place two layers (i = one layer) in each mini envelope)
09641ef5 284 envelopC[5] = envelopD[6] ; //rmin
05a92d59 285 envelopC[6] = envelopD[6] + ((i > 1) ? geom->GetFullSintThick() :
286 geom->GetPreSintThick());//rmax larger for first two layers (preshower)
b13bbe81 287 envelopC[8] = envelopD[6] ; //rmin
05a92d59 288 envelopC[9] = envelopD[6] + ((i > 1 ) ? geom->GetFullSintThick() :
289 geom->GetPreSintThick());//rmax larger for first two layers (preshower)
290 for (int j =0; j < (geom->GetNEta()) ; j++){
291 etamin = geom->GetArm1EtaMin()+
292 (j*geom->GetDeltaEta());
293 etamax = geom->GetArm1EtaMin()+
294 ((j+1)*geom->GetDeltaEta());
295 envelopC[4] = geom->ZFromEtaR(envelopD[6],etamin); //z begin
296 envelopC[7] = geom->ZFromEtaR(envelopD[6],etamax);// z end
f590bb15 297
298 gMC->Gsposp("XPST",1+j+i*(geom->GetNEta()), label.Data(),
ffa6d63b 299 0.0, 0.0, 0.0 , idrotm, "ONLY", envelopC, 10); // Position and define layer
b13bbe81 300 } // end for j
a1469a24 301
c13b5a7c 302 if (i < (geom->GetNLayers()-1)){ // except for the last XU which contains only one scintillator layer
a1469a24 303 envelopD[5] = envelopC[6] ; //rmin
05a92d59 304 envelopD[6] = envelopC[6] + geom->GetPbRadThick(); //rmax
b13bbe81 305 envelopD[8] = envelopC[6] ; //rmin
05a92d59 306 envelopD[9] = envelopC[6] + geom->GetPbRadThick(); //rmax
307 for (int j =0; j < (geom->GetNEta()) ; j++){
308 etamin = geom->GetArm1EtaMin()+
309 (j*geom->GetDeltaEta());
310 etamax = geom->GetArm1EtaMin()+
311 ((j+1)*geom->GetDeltaEta());
312 envelopD[4] = geom->ZFromEtaR(envelopC[6],etamin);//z begin
313 envelopD[7] = geom->ZFromEtaR(envelopC[6],etamax);// z end
a1469a24 314
315 // Position and Define Layer
f590bb15 316
317 gMC->Gsposp("XPBX",1+j+i*(geom->GetNEta()), label.Data(),
a1469a24 318 0.0, 0.0, 0.0 , idrotm, "ONLY", envelopD, 10);
b13bbe81 319 } // end for j
320 } // end if i
61e0abb5 321 } // for i
2012850d 322}
a1469a24 323
b13bbe81 324//______________________________________________________________________
05a92d59 325void AliEMCALv0::Init(void)
326{
b13bbe81 327 // Just prints an information message
9859bfc0 328
329 if(fDebug) {
330 TString message("\n") ;
331 message += "*****************************************" ;
05a92d59 332
b13bbe81 333 // Here the EMCAL initialisation code (if any!)
9859bfc0 334
05a92d59 335 AliEMCALGeometry * geom = GetGeometry() ;
9859bfc0 336
337 if (geom!=0) {
338 message += "AliEMCAL " ;
339 message += Version() ;
340 message += "EMCAL geometry intialized for " ;
341 message += geom->GetName() ;
342 }
343 else {
344 message += "AliEMCAL " ;
345 message += Version() ;
346 message += "EMCAL geometry initialization failed !" ;
05a92d59 347 }
9859bfc0 348 message += "*****************************************" ;
349 Info("Init", message.Data() ) ;
350 }
2012850d 351}