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