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