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