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