]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALv0.cxx
replacing ShuttleInput names with those used in DAQ DA
[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
facb5967 127 fEnvelop1[4] = -geom->GetEnvelop(2)/2.; //zmin
d297ef6e 128 fEnvelop1[5] = geom->GetEnvelop(0) ; // rmin at z1
129 fEnvelop1[6] = geom->GetEnvelop(1) ; // rmax at z1
facb5967 130 fEnvelop1[7] = geom->GetEnvelop(2)/2.; //zmax
d297ef6e 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
facb5967 298 envelopA[4] = -geom->GetEnvelop(2)/2.; // zmin - includes padding
299 envelopA[5] = geom->GetEnvelop(0) ; // rmin at z1 - includes padding
300 envelopA[6] = geom->GetEnvelop(1) ; // rmax at z1 - includes padding
301 envelopA[7] = geom->GetEnvelop(2)/2.; // zmax includes padding
d297ef6e 302
303 envelopA[8] = envelopA[5] ; // radii are the same.
304 envelopA[9] = envelopA[6] ; // radii are the same.
305
306 gMC->Gsvolu("XEN1", "PGON", fIdTmedArr[kIdAIR], envelopA, 10) ; // Polygone filled with air
307 fEnvelop1.Set(10, envelopA);
308 if (gDebug==2) {
309 printf("CreateGeometry: XEN1 = %f, %f\n", envelopA[5], envelopA[6]);
310 printf("CreateGeometry: XU0 = %f, %f\n", envelopA[5], envelopA[6]);
1963b290 311 }
d297ef6e 312 // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)
313 gMC->Gspos(geom->GetNameOfEMCALEnvelope(), 1, "ALIC", 0.0, 0.0, 0.0, fIdRotm, "ONLY") ;
314 }
315
316 // COMPACT, TRD1
317 AliDebug(2,Form("Shish-Kebab geometry : %s", GetTitle()));
318 CreateShishKebabGeometry();
1963b290 319
2012850d 320}
a1469a24 321
b13bbe81 322//______________________________________________________________________
05a92d59 323void AliEMCALv0::Init(void)
324{
b13bbe81 325 // Just prints an information message
aa61eaea 326 AliEMCAL::Init();
4951e003 327 if(AliLog::GetGlobalDebugLevel()>0) {
9859bfc0 328 TString message("\n") ;
c27ad3fb 329 message += "*****************************************\n" ;
05a92d59 330
b13bbe81 331 // Here the EMCAL initialisation code (if any!)
9859bfc0 332
05a92d59 333 AliEMCALGeometry * geom = GetGeometry() ;
9859bfc0 334
335 if (geom!=0) {
336 message += "AliEMCAL " ;
337 message += Version() ;
c27ad3fb 338 message += "EMCAL geometry initialized for " ;
9859bfc0 339 message += geom->GetName() ;
340 }
341 else {
342 message += "AliEMCAL " ;
343 message += Version() ;
344 message += "EMCAL geometry initialization failed !" ;
05a92d59 345 }
c27ad3fb 346 message += "\n*****************************************" ;
fdebddeb 347 printf(message.Data() ) ;
9859bfc0 348 }
2012850d 349}
1963b290 350
351// 24-aug-04 by PAI
4d2e7dc7 352//______________________________________________________________________
1963b290 353void AliEMCALv0::CreateShishKebabGeometry()
cde6a23d 354{
937d0661 355 // TRD1
1963b290 356 AliEMCALGeometry * g = GetGeometry();
357 TString gn(g->GetName()); gn.ToUpper();
cde6a23d 358 // see AliModule::fFIdTmedArr
359 // fIdTmedArr = fIdtmed->GetArray() - 1599 ; // see AliEMCAL::::CreateMaterials()
360 // int kIdAIR=1599, kIdPB = 1600, kIdSC = 1601, kIdSTEEL = 1603;
1963b290 361 // idAL = 1602;
362 Double_t par[10], xpos=0., ypos=0., zpos=0.;
363
e52475ed 364 CreateSmod(g->GetNameOfEMCALEnvelope());
1963b290 365
d87bd045 366 CreateEmod("SMOD","EMOD"); // 18-may-05
367
1d46d1f6 368 if(g->GetKey110DEG()) CreateEmod("SM10","EMOD"); // Nov 1,2006
1963b290 369
370 // Sensitive SC (2x2 tiles)
1d46d1f6 371 double parSCM0[5]={0,0,0,0}, *dummy = 0, parTRAP[11];
d297ef6e 372
373 // double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize(); // Need check
374 double wallThickness = g->GetPhiModuleSize()/g->GetNPHIdiv() - g->GetPhiTileSize();
375 for(int i=0; i<3; i++) parSCM0[i] = fParEMOD[i] - wallThickness;
376 parSCM0[3] = fParEMOD[3];
377 gMC->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
378 gMC->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
379
380 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
1963b290 381 // Division to tile size - 1-oct-04
d297ef6e 382 AliDebug(2,Form(" Divide SCM0 on y-axis %i\n", g->GetNETAdiv()));
383 gMC->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
1963b290 384 // Trapesoid 2x2
d297ef6e 385 parTRAP[0] = parSCM0[3]; // dz
386 parTRAP[1] = TMath::ATan2((parSCM0[1]-parSCM0[0])/2.,2.*parSCM0[3])*180./TMath::Pi(); // theta
387 parTRAP[2] = 0.; // phi
388 // bottom
389 parTRAP[3] = parSCM0[2]/2.; // H1
390 parTRAP[4] = parSCM0[0]/2.; // BL1
391 parTRAP[5] = parTRAP[4]; // TL1
392 parTRAP[6] = 0.0; // ALP1
393 // top
394 parTRAP[7] = parSCM0[2]/2.; // H2
395 parTRAP[8] = parSCM0[1]/2.; // BL2
396 parTRAP[9] = parTRAP[8]; // TL2
397 parTRAP[10]= 0.0; // ALP2
398 AliDebug(2,Form(" ** TRAP ** \n"));
399 for(int i=0; i<11; i++) AliDebug(3, Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
400
401 gMC->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
402 xpos = +(parSCM0[1]+parSCM0[0])/4.;
403 gMC->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
404
405 // Using rotation because SCMX should be the same due to Pb tiles
406 xpos = -xpos;
407 AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
408 gMC->Gspos("SCMX", 2, "SCMY", xpos, 0.0, 0.0, fIdRotm, "ONLY");
1963b290 409 // put LED to the SCM0
d297ef6e 410 AliEMCALShishKebabTrd1Module *mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(0);
411 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
412
413 par[1] = parSCM0[2]/2; // y
414 par[2] = g->GetECPbRadThick()/2.; // z
415
416 int nr=0;
417 ypos = 0.0;
418 zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
419 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.;
420 AliDebug(2,Form(" Pb tiles \n"));
421 for(int iz=0; iz<g->GetNECLayers(); iz++){
422 par[0] = (parSCM0[0] + mod->GetTanBetta()*fSampleWidth*iz)/2.;
423 xpos = par[0] - xCenterSCMX;
424 gMC->Gsposp("PBTI", ++nr, "SCMX", xpos, ypos, zpos, 0, "ONLY", par, 3) ;
425 AliDebug(3,Form(" %i xpos %f zpos %f par[0] %f \n", iz+1, xpos, zpos, par[0]));
426 zpos += fSampleWidth;
427 }
428 AliDebug(2,Form(" Number of Pb tiles in SCMX %i \n", nr));
429
430 } else if(g->GetNPHIdiv()==3 && g->GetNETAdiv()==3) {
431 printf(" before AliEMCALv0::Trd1Tower3X3() : parSCM0");
432 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
433 printf("\n");
434 Trd1Tower3X3(parSCM0);
435 } else if(g->GetNPHIdiv()==1 && g->GetNETAdiv()==1) {
436 // no division in SCM0
437 Trd1Tower1X1(parSCM0);
438 } else if(g->GetNPHIdiv()==4 && g->GetNETAdiv()==4) {
439 Trd1Tower4X4();
1963b290 440 }
d297ef6e 441
1963b290 442}
443
4d2e7dc7 444//______________________________________________________________________
1963b290 445void AliEMCALv0::CreateSmod(const char* mother)
cde6a23d 446{
447 // 18-may-05; mother="XEN1";
d87bd045 448 // child="SMOD" from first to 10th, "SM10" (11th and 12th) (TRD1 case)
1963b290 449 AliEMCALGeometry * g = GetGeometry();
450 TString gn(g->GetName()); gn.ToUpper();
451
6f377f0c 452 Double_t par[3], xpos=0., ypos=0., zpos=0., rpos=0., dphi=0., phi=0.0, phiRad=0.;
d87bd045 453 Double_t par1C = 0.;
1963b290 454 // ===== define Super Module from air - 14x30 module ==== ;
cde6a23d 455 fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
e5a93224 456 AliDebug(2,Form("\n ## Super Module | fSampleWidth %5.3f ## %s \n", fSampleWidth, gn.Data()));
1963b290 457 par[0] = g->GetShellThickness()/2.;
458 par[1] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
459 par[2] = g->GetEtaModuleSize()*15.;
cde6a23d 460 fIdRotm=0;
1963b290 461 int nphism = g->GetNumberOfSuperModules()/2; // 20-may-05
462 if(nphism>0) {
463 dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/nphism;
1d46d1f6 464 // if(g->GetKey110DEG()) dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/(nphism-1);
1963b290 465 rpos = (g->GetEnvelop(0) + g->GetEnvelop(1))/2.;
e5a93224 466 AliDebug(2,Form(" rpos %8.2f : dphi %6.1f degree \n", rpos, dphi));
1963b290 467 }
468
6f377f0c 469 if(gn.Contains("WSUC")) {
1963b290 470 par[0] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
471 par[1] = g->GetShellThickness()/2.;
472 par[2] = g->GetEtaModuleSize()*g->GetNZ()/2. + 5;
473
cde6a23d 474 gMC->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
1963b290 475
e5a93224 476 AliDebug(2,Form("SMOD in WSUC : tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
477 fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
cde6a23d 478 fSmodPar0 = par[0];
479 fSmodPar1 = par[1];
480 fSmodPar2 = par[2];
1963b290 481 nphism = g->GetNumberOfSuperModules();
482 } else {
d297ef6e 483 par[2] = 350./2.; // 11-oct-04 - for 26 division
484 AliDebug(2,Form(" par[0] %7.2f (old) \n", par[0]));
485 Float_t *parSM = g->GetSuperModulesPars();
486 for(int i=0; i<3; i++) par[i] = parSM[i];
487 }
488 gMC->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
489 AliDebug(2,Form("tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
490 fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
491 fSmodPar0 = par[0];
492 fSmodPar2 = par[2];
493 if(g->GetKey110DEG()) { // 12-oct-05
494 par1C = par[1];
495 par[1] /= 2.;
496 gMC->Gsvolu("SM10", "BOX", fIdTmedArr[kIdAIR], par, 3);
497 AliDebug(2,Form(" Super module with name \"SM10\" was created too par[1] = %f\n", par[1]));
498 par[1] = par1C;
499 }
1963b290 500 // Steel plate
d297ef6e 501 if(g->GetSteelFrontThickness() > 0.0) { // 28-mar-05
502 par[0] = g->GetSteelFrontThickness()/2.;
503 gMC->Gsvolu("STPL", "BOX", fIdTmedArr[kIdSTEEL], par, 3);
504 printf("tmed %i | dx %7.2f dy %7.2f dz %7.2f (STPL) \n", fIdTmedArr[kIdSTEEL], par[0],par[1],par[2]);
505 xpos = -(g->GetShellThickness() - g->GetSteelFrontThickness())/2.;
506 gMC->Gspos("STPL", 1, "SMOD", xpos, 0.0, 0.0, 0, "ONLY") ;
1963b290 507 }
508
d87bd045 509 int nr=0, nrsmod=0, i0=0;
1963b290 510
511 // Turn whole super module
1963b290 512 for(int i=i0; i<nphism; i++) {
6f377f0c 513 if(gn.Contains("WSUC")) {
d87bd045 514 xpos = ypos = zpos = 0.0;
cde6a23d 515 fIdRotm = 0;
516 gMC->Gspos("SMOD", 1, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
517 printf(" fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n",
518 fIdRotm, phi, phiRad, xpos, ypos, zpos);
d87bd045 519 nr++;
c63c3c5d 520 } else { // TRD1
d87bd045 521 TString smName("SMOD"); // 12-oct-05
1d46d1f6 522 if(i==5 && g->GetKey110DEG()) {
d87bd045 523 smName = "SM10";
524 nrsmod = nr;
525 nr = 0;
526 }
1963b290 527 phi = g->GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 70, 90, 110, 130, 150, 170
528 phiRad = phi*TMath::Pi()/180.;
529
cde6a23d 530 AliMatrix(fIdRotm, 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
1963b290 531
532 xpos = rpos * TMath::Cos(phiRad);
533 ypos = rpos * TMath::Sin(phiRad);
cde6a23d 534 zpos = fSmodPar2; // 21-sep-04
1d46d1f6 535 if(i==5 && g->GetKey110DEG()) {
d87bd045 536 xpos += (par1C/2. * TMath::Sin(phiRad));
537 ypos -= (par1C/2. * TMath::Cos(phiRad));
538 }
539
1963b290 540 // 1th module in z-direction;
cde6a23d 541 gMC->Gspos(smName.Data(), ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
542 AliDebug(3, Form(" %s : %2i fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : i %i \n",
543 smName.Data(), nr, fIdRotm, phi, phiRad, xpos, ypos, zpos, i));
1963b290 544 // 2th module in z-direction;
1963b290 545 // turn arround X axis; 0<phi<360
d297ef6e 546 double phiy = 90. + phi + 180.;
547 if(phiy>=360.) phiy -= 360.;
548
549 AliMatrix(fIdRotm, 90.0, phi, 90.0, phiy, 180.0, 0.0);
550 gMC->Gspos(smName.Data(), ++nr, mother, xpos, ypos, -zpos, fIdRotm, "ONLY");
551 AliDebug(3, Form(" %s : %2i fIdRotm %3i phiy %6.1f xpos %7.2f ypos %7.2f zpos %7.2f \n",
552 smName.Data(), nr, fIdRotm, phiy, xpos, ypos, -zpos));
1963b290 553 }
554 }
e5a93224 555 AliDebug(2,Form(" Number of Super Modules %i \n", nr+nrsmod));
1963b290 556}
557
4d2e7dc7 558//______________________________________________________________________
1963b290 559void AliEMCALv0::CreateEmod(const char* mother, const char* child)
cde6a23d 560{
561 // 17-may-05; mother="SMOD"; child="EMOD"
1963b290 562 AliEMCALGeometry * g = GetGeometry();
563 TString gn(g->GetName()); gn.ToUpper();
564 // Module definition
d297ef6e 565 Double_t xpos=0., ypos=0., zpos=0.;
1963b290 566 Double_t parSCPA[5], zposSCPA=0.; // passive SC - 13-MAY-05, TRD1 case
567 Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
1963b290 568 int nr=0;
cde6a23d 569 fIdRotm=0;
d297ef6e 570 if(strcmp(mother,"SMOD")==0) {
571 fParEMOD[0] = g->GetEtaModuleSize()/2.; // dx1
572 fParEMOD[1] = g->Get2Trd1Dx2()/2.; // dx2
573 fParEMOD[2] = g->GetPhiModuleSize()/2.;; // dy
574 fParEMOD[3] = g->GetLongModuleSize()/2.; // dz
575 gMC->Gsvolu(child, "TRD1", fIdTmedArr[kIdSTEEL], fParEMOD, 4);
576 // if(gn.Contains("WSUC") || gn.Contains("MAY05")){
577 if(0){ // Jul 12 - should be checked
578 parSCPA[0] = g->GetEtaModuleSize()/2. + tanTrd1*g->GetFrontSteelStrip(); // dx1
579 parSCPA[1] = parSCPA[0] + tanTrd1*g->GetPassiveScintThick(); // dx2
580 parSCPA[2] = g->GetPhiModuleSize()/2.; // dy
581 parSCPA[3] = g->GetPassiveScintThick()/2.; // dz
582 gMC->Gsvolu("SCPA", "TRD1", fIdTmedArr[kIdSC], parSCPA, 4);
583 zposSCPA = -fParEMOD[3] + g->GetFrontSteelStrip() + g->GetPassiveScintThick()/2.;
584 gMC->Gspos ("SCPA", ++nr, child, 0.0, 0.0, zposSCPA, 0, "ONLY");
1963b290 585 }
1963b290 586 }
d297ef6e 587
1963b290 588 nr = 0;
d297ef6e 589 // X->Z(0, 0); Y->Y(90, 90); Z->X(90, 0)
590 AliEMCALShishKebabTrd1Module *mod=0; // current module
591
592 for(int iz=0; iz<g->GetNZ(); iz++) {
593 Double_t angle=90., phiOK=0;
594 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(iz);
595 angle = mod->GetThetaInDegree();
596 if(!gn.Contains("WSUC")) { // ALICE
597 if(iz==0) AliMatrix(fIdRotm, 0.,0., 90.,90., 90.,0.); // z'(x); y'(y); x'(z)
598 else AliMatrix(fIdRotm, 90.-angle,180., 90.0,90.0, angle, 0.);
599 phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
600 // printf(" %2i | angle | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
601 //iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule());
602 xpos = mod->GetPosXfromR() + g->GetSteelFrontThickness() - fSmodPar0;
603 zpos = mod->GetPosZ() - fSmodPar2;
604
605 int iyMax = g->GetNPhi();
606 if(strcmp(mother,"SMOD") && g->GetKey110DEG()) {
607 iyMax /= 2;
1963b290 608 }
d297ef6e 609 for(int iy=0; iy<iyMax; iy++) { // flat in phi
610 ypos = g->GetPhiModuleSize()*(2*iy+1 - iyMax)/2.;
611 gMC->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
612 //printf(" %2i xpos %7.2f ypos %7.2f zpos %7.2f fIdRotm %i\n", nr, xpos, ypos, zpos, fIdRotm);
613 AliDebug(3,Form("%3.3i(%2.2i,%2.2i) ", nr,iy+1,iz+1));
614 }
615 //PH printf("\n");
616 } else { //WSUC
617 if(iz==0) AliMatrix(fIdRotm, 0.,0., 90.,0., 90.,90.); // (x')z; y'(x); z'(y)
618 else AliMatrix(fIdRotm, 90-angle,270., 90.0,0.0, angle,90.);
619 phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
620 printf(" %2i | angle -phiOK | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
621 iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule());
622 zpos = mod->GetPosZ() - fSmodPar2;
623 ypos = mod->GetPosXfromR() - fSmodPar1;
624 printf(" zpos %7.2f ypos %7.2f fIdRotm %i\n xpos ", zpos, xpos, fIdRotm);
625 for(int ix=0; ix<g->GetNPhi(); ix++) { // flat in phi
626 xpos = g->GetPhiModuleSize()*(2*ix+1 - g->GetNPhi())/2.;
627 gMC->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
628 printf(" %7.2f ", xpos);
1963b290 629 }
d297ef6e 630 printf("\n");
1963b290 631 }
632 }
1d46d1f6 633 AliDebug(2,Form(" Number of modules in Super Module(%s) %i \n", mother, nr));
1963b290 634}
635
4d2e7dc7 636//______________________________________________________________________
637void AliEMCALv0::Trd1Tower3X3(const double *parSCM0)
cde6a23d 638{
4d2e7dc7 639 // Started Dec 8,2004 by PAI
640 // Fixed Nov 13,2006
641 printf(" AliEMCALv0::Trd1Tower3X3() : parSCM0");
642 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
643 printf("\n");
644 // Nov 10, 2006 - different name of SCMX
645 double parTRAP[11], *dummy=0;
646 AliEMCALGeometry * g = GetGeometry();
647 TString gn(g->GetName()), scmx;
648 gn.ToUpper();
649 // Division to tile size
650 AliDebug(2,Form("Trd1Tower3X3() : Divide SCM0 on y-axis %i", g->GetNETAdiv()));
651 gMC->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
652 double dx1=parSCM0[0], dx2=parSCM0[1], dy=parSCM0[2], dz=parSCM0[3];
653 double ndiv=3., xpos=0.0;
654 // should be defined once
655 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
656 for(int ix=1; ix<=3; ix++) { // 3X3
657 scmx = "SCX"; // Nov 10,2006
658 // ix=1
659 parTRAP[0] = dz;
660 double xCentBot = 2.*dx1/3.;
661 double xCentTop = 2.*(dx2/4. + dx1/12.);
662 parTRAP[1] = TMath::ATan2((xCentTop-xCentBot),2.*dz)*TMath::RadToDeg(); // theta
663 parTRAP[2] = 0.; // phi
664 // bottom
665 parTRAP[3] = dy/ndiv; // H1
666 parTRAP[4] = dx1/ndiv; // BL1
667 parTRAP[5] = parTRAP[4]; // TL1
668 parTRAP[6] = 0.0; // ALP1
669 // top
670 parTRAP[7] = dy/ndiv; // H2
671 parTRAP[8] = dx2/2 - dx1/6.;// BL2
672 parTRAP[9] = parTRAP[8]; // TL2
673 parTRAP[10]= 0.0; // ALP2
674 xpos = (xCentBot+xCentTop)/2.;
675
676 if (ix==3) {
677 parTRAP[1] = -parTRAP[1];
678 xpos = -xpos;
679 } else if(ix==2) { // central part is box but we treat as trapesoid due to numbering
680 parTRAP[1] = 0.;
681 parTRAP[8] = dx1/ndiv; // BL2
682 parTRAP[9] = parTRAP[8]; // TL2
683 xpos = 0.0;
684 }
685 AliDebug(2,Form(" ** TRAP ** xpos %9.3f\n", xpos));
686 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
687
688 scmx += ix;
689 gMC->Gsvolu(scmx.Data(), "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
690 gMC->Gspos(scmx.Data(), 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
691
692 PbInTrap(parTRAP, scmx);
693 }
694 AliDebug(2,Form("Trd1Tower3X3()", "Ver. 1.0 : was tested."));
1963b290 695}
696
697// 8-dec-04 by PAI
4d2e7dc7 698//______________________________________________________________________
1963b290 699void AliEMCALv0::PbInTrap(const double parTRAP[11], TString n)
cde6a23d 700{
701 // see for example CreateShishKebabGeometry(); just for case TRD1
1963b290 702 static int nr=0;
e5a93224 703 AliDebug(2,Form(" Pb tiles : nrstart %i\n", nr));
1963b290 704 AliEMCALGeometry * g = GetGeometry();
705
706 double par[3];
cde6a23d 707 // double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
1963b290 708 double xpos = 0.0, ypos = 0.0;
cde6a23d 709 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
1963b290 710
711 double coef = (parTRAP[8] - parTRAP[4]) / (2.*parTRAP[0]);
712 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.; // ??
713 // double tan = TMath::Tan(parTRAP[1]*TMath::DegToRad());
714
715 par[1] = parTRAP[3]; // y
716 par[2] = g->GetECPbRadThick()/2.; // z
717 for(int iz=0; iz<g->GetNECLayers(); iz++){
cde6a23d 718 par[0] = parTRAP[4] + coef*fSampleWidth*iz;
1963b290 719 xpos = par[0] - xCenterSCMX;
720 if(parTRAP[1] < 0.) xpos = -xpos;
721 gMC->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
e5a93224 722 AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
cde6a23d 723 zpos += fSampleWidth;
1963b290 724 if(iz%2>0) printf("\n");
725 }
e5a93224 726 AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
727 AliDebug(2,Form(" par[1] %9.3f par[2] %9.3f ypos %9.3f \n", par[1], par[2], ypos));
728 AliDebug(2,Form(" PbInTrap Ver. 1.0 : was tested."));
1963b290 729}
730
731// 8-dec-04 by PAI
4d2e7dc7 732//______________________________________________________________________
1963b290 733void AliEMCALv0::Trd1Tower4X4()
cde6a23d 734{
735 // Not ready yet
1963b290 736}
d25f2c54 737
4d2e7dc7 738//______________________________________________________________________
739void AliEMCALv0::Trd1Tower1X1(double *parSCM0)
d25f2c54 740{
4d2e7dc7 741 // Started Nov 22,2006 by PAI
742 AliDebug(1," AliEMCALv0::Trd1Tower1X1() : parSCM0");
743 for(int i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
744 printf("\n");
745
746 // No division - keeping the same volume logic
747 // and as consequence the same abs is scheme
748 AliDebug(2,"Trd1Tower1X1() : Create SCMX(SCMY) as SCM0");
749
750 gMC->Gsvolu("SCMY", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
751 gMC->Gspos("SCMY", 1, "SCM0", 0.0, 0.0, 0.0, 0, "ONLY");
752 gMC->Gsvolu("SCMX", "TRD1", fIdTmedArr[kIdSC], parSCM0, 4);
753 gMC->Gspos("SCMX", 1, "SCMY", 0.0, 0.0, 0.0, 0, "ONLY");
754
755 // should be defined once
756 double *dummy=0;
757 gMC->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
758
759 PbInTrd1(parSCM0, "SCMX");
760
761 AliDebug(1,"Trd1Tower1X1() : Ver. 0.1 : was tested.");
762}
763
764//______________________________________________________________________
765void AliEMCALv0::PbInTrd1(double *parTrd1, TString n)
766{
767 // see PbInTrap(const double parTrd1[11], TString n)
768 static int nr=0, ndeb=2;
769 AliDebug(ndeb,Form(" Pb tiles : nrstart %i\n", nr));
770 AliEMCALGeometry * g = GetGeometry();
771
772 double par[3];
773 // double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
774 double xpos = 0.0, ypos = 0.0;
775 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
776 double coef = (parTrd1[1] - parTrd1[0]) / (2.*parTrd1[3]);
777
778 par[1] = parTrd1[2]; // y
779 par[2] = g->GetECPbRadThick()/2.; // z
780
781 for(int iz=0; iz<g->GetNECLayers(); iz++){
782 par[0] = parTrd1[0] + coef*fSampleWidth*iz;
783 gMC->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
784 AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
785 zpos += fSampleWidth;
786 if(iz%2>0) printf("\n");
787 }
788 AliDebug(ndeb,Form(" Number of Pb tiles in SCMX %i coef %9.7f ", nr, coef));
789 AliDebug(ndeb,Form(" PbInTrd1 Ver. 0.1 : was tested."));
d25f2c54 790}
791
1963b290 792// 3-feb-05
4d2e7dc7 793//______________________________________________________________________
794void AliEMCALv0::Scm0InTrd2(const AliEMCALGeometry * g, const Double_t emodPar[5], Double_t parSCM0[5])
1963b290 795{
4d2e7dc7 796 // Passive material inside the detector
797 double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize(); //Need check
798 AliDebug(2,Form(" wall thickness %7.5f \n", wallThickness));
799 for(int i=0; i<4; i++) { // on pictures sometimes I can not see 0 -> be carefull!!
800 parSCM0[i] = emodPar[i] - wallThickness;
801 AliDebug(2,Form(" %i parSCMO %7.3f emodPar %7.3f : dif %7.3f \n",
802 i, parSCM0[i],emodPar[i], parSCM0[i]-emodPar[i]));
803 }
804 parSCM0[4] = emodPar[4];
805 gMC->Gsvolu("SCM0", "TRD2", fIdTmedArr[kIdSC], parSCM0, 5); // kIdAIR -> kIdSC
806 gMC->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
807 // Division
808 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
809 Division2X2InScm0(g, parSCM0);
810 } else {
811 Info("Scm0InTrd2"," no division SCM0 in this geometry |%s|\n", g->GetName());
812 assert(0);
813 }
1963b290 814}
815
4d2e7dc7 816//______________________________________________________________________
1963b290 817void AliEMCALv0::Division2X2InScm0(const AliEMCALGeometry * g, const Double_t parSCM0[5])
818{
cde6a23d 819 // Division 2X2
1963b290 820 Double_t parTRAP[11], xpos=0.,ypos=0., dx1=0.0,dx2=0.,dy1=0.0,dy2=0.,dz=0.
821 ,dr1=0.0,dr2=0.;
cde6a23d 822 fIdRotm=0;
1963b290 823
824 Info("Division2X2InScm0","Divide SCM0 on y-axis %i\n", g->GetNETAdiv());
825 TString n("SCMX"), overLapFlagSCMY("ONLY"), overLapFlagSCMX("ONLY");
826 n = "SCM0"; // for testing - 14-mar-05
827 if(n=="SCM0"){
828 PbInTrapForTrd2(parSCM0, n);
829 // overLapFlagSCMY=overLapFlagSCMX="MANY"; // do not work
830 return;
831 }
832
833 dy1 = parSCM0[2] , dy2 = parSCM0[3], dz = parSCM0[4];
834
835 parTRAP[0] = parSCM0[4]; // dz
836 parTRAP[1] = TMath::ATan2((dy2-dy1)/2.,2.*dz)*TMath::RadToDeg();
837 parTRAP[2] = 90.; // phi
838 // bottom
839 parTRAP[3] = parSCM0[2]/2.; // H1
840 parTRAP[4] = parSCM0[0]; // BL1
841 parTRAP[5] = parTRAP[4]; // TL1
842 parTRAP[6] = 0.0; // ALP1
843 // top
844 parTRAP[7] = parSCM0[3]/2.; // H2
845 parTRAP[8] = parSCM0[1]; // BL2
846 parTRAP[9] = parTRAP[8]; // TL2
847 parTRAP[10]= 0.0; // ALP2
e5a93224 848 AliDebug(2,Form(" ** SCMY ** \n"));
849 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
1963b290 850
cde6a23d 851 fIdRotm=0;
852 gMC->Gsvolu("SCMY", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11); // kIdAIR -> kIdSC
1963b290 853 ypos = +(parTRAP[3]+parTRAP[7])/2.; //
e5a93224 854 AliDebug(2,Form(" Y shift SCMY inside SCM0 : %7.3f : opt %s\n", ypos, overLapFlagSCMY.Data()));
cde6a23d 855 gMC->Gspos("SCMY", 1, "SCM0", 0.0, ypos, 0.0, fIdRotm, overLapFlagSCMY.Data()) ;
1963b290 856 // Rotation SCMY around z-axis on 180 degree; x'=-x; y'=-y and z=z
cde6a23d 857 AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
1963b290 858 // We may have problem with numeration due to rotation - 4-feb-05
cde6a23d 859 gMC->Gspos("SCMY", 2, "SCM0", 0.0, -ypos, 0.0, fIdRotm, overLapFlagSCMY.Data());
1963b290 860
861 Info("Division2X2InScm0","Divide SCMY on x-axis %i\n", g->GetNPHIdiv());
862 dx1 = parSCM0[0];
863 dx2 = parSCM0[1];
864 dr1=TMath::Sqrt(dx1*dx1+dy1*dy1);
865 dr2=TMath::Sqrt(dx2*dx2+dy2*dy2);
866
867 parTRAP[0] = parSCM0[4]; // dz
868 parTRAP[1] = TMath::ATan2((dr2-dr1)/2.,2.*dz)*TMath::RadToDeg(); //
869 parTRAP[2] = 45.; // phi
870 // bottom
871 parTRAP[3] = parSCM0[2]/2.; // H1
872 parTRAP[4] = parSCM0[0]/2.; // BL1
873 parTRAP[5] = parTRAP[4]; // TL1
874 parTRAP[6] = 0.0; // ALP1
875 // top
876 parTRAP[7] = parSCM0[3]/2.; // H2
877 parTRAP[8] = parSCM0[1]/2; // BL2
878 parTRAP[9] = parTRAP[8]; // TL2
879 parTRAP[10]= 0.0; // ALP2
e5a93224 880 AliDebug(2,Form(" ** SCMX ** \n"));
881 for(int i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
1963b290 882
cde6a23d 883 fIdRotm=0;
884 gMC->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
1963b290 885 xpos = (parTRAP[4]+parTRAP[8])/2.;
e5a93224 886 AliDebug(2,Form(" X shift SCMX inside SCMX : %7.3f : opt %s\n", xpos, overLapFlagSCMX.Data()));
cde6a23d 887 gMC->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, fIdRotm, overLapFlagSCMX.Data()) ;
888 // AliMatrix(fIdRotm, 90.0,270., 90.0, 0.0, 0.0,0.0); // x'=-y; y'=x; z'=z
889 AliMatrix(fIdRotm, 90.0,90., 90.0, -180.0, 0.0,0.0); // x'=y; y'=-x; z'=z
890 gMC->Gspos("SCMX", 2, "SCMY", -xpos, 0.0, 0.0, fIdRotm, overLapFlagSCMX.Data()) ;
1963b290 891 // PB:
892 if(n=="SCMX" && overLapFlagSCMY == "ONLY") {
893 PbInTrapForTrd2(parTRAP, n);
894 }
895}
896
897// 4-feb-05 by PAI
4d2e7dc7 898//______________________________________________________________________
899void AliEMCALv0::PbInTrapForTrd2(const double *parTRAP, TString name)
cde6a23d 900{
4d2e7dc7 901 // TRD2 cases
902 Double_t *dummy=0;
903 TString pbShape("BOX"), pbtiChonly("ONLY");
904 if(name=="SCM0") {
905 pbShape = "TRD2";
906 // pbtiChonly = "MANY";
907 }
908 gMC->Gsvolu("PBTI", pbShape.Data(), fIdTmedArr[kIdPB], dummy, 0);
909
910 int nr=0;
911 Info("PbInTrapForTrd2"," Pb tiles inside %s: shape %s :pbtiChonly %s\n nrstart %i\n",
912 name.Data(), pbShape.Data(), pbtiChonly.Data(), nr);
913 AliEMCALGeometry * g = GetGeometry();
914
915 double par[5], parPB[5], parSC[5];
916 //double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
917 double xpos = 0.0, ypos = 0.0;
918 double zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
919 if(name == "SCMX") { // common trapezoid - 11 parameters
920 double coef = (parTRAP[8] - parTRAP[4]) / (2.*parTRAP[0]);
921 double xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.; // the same for y
922 AliDebug(2,Form(" xCenterSCMX %8.5f : coef %8.7f \n", xCenterSCMX, coef));
923
924 par[2] = g->GetECPbRadThick()/2.; // z
925 for(int iz=0; iz<g->GetNECLayers(); iz++){
926 par[0] = parTRAP[4] + coef*fSampleWidth*iz;
927 par[1] = par[0];
928 xpos = ypos = par[0] - xCenterSCMX;
929 //if(parTRAP[1] < 0.) xpos = -xpos;
930 gMC->Gsposp("PBTI", ++nr, name.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
931 AliDebug(2,Form(" %2.2i xpos %8.5f zpos %6.3f par[0,1] %6.3f |", iz+1, xpos, zpos, par[0]));
932 if(iz%2>0) AliDebug(2,Form("\n"));
933 zpos += fSampleWidth;
934 }
935 AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
936 AliDebug(2,Form(" par[1] %9.5f par[2] %9.5f ypos %9.5f \n", par[1], par[2], ypos));
937 } else if(name == "SCM0") { // 1-mar-05 ; TRD2 - 5 parameters
938 AliDebug(2,Form(" SCM0 par = "));
939 for(int i=0; i<5; i++) AliDebug(2,Form(" %9.5f ", parTRAP[i]));
940 AliDebug(2,Form("\n zpos %f \n",zpos));
941
942 double tanx = (parTRAP[1] - parTRAP[0]) / (2.*parTRAP[4]); // tanx = tany now
943 double tany = (parTRAP[3] - parTRAP[2]) / (2.*parTRAP[4]), ztmp=0.;
944 parPB[4] = g->GetECPbRadThick()/2.;
945 parSC[2] = g->GetECScintThick()/2.;
946 for(int iz=0; iz<g->GetNECLayers(); iz++){
947 ztmp = fSampleWidth*double(iz);
948 parPB[0] = parTRAP[0] + tanx*ztmp;
949 parPB[1] = parPB[0] + tanx*g->GetECPbRadThick();
950 parPB[2] = parTRAP[2] + tany*ztmp;
951 parPB[3] = parPB[2] + tany*g->GetECPbRadThick();
952 gMC->Gsposp("PBTI", ++nr, name.Data(), xpos, ypos, zpos, 0, pbtiChonly.Data(), parPB, 5) ;
953 AliDebug(2,Form("\n PBTI %2i | zpos %6.3f | par = ", nr, zpos));
954 /*
955 for(int i=0; i<5; i++) printf(" %9.5f ", parPB[i]);
956 // individual SC tile
957 parSC[0] = parPB[0];
958 parSC[1] = parPB[1];
959 gMC->Gsposp("SCTI", nr, name.Data(), xpos, ypos, zpos+g->GetECScintThick(),
960 0, pbtiChonly.Data(), parSC, 3) ;
961 printf("\n SCTI zpos %6.3f | par = ", zpos+g->GetECScintThick());
962 for(int i=0; i<3; i++) printf(" %9.5f ", parPB[i]);
963 */
964 zpos += fSampleWidth;
965 }
966 AliDebug(2,Form("\n"));
967 }
968 Info("PbInTrapForTrd2", "Ver. 0.03 : was tested.");
1963b290 969}
970
971// 15-mar-05
4d2e7dc7 972//______________________________________________________________________
973void AliEMCALv0::PbmoInTrd2(const AliEMCALGeometry * g, const Double_t emodPar[5], Double_t parPBMO[5])
1963b290 974{
4d2e7dc7 975 // Pb inside Trd2
976 Info("PbmoInTrd2"," started : geometry %s ", g->GetName());
977 double wallThickness = g->GetPhiModuleSize()/2. - g->GetPhiTileSize();
978 AliDebug(2,Form(" wall thickness %7.5f \n", wallThickness));
979 for(int i=0; i<4; i++) {
980 parPBMO[i] = emodPar[i] - wallThickness;
981 AliDebug(2,Form(" %i parPBMO %7.3f emodPar %7.3f : dif %7.3f \n",
982 i, parPBMO[i],emodPar[i], parPBMO[i]-emodPar[i]));
983 }
984 parPBMO[4] = emodPar[4];
985 gMC->Gsvolu("PBMO", "TRD2", fIdTmedArr[kIdPB], parPBMO, 5);
986 gMC->Gspos("PBMO", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
987 // Division
988 if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
989 Division2X2InPbmo(g, parPBMO);
990 AliDebug(2,Form(" PBMO, division 2X2 | geometry |%s|\n", g->GetName()));
991 } else {
992 AliDebug(2,Form(" no division PBMO in this geometry |%s|\n", g->GetName()));
993 assert(0);
994 }
1963b290 995}
996
4d2e7dc7 997//______________________________________________________________________
cde6a23d 998void AliEMCALv0::Division2X2InPbmo(const AliEMCALGeometry * g, const Double_t parPBMO[5])
1963b290 999{
cde6a23d 1000 // Division 2X2
1963b290 1001 Info("Division2X2InPbmo"," started : geometry %s ", g->GetName());
1002 //Double_t *dummy=0;
cde6a23d 1003 // gMC->Gsvolu("SCTI", "BOX", fIdTmedArr[kIdSC], dummy, 0);
1963b290 1004
1005 double parSC[3];
cde6a23d 1006 //double fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
1963b290 1007 double xpos = 0.0, ypos = 0.0, zpos = 0.0, ztmp=0;;
1008 double tanx = (parPBMO[1] - parPBMO[0]) / (2.*parPBMO[4]); // tanx = tany now
1009 double tany = (parPBMO[3] - parPBMO[2]) / (2.*parPBMO[4]);
1010 char name[10], named[10], named2[10];
1011
e5a93224 1012 AliDebug(2,Form(" PBMO par = "));
1013 for(int i=0; i<5; i++) AliDebug(2,Form(" %9.5f ", parPBMO[i]));
1014 AliDebug(2,Form("\n"));
1963b290 1015
1016 parSC[2] = g->GetECScintThick()/2.;
cde6a23d 1017 zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick() + g->GetECScintThick()/2.;
e5a93224 1018 AliDebug(2,Form(" parSC[2] %9.5f \n", parSC[2]));
1963b290 1019 for(int iz=0; iz<g->GetNECLayers(); iz++){
cde6a23d 1020 ztmp = g->GetECPbRadThick() + fSampleWidth*double(iz); // Z for previous PB
1963b290 1021 parSC[0] = parPBMO[0] + tanx*ztmp;
1022 parSC[1] = parPBMO[2] + tany*ztmp;
1023
1024 sprintf(name,"SC%2.2i", iz+1);
cde6a23d 1025 gMC->Gsvolu(name, "BOX", fIdTmedArr[kIdSC], parSC, 3);
1963b290 1026 gMC->Gspos(name, 1, "PBMO", xpos, ypos, zpos, 0, "ONLY") ;
e5a93224 1027 AliDebug(2,Form("%s | zpos %6.3f | parSC[0,1]=(%7.5f,%7.5f) -> ",
1028 name, zpos, parSC[0], parSC[1]));
1963b290 1029
1030 sprintf(named,"SY%2.2i", iz+1);
1031 printf(" %s -> ", named);
1032 gMC->Gsdvn(named,name, 2, 2);
1033
1034 sprintf(named2,"SX%2.2i", iz+1);
1035 printf(" %s \n", named2);
1036 gMC->Gsdvn(named2,named, 2, 1);
1037
cde6a23d 1038 zpos += fSampleWidth;
1963b290 1039 }
1040}
c01485dd 1041
4d2e7dc7 1042//______________________________________________________________________
21cf2b24 1043AliEMCALShishKebabTrd1Module* AliEMCALv0::GetShishKebabModule(Int_t neta)
cde6a23d 1044{
1045 // 28-oct-05
c01485dd 1046 AliEMCALShishKebabTrd1Module* trd1=0;
1047 if(fShishKebabModules && neta>=0 && neta<fShishKebabModules->GetSize()) {
1048 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(neta);
1049 }
1050 return trd1;
1051}
5f66b6c6 1052
1053//_____________________________________________________________________________
1054void AliEMCALv0::AddAlignableVolumes() const
1ae500a2 1055{
1056 TString ntmp(GetTitle()); // name of EMCAL geometry
1057
1058 if(ntmp.Contains("WSUC")) {
1059 AddAlignableVolumesInWSUC(); // WSUC case
1060 } else {
1061 AddAlignableVolumesInALICE(); // ALICE case
1062 }
1063}
1064
4d2e7dc7 1065//______________________________________________________________________
1ae500a2 1066void AliEMCALv0::AddAlignableVolumesInALICE() const
5f66b6c6 1067{
1068 //
1069 // Create entries for alignable volumes associating the symbolic volume
1070 // name with the corresponding volume path. Needs to be synchronized with
1071 // eventual changes in the geometry.
1072 //
1073
9aa6a5f6 1074 Float_t * pars = GetGeometry()->GetSuperModulesPars();
1075 double rpos = (GetGeometry()->GetEnvelop(0) + GetGeometry()->GetEnvelop(1))/2.;
1076 double phi, phiRad, xpos, ypos, zpos;
1077
200e17a4 1078 AliGeomManager::ELayerID idEMCAL = AliGeomManager::kEMCAL;
1079 Int_t modUID, modnum = 0;
5f66b6c6 1080 TString volpath, symname;
1081
85653ebc 1082 Int_t nSMod = GetGeometry()->GetNumberOfSuperModules();
9aa6a5f6 1083 for (Int_t smodnum=0; smodnum < nSMod; smodnum++) {
200e17a4 1084 modUID = AliGeomManager::LayerToVolUID(idEMCAL,modnum++);
9aa6a5f6 1085 volpath = "ALIC_1/XEN1_1/SMOD_";
1082109f 1086 volpath += (smodnum+1);
9aa6a5f6 1087 symname = "EMCAL/FullSupermodule";
1088 symname += (smodnum+1);
1089
1090 if(GetGeometry()->GetKey110DEG() && smodnum>=10) {
1091 volpath = "ALIC_1/XEN1_1/SM10_";
1092 volpath += (smodnum-10+1);
1093 symname = "EMCAL/HalfSupermodule";
1094 symname += (smodnum-10+1);
1095 }
1096
200e17a4 1097 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
9aa6a5f6 1098 AliFatal("AliEMCALv0::Unable to set alignable entry!!");
1099
1100 // Creates the Tracking to Local transformation matrix for EMCAL
1101 // modules
200e17a4 1102 TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
9aa6a5f6 1103
85653ebc 1104 phiRad = GetGeometry()->GetPhiCenterOfSM(smodnum); //comes in radians, not degrees
1105 phi = phiRad*180./TMath::Pi(); //need degrees for rot. matrix
9aa6a5f6 1106 xpos = rpos * TMath::Cos(phiRad);
1107 ypos = rpos * TMath::Sin(phiRad);
1108 zpos = pars[2];
1109 if(GetGeometry()->GetKey110DEG() && smodnum >= 10) {
1110 xpos += (pars[1]/2. * TMath::Sin(phiRad));
1111 ypos -= (pars[1]/2. * TMath::Cos(phiRad));
1112 }
1113
1114 TGeoHMatrix *matTtoL;
200e17a4 1115 TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
9aa6a5f6 1116
1117 if(smodnum%2 == 0) {
1118 // pozitive z
1119 TGeoTranslation geoTran0(xpos,ypos, zpos);
1120 TGeoRotation geoRot0("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
1121 TGeoCombiTrans mat0(geoTran0, geoRot0);
1122 matTtoL = new TGeoHMatrix(mat0);
1123
1124 matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
1125 alignableEntry->SetMatrix(matTtoL);
1126
1127 } else {
1128 // negative z
1129 double phiy = 90. + phi + 180.;
1130 if(phiy>=360.) phiy -= 360.;
1131 TGeoTranslation geoTran1(xpos,ypos,-zpos);
1132 TGeoRotation geoRot1("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
1133 TGeoCombiTrans mat1(geoTran1, geoRot1);
1134 matTtoL = new TGeoHMatrix(mat1);
1135
1136 matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
1137 alignableEntry->SetMatrix(matTtoL);
5f66b6c6 1138
5f66b6c6 1139 }
9aa6a5f6 1140
5f66b6c6 1141 }
1142
1143}
1144
4d2e7dc7 1145//______________________________________________________________________
1ae500a2 1146void AliEMCALv0::AddAlignableVolumesInWSUC() const
1147{
1148 //
1149 // Create entries for alignable volumes associating the symbolic volume
1150 // name with the corresponding volume path. Needs to be synchronized with
1151 // eventual changes in the geometry.
1152 //
1153
1154 TString vpstr1 = "WSUC_1/XEN1_1/SMOD_";
1155 TString snstr1 = "EMCAL/CosmicTestSupermodule";
1156 TString volpath, symname;
1157
1158 // #SM is just one
1159 for (Int_t smodnum=0; smodnum < 1; smodnum++) {
1160 symname = snstr1;
1161 symname += (smodnum+1);
1162 volpath = vpstr1;
1163 volpath += (smodnum+1);
1164 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
1165 AliFatal("Unable to set alignable entry!!");
1166 }
1167}