#include <cassert>
#include <TGeometry.h>
#include <TGeoPhysicalNode.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include <TVirtualMC.h>
#include <TArrayI.h>
#include <TROOT.h>
#include <TList.h>
#include <TVector2.h>
#include <cassert>
#include "AliRun.h"
#include "AliLog.h"
#include "AliGeomManager.h"
#include "AliEMCALShishKebabTrd1Module.h"
#include "AliEMCALv0.h"
#include "AliEMCALGeometry.h"
#include "AliEMCALSpaceFrame.h"
ClassImp(AliEMCALv0)
enum
{
kIdAIR = 1599,
kIdPB = 1600,
kIdSC = 1601,
kIdAL = 1602,
kIdSTEEL = 1603,
kIdPAPER = 1604
};
AliEMCALv0::AliEMCALv0()
: AliEMCAL(),
fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0),
fInnerEdge(0),fCalFrame(0)
{
for(Int_t i = 0; i < 5 ; i++) fParEMOD[i]=0.0;
}
AliEMCALv0::AliEMCALv0(const char *name, const char *title,
const Bool_t checkGeoAndRun)
: AliEMCAL(name,title,checkGeoAndRun),
fShishKebabModules(),fEnvelop1(0),fIdRotm(0),fIdTmedArr(0),
fSampleWidth(0),fSmodPar0(0),fSmodPar1(0),fSmodPar2(0),
fInnerEdge(0),fCalFrame(0)
{
for(Int_t i = 0; i < 5 ; i++) fParEMOD[i]=0.0;
TString ntmp(GetTitle());
ntmp.ToUpper();
AliEMCALGeometry *g = GetGeometry() ;
TString gn(g->GetName()); gn.ToUpper();
fShishKebabModules = g->GetShishKebabTrd1Modules();
fGeometry = g;
fSampleWidth = Double_t(g->GetECPbRadThick()+g->GetECScintThick());
if(gn.Contains("V1")) fSampleWidth += 2.*g->GetTrd1BondPaperThick();
AliDebug(2,Form("fGeometry %p : TVirtualMC::GetMC() %p : fSampleWidth %5.4f\n",
fGeometry, TVirtualMC::GetMC(), fSampleWidth));
SetTitle(fGeometry->GetEMCGeometry()->GetName());
}
void AliEMCALv0::CreateGeometry()
{
AliEMCALGeometry * geom = GetGeometry() ;
TString gn(geom->GetName());
gn.ToUpper();
if(!(geom->IsInitialized())){
Error("CreateGeometry","EMCAL Geometry class has not been set up.");
}
fIdTmedArr = fIdtmed->GetArray() - 1599 ;
fIdRotm = 1;
AliMatrix(fIdRotm, 90.0, 0., 90.0, 90.0, 0.0, 0.0) ;
Float_t envelopA[10];
if(gn.Contains("WSUC") ) {
envelopA[0] = 30.;
envelopA[1] = 30;
envelopA[2] = 20;
TVirtualMC::GetMC()->Gsvolu("XEN1", "BOX", fIdTmedArr[kIdSC], envelopA, 3) ;
fEnvelop1.Set(3);
for(Int_t i=0; i<3; i++) fEnvelop1[i] = envelopA[i];
TVirtualMC::GetMC()->Gspos("XEN1", 1, "WSUC", 0.0, 0.0, + 265., fIdRotm, "ONLY") ;
} else {
envelopA[0] = geom->GetArm1PhiMin();
envelopA[1] = geom->GetArm1PhiMax() - geom->GetArm1PhiMin();
envelopA[2] = envelopA[1]/geom->GetEMCGeometry()->GetPhiSuperModule();
envelopA[3] = 2;
envelopA[4] = -geom->GetEnvelop(2)/2.;
envelopA[5] = geom->GetEnvelop(0) ;
envelopA[6] = geom->GetEnvelop(1) ;
envelopA[7] = geom->GetEnvelop(2)/2.;
envelopA[8] = envelopA[5] ;
envelopA[9] = envelopA[6] ;
TVirtualMC::GetMC()->Gsvolu("XEN1", "PGON", fIdTmedArr[kIdAIR], envelopA, 10) ;
fEnvelop1.Set(10, envelopA);
if (gDebug==2) {
printf("CreateGeometry: XEN1 = %f, %f\n", envelopA[5], envelopA[6]);
printf("CreateGeometry: XU0 = %f, %f\n", envelopA[5], envelopA[6]);
}
TVirtualMC::GetMC()->Gspos(geom->GetNameOfEMCALEnvelope(), 1, "ALIC", 0.0, 0.0, 0.0, fIdRotm, "ONLY") ;
}
AliDebug(2,Form("Shish-Kebab geometry : %s", GetTitle()));
CreateShishKebabGeometry();
if(gn.Contains("WSUC")==0) {
AliDebug(2,"Creating EMCAL Space Frame");
fCalFrame = new AliEMCALSpaceFrame();
fCalFrame->CreateGeometry();
}
}
void AliEMCALv0::Init(void)
{
AliEMCAL::Init();
if(AliLog::GetGlobalDebugLevel()>0) {
TString message("\n") ;
message += "*****************************************\n" ;
AliEMCALGeometry * geom = GetGeometry() ;
if (geom!=0) {
message += "AliEMCAL " ;
message += Version() ;
message += "EMCAL geometry initialized for " ;
message += geom->GetName() ;
}
else {
message += "AliEMCAL " ;
message += Version() ;
message += "EMCAL geometry initialization failed !" ;
}
message += "\n*****************************************" ;
printf("%s",message.Data() ) ;
}
}
void AliEMCALv0::CreateShishKebabGeometry()
{
AliEMCALGeometry * g = GetGeometry();
TString gn(g->GetName()); gn.ToUpper();
Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
Double_t par[10], xpos=0., ypos=0., zpos=0.;
CreateSmod(g->GetNameOfEMCALEnvelope());
Int_t * SMTypeList = g->GetEMCSystem();
Int_t tmpType = -1;
for(Int_t i = 0 ; i < g->GetNumberOfSuperModules(); i++) {
if( SMTypeList[i] == tmpType) continue;
else tmpType = SMTypeList[i];
if( tmpType == AliEMCALGeometry::kEMCAL_Standard ) CreateEmod("SMOD","EMOD");
else if( tmpType == AliEMCALGeometry::kEMCAL_Half ) CreateEmod("SM10","EMOD");
else if( tmpType == AliEMCALGeometry::kEMCAL_3rd ) CreateEmod("SM3rd","EMOD");
else if( tmpType == AliEMCALGeometry::kDCAL_Standard ) CreateEmod("DCSM","EMOD");
else if( tmpType == AliEMCALGeometry::kDCAL_Ext ) CreateEmod("DCEXT","EMOD");
else AliError("Unkown SM Type!!");
}
Double_t parSCM0[5]={0,0,0,0}, *dummy = 0, parTRAP[11];
if(!gn.Contains("V1")) {
Double_t wallThickness = g->GetPhiModuleSize()/g->GetNPHIdiv() - g->GetPhiTileSize();
for(Int_t i=0; i<3; i++) parSCM0[i] = fParEMOD[i] - wallThickness;
parSCM0[3] = fParEMOD[3];
TVirtualMC::GetMC()->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
TVirtualMC::GetMC()->Gspos("SCM0", 1, "EMOD", 0., 0., 0., 0, "ONLY") ;
} else {
Double_t wTh = g->GetLateralSteelStrip();
parSCM0[0] = fParEMOD[0] - wTh + tanTrd1*g->GetTrd1AlFrontThick();
parSCM0[1] = fParEMOD[1] - wTh;
parSCM0[2] = fParEMOD[2] - wTh;
parSCM0[3] = fParEMOD[3] - g->GetTrd1AlFrontThick()/2.;
TVirtualMC::GetMC()->Gsvolu("SCM0", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
Double_t zshift = g->GetTrd1AlFrontThick()/2.;
TVirtualMC::GetMC()->Gspos("SCM0", 1, "EMOD", 0., 0., zshift, 0, "ONLY");
CreateAlFrontPlate("EMOD","ALFP");
}
if(g->GetNPHIdiv()==2 && g->GetNETAdiv()==2) {
AliDebug(2,Form(" Divide SCM0 on y-axis %i\n", g->GetNETAdiv()));
TVirtualMC::GetMC()->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2);
parTRAP[0] = parSCM0[3];
parTRAP[1] = TMath::ATan2((parSCM0[1]-parSCM0[0])/2.,2.*parSCM0[3])*180./TMath::Pi();
parTRAP[2] = 0.;
parTRAP[3] = parSCM0[2]/2.;
parTRAP[4] = parSCM0[0]/2.;
parTRAP[5] = parTRAP[4];
parTRAP[6] = 0.0;
parTRAP[7] = parSCM0[2]/2.;
parTRAP[8] = parSCM0[1]/2.;
parTRAP[9] = parTRAP[8];
parTRAP[10]= 0.0;
AliDebug(2,Form(" ** TRAP ** \n"));
for(Int_t i=0; i<11; i++) AliDebug(3, Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
TVirtualMC::GetMC()->Gsvolu("SCMX", "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
xpos = +(parSCM0[1]+parSCM0[0])/4.;
TVirtualMC::GetMC()->Gspos("SCMX", 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
xpos = -xpos;
AliMatrix(fIdRotm, 90.0,180., 90.0, 270.0, 0.0,0.0) ;
TVirtualMC::GetMC()->Gspos("SCMX", 2, "SCMY", xpos, 0.0, 0.0, fIdRotm, "ONLY");
AliEMCALShishKebabTrd1Module *mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(0);
Double_t tanBetta = mod->GetTanBetta();
Int_t nr=0;
ypos = 0.0;
Double_t xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.;
if(!gn.Contains("V1")) {
par[1] = parSCM0[2]/2;
par[2] = g->GetECPbRadThick()/2.;
TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
AliDebug(2,Form(" Pb tiles \n"));
for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
par[0] = (parSCM0[0] + tanBetta*fSampleWidth*iz)/2.;
xpos = par[0] - xCenterSCMX;
TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, "SCMX", xpos, ypos, zpos, 0, "ONLY", par, 3) ;
AliDebug(3,Form(" %i xpos %f zpos %f par[0] %f \n", iz+1, xpos, zpos, par[0]));
zpos += fSampleWidth;
}
AliDebug(2,Form(" Number of Pb tiles in SCMX %i \n", nr));
} else {
par[1] = parSCM0[2]/2.;
par[2] = g->GetTrd1BondPaperThick()/2.;
par[0] = parSCM0[0]/2.;
TVirtualMC::GetMC()->Gsvolu("PAP1", "BOX", fIdTmedArr[kIdPAPER], par, 3);
xpos = par[0] - xCenterSCMX;
zpos = -parSCM0[3] + g->GetTrd1BondPaperThick()/2.;
TVirtualMC::GetMC()->Gspos("PAP1", 1, "SCMX", xpos, ypos, zpos, 0, "ONLY");
for(Int_t iz=0; iz<g->GetNECLayers()-1; iz++){
nr = iz + 1;
Double_t dz = g->GetECScintThick() + g->GetTrd1BondPaperThick() + fSampleWidth*iz;
par[2] = g->GetECPbRadThick()/2. + g->GetTrd1BondPaperThick();
par[0] = (parSCM0[0] + tanBetta*dz)/2.;
TString pa(Form("PA%2.2i",nr));
TVirtualMC::GetMC()->Gsvolu(pa.Data(), "BOX", fIdTmedArr[kIdPAPER], par, 3);
xpos = par[0] - xCenterSCMX;
zpos = -parSCM0[3] + dz + par[2];
TVirtualMC::GetMC()->Gspos(pa.Data(), 1, "SCMX", xpos, ypos, zpos, 0, "ONLY") ;
TString pb(Form("PB%2.2i",nr));
par[2] = g->GetECPbRadThick()/2.;
TVirtualMC::GetMC()->Gsvolu(pb.Data(), "BOX", fIdTmedArr[kIdPB], par, 3);
TVirtualMC::GetMC()->Gspos(pb.Data(), 1, pa.Data(), 0.0, 0.0, 0.0, 0, "ONLY") ;
}
}
} else if(g->GetNPHIdiv()==3 && g->GetNETAdiv()==3) {
printf(" before AliEMCALv0::Trd1Tower3X3() : parSCM0");
for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
printf("\n");
Trd1Tower3X3(parSCM0);
} else if(g->GetNPHIdiv()==1 && g->GetNETAdiv()==1) {
Trd1Tower1X1(parSCM0);
}
}
void AliEMCALv0::CreateSmod(const char* mother)
{
AliEMCALGeometry * g = GetGeometry();
TString gn(g->GetName()); gn.ToUpper();
Double_t par[3], xpos=0., ypos=0., zpos=0., rpos=0., dphi=0., phi=0.0, phiRad=0.;
Double_t parC[3] = {0};
TString smName;
Int_t tmpType = -1;
AliDebug(2,Form("\n ## Super Module | fSampleWidth %5.3f ## %s \n", fSampleWidth, gn.Data()));
par[0] = g->GetShellThickness()/2.;
par[1] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
par[2] = g->GetEtaModuleSize()*g->GetNEta()/2.;
fIdRotm=0;
Int_t nSMod = g->GetNumberOfSuperModules();
Int_t nphism = nSMod/2;
if(nphism > 0) {
dphi = g->GetEMCGeometry()->GetPhiSuperModule();
rpos = (g->GetEnvelop(0) + g->GetEnvelop(1))/2.;
AliDebug(2,Form(" rpos %8.2f : dphi %6.1f degree \n", rpos, dphi));
}
if(gn.Contains("WSUC")) {
Int_t nr=0;
par[0] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
par[1] = g->GetShellThickness()/2.;
par[2] = g->GetEtaModuleSize()*g->GetNZ()/2. + 5;
TVirtualMC::GetMC()->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
AliDebug(2,Form("SMOD in WSUC : tmed %i | dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
fIdTmedArr[kIdAIR], par[0],par[1],par[2]));
fSmodPar0 = par[0];
fSmodPar1 = par[1];
fSmodPar2 = par[2];
nphism = g->GetNumberOfSuperModules();
for(Int_t i=0; i<nphism; i++) {
xpos = ypos = zpos = 0.0;
fIdRotm = 0;
TVirtualMC::GetMC()->Gspos("SMOD", 1, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
printf(" fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n",
fIdRotm, phi, phiRad, xpos, ypos, zpos);
nr++;
}
} else {
AliDebug(2,Form(" par[0] %7.2f (old) \n", par[0]));
for(Int_t i=0; i<3; i++) par[i] = g->GetSuperModulesPar(i);
fSmodPar0 = par[0];
fSmodPar2 = par[2];
Int_t SMOrder = -1;
tmpType = -1;
for (Int_t smodnum = 0; smodnum < nSMod; ++smodnum) {
for(Int_t i=0; i<3; i++) parC[i] = par[i];
if(g->GetSMType(smodnum) == tmpType) {
SMOrder++;
} else {
tmpType = g->GetSMType(smodnum);
SMOrder = 1;
}
phiRad = g->GetPhiCenterOfSMSec(smodnum);
phi = phiRad *180./TMath::Pi();
Double_t phiy = 90. + phi;
Double_t phiz = 0.;
xpos = rpos * TMath::Cos(phiRad);
ypos = rpos * TMath::Sin(phiRad);
zpos = fSmodPar2;
if( tmpType == AliEMCALGeometry::kEMCAL_Standard ) {
smName="SMOD";
} else if( tmpType == AliEMCALGeometry::kEMCAL_Half ) {
smName="SM10";
parC[1] /= 2.;
xpos += (par[1]/2. * TMath::Sin(phiRad));
ypos -= (par[1]/2. * TMath::Cos(phiRad));
} else if( tmpType == AliEMCALGeometry::kEMCAL_3rd ) {
smName="SM3rd";
parC[1] /= 3.;
xpos += (2.*par[1]/3. * TMath::Sin(phiRad));
ypos -= (2.*par[1]/3. * TMath::Cos(phiRad));
} else if( tmpType == AliEMCALGeometry::kDCAL_Standard ) {
smName="DCSM";
parC[2] *= 2./3.;
zpos = fSmodPar2 + g->GetDCALInnerEdge()/2.;
} else if( tmpType == AliEMCALGeometry::kDCAL_Ext ) {
smName="DCEXT";
parC[1] /= 3.;
xpos += (2.*par[1]/3. * TMath::Sin(phiRad));
ypos -= (2.*par[1]/3. * TMath::Cos(phiRad));
} else AliError("Unkown SM Type!!");
if(SMOrder == 1) {
TVirtualMC::GetMC()->Gsvolu(smName.Data(), "BOX", fIdTmedArr[kIdAIR], parC, 3);
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]));
}
if( smodnum%2 == 1) {
phiy += 180.;
if(phiy>=360.) phiy -= 360.;
phiz = 180.;
zpos *= -1.;
}
AliMatrix(fIdRotm, 90.0, phi, 90.0, phiy, phiz, 0.0);
TVirtualMC::GetMC()->Gspos(smName.Data(), SMOrder, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
AliDebug(3, Form(" %s : %2i, fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : i %i \n",
smName.Data(), SMOrder, fIdRotm, phi, phiRad, xpos, ypos, zpos, smodnum));
}
}
AliDebug(2,Form(" Number of Super Modules %i \n", nSMod));
if(g->GetSteelFrontThickness() > 0.0) {
par[0] = g->GetSteelFrontThickness()/2.;
TVirtualMC::GetMC()->Gsvolu("STPL", "BOX", fIdTmedArr[kIdSTEEL], par, 3);
printf("tmed %i | dx %7.2f dy %7.2f dz %7.2f (STPL) \n", fIdTmedArr[kIdSTEEL], par[0],par[1],par[2]);
xpos = -(g->GetShellThickness() - g->GetSteelFrontThickness())/2.;
TVirtualMC::GetMC()->Gspos("STPL", 1, "SMOD", xpos, 0.0, 0.0, 0, "ONLY") ;
}
}
void AliEMCALv0::CreateEmod(const char* mother, const char* child)
{
AliEMCALGeometry * g = GetGeometry();
TString gn(g->GetName()); gn.ToUpper();
Double_t xpos=0., ypos=0., zpos=0.;
if(strcmp(mother,"SMOD")==0) {
fParEMOD[0] = g->GetEtaModuleSize()/2.;
fParEMOD[1] = g->Get2Trd1Dx2()/2.;
fParEMOD[2] = g->GetPhiModuleSize()/2.;;
fParEMOD[3] = g->GetLongModuleSize()/2.;
TVirtualMC::GetMC()->Gsvolu(child, "TRD1", fIdTmedArr[kIdSTEEL], fParEMOD, 4);
}
Int_t nr=0;
fIdRotm=0;
AliEMCALShishKebabTrd1Module *mod=0;
for(Int_t iz=0; iz<g->GetNZ(); iz++) {
Double_t angle=90., phiOK=0;
mod = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(iz);
angle = mod->GetThetaInDegree();
if(!gn.Contains("WSUC")) {
AliMatrix(fIdRotm, 90.-angle,180., 90.0,90.0, angle, 0.);
phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
AliDebug(4,Form(" %2i | angle | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule()));
xpos = mod->GetPosXfromR() + g->GetSteelFrontThickness() - fSmodPar0;
zpos = mod->GetPosZ() - fSmodPar2;
Int_t iyMax = g->GetNPhi();
if(strcmp(mother,"SM10") == 0 ) {
iyMax /= 2;
} else if(strcmp(mother,"SM3rd") == 0 ) {
iyMax /= 3;
} else if(strcmp(mother,"DCEXT") == 0 ) {
iyMax /= 3;
} else if(strcmp(mother,"DCSM") == 0 ) {
if(iz < 8 ) continue;
zpos = mod->GetPosZ() - fSmodPar2 - g->GetDCALInnerEdge()/2.;
} else if(strcmp(mother,"SMOD") != 0 )
AliError("Unknown super module Type!!");
for(Int_t iy=0; iy<iyMax; iy++) {
ypos = g->GetPhiModuleSize()*(2*iy+1 - iyMax)/2.;
TVirtualMC::GetMC()->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
AliDebug(3,Form("%3.3i(%2.2i,%2.2i) ", nr,iy+1,iz+1));
}
} else {
if(iz == 0) AliMatrix(fIdRotm, 0.,0., 90.,0., 90.,90.);
else AliMatrix(fIdRotm, 90-angle,270., 90.0,0.0, angle,90.);
phiOK = mod->GetCenterOfModule().Phi()*180./TMath::Pi();
AliDebug(4,Form(" %2i | angle -phiOK | %6.3f - %6.3f = %6.3f(eta %5.3f)\n",
iz+1, angle, phiOK, angle-phiOK, mod->GetEtaOfCenterOfModule()));
zpos = mod->GetPosZ() - fSmodPar2;
ypos = mod->GetPosXfromR() - fSmodPar1;
for(Int_t ix=0; ix<g->GetNPhi(); ix++)
{
xpos = g->GetPhiModuleSize()*(2*ix+1 - g->GetNPhi())/2.;
TVirtualMC::GetMC()->Gspos(child, ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
}
}
}
AliDebug(2,Form(" Number of modules in Super Module(%s) %i \n", mother, nr));
}
void AliEMCALv0::CreateAlFrontPlate(const char* mother, const char* child)
{
AliEMCALGeometry * g = GetGeometry();
TString gn(g->GetName()); gn.ToUpper();
Double_t trd1Angle = g->GetTrd1Angle()*TMath::DegToRad(), tanTrd1 = TMath::Tan(trd1Angle/2.);
Double_t parALFP[5], zposALFP=0.;
parALFP[0] = g->GetEtaModuleSize()/2. - g->GetLateralSteelStrip();
parALFP[1] = parALFP[0] + tanTrd1*g->GetTrd1AlFrontThick();
parALFP[2] = g->GetPhiModuleSize()/2. - g->GetLateralSteelStrip();
parALFP[3] = g->GetTrd1AlFrontThick()/2.;
TVirtualMC::GetMC()->Gsvolu(child, "TRD1", fIdTmedArr[kIdAL], parALFP, 4);
zposALFP = -fParEMOD[3] + g->GetTrd1AlFrontThick()/2.;
TVirtualMC::GetMC()->Gspos (child, 1, mother, 0.0, 0.0, zposALFP, 0, "ONLY");
}
void AliEMCALv0::Trd1Tower3X3(const Double_t *parSCM0)
{
printf(" AliEMCALv0::Trd1Tower3X3() : parSCM0");
for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
printf("\n");
Double_t parTRAP[11], *dummy=0;
AliEMCALGeometry * g = GetGeometry();
TString gn(g->GetName()), scmx;
gn.ToUpper();
AliDebug(2,Form("Trd1Tower3X3() : Divide SCM0 on y-axis %i", g->GetNETAdiv()));
TVirtualMC::GetMC()->Gsdvn("SCMY","SCM0", g->GetNETAdiv(), 2);
Double_t dx1=parSCM0[0], dx2=parSCM0[1], dy=parSCM0[2], dz=parSCM0[3];
Double_t ndiv=3., xpos=0.0;
TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
for(Int_t ix=1; ix<=3; ix++) {
scmx = "SCX";
parTRAP[0] = dz;
Double_t xCentBot = 2.*dx1/3.;
Double_t xCentTop = 2.*(dx2/4. + dx1/12.);
parTRAP[1] = TMath::ATan2((xCentTop-xCentBot),2.*dz)*TMath::RadToDeg();
parTRAP[2] = 0.;
parTRAP[3] = dy/ndiv;
parTRAP[4] = dx1/ndiv;
parTRAP[5] = parTRAP[4];
parTRAP[6] = 0.0;
parTRAP[7] = dy/ndiv;
parTRAP[8] = dx2/2 - dx1/6.;
parTRAP[9] = parTRAP[8];
parTRAP[10]= 0.0;
xpos = (xCentBot+xCentTop)/2.;
if (ix==3) {
parTRAP[1] = -parTRAP[1];
xpos = -xpos;
} else if(ix==2) {
parTRAP[1] = 0.;
parTRAP[8] = dx1/ndiv;
parTRAP[9] = parTRAP[8];
xpos = 0.0;
}
AliDebug(2,Form(" ** TRAP ** xpos %9.3f\n", xpos));
for(Int_t i=0; i<11; i++) AliDebug(2,Form(" par[%2.2i] %9.4f\n", i, parTRAP[i]));
scmx += ix;
TVirtualMC::GetMC()->Gsvolu(scmx.Data(), "TRAP", fIdTmedArr[kIdSC], parTRAP, 11);
TVirtualMC::GetMC()->Gspos(scmx.Data(), 1, "SCMY", xpos, 0.0, 0.0, 0, "ONLY") ;
PbInTrap(parTRAP, scmx);
}
AliDebug(2,"Trd1Tower3X3 - Ver. 1.0 : was tested.");
}
void AliEMCALv0::PbInTrap(const Double_t parTRAP[11], TString n)
{
static Int_t nr=0;
AliDebug(2,Form(" Pb tiles : nrstart %i\n", nr));
AliEMCALGeometry * g = GetGeometry();
Double_t par[3];
Double_t xpos = 0.0, ypos = 0.0;
Double_t zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
Double_t coef = (parTRAP[8] - parTRAP[4]) / (2.*parTRAP[0]);
Double_t xCenterSCMX = (parTRAP[4] + parTRAP[8])/2.;
par[1] = parTRAP[3];
par[2] = g->GetECPbRadThick()/2.;
for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
par[0] = parTRAP[4] + coef*fSampleWidth*iz;
xpos = par[0] - xCenterSCMX;
if(parTRAP[1] < 0.) xpos = -xpos;
TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
zpos += fSampleWidth;
if(iz%2>0) printf("\n");
}
AliDebug(2,Form(" Number of Pb tiles in SCMX %i coef %9.7f \n", nr, coef));
AliDebug(2,Form(" par[1] %9.3f par[2] %9.3f ypos %9.3f \n", par[1], par[2], ypos));
AliDebug(2,Form(" PbInTrap Ver. 1.0 : was tested."));
}
void AliEMCALv0::Trd1Tower1X1(Double_t *parSCM0)
{
AliDebug(1," AliEMCALv0::Trd1Tower1X1() : parSCM0");
for(Int_t i=0; i<4; i++) printf(" %7.4f ", parSCM0[i]);
printf("\n");
AliDebug(2,"Trd1Tower1X1() : Create SCMX(SCMY) as SCM0");
TVirtualMC::GetMC()->Gsvolu("SCMY", "TRD1", fIdTmedArr[kIdAIR], parSCM0, 4);
TVirtualMC::GetMC()->Gspos("SCMY", 1, "SCM0", 0.0, 0.0, 0.0, 0, "ONLY");
TVirtualMC::GetMC()->Gsvolu("SCMX", "TRD1", fIdTmedArr[kIdSC], parSCM0, 4);
TVirtualMC::GetMC()->Gspos("SCMX", 1, "SCMY", 0.0, 0.0, 0.0, 0, "ONLY");
Double_t *dummy=0;
TVirtualMC::GetMC()->Gsvolu("PBTI", "BOX", fIdTmedArr[kIdPB], dummy, 0);
PbInTrd1(parSCM0, "SCMX");
AliDebug(1,"Trd1Tower1X1() : Ver. 0.1 : was tested.");
}
void AliEMCALv0::PbInTrd1(const Double_t *parTrd1, TString n)
{
static Int_t nr=0, ndeb=2;
AliDebug(ndeb,Form(" Pb tiles : nrstart %i\n", nr));
AliEMCALGeometry * g = GetGeometry();
Double_t par[3];
Double_t xpos = 0.0, ypos = 0.0;
Double_t zpos = -fSampleWidth*g->GetNECLayers()/2. + g->GetECPbRadThick()/2.;
Double_t coef = (parTrd1[1] - parTrd1[0]) / (2.*parTrd1[3]);
par[1] = parTrd1[2];
par[2] = g->GetECPbRadThick()/2.;
for(Int_t iz=0; iz<g->GetNECLayers(); iz++){
par[0] = parTrd1[0] + coef*fSampleWidth*iz;
TVirtualMC::GetMC()->Gsposp("PBTI", ++nr, n.Data(), xpos, ypos, zpos, 0, "ONLY", par, 3) ;
AliDebug(2,Form(" %i xpos %9.3f zpos %9.3f par[0] %9.3f |", iz+1, xpos, zpos, par[0]));
zpos += fSampleWidth;
if(iz%2>0) printf("\n");
}
AliDebug(ndeb,Form(" Number of Pb tiles in SCMX %i coef %9.7f ", nr, coef));
AliDebug(ndeb,Form(" PbInTrd1 Ver. 0.1 : was tested."));
}
AliEMCALShishKebabTrd1Module* AliEMCALv0::GetShishKebabModule(Int_t neta)
{
AliEMCALShishKebabTrd1Module* trd1=0;
if(fShishKebabModules && neta>=0 && neta<fShishKebabModules->GetSize()) {
trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabModules->At(neta);
}
return trd1;
}
void AliEMCALv0::AddAlignableVolumes() const
{
TString ntmp(GetTitle());
if(ntmp.Contains("WSUC")) {
AddAlignableVolumesInWSUC();
} else {
AddAlignableVolumesInALICE();
}
}
void AliEMCALv0::AddAlignableVolumesInALICE() const
{
Float_t pars[] = {GetGeometry()->GetSuperModulesPar(0),GetGeometry()->GetSuperModulesPar(1),GetGeometry()->GetSuperModulesPar(2)};
Double_t rpos = (GetGeometry()->GetEnvelop(0) + GetGeometry()->GetEnvelop(1))/2.;
Double_t phi, phiRad, xpos, ypos, zpos;
AliGeomManager::ELayerID idEMCAL = AliGeomManager::kEMCAL;
Int_t modUID, modnum = 0;
TString volpath, symname;
AliEMCALGeometry * geom = GetGeometry();
Int_t nSMod = geom->GetNumberOfSuperModules();
TString SMPathName;
TString SMName;
Int_t tmpType = -1;
Int_t SMOrder = 0;
for (Int_t smodnum = 0; smodnum < nSMod; ++smodnum) {
modUID = AliGeomManager::LayerToVolUID(idEMCAL,modnum++);
if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Standard ) { SMPathName = "SMOD"; SMName = "FullSupermodule";}
else if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Half ) { SMPathName = "SM10"; SMName = "HalfSupermodule";}
else if(geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_3rd ) { SMPathName = "SM3rd"; SMName = "OneThrdSupermodule";}
else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Standard ) { SMPathName = "DCSM"; SMName = "DCALSupermodule";}
else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Ext ) { SMPathName = "DCEXT"; SMName = "DCALExtensionSM";}
else AliError("Unkown SM Type!!");
if(geom->GetSMType(smodnum) == tmpType) {
SMOrder++;
} else {
tmpType = geom->GetSMType(smodnum);
SMOrder = 1;
}
volpath.Form("ALIC_1/XEN1_1/%s_%d",SMPathName.Data(), SMOrder);
symname.Form("EMCAL/%s%d",SMName.Data(), SMOrder);
if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
AliFatal(Form("AliEMCALv0::Unable to set alignable entry!!\nName: %s\t Path: %s\t ModuleID: %d\n",symname.Data(),volpath.Data(), modUID));
TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
phiRad = GetGeometry()->GetPhiCenterOfSM(smodnum);
phi = phiRad*180./TMath::Pi();
xpos = rpos * TMath::Cos(phiRad);
ypos = rpos * TMath::Sin(phiRad);
zpos = pars[2];
if( geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_Half ) {
xpos += (pars[1]/2. * TMath::Sin(phiRad));
ypos -= (pars[1]/2. * TMath::Cos(phiRad));
} else if ( geom->GetSMType(smodnum) == AliEMCALGeometry::kEMCAL_3rd || geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Ext ) {
xpos += (pars[1]/3. * TMath::Sin(phiRad));
ypos -= (pars[1]/3. * TMath::Cos(phiRad));
} else if( geom->GetSMType(smodnum) == AliEMCALGeometry::kDCAL_Standard ) {
zpos = pars[2]*2./3. + GetGeometry()->GetDCALInnerEdge()/2.;
}
AliDebug(3, Form(" fIdRotm %3i phi %6.13f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f : smodnum %i \n",
fIdRotm, phi, phiRad, xpos, ypos, zpos, smodnum));
TGeoHMatrix *matTtoL;
TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
if(smodnum%2 == 0) {
TGeoTranslation geoTran0(xpos, ypos, zpos);
TGeoRotation geoRot0("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
TGeoCombiTrans mat0(geoTran0, geoRot0);
matTtoL = new TGeoHMatrix(mat0);
matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
alignableEntry->SetMatrix(matTtoL);
} else {
Double_t phiy = 90. + phi + 180.;
if(phiy>=360.) phiy -= 360.;
TGeoTranslation geoTran1(xpos,ypos,-zpos);
TGeoRotation geoRot1("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
TGeoCombiTrans mat1(geoTran1, geoRot1);
matTtoL = new TGeoHMatrix(mat1);
matTtoL->MultiplyLeft(&(globMatrix->Inverse()));
alignableEntry->SetMatrix(matTtoL);
}
}
}
void AliEMCALv0::AddAlignableVolumesInWSUC() const
{
TString vpstr1 = "WSUC_1/XEN1_1/SMOD_";
TString snstr1 = "EMCAL/CosmicTestSupermodule";
TString volpath, symname;
for (Int_t smodnum=0; smodnum < 1; smodnum++) {
symname = snstr1;
symname += (smodnum+1);
volpath = vpstr1;
volpath += (smodnum+1);
if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
AliFatal("Unable to set alignable entry!!");
}
}