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