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