Added new data members to remove magic numbers
[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 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19// Implementation version v0 of EMCAL Manager class
20// An object of this class does not produce hits nor digits
21// It is the one to use if you do not want to produce outputs in TREEH or TREED
ffa6d63b 22// This class places a Geometry of the EMCAL in the ALICE Detector as defined in AliEMCALGeometry.cxx
2012850d 23//*-- Author: Yves Schutz (SUBATECH)
b13bbe81 24//*-- and : Sahal Yacoob (LBL / UCT)
2012850d 25
09641ef5 26// This Version of AliEMCALv0 reduces the number of volumes placed in XEN1 (the envelope) to less than five hundred
27// The Envelope is Placed in Alice, And the Aluminium layer. Mini envelopes (XU) are then placed in XEN1.
28// Each mini envelope contains 2 scintillator, and 2 lead layers, except the last one which contains just one scintillator layer.
29// At the moment I cannot place the 36 and above layers in the mini envelopes so all layers are still placed in XEN1
30
31
2012850d 32// --- ROOT system ---
b13bbe81 33#include "TPGON.h"
2012850d 34#include "TTUBS.h"
35#include "TNode.h"
36#include "TRandom.h"
37#include "TGeometry.h"
09641ef5 38//#include "Tstring.h"
2012850d 39
40// --- Standard library ---
41
b13bbe81 42#include <stdio.h>
43#include <string.h>
44#include <stdlib.h>
45#include <strstream.h>
46#include <iostream.h>
2012850d 47
48// --- AliRoot header files ---
49
50#include "AliEMCALv0.h"
51#include "AliEMCALGeometry.h"
b13bbe81 52#include "AliConst.h"
2012850d 53#include "AliRun.h"
54#include "AliMC.h"
55
56ClassImp(AliEMCALv0)
57
b13bbe81 58//______________________________________________________________________
2012850d 59AliEMCALv0::AliEMCALv0(const char *name, const char *title):
b13bbe81 60 AliEMCAL(name,title){
61 // Standard Constructor
2012850d 62
b13bbe81 63 if (strcmp(GetTitle(),"") != 0 )
64 fGeom = AliEMCALGeometry::GetInstance(GetTitle(), "") ;
61e0abb5 65
2012850d 66}
b13bbe81 67//______________________________________________________________________
68void AliEMCALv0::BuildGeometry(){
69 // Display Geometry for display.C
2012850d 70
b13bbe81 71 const Int_t kColorArm1 = kBlue ;
91e9918b 72
ffa6d63b 73 // Difine the shape of the Calorimeter
2012850d 74
b13bbe81 75 new TTUBS("Envelop1", "Tubs that contains arm 1", "void",
76 fGeom->GetEnvelop(0), // rmin
77 fGeom->GetEnvelop(1) +30 , // rmax
78 fGeom->GetEnvelop(2)/2.0, // half length in Z
79 fGeom->GetArm1PhiMin(), // minimun phi angle
80 fGeom->GetArm1PhiMax() // maximun phi angle
81 );
ffa6d63b 82 // Place the Node
b13bbe81 83 TNode * envelop1node = new TNode("Envelop1", "Arm1 Envelop", "Envelop1") ;
84 envelop1node->SetLineColor(kColorArm1) ;
85 fNodes->Add(envelop1node) ;
2012850d 86}
b13bbe81 87//______________________________________________________________________
88void AliEMCALv0::CreateGeometry(){
89 // Create the EMCAL geometry for Geant
2012850d 90
b13bbe81 91 AliEMCALv0 *emcaltmp = (AliEMCALv0*)gAlice->GetModule("EMCAL") ;
2012850d 92
b13bbe81 93 if ( emcaltmp == NULL ) {
94 Warning("CreateGeometry","detector not found!");
95 return;
96 } // end if
97 // Get pointer to the array containing media indices
98 Int_t *idtmed = fIdtmed->GetArray() - 1599 ;
e13bd4f0 99
ffa6d63b 100 // Create an Envelope within which to place the Detector
2012850d 101
09641ef5 102 Float_t envelopA[5] ;
103 envelopA[0] = fGeom->GetEnvelop(0) ; // rmin
104 envelopA[1] = fGeom->GetEnvelop(1) + 30 ; // rmax
105 envelopA[2] = fGeom->GetEnvelop(2) / 2.0 ; // dz
106 envelopA[3] = fGeom->GetArm1PhiMin() ; // minimun phi angle
107 envelopA[4] = fGeom->GetArm1PhiMax() ; // maximun phi angle
108
109
110 // create XEN1
b13bbe81 111 gMC->Gsvolu("XEN1", "TUBS ", idtmed[1599], envelopA, 5) ; //filled with air
09641ef5 112
113 Int_t idrotm = 1;
114 AliMatrix(idrotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
115
116 // Position the Envelope in Alice
71d7e6ad 117 gMC->Gspos("XEN1", 1, "ALIC", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
09641ef5 118 envelopA[1] =envelopA[0] + fGeom->GetGap2Active();
119 TString label = "XU0";
120
121 envelopA[0] = envelopA[1]+ 3.18 ; //rmin Start mini envelopes after the aluminium layer
122 envelopA[1] = envelopA[0] + 2.2 ; //rmax larger for first two layers (preshower)
123
124 gMC->Gsvolu(label.Data(), "TUBS ", idtmed[1599], envelopA, 5) ; //filled with air
71d7e6ad 125 gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ; // Place XU0 in to XEN1
09641ef5 126
127 for (int i = 1; i < ((fGeom->GetNLayers()-1)/2) + 1 ; i++ ){
128 label = "XU" ;
129 label += i ;
130
131 envelopA[0] = envelopA[1] ; //rmin
132 envelopA[1] = envelopA[0] + 2.0 ; //rmax
133
134 gMC->Gsvolu(label.Data(), "TUBS ", idtmed[1599], envelopA, 5) ; //filled with air
71d7e6ad 135 gMC->Gspos(label.Data(), 1, "XEN1", 0.0, 0.0, 0.0, idrotm, "ONLY") ;
09641ef5 136
137 } // end i
138
139
b13bbe81 140
ffa6d63b 141 // Create the shapes of active material (LEAD/Aluminium/Scintillator) to be placed
b13bbe81 142
ffa6d63b 143 Float_t envelopB[10]; // First Layer of Aluminium
144 Float_t envelopC[10]; // Scintillator Layers
145 Float_t envelopD[10]; // Lead Layers
146
147 envelopC[0] = envelopD[0] = envelopB[0] = fGeom->GetArm1PhiMin(); //starting position in Phi
148 envelopC[1] = envelopD[1] = envelopB[1] = fGeom->GetArm1PhiMax() - // Angular size of the Detector in Phi
b13bbe81 149 fGeom->GetArm1PhiMin();
ffa6d63b 150 envelopC[2] = envelopD[2] = envelopB[2] = fGeom->GetNPhi() ; // Number of Section in Phi
151 envelopD[3] = envelopC[3] = envelopB[3] = 2; // each section will be passed 2 z coordinates
b13bbe81 152
61e0abb5 153 envelopB[4] = (fGeom->GetEnvelop(0) + fGeom->GetGap2Active()) /
ffa6d63b 154 (tan(2*atan(exp(0.7)))) ; // z co-ordinate 1
155 envelopB[5] = fGeom->GetEnvelop(0) + fGeom->GetGap2Active(); //rmin at z1
156 envelopD[6] = envelopB[6] = envelopB[5] + 3.18; //rmax at z1
61e0abb5 157 envelopB[7] = (fGeom->GetEnvelop(0) + fGeom->GetGap2Active()) /
ffa6d63b 158 (tan(2*atan(exp(-0.7)))) ; // z co-ordinate 2
159 envelopB[8] = envelopB[5] ; //
160 envelopB[9] = envelopB[6] ; // radii are the same.
161
162 // filled shapes wit hactive material
163 gMC->Gsvolu("XALU", "PGON", idtmed[1602], envelopB, 10); // Define Aluminium volume completely
164 gMC->Gsvolu("XPST", "PGON", idtmed[1601], 0, 0) ; // The polystyrene layers will be defined when placed
165 gMC->Gsvolu("XPBX", "PGON", idtmed[1600], 0, 0) ; // as will the lead layers
166 gMC->Gsdvn("XPHI", "XPST", fGeom->GetNPhi(), 2) ; // Dividind eta polystyrene divisions into phi segments.
61e0abb5 167
ffa6d63b 168 // Position Aluminium Layer in the Envelope
61e0abb5 169 gMC->Gspos("XALU", 1, "XEN1", 0.0, 0.0, 0.0 , idrotm, "ONLY") ;
b13bbe81 170
ffa6d63b 171// The loop below places the scintillator in Lead Layers alternately.
172
09641ef5 173 for (int i = 0; i < fGeom->GetNLayers() ; i++ ){
174
175 label = "XU" ;
176
177 label += (int) i/2 ; // we will place two layers (i = one layer) in each mini envelope)
178 envelopC[5] = envelopD[6] ; //rmin
179 envelopC[6] = envelopD[6] + ((i > 1) ? 0.5 : 0.6) ; //rmax larger for first two layers (preshower)
b13bbe81 180 envelopC[8] = envelopD[6] ; //rmin
09641ef5 181 envelopC[9] = envelopD[6] + ((i > 1 ) ? 0.5 : 0.6) ; //rmax larger for first two layers (preshower)
b13bbe81 182 for (int j =0; j < (fGeom->GetNZ()) ; j++){
183 envelopC[4] = envelopD[6]/tan(2*atan(exp(0.7-(j*1.4/
ffa6d63b 184 (fGeom->GetNZ()))))); //z begin
b13bbe81 185 envelopC[7] = envelopD[6]/tan(2*atan(exp(0.7-((j+1)*1.4/
ffa6d63b 186 (fGeom->GetNZ()))))); // z end
09641ef5 187 gMC->Gsposp("XPST",1+j+i*(fGeom->GetNZ()), label.Data(), // should be used but there's a weird crash above i = 18,
ffa6d63b 188 0.0, 0.0, 0.0 , idrotm, "ONLY", envelopC, 10); // Position and define layer
b13bbe81 189 } // end for j
190 if (i < (fGeom->GetNLayers()-1)){
09641ef5 191
192 envelopD[5] = envelopC[6] ; //rmin
b13bbe81 193 envelopD[6] = envelopC[6] + 0.5; //rmax
194 envelopD[8] = envelopC[6] ; //rmin
195 envelopD[9] = envelopC[6] + 0.5; //rmax
196 for (int j =0; j < (fGeom->GetNZ()) ; j++){
197 envelopD[4] = envelopC[6]/tan(2*atan(exp(0.7-(j*1.4/
ffa6d63b 198 (fGeom->GetNZ()))))); // z begin
b13bbe81 199 envelopD[7] = envelopC[6]/tan(2*atan(exp(0.7-((j+1)*1.4/
ffa6d63b 200 (fGeom->GetNZ()))))); // z end
09641ef5 201 gMC->Gsposp("XPBX",1+ j+i*(fGeom->GetNZ()), label.Data(),
202 0.0, 0.0, 0.0 , idrotm, "ONLY", envelopD, 10) ; // Position and Define Layer
b13bbe81 203 } // end for j
204 } // end if i
61e0abb5 205 } // for i
2012850d 206}
b13bbe81 207//______________________________________________________________________
208void AliEMCALv0::Init(void){
209 // Just prints an information message
210 Int_t i;
211
212 cout << endl;
213 for(i=0;i<35;i++) cout <<"*";
214 cout << " EMCAL_INIT ";
215 for(i=0;i<35;i++) cout << "*";
216 cout << endl;
217
218 // Here the EMCAL initialisation code (if any!)
219
220 if (fGeom!=0)
221 cout << "AliEMCAL" << Version() << " : EMCAL geometry intialized for "
222 << fGeom->GetName() << endl ;
223 else
224 cout << "AliEMCAL" << Version() <<
225 " : EMCAL geometry initialization failed !" << endl ;
226 for(i=0;i<80;i++) printf("*");
227 cout << endl;
2012850d 228}