+void AliEMCALv0::CreateSmod(const char* mother)
+{
+ // 18-may-05; mother="XEN1";
+ // child="SMOD" from first to 10th, "SM10" (11th and 12th) (TRD1 case)
+ // child="SMON" and "SMOP"("TRD2" case)
+ AliEMCALGeometry * g = GetGeometry();
+ TString gn(g->GetName()); gn.ToUpper();
+
+ Double_t par[3], parTubs[5], xpos=0., ypos=0., zpos=0., rpos=0., dphi=0., phi=0.0, phiRad=0.;
+ Double_t par1C = 0.;
+ // ===== define Super Module from air - 14x30 module ==== ;
+ fSampleWidth = double(g->GetECPbRadThick()+g->GetECScintThick());
+ 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()*15.;
+ fIdRotm=0;
+ int nphism = g->GetNumberOfSuperModules()/2; // 20-may-05
+ if(nphism>0) {
+ dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/nphism;
+ // if(g->GetKey110DEG()) dphi = (g->GetArm1PhiMax() - g->GetArm1PhiMin())/(nphism-1);
+ rpos = (g->GetEnvelop(0) + g->GetEnvelop(1))/2.;
+ AliDebug(2,Form(" rpos %8.2f : dphi %6.1f degree \n", rpos, dphi));
+ }
+
+ if (gn.Contains("TRD2")) { // tubs - 27-jan-05
+ parTubs[0] = g->GetTubsR(); // rmin
+ parTubs[1] = parTubs[0] + g->GetShellThickness(); // rmax ??
+ parTubs[2] = 380./2.; // DZ half length in z; 11-oct-04 - for 26 division
+ parTubs[3] = -dphi/2.; // PHI1 starting angle of the segment;
+ parTubs[4] = +dphi/2.; // PHI2 ending angle of the segment;
+
+ gMC->Gsvolu("SMOP", "TUBS", fIdTmedArr[kIdAIR], parTubs, 5); // pozitive Z
+ gMC->Gsvolu("SMON", "TUBS", fIdTmedArr[kIdAIR], parTubs, 5); // negative Z
+
+ AliDebug(2,Form(" SMOP,N ** TUBS **\n"));
+ AliDebug(2,Form("tmed %i | Rmin %7.2f Rmax %7.2f dz %7.2f phi1,2 (%7.2f,%7.2f)\n",
+ fIdTmedArr[kIdAIR], parTubs[0],parTubs[1],parTubs[2], parTubs[3],parTubs[4]));
+ // have to add 1 cm plastic before EMOD - time solution
+ } else if(gn.Contains("WSUC")) {
+ par[0] = g->GetPhiModuleSize()*g->GetNPhi()/2.;
+ par[1] = g->GetShellThickness()/2.;
+ par[2] = g->GetEtaModuleSize()*g->GetNZ()/2. + 5;
+
+ gMC->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();
+ } else {
+ if (gn.Contains("TWIST")) {
+ par[2] += 0.4; // for 27 division
+ } else if(gn.Contains("TRD")) {
+ par[2] = 350./2.; // 11-oct-04 - for 26 division
+ if(gn.Contains("TRD1")) {
+ AliDebug(2,Form(" par[0] %7.2f (old) \n", par[0]));
+ Float_t *parSM = g->GetSuperModulesPars();
+ for(int i=0; i<3; i++) par[i] = parSM[i];
+ }
+ }
+ gMC->Gsvolu("SMOD", "BOX", fIdTmedArr[kIdAIR], par, 3);
+ AliDebug(2,Form("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];
+ fSmodPar2 = par[2];
+ if(g->GetKey110DEG()) { // 12-oct-05
+ par1C = par[1];
+ par[1] /= 2.;
+ gMC->Gsvolu("SM10", "BOX", fIdTmedArr[kIdAIR], par, 3);
+ AliDebug(2,Form(" Super module with name \"SM10\" was created too par[1] = %f\n", par[1]));
+ par[1] = par1C;
+ }
+ // Steel plate
+ if(g->GetSteelFrontThickness() > 0.0) { // 28-mar-05
+ par[0] = g->GetSteelFrontThickness()/2.;
+ gMC->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.;
+ gMC->Gspos("STPL", 1, "SMOD", xpos, 0.0, 0.0, 0, "ONLY") ;
+ }
+ }
+
+ int nr=0, nrsmod=0, i0=0;
+ if(gn.Contains("TEST")) {nphism = 1;} // just only 2 super modules;
+
+ // Turn whole super module
+ int turnSupMod = 1; // should be ONE; for testing = 0
+ for(int i=i0; i<nphism; i++) {
+ if (gn.Contains("TRD2")) { // tubs - 27-jan-05
+ if(i==i0) {
+ printf("** TRD2 ** ");
+ if(turnSupMod==1) printf(" No 3 degree rotation !!! ");
+ printf("\n");
+ }
+ Double_t phic=0., phicRad=0.; // phi angle of arc center
+ phic = g->GetArm1PhiMin() + dphi*(2*i+1)/2.; //
+ phicRad = phic*TMath::DegToRad();
+ phi = phic - g->GetTubsTurnAngle();
+ phiRad = phi*TMath::DegToRad();
+ if(turnSupMod==1) {
+ TVector2 vc; // position of super module center
+ vc.SetMagPhi(parTubs[0], phicRad);
+ TVector2 vcTurn; // position of super module center with turn
+ vcTurn.SetMagPhi(parTubs[0], phiRad);
+ TVector2 vcShift = vc - vcTurn;
+ phic = phi;
+
+ xpos = vcShift.X();
+ ypos = vcShift.Y();
+ } else { // 1-mar-05 ; just for testing - no turn od SMOD; looks good
+ xpos = ypos = 0.0;
+ }
+ zpos = parTubs[2];
+ AliMatrix(fIdRotm, 90.0, phic, 90.0, 90.0+phic, 0.0, 0.0);
+
+ gMC->Gspos("SMOP", ++nr, mother, xpos, ypos, zpos, fIdRotm, "ONLY") ;
+ printf("SMOP %2i | %2i fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n",
+ i, nr, fIdRotm, phic, phicRad, xpos, ypos, zpos);
+ printf(" phiy(90+phic) %6.1f \n", 90. + phic);
+
+ if(!gn.Contains("TEST1") && g->GetNumberOfSuperModules() > 1){
+ // double phiy = 90. + phic + 180.;
+ // if(phiy>=360.) phiy -= 360.;
+ // printf(" phiy %6.1f \n", phiy);
+ // AliMatrix(fIdRotm, 90.0, phic, 90.0, phiy, 180.0, 0.0);
+ gMC->Gspos("SMON", nr, mother, xpos, ypos, -zpos, fIdRotm, "ONLY") ;
+ printf("SMON %2i | %2i fIdRotm %3i phi %6.1f(%5.3f) xpos %7.2f ypos %7.2f zpos %7.2f \n",
+ i, nr, fIdRotm, phic, phicRad, xpos, ypos, -zpos);
+ }
+ } else if(gn.Contains("WSUC")) {
+ xpos = ypos = zpos = 0.0;
+ fIdRotm = 0;
+ gMC->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 { // TRD1
+ TString smName("SMOD"); // 12-oct-05
+ if(i==5 && g->GetKey110DEG()) {
+ smName = "SM10";
+ nrsmod = nr;
+ nr = 0;
+ }
+ phi = g->GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 70, 90, 110, 130, 150, 170
+ phiRad = phi*TMath::Pi()/180.;
+
+ AliMatrix(fIdRotm, 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
+
+ xpos = rpos * TMath::Cos(phiRad);
+ ypos = rpos * TMath::Sin(phiRad);
+ zpos = fSmodPar2; // 21-sep-04
+ if(i==5 && g->GetKey110DEG()) {
+ xpos += (par1C/2. * TMath::Sin(phiRad));
+ ypos -= (par1C/2. * TMath::Cos(phiRad));
+ }
+
+ // 1th module in z-direction;
+ gMC->Gspos(smName.Data(), ++nr, 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(), nr, fIdRotm, phi, phiRad, xpos, ypos, zpos, i));
+ // 2th module in z-direction;
+ if(gn.Contains("TWIST") || gn.Contains("TRD")) {
+ // turn arround X axis; 0<phi<360
+ double phiy = 90. + phi + 180.;
+ if(phiy>=360.) phiy -= 360.;
+
+ AliMatrix(fIdRotm, 90.0, phi, 90.0, phiy, 180.0, 0.0);
+ gMC->Gspos(smName.Data(), ++nr, mother, xpos, ypos, -zpos, fIdRotm, "ONLY");
+ AliDebug(3, Form(" %s : %2i fIdRotm %3i phiy %6.1f xpos %7.2f ypos %7.2f zpos %7.2f \n",
+ smName.Data(), nr, fIdRotm, phiy, xpos, ypos, -zpos));
+ } else {
+ gMC->Gspos("SMOD", ++nr, mother, xpos, ypos, -zpos, fIdRotm, "ONLY");
+ }
+ }
+ }
+ AliDebug(2,Form(" Number of Super Modules %i \n", nr+nrsmod));
+}