]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALv0.cxx
remove classes alredy moved to EMCALcalib library
[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)
d87bd045 24// : Aleksei Pavlinov (WSU) SHASHLYK
2012850d 25
26// --- ROOT system ---
7dd95fbf 27#include <cassert>
a1469a24 28
cde6a23d 29#include <TNode.h>
30#include <TBRIK.h>
31#include <TTRD1.h>
cde6a23d 32#include <TTRAP.h>
33#include <TPGON.h>
34#include <TTUBS.h>
35#include <TGeometry.h>
9aa6a5f6 36#include <TGeoPhysicalNode.h>
37#include <TGeoManager.h>
268f57b1 38#include <TGeoMatrix.h>
cde6a23d 39#include <TVirtualMC.h>
40#include <TArrayI.h>
41#include <TROOT.h>
42#include <TList.h>
43#include <TVector2.h>
21e7df44 44#include <cassert>
1963b290 45
46#include "AliEMCALShishKebabModule.h"
47#include "AliEMCALShishKebabTrd1Module.h"
a1469a24 48
2012850d 49// --- Standard library ---
50
d64c959b 51//#include <stdio.h>
2012850d 52
53// --- AliRoot header files ---
54
55#include "AliEMCALv0.h"
56#include "AliEMCALGeometry.h"
57#include "AliRun.h"
4951e003 58#include "AliLog.h"
200e17a4 59#include "AliGeomManager.h"
2012850d 60
61ClassImp(AliEMCALv0)
62
cde6a23d 63// EMCAL material
64enum
65 {
66 kIdAIR = 1599,
67 kIdPB = 1600,
68 kIdSC = 1601,
69 kIdSTEEL = 1603
70 };
18a21c7c 71
72
73//______________________________________________________________________
74AliEMCALv0::AliEMCALv0()
75 : AliEMCAL(),
76 fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
77 fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0)
78{
79 //default ctor
80}
81
b13bbe81 82//______________________________________________________________________
18a21c7c 83AliEMCALv0::AliEMCALv0(const char *name, const char *title)
84 : AliEMCAL(name,title),
85 fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
86 fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0)
05a92d59 87{
88 // ctor : title is used to identify the layout
d25f2c54 89 // Apr 25, 2006
90 // Nov 22, 2006 - case of 1X1
e5a93224 91 TString ntmp(GetTitle());
92 ntmp.ToUpper();
e5a93224 93
e52475ed 94 AliEMCALGeometry *geom = GetGeometry() ;
e52475ed 95 fShishKebabModules = geom->GetShishKebabTrd1Modules();
2012850d 96}
a1469a24 97
b13bbe81 98//______________________________________________________________________
05a92d59 99void AliEMCALv0::BuildGeometry()
100{
d297ef6e 101 // Display Geometry for display.C
102
103 const Int_t kColorArm1 = kBlue ;
104
105 AliEMCALGeometry * geom = GetGeometry();
106
107 TString gn(geom->GetName());
108 gn.ToUpper();
109
110 // Define the shape of the Calorimeter
111 TNode * top = gAlice->GetGeometry()->GetNode("alice") ; // See AliceGeom/Nodes
112 TNode * envelopNode = 0;
113 char *envn = "Envelop1";
114 if(gn.Contains("WSUC")) {
115 envelopNode = BuildGeometryOfWSUC();
116 } else { // Shish-kebab now for compact and TRD1 cases (ALIC)
117 envn="Envelop2";
118 TPGON *pgon = new TPGON(envn, "PGON that contains arm 1", "void",
119 geom->GetArm1PhiMin(),geom->GetArm1PhiMax()-geom->GetArm1PhiMin(),geom->GetNPhiSuperModule(), 2);
120 // define section
121 if (fEnvelop1.GetSize()<8) {
122 fEnvelop1.Set(10);
123 fEnvelop1[0] = geom->GetArm1PhiMin(); // minimum phi angle
124 fEnvelop1[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
125 fEnvelop1[2] = geom->GetNPhiSuperModule();
126 fEnvelop1[3] = 2; // 2 z coordinates
127 fEnvelop1[4] = -350.;
128 fEnvelop1[5] = geom->GetEnvelop(0) ; // rmin at z1
129 fEnvelop1[6] = geom->GetEnvelop(1) ; // rmax at z1
130 fEnvelop1[7] = 350.;
131 fEnvelop1[8] = fEnvelop1[5] ; // radii are the same.
132 fEnvelop1[9] = fEnvelop1[6] ; // radii are the same.
1963b290 133 }
d297ef6e 134 pgon->DefineSection(0, fEnvelop1[4], fEnvelop1[5], fEnvelop1[6]);
135 pgon->DefineSection(1, fEnvelop1[7], fEnvelop1[5], fEnvelop1[6]);
136 top->cd();
137 envelopNode = new TNode(envn, "Arm1 Envelop2", envn, 0., 0., 0., "") ;
138 }
139
140 envelopNode->SetLineColor(kColorArm1) ;
141 fNodes->Add(envelopNode);
1963b290 142}
143
4d2e7dc7 144//______________________________________________________________________
1963b290 145TNode *AliEMCALv0::BuildGeometryOfWSUC()
cde6a23d 146{
147 // June 8, 2005; see directory geant3/TGeant3/G3toRoot.cxx
1963b290 148 // enum EColor { kWhite, kBlack, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan } - see $ROOTSYS/include/Gtypes.h
d297ef6e 149 AliEMCALGeometry * g = GetGeometry();
150 TNode * top = gAlice->GetGeometry()->GetNode("alice") ; // See AliceGeom/Nodes
151 top->cd();
1963b290 152
d297ef6e 153 TNode *envelopNode = 0;
154 char *name = "";
155 /*
1963b290 156 name = "WSUC";
d297ef6e 157 new TBRIK(name, "WSUC(XEN1 in Geant)","void",fEnvelop1[0],fEnvelop1[1],fEnvelop1[2]);
1963b290 158 envelopNode = new TNode(name, "envelope for WSUC", name, 0., 0., 0., "");
d297ef6e 159 envelopNode->SetVisibility(0);
160 */
161
162 TNode *emod=0, *scmx=0;
163 name = "SMOD"; // super module
164 new TBRIK(name, "SMOD(SMOD in Geant)","void", fSmodPar0,fSmodPar1,fSmodPar2);
165 if(envelopNode) envelopNode->cd();
166 TNode *smod = new TNode(name, "SMOD", name, 0., 0., 0., "");
167 smod->SetLineColor(kBlue) ;
168 if(envelopNode==0) envelopNode = smod;
169
170 name = "EMOD"; // see CreateEMOD
171 TTRD1 *emodTrd1 = new TTRD1(name, "EMOD(EMOD in Geant)","void", float(fParEMOD[0]),
172 float(fParEMOD[1]),float(fParEMOD[2]),float(fParEMOD[3]));
173
174 // SCMX = EMOD/4 for simplicity of drawing
175 name = "SCMX";
176 Float_t dz=0.,theta=0.,phi=0.,h1=0.,bl1=0.,tl1=0.,alpha1=0.,h2=0.,bl2=0.,tl2=0.,alpha2=0.;
177 h1 = emodTrd1->GetDy()/2.;
178 bl1 = emodTrd1->GetDx()/2.;
179 tl1 = bl1;
180 alpha1 = 0.;
181 h2 = emodTrd1->GetDy()/2.;
182 bl2 = emodTrd1->GetDx2()/2.;
183 tl2 = bl2;
184 alpha2 = 0.;
185
186 dz = emodTrd1->GetDz();
187 double dr = TMath::Sqrt((h2-h1)*(h2-h1)+(bl2-bl1)*(bl2-bl1));
188 theta = TMath::ATan2(dr,2.*dz) * TMath::RadToDeg();
189 phi = 180.;
190
191 TTRAP *scmxTrap = new TTRAP(name, "SCMX(SCMX as in Geant)","void",
192 dz,theta,phi, h1,bl1,tl1,alpha1, h2,bl2,tl2,alpha2);
193 // scmxTrap->Dump();
194 Float_t xShiftSCMX = (emodTrd1->GetDx() + emodTrd1->GetDx2())/4.;
195 Float_t yShiftSCMX = emodTrd1->GetDy()/2.;
196 printf(" xShiftSCMX %7.4f yShiftSCMX %7.4f \n",xShiftSCMX,yShiftSCMX);
197
198 name = "EMOD"; // see CreateEMOD
199 smod->cd();
1963b290 200
d297ef6e 201 AliEMCALShishKebabTrd1Module *mod=0;
202 Double_t angle=90., xpos=0.,ypos=0.,zpos=0., xposSCMX=0.,yposSCMX=0.,zposSCMX=0.;
203 char rtmn[100], rtmt[100];
204 TRotMatrix *rtm=0, *rtmSCMX=0;
205 int numEmod=0;
206 for(int iz=0; iz<g->GetNZ(); iz++) {
207 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(iz);
208 zpos = mod->GetPosZ() - fSmodPar2;
209 ypos = mod->GetPosXfromR() - fSmodPar1;
210
211 angle = mod->GetThetaInDegree();
212 sprintf(rtmn,"rmEmod%5.1f",angle);
213 sprintf(rtmt,"rotation matrix for EMOD, iz=%i, angle = %6.3f",iz, angle);
214 if(iz==0) rtm = new TRotMatrix(rtmn, rtmt,0.,0., 90.,0., 90.,90.); // z'(x); y'(y); x'(z)
215 else rtm = new TRotMatrix(rtmn, rtmt,90.-angle,270., 90.0,0.0, angle,90.);
216
217 TGeometry *tg = gAlice->GetGeometry();
218 for(int ix=0; ix<g->GetNPhi(); ix++) { // flat in phi
219 xpos = g->GetPhiModuleSize()*(2*ix+1 - g->GetNPhi())/2.;
220 sprintf(rtmt,"EMOD, iz %i, ix %i, angle %6.3f",iz,ix, angle);
221 TString namNode=name;
222 namNode += numEmod++;
223 smod->cd();
224 emod = new TNode(namNode.Data(), rtmt, (TShape*)emodTrd1, xpos,ypos,zpos,rtm);
225 // emod->SetLineColor(kGreen) ;
226 emod->SetVisibility(0); // SCMX will bi visible
227 if(scmxTrap) { // 4(2x2) sensetive volume inside EMOD
228 emod->cd();
229 zposSCMX = 0.;
230 for(int jy=0; jy<2; jy++){ // division on y
231 yposSCMX = yShiftSCMX *(2*jy - 1);
232 for(int jx=0; jx<2; jx++){ // division on x
233 Double_t theta1=90.,phi1=0., theta2=90.,phi2=90., theta3=0.,phi3=0 ;
234 xposSCMX = xShiftSCMX *(2*jx - 1);
235 namNode = "SCMX";
236 namNode += jy;
237 namNode += jx;
238 sprintf(rtmn,"rm%s",namNode.Data());
239 sprintf(rtmt,"rotation matrix for %s inside EMOD",namNode.Data());
240 rtmSCMX = tg->GetRotMatrix(rtmn);
241 if(jx == 1) {
242 phi1 = 180.; // x' = -x
243 phi2 = 270.; // y' = -y
244 }
245 if(rtmSCMX == 0) rtmSCMX = new TRotMatrix(rtmn,rtmt, theta1,phi1, theta2,phi2, theta3,phi3);
246 sprintf(rtmt,"%s inside %s", namNode.Data(), emod->GetName());
247 scmx = new TNode(namNode.Data(), rtmt, (TShape*)scmxTrap, xposSCMX,yposSCMX,zposSCMX,rtmSCMX);
248 scmx->SetLineColor(kMagenta);
249 }
250 }
251 }
252 }
253 }
254 // emod->Draw(); // for testing
255
256 return envelopNode;
2012850d 257}
a1469a24 258
b13bbe81 259//______________________________________________________________________
05a92d59 260void AliEMCALv0::CreateGeometry()
261{
f590bb15 262 // Create the EMCAL geometry for Geant
263 // Geometry of a tower
d297ef6e 264
265 AliEMCALGeometry * geom = GetGeometry() ;
266 TString gn(geom->GetName());
267 gn.ToUpper();
268
269 if(!(geom->IsInitialized())){
270 Error("CreateGeometry","EMCAL Geometry class has not been set up.");
271 } // end if
272
273 // Get pointer to the array containing media indices
274 fIdTmedArr = fIdtmed->GetArray() - 1599 ;
275
276 fIdRotm = 1;
277 // gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3) - see AliModule
278 AliMatrix(fIdRotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
279
280 // Create the EMCAL Mother Volume (a polygone) within which to place the Detector and named XEN1
281
282 Float_t envelopA[10];
283 if(gn.Contains("WSUC") ) { // TRD1 for WSUC facility
284 // 17-may-05 - just BOX
285 envelopA[0] = 26;
286 envelopA[1] = 15;
287 envelopA[2] = 30;
288 gMC->Gsvolu("XEN1", "BOX", fIdTmedArr[kIdSC], envelopA, 3) ;
289 fEnvelop1.Set(3);
290 for(int i=0; i<3; i++) fEnvelop1[i] = envelopA[i]; // 23-may-05
291 // Position the EMCAL Mother Volume (XEN1) in WSUC
292 gMC->Gspos("XEN1", 1, "WSUC", 0.0, 0.0, 0.0, fIdRotm, "ONLY") ;
293 } else {
294 envelopA[0] = geom->GetArm1PhiMin(); // minimum phi angle
295 envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
296 envelopA[2] = geom->GetNPhiSuperModule(); // number of sections in phi
297 envelopA[3] = 2; // 2 z coordinates
298 // envelopA[4] = geom->ZFromEtaR(geom->GetEnvelop(1),
299 //geom->GetArm1EtaMin()); // z coordinate 1
300 envelopA[4] = -350.; // AM 30/5/2006
301
fdebddeb 302 //add some padding for mother volume
d297ef6e 303 envelopA[5] = geom->GetEnvelop(0) ; // rmin at z1
304 envelopA[6] = geom->GetEnvelop(1) ; // rmax at z1
305 // envelopA[7] = geom->ZFromEtaR(geom->GetEnvelop(1),
306 // geom->GetArm1EtaMax()); // z coordinate 2
307 envelopA[7] = 350.; // AM 30/5/2006
308
309 envelopA[8] = envelopA[5] ; // radii are the same.
310 envelopA[9] = envelopA[6] ; // radii are the same.
311
312 gMC->Gsvolu("XEN1", "PGON", fIdTmedArr[kIdAIR], envelopA, 10) ; // Polygone filled with air
313 fEnvelop1.Set(10, envelopA);
314 if (gDebug==2) {
315 printf("CreateGeometry: XEN1 = %f, %f\n", envelopA[5], envelopA[6]);
316 printf("CreateGeometry: XU0 = %f, %f\n", envelopA[5], envelopA[6]);
1963b290 317 }
d297ef6e 318 // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)
319 gMC->Gspos(geom->GetNameOfEMCALEnvelope(), 1, "ALIC", 0.0, 0.0, 0.0, fIdRotm, "ONLY") ;
320 }
321
322 // COMPACT, TRD1
323 AliDebug(2,Form("Shish-Kebab geometry : %s", GetTitle()));
324 CreateShishKebabGeometry();
1963b290 325
2012850d 326}
a1469a24 327
b13bbe81 328//______________________________________________________________________
05a92d59 329void AliEMCALv0::Init(void)
330{
b13bbe81 331 // Just prints an information message
aa61eaea 332 AliEMCAL::Init();
4951e003 333 if(AliLog::GetGlobalDebugLevel()>0) {
9859bfc0 334 TString message("\n") ;
c27ad3fb 335 message += "*****************************************\n" ;
05a92d59 336
b13bbe81 337 // Here the EMCAL initialisation code (if any!)
9859bfc0 338
05a92d59 339 AliEMCALGeometry * geom = GetGeometry() ;
9859bfc0 340
341 if (geom!=0) {
342 message += "AliEMCAL " ;
343 message += Version() ;
c27ad3fb 344 message += "EMCAL geometry initialized for " ;
9859bfc0 345 message += geom->GetName() ;
346 }
347 else {
348 message += "AliEMCAL " ;
349 message += Version() ;
350 message += "EMCAL geometry initialization failed !" ;
05a92d59 351 }
c27ad3fb 352 message += "\n*****************************************" ;
fdebddeb 353 printf(message.Data() ) ;
9859bfc0 354 }
2012850d 355}
1963b290 356
357// 24-aug-04 by PAI
4d2e7dc7 358//______________________________________________________________________
1963b290 359void AliEMCALv0::CreateShishKebabGeometry()
cde6a23d 360{
937d0661 361 // TRD1
1963b290 362 AliEMCALGeometry * g = GetGeometry();
363 TString gn(g->GetName()); gn.ToUpper();
cde6a23d 364 // see AliModule::fFIdTmedArr
365 // fIdTmedArr = fIdtmed->GetArray() - 1599 ; // see AliEMCAL::::CreateMaterials()
366 // int kIdAIR=1599, kIdPB = 1600, kIdSC = 1601, kIdSTEEL = 1603;
1963b290 367 // idAL = 1602;
368 Double_t par[10], xpos=0., ypos=0., zpos=0.;
369
e52475ed 370 CreateSmod(g->GetNameOfEMCALEnvelope());
1963b290 371
d87bd045 372 CreateEmod("SMOD","EMOD"); // 18-may-05
373
1d46d1f6 374 if(g->GetKey110DEG()) CreateEmod("SM10","EMOD"); // Nov 1,2006
1963b290 375
376 // Sensitive SC (2x2 tiles)
1d46d1f6 377 double parSCM0[5]={0,0,0,0}, *dummy = 0, parTRAP[11];
d297ef6e 378
379 // double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize(); // Need check
380 double wallThickness = g->GetPhiModuleSize()/g->GetNPHIdiv() - g->GetPhiTileSize();
381 for(int i=0; i<3; i++) parSCM0[i] = fParEMOD[i] - wallThickness;
382 parSCM0[3] = fParEMOD[3];
383 gMC->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
384 gMC->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
385
386 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
1963b290 387 // Division to tile size - 1-oct-04
d297ef6e 388 AliDebug(2,Form(" Divide SCM0 on y-axis %i\n", g->GetNETAdiv()));
389 gMC->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
1963b290 390 // Trapesoid 2x2
d297ef6e 391 parTRAP[0] = parSCM0[3]; // dz
392 parTRAP[1] = TMath::ATan2((parSCM0[1]-parSCM0[0])/2.,2.*parSCM0[3])*180./TMath::Pi(); // theta
393 parTRAP[2] = 0.; // phi
394 // bottom
395 parTRAP[3] = parSCM0[2]/2.; // H1
396 parTRAP[4] = parSCM0[0]/2.; // BL1
397 parTRAP[5] = parTRAP[4]; // TL1
398 parTRAP[6] = 0.0; // ALP1
399 // top
400 parTRAP[7] = parSCM0[2]/2.; // H2
401 parTRAP[8] = parSCM0[1]/2.; // BL2
402 parTRAP[9] = parTRAP[8]; // TL2
403 parTRAP[10]= 0.0; // ALP2
404 AliDebug(2,Form(" ** TRAP ** \n"));
405 for(int i=0; i<11; i++) AliDebug(3, Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
406
407 gMC->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
408 xpos = +(parSCM0[1]+parSCM0[0])/4.;
409 gMC->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
410
411 // Using rotation because SCMX should be the same due to Pb tiles
412 xpos = -xpos;
413 AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
414 gMC->Gspos("SCMX", 2, "SCMY", xpos, 0.0, 0.0, fIdRotm, "ONLY");
1963b290 415 // put LED to the SCM0
d297ef6e 416 AliEMCALShishKebabTrd1Module *mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(0);
417 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
418
419 par[1] = parSCM0[2]/2; // y
420 par[2] = g->GetECPbRadThick()/2.; // z
421
422 int nr=0;
423 ypos = 0.0;
424 zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
425 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.;
426 AliDebug(2,Form(" Pb tiles \n"));
427 for(int iz=0; iz<g->GetNECLayers(); iz++){
428 par[0] = (parSCM0[0] + mod->GetTanBetta()*fSampleWidth*iz)/2.;
429 xpos = par[0] - xCenterSCMX;
430 gMC->Gsposp("PBTI", ++nr, "SCMX", xpos, ypos, zpos, 0, "ONLY", par, 3) ;
431 AliDebug(3,Form(" %i xpos %f zpos %f par[0] %f \n", iz+1, xpos, zpos, par[0]));
432 zpos += fSampleWidth;
433 }
434 AliDebug(2,Form(" Number of Pb tiles in SCMX %i \n", nr));
435
436 } else if(g->GetNPHIdiv()==3 && g->GetNETAdiv()==3) {
437 printf(" before AliEMCALv0::Trd1Tower3X3() : parSCM0");
438 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
439 printf("\n");
440 Trd1Tower3X3(parSCM0);
441 } else if(g->GetNPHIdiv()==1 && g->GetNETAdiv()==1) {
442 // no division in SCM0
443 Trd1Tower1X1(parSCM0);
444 } else if(g->GetNPHIdiv()==4 && g->GetNETAdiv()==4) {
445 Trd1Tower4X4();
1963b290 446 }
d297ef6e 447
1963b290 448}
449
4d2e7dc7 450//______________________________________________________________________
1963b290 451void AliEMCALv0::CreateSmod(const char* mother)
cde6a23d 452{
453 // 18-may-05; mother="XEN1";
d87bd045 454 // child="SMOD" from first to 10th, "SM10" (11th and 12th) (TRD1 case)
1963b290 455 AliEMCALGeometry * g = GetGeometry();
456 TString gn(g->GetName()); gn.ToUpper();
457
6f377f0c 458 Double_t par[3], xpos=0., ypos=0., zpos=0., rpos=0., dphi=0., phi=0.0, phiRad=0.;
d87bd045 459 Double_t par1C = 0.;
1963b290 460 // ===== define Super Module from air - 14x30 module ==== ;
cde6a23d 461 fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
e5a93224 462 AliDebug(2,Form("\n ## Super Module | fSampleWidth %5.3f ## %s \n", fSampleWidth, gn.Data()));
1963b290 463 par[0] = g->GetShellThickness()/2.;
464 par[1] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
465 par[2] = g->GetEtaModuleSize()*15.;
cde6a23d 466 fIdRotm=0;
1963b290 467 int nphism = g->GetNumberOfSuperModules()/2; // 20-may-05
468 if(nphism>0) {
469 dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/nphism;
1d46d1f6 470 // if(g->GetKey110DEG()) dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/(nphism-1);
1963b290 471 rpos = (g->GetEnvelop(0) + g->GetEnvelop(1))/2.;
e5a93224 472 AliDebug(2,Form(" rpos %8.2f : dphi %6.1f degree \n", rpos, dphi));
1963b290 473 }
474
6f377f0c 475 if(gn.Contains("WSUC")) {
1963b290 476 par[0] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
477 par[1] = g->GetShellThickness()/2.;
478 par[2] = g->GetEtaModuleSize()*g->GetNZ()/2. + 5;
479
cde6a23d 480 gMC->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
1963b290 481
e5a93224 482 AliDebug(2,Form("SMOD in WSUC : tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
483 fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
cde6a23d 484 fSmodPar0 = par[0];
485 fSmodPar1 = par[1];
486 fSmodPar2 = par[2];
1963b290 487 nphism = g->GetNumberOfSuperModules();
488 } else {
d297ef6e 489 par[2] = 350./2.; // 11-oct-04 - for 26 division
490 AliDebug(2,Form(" par[0] %7.2f (old) \n", par[0]));
491 Float_t *parSM = g->GetSuperModulesPars();
492 for(int i=0; i<3; i++) par[i] = parSM[i];
493 }
494 gMC->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
495 AliDebug(2,Form("tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
496 fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
497 fSmodPar0 = par[0];
498 fSmodPar2 = par[2];
499 if(g->GetKey110DEG()) { // 12-oct-05
500 par1C = par[1];
501 par[1] /= 2.;
502 gMC->Gsvolu("SM10", "BOX", fIdTmedArr[kIdAIR], par, 3);
503 AliDebug(2,Form(" Super module with name \"SM10\" was created too par[1] = %f\n", par[1]));
504 par[1] = par1C;
505 }
1963b290 506 // Steel plate
d297ef6e 507 if(g->GetSteelFrontThickness() > 0.0) { // 28-mar-05
508 par[0] = g->GetSteelFrontThickness()/2.;
509 gMC->Gsvolu("STPL", "BOX", fIdTmedArr[kIdSTEEL], par, 3);
510 printf("tmed %i | dx %7.2f dy %7.2f dz %7.2f (STPL) \n", fIdTmedArr[kIdSTEEL], par[0],par[1],par[2]);
511 xpos = -(g->GetShellThickness() - g->GetSteelFrontThickness())/2.;
512 gMC->Gspos("STPL", 1, "SMOD", xpos, 0.0, 0.0, 0, "ONLY") ;
1963b290 513 }
514
d87bd045 515 int nr=0, nrsmod=0, i0=0;
1963b290 516
517 // Turn whole super module
1963b290 518 for(int i=i0; i<nphism; i++) {
6f377f0c 519 if(gn.Contains("WSUC")) {
d87bd045 520 xpos = ypos = zpos = 0.0;
cde6a23d 521 fIdRotm = 0;
522 gMC->Gspos("SMOD", 1, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
523 printf(" fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n",
524 fIdRotm, phi, phiRad, xpos, ypos, zpos);
d87bd045 525 nr++;
c63c3c5d 526 } else { // TRD1
d87bd045 527 TString smName("SMOD"); // 12-oct-05
1d46d1f6 528 if(i==5 && g->GetKey110DEG()) {
d87bd045 529 smName = "SM10";
530 nrsmod = nr;
531 nr = 0;
532 }
1963b290 533 phi = g->GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 70, 90, 110, 130, 150, 170
534 phiRad = phi*TMath::Pi()/180.;
535
cde6a23d 536 AliMatrix(fIdRotm, 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
1963b290 537
538 xpos = rpos * TMath::Cos(phiRad);
539 ypos = rpos * TMath::Sin(phiRad);
cde6a23d 540 zpos = fSmodPar2; // 21-sep-04
1d46d1f6 541 if(i==5 && g->GetKey110DEG()) {
d87bd045 542 xpos += (par1C/2. * TMath::Sin(phiRad));
543 ypos -= (par1C/2. * TMath::Cos(phiRad));
544 }
545
1963b290 546 // 1th module in z-direction;
cde6a23d 547 gMC->Gspos(smName.Data(), ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
548 AliDebug(3, Form(" %s : %2i fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : i %i \n",
549 smName.Data(), nr, fIdRotm, phi, phiRad, xpos, ypos, zpos, i));
1963b290 550 // 2th module in z-direction;
1963b290 551 // turn arround X axis; 0<phi<360
d297ef6e 552 double phiy = 90. + phi + 180.;
553 if(phiy>=360.) phiy -= 360.;
554
555 AliMatrix(fIdRotm, 90.0, phi, 90.0, phiy, 180.0, 0.0);
556 gMC->Gspos(smName.Data(), ++nr, mother, xpos, ypos, -zpos, fIdRotm, "ONLY");
557 AliDebug(3, Form(" %s : %2i fIdRotm %3i phiy %6.1f xpos %7.2f ypos %7.2f zpos %7.2f \n",
558 smName.Data(), nr, fIdRotm, phiy, xpos, ypos, -zpos));
1963b290 559 }
560 }
e5a93224 561 AliDebug(2,Form(" Number of Super Modules %i \n", nr+nrsmod));
1963b290 562}
563
4d2e7dc7 564//______________________________________________________________________
1963b290 565void AliEMCALv0::CreateEmod(const char* mother, const char* child)
cde6a23d 566{
567 // 17-may-05; mother="SMOD"; child="EMOD"
1963b290 568 AliEMCALGeometry * g = GetGeometry();
569 TString gn(g->GetName()); gn.ToUpper();
570 // Module definition
d297ef6e 571 Double_t xpos=0., ypos=0., zpos=0.;
1963b290 572 Double_t parSCPA[5], zposSCPA=0.; // passive SC - 13-MAY-05, TRD1 case
573 Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
1963b290 574 int nr=0;
cde6a23d 575 fIdRotm=0;
d297ef6e 576 if(strcmp(mother,"SMOD")==0) {
577 fParEMOD[0] = g->GetEtaModuleSize()/2.; // dx1
578 fParEMOD[1] = g->Get2Trd1Dx2()/2.; // dx2
579 fParEMOD[2] = g->GetPhiModuleSize()/2.;; // dy
580 fParEMOD[3] = g->GetLongModuleSize()/2.; // dz
581 gMC->Gsvolu(child, "TRD1", fIdTmedArr[kIdSTEEL], fParEMOD, 4);
582 // if(gn.Contains("WSUC") || gn.Contains("MAY05")){
583 if(0){ // Jul 12 - should be checked
584 parSCPA[0] = g->GetEtaModuleSize()/2. + tanTrd1*g->GetFrontSteelStrip(); // dx1
585 parSCPA[1] = parSCPA[0] + tanTrd1*g->GetPassiveScintThick(); // dx2
586 parSCPA[2] = g->GetPhiModuleSize()/2.; // dy
587 parSCPA[3] = g->GetPassiveScintThick()/2.; // dz
588 gMC->Gsvolu("SCPA", "TRD1", fIdTmedArr[kIdSC], parSCPA, 4);
589 zposSCPA = -fParEMOD[3] + g->GetFrontSteelStrip() + g->GetPassiveScintThick()/2.;
590 gMC->Gspos ("SCPA", ++nr, child, 0.0, 0.0, zposSCPA, 0, "ONLY");
1963b290 591 }
1963b290 592 }
d297ef6e 593
1963b290 594 nr = 0;
d297ef6e 595 // X->Z(0, 0); Y->Y(90, 90); Z->X(90, 0)
596 AliEMCALShishKebabTrd1Module *mod=0; // current module
597
598 for(int iz=0; iz<g->GetNZ(); iz++) {
599 Double_t angle=90., phiOK=0;
600 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(iz);
601 angle = mod->GetThetaInDegree();
602 if(!gn.Contains("WSUC")) { // ALICE
603 if(iz==0) AliMatrix(fIdRotm, 0.,0., 90.,90., 90.,0.); // z'(x); y'(y); x'(z)
604 else AliMatrix(fIdRotm, 90.-angle,180., 90.0,90.0, angle, 0.);
605 phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
606 // printf(" %2i | angle | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
607 //iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule());
608 xpos = mod->GetPosXfromR() + g->GetSteelFrontThickness() - fSmodPar0;
609 zpos = mod->GetPosZ() - fSmodPar2;
610
611 int iyMax = g->GetNPhi();
612 if(strcmp(mother,"SMOD") && g->GetKey110DEG()) {
613 iyMax /= 2;
1963b290 614 }
d297ef6e 615 for(int iy=0; iy<iyMax; iy++) { // flat in phi
616 ypos = g->GetPhiModuleSize()*(2*iy+1 - iyMax)/2.;
617 gMC->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
618 //printf(" %2i xpos %7.2f ypos %7.2f zpos %7.2f fIdRotm %i\n", nr, xpos, ypos, zpos, fIdRotm);
619 AliDebug(3,Form("%3.3i(%2.2i,%2.2i) ", nr,iy+1,iz+1));
620 }
621 //PH printf("\n");
622 } else { //WSUC
623 if(iz==0) AliMatrix(fIdRotm, 0.,0., 90.,0., 90.,90.); // (x')z; y'(x); z'(y)
624 else AliMatrix(fIdRotm, 90-angle,270., 90.0,0.0, angle,90.);
625 phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
626 printf(" %2i | angle -phiOK | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
627 iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule());
628 zpos = mod->GetPosZ() - fSmodPar2;
629 ypos = mod->GetPosXfromR() - fSmodPar1;
630 printf(" zpos %7.2f ypos %7.2f fIdRotm %i\n xpos ", zpos, xpos, fIdRotm);
631 for(int ix=0; ix<g->GetNPhi(); ix++) { // flat in phi
632 xpos = g->GetPhiModuleSize()*(2*ix+1 - g->GetNPhi())/2.;
633 gMC->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
634 printf(" %7.2f ", xpos);
1963b290 635 }
d297ef6e 636 printf("\n");
1963b290 637 }
638 }
1d46d1f6 639 AliDebug(2,Form(" Number of modules in Super Module(%s) %i \n", mother, nr));
1963b290 640}
641
4d2e7dc7 642//______________________________________________________________________
643void AliEMCALv0::Trd1Tower3X3(const double *parSCM0)
cde6a23d 644{
4d2e7dc7 645 // Started Dec 8,2004 by PAI
646 // Fixed Nov 13,2006
647 printf(" AliEMCALv0::Trd1Tower3X3() : parSCM0");
648 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
649 printf("\n");
650 // Nov 10, 2006 - different name of SCMX
651 double parTRAP[11], *dummy=0;
652 AliEMCALGeometry * g = GetGeometry();
653 TString gn(g->GetName()), scmx;
654 gn.ToUpper();
655 // Division to tile size
656 AliDebug(2,Form("Trd1Tower3X3() : Divide SCM0 on y-axis %i", g->GetNETAdiv()));
657 gMC->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
658 double dx1=parSCM0[0], dx2=parSCM0[1], dy=parSCM0[2], dz=parSCM0[3];
659 double ndiv=3., xpos=0.0;
660 // should be defined once
661 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
662 for(int ix=1; ix<=3; ix++) { // 3X3
663 scmx = "SCX"; // Nov 10,2006
664 // ix=1
665 parTRAP[0] = dz;
666 double xCentBot = 2.*dx1/3.;
667 double xCentTop = 2.*(dx2/4. + dx1/12.);
668 parTRAP[1] = TMath::ATan2((xCentTop-xCentBot),2.*dz)*TMath::RadToDeg(); // theta
669 parTRAP[2] = 0.; // phi
670 // bottom
671 parTRAP[3] = dy/ndiv; // H1
672 parTRAP[4] = dx1/ndiv; // BL1
673 parTRAP[5] = parTRAP[4]; // TL1
674 parTRAP[6] = 0.0; // ALP1
675 // top
676 parTRAP[7] = dy/ndiv; // H2
677 parTRAP[8] = dx2/2 - dx1/6.;// BL2
678 parTRAP[9] = parTRAP[8]; // TL2
679 parTRAP[10]= 0.0; // ALP2
680 xpos = (xCentBot+xCentTop)/2.;
681
682 if (ix==3) {
683 parTRAP[1] = -parTRAP[1];
684 xpos = -xpos;
685 } else if(ix==2) { // central part is box but we treat as trapesoid due to numbering
686 parTRAP[1] = 0.;
687 parTRAP[8] = dx1/ndiv; // BL2
688 parTRAP[9] = parTRAP[8]; // TL2
689 xpos = 0.0;
690 }
691 AliDebug(2,Form(" ** TRAP ** xpos %9.3f\n", xpos));
692 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
693
694 scmx += ix;
695 gMC->Gsvolu(scmx.Data(), "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
696 gMC->Gspos(scmx.Data(), 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
697
698 PbInTrap(parTRAP, scmx);
699 }
700 AliDebug(2,Form("Trd1Tower3X3()", "Ver. 1.0 : was tested."));
1963b290 701}
702
703// 8-dec-04 by PAI
4d2e7dc7 704//______________________________________________________________________
1963b290 705void AliEMCALv0::PbInTrap(const double parTRAP[11], TString n)
cde6a23d 706{
707 // see for example CreateShishKebabGeometry(); just for case TRD1
1963b290 708 static int nr=0;
e5a93224 709 AliDebug(2,Form(" Pb tiles : nrstart %i\n", nr));
1963b290 710 AliEMCALGeometry * g = GetGeometry();
711
712 double par[3];
cde6a23d 713 // double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
1963b290 714 double xpos = 0.0, ypos = 0.0;
cde6a23d 715 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
1963b290 716
717 double coef = (parTRAP[8] - parTRAP[4]) / (2.*parTRAP[0]);
718 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.; // ??
719 // double tan = TMath::Tan(parTRAP[1]*TMath::DegToRad());
720
721 par[1] = parTRAP[3]; // y
722 par[2] = g->GetECPbRadThick()/2.; // z
723 for(int iz=0; iz<g->GetNECLayers(); iz++){
cde6a23d 724 par[0] = parTRAP[4] + coef*fSampleWidth*iz;
1963b290 725 xpos = par[0] - xCenterSCMX;
726 if(parTRAP[1] < 0.) xpos = -xpos;
727 gMC->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
e5a93224 728 AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
cde6a23d 729 zpos += fSampleWidth;
1963b290 730 if(iz%2>0) printf("\n");
731 }
e5a93224 732 AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
733 AliDebug(2,Form(" par[1] %9.3f par[2] %9.3f ypos %9.3f \n", par[1], par[2], ypos));
734 AliDebug(2,Form(" PbInTrap Ver. 1.0 : was tested."));
1963b290 735}
736
737// 8-dec-04 by PAI
4d2e7dc7 738//______________________________________________________________________
1963b290 739void AliEMCALv0::Trd1Tower4X4()
cde6a23d 740{
741 // Not ready yet
1963b290 742}
d25f2c54 743
4d2e7dc7 744//______________________________________________________________________
745void AliEMCALv0::Trd1Tower1X1(double *parSCM0)
d25f2c54 746{
4d2e7dc7 747 // Started Nov 22,2006 by PAI
748 AliDebug(1," AliEMCALv0::Trd1Tower1X1() : parSCM0");
749 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
750 printf("\n");
751
752 // No division - keeping the same volume logic
753 // and as consequence the same abs is scheme
754 AliDebug(2,"Trd1Tower1X1() : Create SCMX(SCMY) as SCM0");
755
756 gMC->Gsvolu("SCMY", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
757 gMC->Gspos("SCMY", 1, "SCM0", 0.0, 0.0, 0.0, 0, "ONLY");
758 gMC->Gsvolu("SCMX", "TRD1", fIdTmedArr[kIdSC], parSCM0, 4);
759 gMC->Gspos("SCMX", 1, "SCMY", 0.0, 0.0, 0.0, 0, "ONLY");
760
761 // should be defined once
762 double *dummy=0;
763 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
764
765 PbInTrd1(parSCM0, "SCMX");
766
767 AliDebug(1,"Trd1Tower1X1() : Ver. 0.1 : was tested.");
768}
769
770//______________________________________________________________________
771void AliEMCALv0::PbInTrd1(double *parTrd1, TString n)
772{
773 // see PbInTrap(const double parTrd1[11], TString n)
774 static int nr=0, ndeb=2;
775 AliDebug(ndeb,Form(" Pb tiles : nrstart %i\n", nr));
776 AliEMCALGeometry * g = GetGeometry();
777
778 double par[3];
779 // double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
780 double xpos = 0.0, ypos = 0.0;
781 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
782 double coef = (parTrd1[1] - parTrd1[0]) / (2.*parTrd1[3]);
783
784 par[1] = parTrd1[2]; // y
785 par[2] = g->GetECPbRadThick()/2.; // z
786
787 for(int iz=0; iz<g->GetNECLayers(); iz++){
788 par[0] = parTrd1[0] + coef*fSampleWidth*iz;
789 gMC->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
790 AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
791 zpos += fSampleWidth;
792 if(iz%2>0) printf("\n");
793 }
794 AliDebug(ndeb,Form(" Number of Pb tiles in SCMX %i coef %9.7f ", nr, coef));
795 AliDebug(ndeb,Form(" PbInTrd1 Ver. 0.1 : was tested."));
d25f2c54 796}
797
1963b290 798// 3-feb-05
4d2e7dc7 799//______________________________________________________________________
800void AliEMCALv0::Scm0InTrd2(const AliEMCALGeometry * g, const Double_t emodPar[5], Double_t parSCM0[5])
1963b290 801{
4d2e7dc7 802 // Passive material inside the detector
803 double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize(); //Need check
804 AliDebug(2,Form(" wall thickness %7.5f \n", wallThickness));
805 for(int i=0; i<4; i++) { // on pictures sometimes I can not see 0 -> be carefull!!
806 parSCM0[i] = emodPar[i] - wallThickness;
807 AliDebug(2,Form(" %i parSCMO %7.3f emodPar %7.3f : dif %7.3f \n",
808 i, parSCM0[i],emodPar[i], parSCM0[i]-emodPar[i]));
809 }
810 parSCM0[4] = emodPar[4];
811 gMC->Gsvolu("SCM0", "TRD2", fIdTmedArr[kIdSC], parSCM0, 5); // kIdAIR -> kIdSC
812 gMC->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
813 // Division
814 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
815 Division2X2InScm0(g, parSCM0);
816 } else {
817 Info("Scm0InTrd2"," no division SCM0 in this geometry |%s|\n", g->GetName());
818 assert(0);
819 }
1963b290 820}
821
4d2e7dc7 822//______________________________________________________________________
1963b290 823void AliEMCALv0::Division2X2InScm0(const AliEMCALGeometry * g, const Double_t parSCM0[5])
824{
cde6a23d 825 // Division 2X2
1963b290 826 Double_t parTRAP[11], xpos=0.,ypos=0., dx1=0.0,dx2=0.,dy1=0.0,dy2=0.,dz=0.
827 ,dr1=0.0,dr2=0.;
cde6a23d 828 fIdRotm=0;
1963b290 829
830 Info("Division2X2InScm0","Divide SCM0 on y-axis %i\n", g->GetNETAdiv());
831 TString n("SCMX"), overLapFlagSCMY("ONLY"), overLapFlagSCMX("ONLY");
832 n = "SCM0"; // for testing - 14-mar-05
833 if(n=="SCM0"){
834 PbInTrapForTrd2(parSCM0, n);
835 // overLapFlagSCMY=overLapFlagSCMX="MANY"; // do not work
836 return;
837 }
838
839 dy1 = parSCM0[2] , dy2 = parSCM0[3], dz = parSCM0[4];
840
841 parTRAP[0] = parSCM0[4]; // dz
842 parTRAP[1] = TMath::ATan2((dy2-dy1)/2.,2.*dz)*TMath::RadToDeg();
843 parTRAP[2] = 90.; // phi
844 // bottom
845 parTRAP[3] = parSCM0[2]/2.; // H1
846 parTRAP[4] = parSCM0[0]; // BL1
847 parTRAP[5] = parTRAP[4]; // TL1
848 parTRAP[6] = 0.0; // ALP1
849 // top
850 parTRAP[7] = parSCM0[3]/2.; // H2
851 parTRAP[8] = parSCM0[1]; // BL2
852 parTRAP[9] = parTRAP[8]; // TL2
853 parTRAP[10]= 0.0; // ALP2
e5a93224 854 AliDebug(2,Form(" ** SCMY ** \n"));
855 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
1963b290 856
cde6a23d 857 fIdRotm=0;
858 gMC->Gsvolu("SCMY", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11); // kIdAIR -> kIdSC
1963b290 859 ypos = +(parTRAP[3]+parTRAP[7])/2.; //
e5a93224 860 AliDebug(2,Form(" Y shift SCMY inside SCM0 : %7.3f : opt %s\n", ypos, overLapFlagSCMY.Data()));
cde6a23d 861 gMC->Gspos("SCMY", 1, "SCM0", 0.0, ypos, 0.0, fIdRotm, overLapFlagSCMY.Data()) ;
1963b290 862 // Rotation SCMY around z-axis on 180 degree; x'=-x; y'=-y and z=z
cde6a23d 863 AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
1963b290 864 // We may have problem with numeration due to rotation - 4-feb-05
cde6a23d 865 gMC->Gspos("SCMY", 2, "SCM0", 0.0, -ypos, 0.0, fIdRotm, overLapFlagSCMY.Data());
1963b290 866
867 Info("Division2X2InScm0","Divide SCMY on x-axis %i\n", g->GetNPHIdiv());
868 dx1 = parSCM0[0];
869 dx2 = parSCM0[1];
870 dr1=TMath::Sqrt(dx1*dx1+dy1*dy1);
871 dr2=TMath::Sqrt(dx2*dx2+dy2*dy2);
872
873 parTRAP[0] = parSCM0[4]; // dz
874 parTRAP[1] = TMath::ATan2((dr2-dr1)/2.,2.*dz)*TMath::RadToDeg(); //
875 parTRAP[2] = 45.; // phi
876 // bottom
877 parTRAP[3] = parSCM0[2]/2.; // H1
878 parTRAP[4] = parSCM0[0]/2.; // BL1
879 parTRAP[5] = parTRAP[4]; // TL1
880 parTRAP[6] = 0.0; // ALP1
881 // top
882 parTRAP[7] = parSCM0[3]/2.; // H2
883 parTRAP[8] = parSCM0[1]/2; // BL2
884 parTRAP[9] = parTRAP[8]; // TL2
885 parTRAP[10]= 0.0; // ALP2
e5a93224 886 AliDebug(2,Form(" ** SCMX ** \n"));
887 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
1963b290 888
cde6a23d 889 fIdRotm=0;
890 gMC->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
1963b290 891 xpos = (parTRAP[4]+parTRAP[8])/2.;
e5a93224 892 AliDebug(2,Form(" X shift SCMX inside SCMX : %7.3f : opt %s\n", xpos, overLapFlagSCMX.Data()));
cde6a23d 893 gMC->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, fIdRotm, overLapFlagSCMX.Data()) ;
894 // AliMatrix(fIdRotm, 90.0,270., 90.0, 0.0, 0.0,0.0); // x'=-y; y'=x; z'=z
895 AliMatrix(fIdRotm, 90.0,90., 90.0, -180.0, 0.0,0.0); // x'=y; y'=-x; z'=z
896 gMC->Gspos("SCMX", 2, "SCMY", -xpos, 0.0, 0.0, fIdRotm, overLapFlagSCMX.Data()) ;
1963b290 897 // PB:
898 if(n=="SCMX" && overLapFlagSCMY == "ONLY") {
899 PbInTrapForTrd2(parTRAP, n);
900 }
901}
902
903// 4-feb-05 by PAI
4d2e7dc7 904//______________________________________________________________________
905void AliEMCALv0::PbInTrapForTrd2(const double *parTRAP, TString name)
cde6a23d 906{
4d2e7dc7 907 // TRD2 cases
908 Double_t *dummy=0;
909 TString pbShape("BOX"), pbtiChonly("ONLY");
910 if(name=="SCM0") {
911 pbShape = "TRD2";
912 // pbtiChonly = "MANY";
913 }
914 gMC->Gsvolu("PBTI", pbShape.Data(), fIdTmedArr[kIdPB], dummy, 0);
915
916 int nr=0;
917 Info("PbInTrapForTrd2"," Pb tiles inside %s: shape %s :pbtiChonly %s\n nrstart %i\n",
918 name.Data(), pbShape.Data(), pbtiChonly.Data(), nr);
919 AliEMCALGeometry * g = GetGeometry();
920
921 double par[5], parPB[5], parSC[5];
922 //double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
923 double xpos = 0.0, ypos = 0.0;
924 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
925 if(name == "SCMX") { // common trapezoid - 11 parameters
926 double coef = (parTRAP[8] - parTRAP[4]) / (2.*parTRAP[0]);
927 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.; // the same for y
928 AliDebug(2,Form(" xCenterSCMX %8.5f : coef %8.7f \n", xCenterSCMX, coef));
929
930 par[2] = g->GetECPbRadThick()/2.; // z
931 for(int iz=0; iz<g->GetNECLayers(); iz++){
932 par[0] = parTRAP[4] + coef*fSampleWidth*iz;
933 par[1] = par[0];
934 xpos = ypos = par[0] - xCenterSCMX;
935 //if(parTRAP[1] < 0.) xpos = -xpos;
936 gMC->Gsposp("PBTI", ++nr, name.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
937 AliDebug(2,Form(" %2.2i xpos %8.5f zpos %6.3f par[0,1] %6.3f |", iz+1, xpos, zpos, par[0]));
938 if(iz%2>0) AliDebug(2,Form("\n"));
939 zpos += fSampleWidth;
940 }
941 AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
942 AliDebug(2,Form(" par[1] %9.5f par[2] %9.5f ypos %9.5f \n", par[1], par[2], ypos));
943 } else if(name == "SCM0") { // 1-mar-05 ; TRD2 - 5 parameters
944 AliDebug(2,Form(" SCM0 par = "));
945 for(int i=0; i<5; i++) AliDebug(2,Form(" %9.5f ", parTRAP[i]));
946 AliDebug(2,Form("\n zpos %f \n",zpos));
947
948 double tanx = (parTRAP[1] - parTRAP[0]) / (2.*parTRAP[4]); // tanx = tany now
949 double tany = (parTRAP[3] - parTRAP[2]) / (2.*parTRAP[4]), ztmp=0.;
950 parPB[4] = g->GetECPbRadThick()/2.;
951 parSC[2] = g->GetECScintThick()/2.;
952 for(int iz=0; iz<g->GetNECLayers(); iz++){
953 ztmp = fSampleWidth*double(iz);
954 parPB[0] = parTRAP[0] + tanx*ztmp;
955 parPB[1] = parPB[0] + tanx*g->GetECPbRadThick();
956 parPB[2] = parTRAP[2] + tany*ztmp;
957 parPB[3] = parPB[2] + tany*g->GetECPbRadThick();
958 gMC->Gsposp("PBTI", ++nr, name.Data(), xpos, ypos, zpos, 0, pbtiChonly.Data(), parPB, 5) ;
959 AliDebug(2,Form("\n PBTI %2i | zpos %6.3f | par = ", nr, zpos));
960 /*
961 for(int i=0; i<5; i++) printf(" %9.5f ", parPB[i]);
962 // individual SC tile
963 parSC[0] = parPB[0];
964 parSC[1] = parPB[1];
965 gMC->Gsposp("SCTI", nr, name.Data(), xpos, ypos, zpos+g->GetECScintThick(),
966 0, pbtiChonly.Data(), parSC, 3) ;
967 printf("\n SCTI zpos %6.3f | par = ", zpos+g->GetECScintThick());
968 for(int i=0; i<3; i++) printf(" %9.5f ", parPB[i]);
969 */
970 zpos += fSampleWidth;
971 }
972 AliDebug(2,Form("\n"));
973 }
974 Info("PbInTrapForTrd2", "Ver. 0.03 : was tested.");
1963b290 975}
976
977// 15-mar-05
4d2e7dc7 978//______________________________________________________________________
979void AliEMCALv0::PbmoInTrd2(const AliEMCALGeometry * g, const Double_t emodPar[5], Double_t parPBMO[5])
1963b290 980{
4d2e7dc7 981 // Pb inside Trd2
982 Info("PbmoInTrd2"," started : geometry %s ", g->GetName());
983 double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize();
984 AliDebug(2,Form(" wall thickness %7.5f \n", wallThickness));
985 for(int i=0; i<4; i++) {
986 parPBMO[i] = emodPar[i] - wallThickness;
987 AliDebug(2,Form(" %i parPBMO %7.3f emodPar %7.3f : dif %7.3f \n",
988 i, parPBMO[i],emodPar[i], parPBMO[i]-emodPar[i]));
989 }
990 parPBMO[4] = emodPar[4];
991 gMC->Gsvolu("PBMO", "TRD2", fIdTmedArr[kIdPB], parPBMO, 5);
992 gMC->Gspos("PBMO", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
993 // Division
994 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
995 Division2X2InPbmo(g, parPBMO);
996 AliDebug(2,Form(" PBMO, division 2X2 | geometry |%s|\n", g->GetName()));
997 } else {
998 AliDebug(2,Form(" no division PBMO in this geometry |%s|\n", g->GetName()));
999 assert(0);
1000 }
1963b290 1001}
1002
4d2e7dc7 1003//______________________________________________________________________
cde6a23d 1004void AliEMCALv0::Division2X2InPbmo(const AliEMCALGeometry * g, const Double_t parPBMO[5])
1963b290 1005{
cde6a23d 1006 // Division 2X2
1963b290 1007 Info("Division2X2InPbmo"," started : geometry %s ", g->GetName());
1008 //Double_t *dummy=0;
cde6a23d 1009 // gMC->Gsvolu("SCTI", "BOX", fIdTmedArr[kIdSC], dummy, 0);
1963b290 1010
1011 double parSC[3];
cde6a23d 1012 //double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
1963b290 1013 double xpos = 0.0, ypos = 0.0, zpos = 0.0, ztmp=0;;
1014 double tanx = (parPBMO[1] - parPBMO[0]) / (2.*parPBMO[4]); // tanx = tany now
1015 double tany = (parPBMO[3] - parPBMO[2]) / (2.*parPBMO[4]);
1016 char name[10], named[10], named2[10];
1017
e5a93224 1018 AliDebug(2,Form(" PBMO par = "));
1019 for(int i=0; i<5; i++) AliDebug(2,Form(" %9.5f ", parPBMO[i]));
1020 AliDebug(2,Form("\n"));
1963b290 1021
1022 parSC[2] = g->GetECScintThick()/2.;
cde6a23d 1023 zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick() + g->GetECScintThick()/2.;
e5a93224 1024 AliDebug(2,Form(" parSC[2] %9.5f \n", parSC[2]));
1963b290 1025 for(int iz=0; iz<g->GetNECLayers(); iz++){
cde6a23d 1026 ztmp = g->GetECPbRadThick() + fSampleWidth*double(iz); // Z for previous PB
1963b290 1027 parSC[0] = parPBMO[0] + tanx*ztmp;
1028 parSC[1] = parPBMO[2] + tany*ztmp;
1029
1030 sprintf(name,"SC%2.2i", iz+1);
cde6a23d 1031 gMC->Gsvolu(name, "BOX", fIdTmedArr[kIdSC], parSC, 3);
1963b290 1032 gMC->Gspos(name, 1, "PBMO", xpos, ypos, zpos, 0, "ONLY") ;
e5a93224 1033 AliDebug(2,Form("%s | zpos %6.3f | parSC[0,1]=(%7.5f,%7.5f) -> ",
1034 name, zpos, parSC[0], parSC[1]));
1963b290 1035
1036 sprintf(named,"SY%2.2i", iz+1);
1037 printf(" %s -> ", named);
1038 gMC->Gsdvn(named,name, 2, 2);
1039
1040 sprintf(named2,"SX%2.2i", iz+1);
1041 printf(" %s \n", named2);
1042 gMC->Gsdvn(named2,named, 2, 1);
1043
cde6a23d 1044 zpos += fSampleWidth;
1963b290 1045 }
1046}
c01485dd 1047
4d2e7dc7 1048//______________________________________________________________________
21cf2b24 1049AliEMCALShishKebabTrd1Module* AliEMCALv0::GetShishKebabModule(Int_t neta)
cde6a23d 1050{
1051 // 28-oct-05
c01485dd 1052 AliEMCALShishKebabTrd1Module* trd1=0;
1053 if(fShishKebabModules && neta>=0 && neta<fShishKebabModules->GetSize()) {
1054 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(neta);
1055 }
1056 return trd1;
1057}
5f66b6c6 1058
1059//_____________________________________________________________________________
1060void AliEMCALv0::AddAlignableVolumes() const
1ae500a2 1061{
1062 TString ntmp(GetTitle()); // name of EMCAL geometry
1063
1064 if(ntmp.Contains("WSUC")) {
1065 AddAlignableVolumesInWSUC(); // WSUC case
1066 } else {
1067 AddAlignableVolumesInALICE(); // ALICE case
1068 }
1069}
1070
4d2e7dc7 1071//______________________________________________________________________
1ae500a2 1072void AliEMCALv0::AddAlignableVolumesInALICE() const
5f66b6c6 1073{
1074 //
1075 // Create entries for alignable volumes associating the symbolic volume
1076 // name with the corresponding volume path. Needs to be synchronized with
1077 // eventual changes in the geometry.
1078 //
1079
9aa6a5f6 1080 Float_t * pars = GetGeometry()->GetSuperModulesPars();
1081 double rpos = (GetGeometry()->GetEnvelop(0) + GetGeometry()->GetEnvelop(1))/2.;
1082 double phi, phiRad, xpos, ypos, zpos;
1083
200e17a4 1084 AliGeomManager::ELayerID idEMCAL = AliGeomManager::kEMCAL;
1085 Int_t modUID, modnum = 0;
5f66b6c6 1086 TString volpath, symname;
1087
85653ebc 1088 Int_t nSMod = GetGeometry()->GetNumberOfSuperModules();
9aa6a5f6 1089 for (Int_t smodnum=0; smodnum < nSMod; smodnum++) {
200e17a4 1090 modUID = AliGeomManager::LayerToVolUID(idEMCAL,modnum++);
9aa6a5f6 1091 volpath = "ALIC_1/XEN1_1/SMOD_";
1082109f 1092 volpath += (smodnum+1);
9aa6a5f6 1093 symname = "EMCAL/FullSupermodule";
1094 symname += (smodnum+1);
1095
1096 if(GetGeometry()->GetKey110DEG() && smodnum>=10) {
1097 volpath = "ALIC_1/XEN1_1/SM10_";
1098 volpath += (smodnum-10+1);
1099 symname = "EMCAL/HalfSupermodule";
1100 symname += (smodnum-10+1);
1101 }
1102
200e17a4 1103 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
9aa6a5f6 1104 AliFatal("AliEMCALv0::Unable to set alignable entry!!");
1105
1106 // Creates the Tracking to Local transformation matrix for EMCAL
1107 // modules
200e17a4 1108 TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
9aa6a5f6 1109
85653ebc 1110 phiRad = GetGeometry()->GetPhiCenterOfSM(smodnum); //comes in radians, not degrees
1111 phi = phiRad*180./TMath::Pi(); //need degrees for rot. matrix
9aa6a5f6 1112 xpos = rpos * TMath::Cos(phiRad);
1113 ypos = rpos * TMath::Sin(phiRad);
1114 zpos = pars[2];
1115 if(GetGeometry()->GetKey110DEG() && smodnum >= 10) {
1116 xpos += (pars[1]/2. * TMath::Sin(phiRad));
1117 ypos -= (pars[1]/2. * TMath::Cos(phiRad));
1118 }
1119
1120 TGeoHMatrix *matTtoL;
200e17a4 1121 TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
9aa6a5f6 1122
1123 if(smodnum%2 == 0) {
1124 // pozitive z
1125 TGeoTranslation geoTran0(xpos,ypos, zpos);
1126 TGeoRotation geoRot0("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
1127 TGeoCombiTrans mat0(geoTran0, geoRot0);
1128 matTtoL = new TGeoHMatrix(mat0);
1129
1130 matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
1131 alignableEntry->SetMatrix(matTtoL);
1132
1133 } else {
1134 // negative z
1135 double phiy = 90. + phi + 180.;
1136 if(phiy>=360.) phiy -= 360.;
1137 TGeoTranslation geoTran1(xpos,ypos,-zpos);
1138 TGeoRotation geoRot1("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
1139 TGeoCombiTrans mat1(geoTran1, geoRot1);
1140 matTtoL = new TGeoHMatrix(mat1);
1141
1142 matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
1143 alignableEntry->SetMatrix(matTtoL);
5f66b6c6 1144
5f66b6c6 1145 }
9aa6a5f6 1146
5f66b6c6 1147 }
1148
1149}
1150
4d2e7dc7 1151//______________________________________________________________________
1ae500a2 1152void AliEMCALv0::AddAlignableVolumesInWSUC() const
1153{
1154 //
1155 // Create entries for alignable volumes associating the symbolic volume
1156 // name with the corresponding volume path. Needs to be synchronized with
1157 // eventual changes in the geometry.
1158 //
1159
1160 TString vpstr1 = "WSUC_1/XEN1_1/SMOD_";
1161 TString snstr1 = "EMCAL/CosmicTestSupermodule";
1162 TString volpath, symname;
1163
1164 // #SM is just one
1165 for (Int_t smodnum=0; smodnum < 1; smodnum++) {
1166 symname = snstr1;
1167 symname += (smodnum+1);
1168 volpath = vpstr1;
1169 volpath += (smodnum+1);
1170 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
1171 AliFatal("Unable to set alignable entry!!");
1172 }
1173}