]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSlatGeometryBuilder.cxx
Removing dependence on ESD files and new possibility for selecting muon multiplicity...
[u/mrichter/AliRoot.git] / MUON / AliMUONSlatGeometryBuilder.cxx
index 891cf425685ca45bbe39050fef94e582ebd171fa..a212a912797488c53ffb5444864268f292a45416 100644 (file)
@@ -227,7 +227,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   Float_t xxmax = (kBframeLength - kNulocLength)/2.; 
   Int_t index=0;
   Int_t* fStations = new Int_t[5];
-  for (Int_t i=0; i<5; i++) fStations[i] = 1;
+  for (Int_t iSt=0; iSt<5; iSt++) fStations[iSt] = 1;
   fStations[2] = 1;
      
   if (fStations[2])
@@ -261,7 +261,6 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
       Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
       Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
-      Float_t *dum=0;
       Float_t pcbDLength3   = (kPcbLength - tlength);
       
       // For rounded pcb of central slat
@@ -294,7 +293,8 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       char idSlatCh6[5];
       Float_t xSlat3;
       Float_t ySlat3 = 0;
-      Float_t angle = 0.;
+      angle = 0.;
+
       Float_t spar2[3];
       for (i = 0; i < kNslats3; i++){
 
@@ -314,7 +314,8 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        spar2[1] = spar[1];
        spar2[2] = spar[2]; 
        Float_t dzCh3 = dzCh; 
-       Float_t zSlat3 = (i%2 ==0)? -zSlat : zSlat; // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ?
+       Float_t dzSlat3 = -0.25; // see drawing PQ7EN345-6 (Delta_slat=80mm instead 85mm)
+       Float_t zSlat3 = (i%2 ==0)? -(zSlat+dzSlat3) : (zSlat+dzSlat3); // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ? -> Indeed, fixed J.C.
 
        sprintf(idSlatCh5,"LA%d",i+kNslats3-1);
        detElemId = 509 - (i + kNslats3-1-4);
@@ -498,16 +499,15 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        // Get shape
        Int_t nSlatType = 2;
        Int_t nVol = 8;
-       char slatType[3] = "CD"; // C: central slat; D: rounded slat
-       char volLetter[9] = "CNXIPHBG";
-       char volName[5] = "SC5C";
-       char compName[11] = "SC5C";
-       char csName[14] = "centerSlatC5C";
+       const char* slatType = "CD"; // C: central slat; D: rounded slat
+       const char* volLetter = "CNXIPHBG";
+       TString volName;
+       TString compName;
+       TString csName;
        TGeoVolume *mVol = 0x0;
        TObjArray centerSlat(nSlatType*((nVol+1)*2));   
        TObjArray composite(nSlatType*((nVol+1)*2));
 
-
        // Beam shield recess
        new TGeoTube("tubeCut", 0., AliMUONConstants::Rmin(2), kSlatWidth/2.+0.001);
        // Displacement
@@ -515,6 +515,12 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        trCTube->RegisterYourself();
        TGeoTranslation* trDTube = new TGeoTranslation("trDTube", -(kPcbLength+kVframeLength)/2., -kYpos3[1], 0.);
        trDTube->RegisterYourself();
+       TGeoTranslation* trCBTube = new TGeoTranslation("trCBTube", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
+       trCBTube->Add(trCTube);
+       trCBTube->RegisterYourself();
+       TGeoTranslation* trDBTube = new TGeoTranslation("trDBTube", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
+       trDBTube->Add(trDTube);
+       trDBTube->RegisterYourself();
 
        Float_t cPhi2 = (TMath::Pi()/2.-TMath::ACos((kSensHeight/2.)/(AliMUONConstants::Rmin(2)-kRframeLength)));
        TGeoBBox *boxCCut = new TGeoBBox("boxCCut",(cFramepar3[1]-cFramepar3[0]*TMath::Cos(cPhi2))/2., hFramepar3[1], cFramepar3[2]+0.001);
@@ -534,7 +540,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
            for (int iVol = 0; iVol<nVol; iVol++){
              Int_t lIndex = (iCh-5)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
-             sprintf(volName,"S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
+             volName=Form("S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
              mVol = gGeoManager->FindVolumeFast(volName);
              if ( !mVol ) {
                AliErrorStream() 
@@ -542,21 +548,18 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
              }
              else {
                centerSlat[lIndex] = mVol->GetShape();
-               sprintf(csName,"centerSlat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
+               csName=Form("centerSlat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
                ((TGeoShape*)centerSlat[lIndex])->SetName(csName); 
 
                // Composite shape
                TString compOperation(csName);
                compOperation+="-tubeCut:tr";
                compOperation+=slatType[iSlatType];
-               compOperation+="Tube";
                if (strstr(volName,"B")){
-                 // Displacement
-                 TGeoTranslation* trB = new TGeoTranslation("trB", 0., -( kPcbHeight - kBframeHeight ) / 2., 0.);
-                 trB->RegisterYourself();
-                 compOperation.ReplaceAll("-tubeCut",":trB-tubeCut");
+                 compOperation+="B";
                }
-               sprintf(compName,"composite%d%c",iCh,volLetter[iVol]);
+               compOperation+="Tube";
+               compName=Form("composite%d%c",iCh,volLetter[iVol]);
                composite[lIndex] = new TGeoCompositeShape(compName, compOperation.Data()); 
                
                // Reset shape to volume      
@@ -566,7 +569,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
            // For rounded spacer
            Int_t lIndex = (iCh-5)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
-           sprintf(volName,"S%c%dD",slatType[iSlatType],iCh);
+           volName=Form("S%c%dD",slatType[iSlatType],iCh);
            mVol = gGeoManager->FindVolumeFast(volName);
            if ( !mVol ) {
              AliErrorStream() 
@@ -574,7 +577,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
            }
            else {
              centerSlat[lIndex] = mVol->GetShape();
-             sprintf(csName,"centerSlat%c%dD",slatType[iSlatType],iCh);
+             csName=Form("centerSlat%c%dD",slatType[iSlatType],iCh);
              ((TGeoShape*)centerSlat[lIndex])->SetName(csName);                  
              
              // Composite shape
@@ -586,7 +589,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
                compOperation.Prepend("(");
                compOperation+="+boxVframe:trVBox)*boxDCut:trDBox";
              }
-             sprintf(compName,"composite%c%dD",slatType[iSlatType],iCh);
+             compName=Form("composite%c%dD",slatType[iSlatType],iCh);
              composite[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());             
              // Reset shape to volume      
              mVol->SetShape((TGeoShape*)composite[lIndex]);
@@ -657,7 +660,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          // position the panels and the insulating material 
          for (j = 0; j < kNPCB3[i]; j++){
            index++;
-           Float_t xx = kSensLength * (-kNPCB3[i]/2. + j + 0.5); 
+           xx = kSensLength * (-kNPCB3[i]/2. + j + 0.5); 
            Float_t xx2 = xx - pcbDLength3/2.; 
            Float_t xx3 = xx + (kSensLength-csvPcbLength)/2.;
 
@@ -752,17 +755,17 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
       gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
       gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
-      gMC->Gspos("SC5B",1,"SC5P",0., 0.,0.,0,"ONLY"); 
-      gMC->Gspos("SC5B",2,"SC5P",0., 0.,0.,rotB,"ONLY"); 
-      gMC->Gspos("SD5B",1,"SD5P",0., 0.,0.,0,"ONLY"); 
+      gMC->Gspos("SC5B",1,"SC5P",0., yborder,0.,rotB,"ONLY"); 
+      gMC->Gspos("SC5B",2,"SC5P",0.,-yborder,0.,0,"ONLY"); 
       gMC->Gspos("S05B",1,"SD5P",0., yborder,0.,0,"ONLY"); 
+      gMC->Gspos("SD5B",1,"SD5P",0.,-yborder,0.,0,"ONLY"); 
 
       gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
       gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
-      gMC->Gspos("SC6B",1,"SC6P",0., 0.,0.,0,"ONLY"); 
-      gMC->Gspos("SC6B",2,"SC6P",0., 0.,0.,rotB,"ONLY"); 
-      gMC->Gspos("SD6B",1,"SD6P",0., 0.,0.,0,"ONLY"); 
+      gMC->Gspos("SC6B",1,"SC6P",0., yborder,0.,rotB,"ONLY"); 
+      gMC->Gspos("SC6B",2,"SC6P",0.,-yborder,0.,0,"ONLY"); 
       gMC->Gspos("S06B",1,"SD6P",0., yborder,0.,0,"ONLY"); 
+      gMC->Gspos("SD6B",1,"SD6P",0.,-yborder,0.,0,"ONLY"); 
   
       // create the NULOC volume and position it in the horizontal frame
       gMC->Gsvolu("S05E","BOX",kNulocMaterial,nulocpar,3);
@@ -783,16 +786,16 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          gMC->Gspos("S05E",2*index  ,"SB5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
        }
        if (xx > -xxmax3 && xx< xxmax3) {
-         gMC->Gspos("S05E",2*index-1,"SC5B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2., 0, "ONLY");
-         gMC->Gspos("S05E",2*index  ,"SC5B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2., 0, "ONLY");
-         gMC->Gspos("S06E",2*index-1,"SC6B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-         gMC->Gspos("S06E",2*index  ,"SC6B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S05E",2*index-1,"SC5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2., 0, "ONLY");
+         gMC->Gspos("S05E",2*index  ,"SC5B", xx, 0., kBframeWidth/2.- kNulocWidth/2., 0, "ONLY");
+         gMC->Gspos("S06E",2*index-1,"SC6B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S06E",2*index  ,"SC6B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
        }
        if (xx > xxmax4 && xx< xxmax) {
-         gMC->Gspos("S05E",2*index-1,"SD5B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-         gMC->Gspos("S05E",2*index  ,"SD5B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
-         gMC->Gspos("S06E",2*index-1,"SD6B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-         gMC->Gspos("S06E",2*index  ,"SD6B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S05E",2*index-1,"SD5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S05E",2*index  ,"SD5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S06E",2*index-1,"SD6B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+         gMC->Gspos("S06E",2*index  ,"SD6B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
        }
       }
       
@@ -867,7 +870,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          cablepar6[0] = supporthlengthCh6/2.;
          lCableX6 = 0.;
          lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
-         lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+         lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
          if(i==0){ // central slat is shorter (rounded)
            cablepar[0] -= (kPcbLength-csvPcbLength)/2.;
            lCableX = (kPcbLength-csvPcbLength)/2.;
@@ -909,7 +912,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          cablepar6[0] = (supporthlengthCh6-kPcbLength-kVframeLength)/2.;
          lCableX6 = (kPcbLength+kVframeLength)/2.;
          lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
-         lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+         lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
          gMC->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);       
          gMC->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
          gMC->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar6,3);    
@@ -934,7 +937,8 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        else {
          lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1];
        }
-       lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+       lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
+
        if (i<=2){ // shortened pcb
          cablepar[0] += pcbDLength3/2.;
          lCableX -=  pcbDLength3/2.;
@@ -1168,11 +1172,11 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       // Get shape
       Int_t nSlatType = 1;
       Int_t nVol = 8;
-      char slatType[2] = "D"; // D: Rounded slat
-      char volLetter[9] = "CNXIPHBG";
-      char volName[5] = "SD7C";
-      char compName[14] = "SD7C";
-      char csName[16] = "rounded4SlatD7C";
+      const char* slatType = "D"; // D: Rounded slat
+      const char* volLetter = "CNXIPHBG";
+      TString volName;
+      TString compName;
+      TString csName;
       TGeoVolume *mVol = 0x0;
       // Beam shield recess
       new TGeoTube("tube4Cut", 0., AliMUONConstants::Rmin(3), kSlatWidth/2.+0.001);
@@ -1180,6 +1184,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       // Displacement
       TGeoTranslation* trDTube4 = new TGeoTranslation("trDTube4", -(kPcbLength+kVframeLength)/2., -kYpos41[1], 0.);
       trDTube4->RegisterYourself();
+      TGeoTranslation* trDBTube4 = new TGeoTranslation("trDBTube4", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
+      trDBTube4->Add(trDTube4);
+      trDBTube4->RegisterYourself();
+
       TObjArray composite4(nSlatType*((nVol+1)*2));
       new TGeoBBox("box4DCut",(kPcbLength+kVframeLength)/2., hFramepar[1], vFramepar[2]+0.001);
       // Displacement
@@ -1194,7 +1202,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
          for (int iVol = 0; iVol<nVol; iVol++){
            Int_t lIndex = (iCh-7)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
-           sprintf(volName,"S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
+           volName=Form("S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
            mVol = gGeoManager->FindVolumeFast(volName);
            if ( !mVol ) {
              AliErrorStream() 
@@ -1202,24 +1210,18 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
            }
            else {
              rounded4Slat[lIndex] = mVol->GetShape();
-             sprintf(csName,"rounded4Slat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
+             csName=Form("rounded4Slat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
              ((TGeoShape*)rounded4Slat[lIndex])->SetName(csName);
              
              // Composite shape
              TString compOperation(csName);
              compOperation+="-tube4Cut:tr";
              compOperation+=slatType[iSlatType];
-             compOperation+="Tube4";
              if (strstr(volName,"B")){
-               // Displacement
-               Float_t posXb = 0.;
-               Float_t posYb = -( kPcbHeight - kBframeHeight ) / 2.;
-               Float_t posZb = 0.;
-               TGeoTranslation* trB = new TGeoTranslation("trB", posXb, posYb, posZb);
-               trB->RegisterYourself();
-               compOperation.ReplaceAll("-tube4Cut",":trB-tube4Cut");
-             }
-             sprintf(compName,"composite4%d%c",iCh,volLetter[iVol]);
+               compOperation+="B";
+             }       
+             compOperation+="Tube4";
+             compName=Form("composite4%d%c",iCh,volLetter[iVol]);
              composite4[lIndex] = new TGeoCompositeShape(compName, compOperation.Data()); 
              
              // Reset shape to volume      
@@ -1229,7 +1231,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
          // For rounded spacer
          Int_t lIndex = (iCh-7)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
-         sprintf(volName,"S%c%dD",slatType[iSlatType],iCh);
+         volName=Form("S%c%dD",slatType[iSlatType],iCh);
          mVol = gGeoManager->FindVolumeFast(volName);
          if ( !mVol ) {
            AliErrorStream() 
@@ -1237,7 +1239,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          }
          else {
            rounded4Slat[lIndex] = mVol->GetShape();
-           sprintf(csName,"rounded4Slat%c%dD",slatType[iSlatType],iCh);
+           csName=Form("rounded4Slat%c%dD",slatType[iSlatType],iCh);
            ((TGeoShape*)rounded4Slat[lIndex])->SetName(csName);
            
            // Composite shape
@@ -1246,7 +1248,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
              compOperation.Prepend("(");
              compOperation+="+box4Vframe:trVBox4)*box4DCut:trDBox4";
            }
-           sprintf(compName,"composite4%c%dD",slatType[iSlatType],iCh);
+           compName=Form("composite4%c%dD",slatType[iSlatType],iCh);
            composite4[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());              
            // Reset shape to volume      
            mVol->SetShape((TGeoShape*)composite4[lIndex]);
@@ -1285,7 +1287,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        // position the panels and the insulating material 
        for (j = 0; j < kNPCB4[i]; j++){
          index++;
-         Float_t xx = kSensLength * (-kNPCB4[i]/2.+j+.5); 
+         xx = kSensLength * (-kNPCB4[i]/2.+j+.5); 
          Float_t zPanel = spar[2] - nomexbpar[2]; 
          if (i==1 && j==0){ // Rounded pcb of rounded slat
            GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("SD7X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
@@ -1340,12 +1342,12 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
     gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
     gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY");
-    gMC->Gspos("SD7B",1,"SD7P",0., 0.,0.,0,"ONLY"); 
-    gMC->Gspos("S07B",1,"SD7P",0., yborder,0.,0,"ONLY"); 
+    gMC->Gspos("S07B",1,"SD7P",0., yborder,0.,0,"ONLY");
+    gMC->Gspos("SD7B",1,"SD7P",0.,-yborder,0.,0,"ONLY");  
     gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
     gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
-    gMC->Gspos("SD8B",1,"SD8P",0., 0.,0.,0,"ONLY"); 
     gMC->Gspos("S08B",1,"SD8P",0., yborder,0.,0,"ONLY"); 
+    gMC->Gspos("SD8B",1,"SD8P",0.,-yborder,0.,0,"ONLY"); 
 
     // create the NULOC volume and position it in the horizontal frame
 
@@ -1362,10 +1364,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       gMC->Gspos("S08E",2*index  ,"S08B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
     }
     if (xx > xxmax4 && xx< xxmax) {
-      gMC->Gspos("S07E",2*index-1,"SD7B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S07E",2*index  ,"SD7B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S08E",2*index-1,"SD8B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S08E",2*index  ,"SD8B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S07E",2*index-1,"SD7B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S07E",2*index  ,"SD7B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S08E",2*index-1,"SD8B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S08E",2*index  ,"SD8B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
     }
 
     //
@@ -1428,7 +1430,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        lCableX = kXpos4[i]/2.;
        lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1];
        lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1];
-       lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+       lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
        gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);  
        gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
        gMC->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3);       
@@ -1465,7 +1467,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        lCableX = (kPcbLength+kVframeLength)/2.;
        lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
        lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
-       lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+       lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
        gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3); 
        gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3); 
        gMC->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3); 
@@ -1483,7 +1485,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1];
        lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1];
       }
-      lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+      lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
       gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3); 
       gMC->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3); 
       gMC->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3); 
@@ -1720,11 +1722,11 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       // Get shape
       Int_t nSlatType = 1;
       Int_t nVol = 8;
-      char slatType[2] = "D"; // D: Rounde slat
-      char volLetter[9] = "CNXIPHBG";
-      char volName[5] = "SD9D";
-      char compName[14] = "SD9D";
-      char csName[16] = "rounded5SlatD9D";
+      const char* slatType = "D"; // D: Rounde slat
+      const char* volLetter = "CNXIPHBG";
+      TString volName;
+      TString compName;
+      TString csName;
       TGeoVolume *mVol = 0x0;
       // Beam shield recess
       new TGeoTube("tube5Cut", 0., AliMUONConstants::Rmin(4), kSlatWidth/2.+0.001);
@@ -1732,6 +1734,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       // Displacement
       TGeoTranslation* trDTube5 = new TGeoTranslation("trDTube5", -(kPcbLength+kVframeLength)/2., -kYpos5[1], 0.);
       trDTube5->RegisterYourself();
+      TGeoTranslation* trDBTube5 = new TGeoTranslation("trDBTube5", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
+      trDBTube5->Add(trDTube5);
+      trDBTube5->RegisterYourself();
+
       TObjArray composite5(nSlatType*((nVol+1)*2));
       new TGeoBBox("box5DCut",(kPcbLength+kVframeLength)/2., hFramepar[1], vFramepar[2]+0.001);
       // Displacement
@@ -1746,7 +1752,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
          for (int iVol = 0; iVol<nVol; iVol++){
            Int_t lIndex = (iCh-9)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
-           sprintf(volName,"S%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
+           volName=Form("S%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
            mVol = gGeoManager->FindVolumeFast(volName);
            if ( !mVol ) {
              AliErrorStream() 
@@ -1754,21 +1760,18 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
            }
            else {
              rounded5Slat[lIndex] = mVol->GetShape();
-             sprintf(csName,"rounded5Slat%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
+             csName=Form("rounded5Slat%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
              ((TGeoShape*)rounded5Slat[lIndex])->SetName(csName);  
              
              // Composite shape
              TString compOperation(csName);
              compOperation+="-tube5Cut:tr";
              compOperation+=slatType[iSlatType];
-             compOperation+="Tube5";
              if (strstr(volName,"B")){
-               // Displacement
-               TGeoTranslation* trB = new TGeoTranslation("trB", 0., -(kPcbHeight - kBframeHeight)/2., 0.);
-               trB->RegisterYourself();
-               compOperation.ReplaceAll("-tube5Cut",":trB-tube5Cut");
+               compOperation+="B";
              }
-             sprintf(compName,"composite5%d%c",iCh,volLetter[iVol]);
+             compOperation+="Tube5";
+             compName=Form("composite5%d%c",iCh,volLetter[iVol]);
              composite5[lIndex] = new TGeoCompositeShape(compName, compOperation.Data()); 
              
              // Reset shape to volume      
@@ -1778,7 +1781,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
          // For rounded spacer
          Int_t lIndex = (iCh-9)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
-         sprintf(volName,"S%c%dD",slatType[iSlatType],iCh%10);
+         volName=Form("S%c%dD",slatType[iSlatType],iCh%10);
          mVol = gGeoManager->FindVolumeFast(volName);
          if ( !mVol ) {
            AliErrorStream() 
@@ -1786,7 +1789,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          }
          else {
            rounded5Slat[lIndex] = mVol->GetShape();
-           sprintf(csName,"rounded5Slat%c%dD",slatType[iSlatType],iCh%10);
+           csName=Form("rounded5Slat%c%dD",slatType[iSlatType],iCh%10);
            ((TGeoShape*)rounded5Slat[lIndex])->SetName(csName);                  
            
            // Composite shape
@@ -1795,7 +1798,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
              compOperation.Prepend("(");
              compOperation+="+box5Vframe:trVBox5)*box5DCut:trDBox5";
            }
-           sprintf(compName,"composite5%c%dD",slatType[iSlatType],iCh%10);
+           compName=Form("composite5%c%dD",slatType[iSlatType],iCh%10);
            composite5[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());              
            // Reset shape to volume      
            mVol->SetShape((TGeoShape*)composite5[lIndex]);
@@ -1833,7 +1836,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        // position the panels and the insulating material 
        for (j = 0; j < kNPCB5[i]; j++){
          index++;
-         Float_t xx = kSensLength * (-kNPCB5[i]/2.+j+.5); 
+         xx = kSensLength * (-kNPCB5[i]/2.+j+.5); 
 
          Float_t zPanel = spar[2] - nomexbpar[2]; 
          if (i==1 && j==0){ // Rounded pcb of rounded slat 
@@ -1890,12 +1893,12 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
     gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
     gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
-    gMC->Gspos("SD9B",1,"SD9P",0., 0.,0.,0,"ONLY"); 
     gMC->Gspos("S09B",1,"SD9P",0., yborder,0.,0,"ONLY"); 
+    gMC->Gspos("SD9B",1,"SD9P",0.,-yborder,0.,0,"ONLY"); 
     gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
     gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
-    gMC->Gspos("SD0B",1,"SD0P",0., 0.,0.,0,"ONLY"); 
     gMC->Gspos("S10B",1,"SD0P",0., yborder,0.,0,"ONLY"); 
+    gMC->Gspos("SD0B",1,"SD0P",0.,-yborder,0.,0,"ONLY"); 
 
     //      // create the NULOC volume and position it in the horizontal frame
 
@@ -1912,10 +1915,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       gMC->Gspos("S10E",2*index  ,"S10B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
     }
     if (xx > xxmax4 && xx< xxmax) {
-      gMC->Gspos("S09E",2*index-1,"SD9B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S09E",2*index  ,"SD9B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S10E",2*index-1,"SD0B", xx, -yborder,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
-      gMC->Gspos("S10E",2*index  ,"SD0B", xx, -yborder, kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S09E",2*index-1,"SD9B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S09E",2*index  ,"SD9B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S10E",2*index-1,"SD0B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
+      gMC->Gspos("S10E",2*index  ,"SD0B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
     }
 
     //    
@@ -1971,7 +1974,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        else {
          lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1];
        }
-       lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+       lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
        gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);  
        gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
        // Then bottom cables
@@ -1998,7 +2001,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        cablepar[0] = (supporthlength-kPcbLength-kVframeLength)/2.;
        lCableX = (kPcbLength+kVframeLength)/2.;
        lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
-       lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+       lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
        gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3); 
        gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3); 
       }        
@@ -2013,7 +2016,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       else {
        lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1];
       }
-      lCableZ = TMath::Power(-1,i)*(nomexthickness+carbonthickness+(iCable++)*kCableWidth)/2.;
+      lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);       
       gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3); 
       gMC->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3); 
       if(i>0){
@@ -2051,11 +2054,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
 }
 
-
 //______________________________________________________________________________
-void AliMUONSlatGeometryBuilder::SetTransformations()
+void AliMUONSlatGeometryBuilder::SetVolumes()
 {
-/// Defines the transformations for the station345 chambers.
+/// Defines the volumes for the station345 chambers.
 
   if (gAlice->GetModule("DIPO")) {
     // if DIPO is preset, the whole station will be placed in DDIP volume
@@ -2088,6 +2090,13 @@ void AliMUONSlatGeometryBuilder::SetTransformations()
   SetVolume(13, "SC09O", true);
   SetVolume(14, "SC10I", true);
   SetVolume(15, "SC10O", true);
+}
+
+
+//______________________________________________________________________________
+void AliMUONSlatGeometryBuilder::SetTransformations()
+{
+/// Defines the transformations for the station345 chambers.
 
 // Stations 345 are not perpendicular to the beam axis
 // See AliMUONConstants class