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