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