LCOV - code coverage report
Current view: top level - EMCAL/EMCALsim - AliEMCALv0.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 305 499 61.1 %
Date: 2016-06-14 17:26:59 Functions: 11 19 57.9 %

          Line data    Source code
       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             : //          : Alexei Pavlinov (WSU)     SHASHLYK
      25             : //          : Adapted for DCAL by M.L. Wang CCNU & Subatech Oct-19-2012
      26             : // --- ROOT system ---
      27             : #include <cassert>
      28             : 
      29             : #include <TGeometry.h>
      30             : #include <TGeoPhysicalNode.h>
      31             : #include <TGeoManager.h>
      32             : #include <TGeoMatrix.h>
      33             : #include <TVirtualMC.h>
      34             : #include <TArrayI.h>
      35             : #include <TROOT.h>
      36             : #include <TList.h>
      37             : #include <TVector2.h>
      38             : #include <cassert>
      39             : 
      40             : // --- Standard library ---
      41             : 
      42             : //#include <stdio.h>
      43             : 
      44             : // --- AliRoot header files ---
      45             : #include "AliRun.h"
      46             : #include "AliLog.h"
      47             : #include "AliGeomManager.h"
      48             : 
      49             : //--- EMCAL system---
      50             : #include "AliEMCALShishKebabTrd1Module.h"
      51             : #include "AliEMCALv0.h"
      52             : #include "AliEMCALGeometry.h"
      53             : #include "AliEMCALSpaceFrame.h"
      54             : 
      55             : 
      56             : 
      57          42 : ClassImp(AliEMCALv0)
      58             : 
      59             : // EMCAL material: look to the AliEMCAL.cxx
      60             : enum
      61             :  {
      62             :   kIdAIR   = 1599, 
      63             :   kIdPB    = 1600, 
      64             :   kIdSC    = 1601, 
      65             :   kIdAL    = 1602, 
      66             :   kIdSTEEL = 1603,
      67             :   kIdPAPER = 1604
      68             :  };
      69             : 
      70             : 
      71             : //______________________________________________________________________
      72             : AliEMCALv0::AliEMCALv0()
      73          12 :   : AliEMCAL(),
      74          24 :     fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
      75          12 :     fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0),
      76          12 :     fInnerEdge(0),fCalFrame(0)
      77          36 : {
      78             :   //default ctor
      79         144 :   for(Int_t i = 0; i < 5 ; i++) fParEMOD[i]=0.0;
      80          12 : }
      81             : 
      82             : //______________________________________________________________________
      83             : AliEMCALv0::AliEMCALv0(const char *name, const char *title, 
      84             :                        const Bool_t checkGeoAndRun)
      85           1 :   : AliEMCAL(name,title,checkGeoAndRun),
      86           2 :     fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
      87           1 :     fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0),
      88           1 :     fInnerEdge(0),fCalFrame(0)
      89           2 : {
      90             :   // ctor : title is used to identify the layout
      91             :   // Apr 25, 2006
      92             :   // Nov 22, 2006 - case of 1X1  
      93             :   
      94          12 :   for(Int_t i = 0; i < 5 ; i++) fParEMOD[i]=0.0;
      95             :   
      96           2 :   TString ntmp(GetTitle());
      97           1 :   ntmp.ToUpper();
      98             : 
      99           2 :   fGeometry = GetGeometry() ; 
     100             :     
     101           2 :   TString gn(fGeometry->GetName()); 
     102           1 :   gn.ToUpper();
     103             :   
     104           1 :   fShishKebabModules = fGeometry->GetShishKebabTrd1Modules(); 
     105             : 
     106           3 :   fSampleWidth = Double_t(fGeometry->GetECPbRadThick() + fGeometry->GetECScintThick());
     107             :   
     108           4 :   if(gn.Contains("V1")) fSampleWidth += 2.*fGeometry->GetTrd1BondPaperThick();
     109             :   
     110           5 :   AliDebug(2,Form("fGeometry %p : TVirtualMC::GetMC() %p : fSampleWidth %5.4f\n", 
     111             :          fGeometry, TVirtualMC::GetMC(), fSampleWidth));
     112             :   
     113             :   // Set geometry name again, in case it was changed during the initialization of the geometry.
     114           2 :   SetTitle(fGeometry->GetEMCGeometry()->GetName());
     115           1 : }
     116             : 
     117             : //______________________________________________________________________
     118             : void AliEMCALv0::CreateGeometry()
     119             : {
     120             :   // Create the EMCAL geometry for Geant
     121             :   // Geometry of a tower
     122             : 
     123           2 :   AliEMCALGeometry * geom = GetGeometry() ; 
     124           1 :   TString gn(geom->GetName());
     125           1 :   gn.ToUpper(); 
     126             :   
     127           1 :   if(!(geom->IsInitialized())){
     128           0 :     Error("CreateGeometry","EMCAL Geometry class has not been set up.");
     129             :   } // end if
     130             : 
     131             :   // Get pointer to the array containing media indices
     132           1 :   fIdTmedArr = fIdtmed->GetArray() - 1599 ;
     133             :   
     134           1 :   fIdRotm = 1;
     135             :   //  TVirtualMC::GetMC()->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3) - see AliModule
     136           1 :   AliMatrix(fIdRotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ; 
     137             :   
     138             :   // Create the EMCAL Mother Volume (a polygone) within which to place the Detector and named XEN1 
     139             :   
     140           1 :   Float_t envelopA[10];
     141           2 :   if(gn.Contains("WSUC") ) { // TRD1 for WSUC facility
     142             :     // Nov 25,2010
     143           0 :     envelopA[0] = 30.;
     144           0 :     envelopA[1] = 30;
     145           0 :     envelopA[2] = 20;
     146           0 :     TVirtualMC::GetMC()->Gsvolu("XEN1", "BOX", fIdTmedArr[kIdSC], envelopA, 3) ;
     147           0 :     fEnvelop1.Set(3);
     148           0 :     for(Int_t i=0; i<3; i++) fEnvelop1[i] = envelopA[i]; // 23-may-05  
     149             :     // Position the EMCAL Mother Volume (XEN1) in WSUC.
     150             :     // Look to AliEMCALWsuCosmicRaySetUp.  
     151           0 :     TVirtualMC::GetMC()->Gspos("XEN1", 1, "WSUC", 0.0, 0.0, + 265., fIdRotm, "ONLY") ;
     152             :   } else { 
     153           2 :     envelopA[0] = geom->GetArm1PhiMin();                         // minimum phi angle
     154           3 :     envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin(); // angular range in phi
     155           1 :     envelopA[2] = envelopA[1]/geom->GetEMCGeometry()->GetPhiSuperModule();         // Section of that
     156           1 :     envelopA[3] = 2;                                             // 2: z coordinates
     157           2 :     envelopA[4] = -geom->GetEnvelop(2)/2.;                       // zmin - includes padding
     158           2 :     envelopA[5] = geom->GetEnvelop(0) ;                          // rmin at z1 - includes padding
     159           2 :     envelopA[6] = geom->GetEnvelop(1) ;                          // rmax at z1 - includes padding
     160           2 :     envelopA[7] = geom->GetEnvelop(2)/2.;                        // zmax includes padding
     161             :     
     162           1 :     envelopA[8] = envelopA[5] ;                                  // radii are the same.
     163           1 :     envelopA[9] = envelopA[6] ;                                  // radii are the same.
     164             : 
     165           2 :     TVirtualMC::GetMC()->Gsvolu("XEN1", "PGON", fIdTmedArr[kIdAIR], envelopA, 10) ;   // Polygone filled with air 
     166           1 :     fEnvelop1.Set(10, envelopA);
     167           1 :     if (gDebug==2) {
     168           0 :       printf("CreateGeometry: XEN1 = %f, %f\n", envelopA[5], envelopA[6]); 
     169           0 :       printf("CreateGeometry: XU0 = %f, %f\n", envelopA[5], envelopA[6]); 
     170             :     }
     171             :     // Position the EMCAL Mother Volume (XEN1) in Alice (ALIC)  
     172           3 :     TVirtualMC::GetMC()->Gspos(geom->GetNameOfEMCALEnvelope(), 1, "ALIC", 0.0, 0.0, 0.0, fIdRotm, "ONLY") ;
     173             :   }
     174             : 
     175             :   // COMPACT, TRD1
     176           5 :   AliDebug(2,Form("Shish-Kebab geometry : %s", GetTitle())); 
     177           1 :   CreateShishKebabGeometry();
     178             : 
     179           2 :   if(gn.Contains("WSUC")==0) { // Nov 24,2010 for TB
     180             :   //Space Frame
     181           5 :     AliDebug(2,"Creating EMCAL Space Frame");
     182           3 :     fCalFrame = new AliEMCALSpaceFrame();
     183           1 :     fCalFrame->CreateGeometry();
     184             :   }
     185             :   
     186             :   // Set the sampling fraction used at creation hit level
     187             :   // Previously called in AliEMCALEMCGeometry::Init(), put it here for proper initialization by Geant3/4
     188           5 :   geom->GetEMCGeometry()->DefineSamplingFraction(TVirtualMC::GetMC()->GetName(),TVirtualMC::GetMC()->GetTitle());
     189           1 : }
     190             : 
     191             : //______________________________________________________________________
     192             : void AliEMCALv0::Init(void)
     193             : {
     194             :     // Just prints an information message
     195           2 :   AliEMCAL::Init();
     196           1 :   if(AliLog::GetGlobalDebugLevel()>0) { 
     197           0 :     TString message("\n") ; 
     198           0 :     message += "*****************************************\n" ;
     199             :     
     200             :     // Here the EMCAL initialisation code (if any!)
     201             :     
     202           0 :     AliEMCALGeometry * geom = GetGeometry() ; 
     203             :     
     204           0 :     if (geom!=0) {   
     205           0 :       message += "AliEMCAL " ; 
     206           0 :       message += Version() ; 
     207           0 :       message += "EMCAL geometry initialized for " ; 
     208           0 :       message += geom->GetName()  ;
     209             :     }
     210             :     else {
     211           0 :       message += "AliEMCAL " ; 
     212           0 :       message += Version() ;  
     213           0 :       message += "EMCAL geometry initialization failed !" ; 
     214             :     }
     215           0 :     message += "\n*****************************************" ;
     216           0 :     printf("%s",message.Data() ) ; 
     217           0 :   }
     218           1 : }
     219             : 
     220             : // 24-aug-04 by PAI
     221             : //______________________________________________________________________
     222             : void AliEMCALv0::CreateShishKebabGeometry()
     223             : {  
     224             :   // Oct 26,2010
     225             :   // TRD1
     226           2 :   AliEMCALGeometry * g = GetGeometry(); 
     227           1 :   TString gn(g->GetName()); gn.ToUpper(); 
     228           3 :   Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
     229             :   // see AliModule::fFIdTmedArr
     230             :   //  fIdTmedArr = fIdtmed->GetArray() - 1599 ; // see AliEMCAL::::CreateMaterials()
     231             :   //  Int_t kIdAIR=1599, kIdPB = 1600, kIdSC = 1601, kIdSTEEL = 1603;
     232             :   //  idAL = 1602;
     233           1 :   Double_t par[10], xpos=0., ypos=0., zpos=0.;
     234             : 
     235           2 :   CreateSmod(g->GetNameOfEMCALEnvelope());
     236             : 
     237           1 :   Int_t * SMTypeList = g->GetEMCSystem();
     238             :   Int_t tmpType = -1;
     239          63 :   for(Int_t i = 0 ; i < g->GetNumberOfSuperModules(); i++) {
     240          20 :     if( SMTypeList[i] == tmpType) continue;
     241             :     else  tmpType = SMTypeList[i];
     242             : 
     243           5 :     if( tmpType == AliEMCALGeometry::kEMCAL_Standard ) CreateEmod("SMOD","EMOD");   // 18-may-05 
     244           3 :     else if( tmpType == AliEMCALGeometry::kEMCAL_Half     ) CreateEmod("SM10","EMOD");   // Nov 1,2006 1/2 SM
     245           4 :     else if( tmpType == AliEMCALGeometry::kEMCAL_3rd      ) CreateEmod("SM3rd","EMOD");  // Feb 1,2012 1/3 SM
     246           3 :     else if( tmpType == AliEMCALGeometry::kDCAL_Standard  ) CreateEmod("DCSM","EMOD");   // Mar 13, 2012, 6 or 10 DCSM
     247           2 :     else if( tmpType == AliEMCALGeometry::kDCAL_Ext       ) CreateEmod("DCEXT","EMOD");  // Mar 13, 2012, DCAL extension SM
     248           0 :     else AliError("Unkown SM Type!!");
     249             :   }
     250             : 
     251             :   // Sensitive SC  (2x2 tiles)
     252           1 :   Double_t parSCM0[5]={0,0,0,0}, *dummy = 0, parTRAP[11];
     253             : 
     254           2 :   if(!gn.Contains("V1")) {
     255           0 :     Double_t wallThickness = g->GetPhiModuleSize()/g->GetNPHIdiv() -  g->GetPhiTileSize();
     256           0 :     for(Int_t i=0; i<3; i++) parSCM0[i] = fParEMOD[i] - wallThickness;
     257           0 :     parSCM0[3] = fParEMOD[3];
     258           0 :     TVirtualMC::GetMC()->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
     259           0 :     TVirtualMC::GetMC()->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
     260           0 :   } else {
     261           2 :     Double_t wTh = g->GetLateralSteelStrip();
     262           2 :     parSCM0[0] = fParEMOD[0] - wTh + tanTrd1*g->GetTrd1AlFrontThick();
     263           1 :     parSCM0[1] = fParEMOD[1] - wTh;
     264           1 :     parSCM0[2] = fParEMOD[2] - wTh;
     265           2 :     parSCM0[3] = fParEMOD[3] - g->GetTrd1AlFrontThick()/2.;
     266           2 :     TVirtualMC::GetMC()->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
     267           2 :     Double_t zshift = g->GetTrd1AlFrontThick()/2.;
     268           2 :     TVirtualMC::GetMC()->Gspos("SCM0", 1, "EMOD", 0., 0., zshift, 0, "ONLY");
     269             :     // 
     270           1 :     CreateAlFrontPlate("EMOD","ALFP");
     271             :   }
     272             : 
     273           4 :   if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
     274             :     // Division to tile size - 1-oct-04
     275           5 :     AliDebug(2,Form(" Divide SCM0 on y-axis %i\n", g->GetNETAdiv()));
     276           3 :     TVirtualMC::GetMC()->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
     277             :     // Trapesoid 2x2
     278           1 :     parTRAP[0] = parSCM0[3];    // dz
     279           2 :     parTRAP[1] = TMath::ATan2((parSCM0[1]-parSCM0[0])/2.,2.*parSCM0[3])*180./TMath::Pi(); // theta
     280           1 :     parTRAP[2] = 0.;           // phi
     281             :     // bottom
     282           1 :     parTRAP[3] = parSCM0[2]/2.; // H1
     283           1 :     parTRAP[4] = parSCM0[0]/2.; // BL1
     284           1 :     parTRAP[5] = parTRAP[4];    // TL1
     285           1 :     parTRAP[6] = 0.0;           // ALP1
     286             :     // top
     287           1 :     parTRAP[7] = parSCM0[2]/2.; // H2
     288           1 :     parTRAP[8] = parSCM0[1]/2.; // BL2
     289           1 :     parTRAP[9] = parTRAP[8];    // TL2
     290           1 :     parTRAP[10]= 0.0;           // ALP2
     291           5 :     AliDebug(2,Form(" ** TRAP ** \n"));
     292          79 :     for(Int_t i=0; i<11; i++) AliDebug(3, Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
     293             :     
     294           2 :     TVirtualMC::GetMC()->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
     295           1 :     xpos = +(parSCM0[1]+parSCM0[0])/4.;
     296           2 :     TVirtualMC::GetMC()->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
     297             : 
     298             :     // Using rotation because SCMX should be the same due to Pb tiles
     299           1 :     xpos = -xpos; 
     300           1 :     AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
     301           2 :     TVirtualMC::GetMC()->Gspos("SCMX", 2, "SCMY", xpos, 0.0, 0.0, fIdRotm, "ONLY");
     302             :     // put LED to the SCM0 
     303           2 :     AliEMCALShishKebabTrd1Module *mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(0);
     304           1 :     Double_t tanBetta = mod->GetTanBetta();
     305             : 
     306             :     Int_t nr=0; 
     307             :     ypos = 0.0; 
     308           1 :     Double_t xCenterSCMX =  (parTRAP[4] +  parTRAP[8])/2.;
     309           2 :     if(!gn.Contains("V1")) {
     310             :       par[1] = parSCM0[2]/2;            // y 
     311           0 :       par[2] = g->GetECPbRadThick()/2.; // z
     312           0 :       TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
     313           0 :       zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
     314           0 :       AliDebug(2,Form(" Pb tiles \n"));
     315           0 :       for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
     316           0 :         par[0] = (parSCM0[0] + tanBetta*fSampleWidth*iz)/2.;
     317           0 :         xpos   = par[0] - xCenterSCMX;
     318           0 :         TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, "SCMX", xpos, ypos, zpos, 0, "ONLY", par, 3) ;
     319           0 :         AliDebug(3,Form(" %i xpos %f zpos %f par[0] %f \n", iz+1, xpos, zpos, par[0]));
     320           0 :         zpos += fSampleWidth;
     321             :       } 
     322           0 :       AliDebug(2,Form(" Number of Pb tiles in SCMX %i \n", nr));
     323             :     } else {
     324             :       // Oct 26, 2010
     325             :       // First sheet of paper
     326           1 :       par[1] = parSCM0[2]/2.;                 // y 
     327           2 :       par[2] = g->GetTrd1BondPaperThick()/2.; // z
     328           1 :       par[0] = parSCM0[0]/2.;                 // x 
     329           2 :       TVirtualMC::GetMC()->Gsvolu("PAP1", "BOX", fIdTmedArr[kIdPAPER], par, 3);
     330           1 :       xpos = par[0] - xCenterSCMX;
     331           2 :       zpos = -parSCM0[3] + g->GetTrd1BondPaperThick()/2.;
     332           2 :       TVirtualMC::GetMC()->Gspos("PAP1", 1, "SCMX", xpos, ypos, zpos, 0, "ONLY");
     333         231 :       for(Int_t iz=0; iz<g->GetNECLayers()-1; iz++){
     334          76 :         nr = iz + 1;
     335         228 :         Double_t dz = g->GetECScintThick() + g->GetTrd1BondPaperThick() + fSampleWidth*iz;
     336             :         // PB + 2 paper sheets
     337         228 :         par[2] = g->GetECPbRadThick()/2. + g->GetTrd1BondPaperThick(); // z
     338          76 :         par[0] = (parSCM0[0] + tanBetta*dz)/2.;
     339         152 :         TString pa(Form("PA%2.2i",nr));
     340         228 :         TVirtualMC::GetMC()->Gsvolu(pa.Data(), "BOX", fIdTmedArr[kIdPAPER], par, 3);
     341          76 :         xpos   = par[0] - xCenterSCMX;
     342          76 :         zpos   = -parSCM0[3] + dz + par[2];
     343         228 :         TVirtualMC::GetMC()->Gspos(pa.Data(), 1, "SCMX", xpos, ypos, zpos, 0, "ONLY") ;
     344             :         // Pb
     345         152 :         TString pb(Form("PB%2.2i",nr));
     346         152 :         par[2] = g->GetECPbRadThick()/2.; // z
     347         228 :         TVirtualMC::GetMC()->Gsvolu(pb.Data(), "BOX", fIdTmedArr[kIdPB], par, 3);
     348         304 :         TVirtualMC::GetMC()->Gspos(pb.Data(), 1, pa.Data(), 0.0, 0.0, 0.0, 0, "ONLY") ;
     349          76 :       } 
     350             :     }
     351             :     
     352           1 :   } else if(g->GetNPHIdiv()==3 && g->GetNETAdiv()==3) {
     353           0 :     printf(" before AliEMCALv0::Trd1Tower3X3() : parSCM0");
     354           0 :     for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
     355           0 :     printf("\n"); 
     356           0 :     Trd1Tower3X3(parSCM0);
     357           0 :   } else if(g->GetNPHIdiv()==1 && g->GetNETAdiv()==1) {
     358             :     // no division in SCM0
     359           0 :     Trd1Tower1X1(parSCM0);
     360             :   }
     361             :   
     362           1 : }
     363             : 
     364             : //______________________________________________________________________
     365             : void AliEMCALv0::CreateSmod(const char* mother)
     366             : { 
     367             :   // 18-may-05; mother="XEN1";
     368             :   // child="SMOD" from first to 10th, "SM10" (11th and 12th)
     369             :   // "DCSM" from 13th to 18/22th (TRD1 case), "DCEXT"(18th and 19th)  adapted for DCAL, Oct-23-2012
     370           2 :   AliEMCALGeometry * g = GetGeometry(); 
     371           1 :   TString gn(g->GetName()); gn.ToUpper();
     372             : 
     373           1 :   Double_t par[3], xpos=0., ypos=0., zpos=0., rpos=0., dphi=0., phi=0.0, phiRad=0.;
     374           1 :   Double_t parC[3] = {0};
     375           1 :   TString smName;
     376             :   Int_t tmpType = -1;
     377             : 
     378             :   //  ===== define Super Module from air - 14x30 module ==== ;
     379           5 :   AliDebug(2,Form("\n ## Super Module | fSampleWidth %5.3f ## %s \n", fSampleWidth, gn.Data()));
     380           2 :   par[0] = g->GetShellThickness()/2.;
     381           3 :   par[1] = g->GetPhiModuleSize()*g->GetNPhi()/2.; 
     382           3 :   par[2] = g->GetEtaModuleSize()*g->GetNEta()/2.;
     383           1 :   fIdRotm=0;
     384           1 :   Int_t nSMod = g->GetNumberOfSuperModules(); 
     385           1 :   Int_t nphism = nSMod/2; // 20-may-05
     386           1 :   if(nphism > 0) {
     387           1 :     dphi = g->GetEMCGeometry()->GetPhiSuperModule();
     388           3 :     rpos = (g->GetEnvelop(0) + g->GetEnvelop(1))/2.;
     389           5 :     AliDebug(2,Form(" rpos %8.2f : dphi %6.1f degree \n", rpos, dphi));
     390             :   }
     391             : 
     392           2 :   if(gn.Contains("WSUC")) {
     393             :     Int_t nr=0;
     394           0 :     par[0] = g->GetPhiModuleSize()*g->GetNPhi()/2.; 
     395           0 :     par[1] = g->GetShellThickness()/2.;
     396           0 :     par[2] = g->GetEtaModuleSize()*g->GetNZ()/2. + 5; 
     397             : 
     398           0 :     TVirtualMC::GetMC()->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
     399             : 
     400           0 :     AliDebug(2,Form("SMOD in WSUC : tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n", 
     401             :                     fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
     402           0 :     fSmodPar0 = par[0]; 
     403           0 :     fSmodPar1 = par[1];
     404           0 :     fSmodPar2 = par[2];
     405           0 :     nphism   =  g->GetNumberOfSuperModules();
     406           0 :     for(Int_t i=0; i<nphism; i++) {
     407             :       xpos = ypos = zpos = 0.0;
     408           0 :       fIdRotm = 0;
     409           0 :       TVirtualMC::GetMC()->Gspos("SMOD", 1, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
     410           0 :       printf(" fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n", 
     411           0 :       fIdRotm, phi, phiRad, xpos, ypos, zpos);
     412           0 :       nr++;
     413             :     }
     414           0 :   } else {// ALICE
     415           5 :     AliDebug(2,Form(" par[0] %7.2f (old) \n",  par[0]));
     416          11 :     for(Int_t i=0; i<3; i++) par[i] = g->GetSuperModulesPar(i);
     417           1 :     fSmodPar0 = par[0]; 
     418           1 :     fSmodPar2 = par[2];
     419             :     Int_t SMOrder = -1;
     420             :     tmpType = -1;
     421          42 :     for (Int_t smodnum = 0; smodnum < nSMod; ++smodnum) {
     422         160 :       for(Int_t i=0; i<3; i++) parC[i] = par[i];
     423          20 :       if(g->GetSMType(smodnum) == tmpType) {
     424          16 :         SMOrder++;
     425          16 :       } else {
     426           4 :         tmpType = g->GetSMType(smodnum);
     427             :         SMOrder = 1;
     428             :       }
     429             : 
     430          20 :       phiRad = g->GetPhiCenterOfSMSec(smodnum); // NEED  phi= 90, 110, 130, 150, 170, 190(not center)... 
     431          20 :       phi    = phiRad *180./TMath::Pi();
     432          20 :       Double_t phiy = 90. + phi;
     433             :       Double_t phiz = 0.;
     434             : 
     435          20 :       xpos = rpos * TMath::Cos(phiRad);
     436          20 :       ypos = rpos * TMath::Sin(phiRad);
     437          20 :       zpos = fSmodPar2; // 21-sep-04
     438          20 :       if(        tmpType == AliEMCALGeometry::kEMCAL_Standard ) {
     439          10 :         smName="SMOD";
     440          10 :       } else if( tmpType == AliEMCALGeometry::kEMCAL_Half ) {
     441           0 :         smName="SM10";
     442           0 :         parC[1] /= 2.;
     443           0 :         xpos += (par[1]/2. * TMath::Sin(phiRad));
     444           0 :         ypos -= (par[1]/2. * TMath::Cos(phiRad));
     445          10 :       } else if( tmpType == AliEMCALGeometry::kEMCAL_3rd ) {
     446           2 :         smName="SM3rd";
     447           2 :         parC[1] /= 3.;
     448           2 :         xpos += (2.*par[1]/3. * TMath::Sin(phiRad));
     449           2 :         ypos -= (2.*par[1]/3. * TMath::Cos(phiRad));
     450          10 :       } else if( tmpType == AliEMCALGeometry::kDCAL_Standard ) {
     451           6 :         smName="DCSM";
     452           6 :         parC[2] *= 2./3.;
     453          12 :         zpos = fSmodPar2 + g->GetDCALInnerEdge()/2.; // 21-sep-04
     454           8 :       } else if( tmpType == AliEMCALGeometry::kDCAL_Ext ) {
     455           2 :         smName="DCEXT";
     456           2 :         parC[1] /= 3.;
     457           2 :         xpos += (2.*par[1]/3. * TMath::Sin(phiRad));
     458           2 :         ypos -= (2.*par[1]/3. * TMath::Cos(phiRad));
     459           2 :       } else AliError("Unkown SM Type!!");
     460             : 
     461          20 :       if(SMOrder == 1) {//first time, create the SM
     462          12 :         TVirtualMC::GetMC()->Gsvolu(smName.Data(), "BOX", fIdTmedArr[kIdAIR], parC, 3);
     463          20 :         AliDebug(2,Form(" Super module with name \"%s\" was created in \"box\" with: par[0] = %f, par[1] = %f, par[2] = %f\n", smName.Data(), parC[0], parC[1], parC[2]));
     464             :       }
     465             : 
     466          20 :       if( smodnum%2 == 1) {
     467          10 :         phiy += 180.;
     468          20 :         if(phiy>=360.) phiy -= 360.;
     469             :         phiz = 180.;
     470          10 :         zpos *= -1.;
     471          10 :       }
     472          20 :       AliMatrix(fIdRotm, 90.0, phi, 90.0, phiy, phiz, 0.0);
     473          60 :       TVirtualMC::GetMC()->Gspos(smName.Data(), SMOrder, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
     474         100 :       AliDebug(3, Form(" %s : %2i, fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : i %i \n",            
     475             :                        smName.Data(), SMOrder, fIdRotm, phi, phiRad, xpos, ypos, zpos, smodnum));
     476             :     }
     477             :   }
     478           5 :   AliDebug(2,Form(" Number of Super Modules %i \n", nSMod));
     479             : 
     480             :   // Steel plate
     481           2 :   if(g->GetSteelFrontThickness() > 0.0) { // 28-mar-05
     482           0 :     par[0] = g->GetSteelFrontThickness()/2.;
     483           0 :     TVirtualMC::GetMC()->Gsvolu("STPL", "BOX", fIdTmedArr[kIdSTEEL], par, 3);
     484           0 :     printf("tmed %i | dx %7.2f dy %7.2f dz %7.2f (STPL) \n", fIdTmedArr[kIdSTEEL], par[0],par[1],par[2]);
     485           0 :     xpos = -(g->GetShellThickness() - g->GetSteelFrontThickness())/2.;
     486           0 :     TVirtualMC::GetMC()->Gspos("STPL", 1, "SMOD", xpos, 0.0, 0.0, 0, "ONLY") ;
     487             :   }
     488           1 : }
     489             : 
     490             : //______________________________________________________________________
     491             : void AliEMCALv0::CreateEmod(const char* mother, const char* child)
     492             : { 
     493             :   // 17-may-05; mother="SMOD"; child="EMOD"
     494             :   // Oct 26,2010 
     495           8 :   AliEMCALGeometry * g = GetGeometry(); 
     496           4 :   TString gn(g->GetName()); gn.ToUpper(); 
     497             :   // Module definition
     498             :   Double_t xpos=0., ypos=0., zpos=0.;
     499             :   //Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad();tanTrd1 = TMath::Tan(trd1Angle/2.);
     500             : 
     501           8 :   if(strcmp(mother,"SMOD")==0) {
     502           2 :     fParEMOD[0] = g->GetEtaModuleSize()/2.;   // dx1
     503           2 :     fParEMOD[1] = g->Get2Trd1Dx2()/2.;        // dx2
     504           2 :     fParEMOD[2] = g->GetPhiModuleSize()/2.;;  // dy
     505           2 :     fParEMOD[3] = g->GetLongModuleSize()/2.;  // dz
     506           2 :     TVirtualMC::GetMC()->Gsvolu(child, "TRD1", fIdTmedArr[kIdSTEEL], fParEMOD, 4);
     507             :   }
     508             :   
     509             :   Int_t nr=0;
     510           4 :   fIdRotm=0;
     511             :   // X->Z(0, 0); Y->Y(90, 90); Z->X(90, 0)
     512             :   AliEMCALShishKebabTrd1Module *mod=0; // current module
     513             : 
     514         300 :   for(Int_t iz=0; iz<g->GetNZ(); iz++) {
     515             :     Double_t  angle=90., phiOK=0;
     516         192 :     mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(iz);
     517          96 :     angle = mod->GetThetaInDegree();
     518         192 :     if(!gn.Contains("WSUC")) { // ALICE 
     519          96 :       AliMatrix(fIdRotm, 90.-angle,180., 90.0,90.0, angle, 0.);
     520         192 :       phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi(); 
     521         480 :       AliDebug(4,Form(" %2i | angle | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
     522             :                       iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule()));
     523         288 :       xpos = mod->GetPosXfromR() + g->GetSteelFrontThickness() - fSmodPar0;
     524         192 :       zpos = mod->GetPosZ() - fSmodPar2;
     525             :       
     526          96 :       Int_t iyMax = g->GetNPhi();
     527         192 :       if(strcmp(mother,"SM10") == 0 ) {
     528           0 :          iyMax /= 2;
     529         192 :       } else if(strcmp(mother,"SM3rd") == 0 ) {
     530          24 :          iyMax /= 3;
     531         168 :       } else if(strcmp(mother,"DCEXT") == 0 ) {
     532          24 :          iyMax /= 3;
     533         120 :       } else if(strcmp(mother,"DCSM") == 0 ) {
     534          32 :         if(iz < 8 ) continue;//!!!DCSM from 8th to 23th
     535          48 :         zpos = mod->GetPosZ() - fSmodPar2 - g->GetDCALInnerEdge()/2.;
     536          64 :       } else if(strcmp(mother,"SMOD") != 0 ) 
     537           0 :         AliError("Unknown super module Type!!");
     538        1520 :       for(Int_t iy=0; iy<iyMax; iy++) { // flat in phi
     539        1344 :         ypos = g->GetPhiModuleSize()*(2*iy+1 - iyMax)/2.;
     540        1344 :         TVirtualMC::GetMC()->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
     541             :         //
     542             :         //printf(" %2i xpos %7.2f ypos %7.2f zpos %7.2f fIdRotm %i\n", nr, xpos, ypos, zpos, fIdRotm);
     543        3360 :         AliDebug(3,Form("%3.3i(%2.2i,%2.2i) ", nr,iy+1,iz+1));
     544             :       }
     545             :       //PH          printf("\n");
     546          88 :     } else { //WSUC
     547           0 :       if(iz == 0) AliMatrix(fIdRotm, 0.,0., 90.,0., 90.,90.); // (x')z; y'(x); z'(y)
     548           0 :       else        AliMatrix(fIdRotm, 90-angle,270., 90.0,0.0, angle,90.);
     549           0 :       phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi(); 
     550           0 :       AliDebug(4,Form(" %2i | angle -phiOK | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
     551             :                       iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule()));
     552           0 :       zpos = mod->GetPosZ()      - fSmodPar2;
     553           0 :       ypos = mod->GetPosXfromR() - fSmodPar1;
     554             :       //printf(" zpos %7.2f ypos %7.2f fIdRotm %i\n xpos ", zpos, xpos, fIdRotm);
     555           0 :       for(Int_t ix=0; ix<g->GetNPhi(); ix++) 
     556             :       { // flat in phi
     557           0 :         xpos = g->GetPhiModuleSize()*(2*ix+1 - g->GetNPhi())/2.;
     558           0 :         TVirtualMC::GetMC()->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
     559             :         //printf(" %7.2f ", xpos);
     560             :       }
     561             :       //printf("\n");
     562             :     }
     563          88 :   }
     564          20 :   AliDebug(2,Form(" Number of modules in Super Module(%s) %i \n", mother, nr));
     565           4 : }
     566             : 
     567             : void AliEMCALv0::CreateAlFrontPlate(const char* mother, const char* child)
     568             : {
     569             :   // Oct 26,2010 : Al front plate : ALFP
     570           2 :   AliEMCALGeometry * g = GetGeometry(); 
     571           1 :   TString gn(g->GetName()); gn.ToUpper(); 
     572           3 :   Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
     573           1 :   Double_t parALFP[5], zposALFP=0.;
     574             : 
     575           3 :   parALFP[0] = g->GetEtaModuleSize()/2. - g->GetLateralSteelStrip();    // dx1
     576           2 :   parALFP[1] = parALFP[0]               + tanTrd1*g->GetTrd1AlFrontThick(); // dx2
     577           3 :   parALFP[2] = g->GetPhiModuleSize()/2. - g->GetLateralSteelStrip();    // dy
     578           2 :   parALFP[3] = g->GetTrd1AlFrontThick()/2.; // dz
     579           2 :   TVirtualMC::GetMC()->Gsvolu(child, "TRD1", fIdTmedArr[kIdAL], parALFP, 4);
     580           2 :   zposALFP   = -fParEMOD[3] + g->GetTrd1AlFrontThick()/2.;
     581           2 :   TVirtualMC::GetMC()->Gspos (child, 1, mother, 0.0, 0.0, zposALFP, 0, "ONLY");
     582           1 : }
     583             : 
     584             : //______________________________________________________________________
     585             : void AliEMCALv0::Trd1Tower3X3(const Double_t *parSCM0)
     586             : {
     587             :   // Started Dec 8,2004 by PAI
     588             :   // Fixed Nov 13,2006
     589           0 :   printf(" AliEMCALv0::Trd1Tower3X3() : parSCM0");
     590           0 :   for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
     591           0 :   printf("\n"); 
     592             :   // Nov 10, 2006 - different name of SCMX
     593           0 :   Double_t parTRAP[11], *dummy=0;
     594           0 :   AliEMCALGeometry * g = GetGeometry(); 
     595           0 :   TString gn(g->GetName()), scmx; 
     596           0 :   gn.ToUpper(); 
     597             :  // Division to tile size 
     598           0 :   AliDebug(2,Form("Trd1Tower3X3() : Divide SCM0 on y-axis %i", g->GetNETAdiv()));
     599           0 :   TVirtualMC::GetMC()->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2); // y-axis
     600           0 :   Double_t dx1=parSCM0[0], dx2=parSCM0[1], dy=parSCM0[2], dz=parSCM0[3];
     601             :   Double_t ndiv=3., xpos=0.0;
     602             :   // should be defined once
     603           0 :   TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
     604           0 :   for(Int_t ix=1; ix<=3; ix++) { // 3X3
     605           0 :     scmx = "SCX"; // Nov 10,2006 
     606             :     // ix=1
     607           0 :     parTRAP[0] = dz;
     608           0 :     Double_t xCentBot = 2.*dx1/3.;
     609           0 :     Double_t xCentTop = 2.*(dx2/4. + dx1/12.);
     610           0 :     parTRAP[1] = TMath::ATan2((xCentTop-xCentBot),2.*dz)*TMath::RadToDeg(); // theta
     611           0 :     parTRAP[2] = 0.;           // phi
     612             :     // bottom
     613           0 :     parTRAP[3] = dy/ndiv;      // H1
     614           0 :     parTRAP[4] = dx1/ndiv;     // BL1
     615           0 :     parTRAP[5] = parTRAP[4];   // TL1
     616           0 :     parTRAP[6] = 0.0;          // ALP1
     617             :     // top
     618           0 :     parTRAP[7] = dy/ndiv;      // H2
     619           0 :     parTRAP[8] = dx2/2 - dx1/6.;// BL2
     620           0 :     parTRAP[9] = parTRAP[8];   // TL2
     621           0 :     parTRAP[10]= 0.0;          // ALP2
     622           0 :     xpos = (xCentBot+xCentTop)/2.;
     623             : 
     624           0 :     if      (ix==3) {
     625           0 :       parTRAP[1] = -parTRAP[1];
     626           0 :       xpos = -xpos;
     627           0 :     } else if(ix==2) { // central part is box but we treat as trapesoid due to numbering
     628           0 :       parTRAP[1] = 0.;
     629           0 :       parTRAP[8] = dx1/ndiv;     // BL2
     630           0 :       parTRAP[9] = parTRAP[8];   // TL2
     631             :       xpos = 0.0;
     632           0 :     }
     633           0 :     AliDebug(2,Form(" ** TRAP ** xpos %9.3f\n", xpos));
     634           0 :     for(Int_t i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
     635             : 
     636           0 :     scmx += ix;
     637           0 :     TVirtualMC::GetMC()->Gsvolu(scmx.Data(), "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
     638           0 :     TVirtualMC::GetMC()->Gspos(scmx.Data(), 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
     639             : 
     640           0 :     PbInTrap(parTRAP, scmx);
     641             :   }
     642           0 :   AliDebug(2,"Trd1Tower3X3 - Ver. 1.0 : was tested.");
     643           0 : }
     644             : 
     645             : // 8-dec-04 by PAI
     646             : //______________________________________________________________________
     647             : void AliEMCALv0::PbInTrap(const Double_t parTRAP[11], TString n)
     648             : {
     649             :  // see for example CreateShishKebabGeometry(); just for case TRD1
     650             :   static Int_t nr=0;
     651           0 :   AliDebug(2,Form(" Pb tiles : nrstart %i\n", nr));
     652           0 :   AliEMCALGeometry * g = GetGeometry(); 
     653             : 
     654           0 :   Double_t par[3];
     655             :   Double_t xpos = 0.0, ypos = 0.0;
     656           0 :   Double_t zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
     657             : 
     658           0 :   Double_t coef = (parTRAP[8] -  parTRAP[4]) / (2.*parTRAP[0]);
     659           0 :   Double_t xCenterSCMX =  (parTRAP[4] +  parTRAP[8])/2.; // ??
     660             :   //  Double_t tan = TMath::Tan(parTRAP[1]*TMath::DegToRad());
     661             : 
     662           0 :   par[1] = parTRAP[3];              // y 
     663           0 :   par[2] = g->GetECPbRadThick()/2.; // z
     664           0 :   for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
     665           0 :     par[0] = parTRAP[4] + coef*fSampleWidth*iz;
     666           0 :     xpos   = par[0] - xCenterSCMX;
     667           0 :     if(parTRAP[1] < 0.) xpos = -xpos;
     668           0 :     TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
     669           0 :     AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
     670           0 :     zpos += fSampleWidth;
     671           0 :     if(iz%2>0) printf("\n");
     672             :   } 
     673           0 :   AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
     674           0 :   AliDebug(2,Form(" par[1] %9.3f  par[2] %9.3f ypos %9.3f \n", par[1], par[2], ypos)); 
     675           0 :   AliDebug(2,Form(" PbInTrap Ver. 1.0 : was tested."));
     676           0 : }
     677             : 
     678             : //______________________________________________________________________
     679             : void AliEMCALv0::Trd1Tower1X1(Double_t *parSCM0)
     680             : {
     681             :   // Started Nov 22,2006 by PAI
     682           0 :   AliDebug(1," AliEMCALv0::Trd1Tower1X1() : parSCM0");
     683           0 :   for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
     684           0 :   printf("\n"); 
     685             : 
     686             :   // No division - keeping the same volume logic 
     687             :   // and as consequence the same abs is scheme
     688           0 :   AliDebug(2,"Trd1Tower1X1() : Create SCMX(SCMY) as SCM0");
     689             : 
     690           0 :   TVirtualMC::GetMC()->Gsvolu("SCMY", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
     691           0 :   TVirtualMC::GetMC()->Gspos("SCMY", 1, "SCM0", 0.0, 0.0, 0.0, 0, "ONLY");
     692           0 :   TVirtualMC::GetMC()->Gsvolu("SCMX", "TRD1", fIdTmedArr[kIdSC], parSCM0, 4);
     693           0 :   TVirtualMC::GetMC()->Gspos("SCMX", 1, "SCMY", 0.0, 0.0, 0.0, 0, "ONLY");
     694             : 
     695             :   // should be defined once
     696             :   Double_t *dummy=0;
     697           0 :   TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
     698             : 
     699           0 :   PbInTrd1(parSCM0, "SCMX");
     700             : 
     701           0 :   AliDebug(1,"Trd1Tower1X1() : Ver. 0.1 : was tested.");
     702           0 : }
     703             : 
     704             : //______________________________________________________________________
     705             : void AliEMCALv0::PbInTrd1(const Double_t *parTrd1, TString n)
     706             : {
     707             :  // see PbInTrap(const Double_t parTrd1[11], TString n)
     708             :   static Int_t nr=0, ndeb=2;
     709           0 :   AliDebug(ndeb,Form(" Pb tiles : nrstart %i\n", nr));
     710           0 :   AliEMCALGeometry * g = GetGeometry(); 
     711             : 
     712           0 :   Double_t par[3];
     713             :   Double_t xpos = 0.0, ypos = 0.0;
     714           0 :   Double_t zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
     715           0 :   Double_t coef = (parTrd1[1] -  parTrd1[0]) / (2.*parTrd1[3]);
     716             : 
     717           0 :   par[1] = parTrd1[2];              // y 
     718           0 :   par[2] = g->GetECPbRadThick()/2.; // z
     719             : 
     720           0 :   for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
     721           0 :     par[0] = parTrd1[0] + coef*fSampleWidth*iz;
     722           0 :     TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
     723           0 :     AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
     724           0 :     zpos += fSampleWidth;
     725           0 :     if(iz%2>0) printf("\n");
     726             :   } 
     727           0 :   AliDebug(ndeb,Form(" Number of Pb tiles in SCMX %i coef %9.7f ", nr, coef));
     728           0 :   AliDebug(ndeb,Form(" PbInTrd1 Ver. 0.1 : was tested."));
     729           0 : }
     730             : 
     731             : //______________________________________________________________________
     732             : AliEMCALShishKebabTrd1Module* AliEMCALv0::GetShishKebabModule(Int_t neta)
     733             : { 
     734             :   // 28-oct-05
     735             :   AliEMCALShishKebabTrd1Module* trd1=0;
     736           0 :   if(fShishKebabModules && neta>=0 && neta<fShishKebabModules->GetSize()) {
     737           0 :     trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(neta);
     738           0 :   }
     739           0 :   return trd1;
     740             : }
     741             : 
     742             : //_____________________________________________________________________________
     743             : void AliEMCALv0::AddAlignableVolumes() const
     744             : {
     745             :   //Add volumes which are alignable (?)
     746           2 :   TString ntmp(GetTitle()); // name of EMCAL geometry
     747             : 
     748           2 :   if(ntmp.Contains("WSUC")) {
     749           1 :     AddAlignableVolumesInWSUC();  // WSUC case
     750             :   } else {
     751           1 :     AddAlignableVolumesInALICE(); // ALICE case
     752             :   }
     753           1 : }
     754             : 
     755             : //______________________________________________________________________
     756             : void AliEMCALv0::AddAlignableVolumesInALICE() const
     757             : {
     758             :   //
     759             :   // Create entries for alignable volumes associating the symbolic volume
     760             :   // name with the corresponding volume path. Needs to be synchronized with
     761             :   // eventual changes in the geometry.
     762             :   //
     763             : 
     764           2 :   Float_t pars[] = {GetGeometry()->GetSuperModulesPar(0),GetGeometry()->GetSuperModulesPar(1),GetGeometry()->GetSuperModulesPar(2)};
     765           1 :   Double_t rpos = (GetGeometry()->GetEnvelop(0) + GetGeometry()->GetEnvelop(1))/2.;
     766             :   Double_t phi, phiRad, xpos, ypos, zpos;
     767             : 
     768             :   AliGeomManager::ELayerID idEMCAL = AliGeomManager::kEMCAL;
     769             :   Int_t modUID, modnum = 0;
     770           1 :   TString volpath, symname;
     771             : 
     772           1 :   AliEMCALGeometry * geom = GetGeometry();
     773           1 :   Int_t nSMod = geom->GetNumberOfSuperModules(); 
     774           1 :   TString SMPathName;
     775           1 :   TString SMName;
     776             :   Int_t tmpType = -1;
     777             :   Int_t SMOrder = 0;
     778             : 
     779          42 :   for (Int_t smodnum = 0; smodnum < nSMod; ++smodnum) {
     780          40 :     modUID = AliGeomManager::LayerToVolUID(idEMCAL,modnum++);
     781          40 :     if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Standard )      { SMPathName = "SMOD";  SMName = "FullSupermodule";}
     782          10 :     else if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Half )     { SMPathName = "SM10";  SMName = "HalfSupermodule";}
     783          14 :     else if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_3rd )      { SMPathName = "SM3rd"; SMName = "OneThrdSupermodule";}
     784          20 :     else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Standard ) { SMPathName = "DCSM";  SMName = "DCALSupermodule";}
     785           6 :     else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Ext )      { SMPathName = "DCEXT"; SMName = "DCALExtensionSM";}
     786           0 :     else AliError("Unkown SM Type!!");
     787             : 
     788          20 :     if(geom->GetSMType(smodnum) == tmpType) {
     789          16 :       SMOrder++;
     790          16 :     } else {
     791           4 :       tmpType = geom->GetSMType(smodnum);
     792             :       SMOrder = 1;
     793             :     }
     794             : 
     795          40 :     volpath.Form("ALIC_1/XEN1_1/%s_%d",SMPathName.Data(), SMOrder);
     796          40 :     symname.Form("EMCAL/%s%d",SMName.Data(), SMOrder);
     797             : 
     798          80 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
     799           0 :       AliFatal(Form("AliEMCALv0::Unable to set alignable entry!!\nName: %s\t Path: %s\t ModuleID: %d\n",symname.Data(),volpath.Data(), modUID));
     800             : 
     801             :     // Creates the Tracking to Local transformation matrix for EMCAL
     802             :     // modules                         
     803          20 :     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
     804             : 
     805          40 :     phiRad = GetGeometry()->GetPhiCenterOfSM(smodnum);  //comes in radians, not degrees
     806          20 :     phi = phiRad*180./TMath::Pi();             //need degrees for rot. matrix
     807          20 :     xpos = rpos * TMath::Cos(phiRad);
     808          20 :     ypos = rpos * TMath::Sin(phiRad);
     809          20 :     zpos = pars[2];
     810          20 :     if( geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Half ) {
     811           0 :       xpos += (pars[1]/2. * TMath::Sin(phiRad));  //  half SM!
     812           0 :       ypos -= (pars[1]/2. * TMath::Cos(phiRad));
     813          38 :     } else if ( geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_3rd || geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Ext ) {
     814           4 :       xpos += (pars[1]/3. * TMath::Sin(phiRad));  // one_third SM !
     815           4 :       ypos -= (pars[1]/3. * TMath::Cos(phiRad));
     816          20 :     } else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Standard ) {
     817          18 :       zpos = pars[2]*2./3. + GetGeometry()->GetDCALInnerEdge()/2.;
     818           6 :     }
     819             :     
     820         100 :     AliDebug(3, Form("  fIdRotm %3i phi %6.13f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : smodnum %i \n", 
     821             :                        fIdRotm, phi, phiRad, xpos, ypos, zpos, smodnum));
     822             :    
     823             :     TGeoHMatrix *matTtoL;
     824          20 :     TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
     825             : 
     826          20 :     if(smodnum%2 == 0) {
     827             :       // pozitive z 
     828          10 :       TGeoTranslation geoTran0(xpos, ypos, zpos); 
     829          10 :       TGeoRotation geoRot0("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
     830          10 :       TGeoCombiTrans mat0(geoTran0, geoRot0);
     831          20 :       matTtoL = new TGeoHMatrix(mat0);
     832             : 
     833          20 :       matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
     834          10 :       alignableEntry->SetMatrix(matTtoL);
     835             : 
     836          10 :     } else {
     837             :       // negative z                                                                                 
     838          10 :       Double_t phiy = 90. + phi + 180.;
     839          20 :       if(phiy>=360.) phiy -= 360.;
     840          10 :       TGeoTranslation geoTran1(xpos,ypos,-zpos);
     841          10 :       TGeoRotation geoRot1("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
     842          10 :       TGeoCombiTrans mat1(geoTran1, geoRot1);
     843          20 :       matTtoL = new TGeoHMatrix(mat1);
     844             : 
     845          20 :       matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
     846          10 :       alignableEntry->SetMatrix(matTtoL);
     847             : 
     848          10 :     }
     849             : 
     850             :   }
     851             : 
     852           1 : }
     853             : 
     854             : //______________________________________________________________________
     855             : void AliEMCALv0::AddAlignableVolumesInWSUC() const
     856             : {
     857             :   //
     858             :   // Create entries for alignable volumes associating the symbolic volume
     859             :   // name with the corresponding volume path. Needs to be synchronized with
     860             :   // eventual changes in the geometry.
     861             :   //
     862             : 
     863           0 :   TString vpstr1 = "WSUC_1/XEN1_1/SMOD_";
     864           0 :   TString snstr1 = "EMCAL/CosmicTestSupermodule";
     865           0 :   TString volpath, symname;
     866             : 
     867             :   // #SM is just one 
     868           0 :   for (Int_t smodnum=0; smodnum < 1; smodnum++) {
     869           0 :     symname = snstr1;
     870           0 :     symname += (smodnum+1);
     871           0 :     volpath = vpstr1;
     872           0 :     volpath += (smodnum+1);
     873           0 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
     874           0 :       AliFatal("Unable to set alignable entry!!");
     875             :   }
     876           0 : }

Generated by: LCOV version 1.11