]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt1GeometryBuilderV2.cxx
Fixes for #73467: Corrupted MUON hits when using AliRoot with Root v5.27/05 and v5...
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1GeometryBuilderV2.cxx
index 3462f2eac797897931d2ff2d2af5ad68a3585839..a6fb1e64ae8cf8369825d629d67033c6840b88fe 100644 (file)
 
 #include "AliMpSegmentation.h"
 #include "AliMpDEManager.h"
-#include "AliMpContainers.h"
 #include "AliMpConstants.h"
 #include "AliMpCDB.h"
-#include "AliMpSectorSegmentation.h"
 #include "AliMpSector.h"
 #include "AliMpRow.h"
 #include "AliMpVRowSegment.h"
 #include "AliMagF.h"
 #include "AliLog.h"
 
-#include <TVector2.h>
-#include <TVector3.h>
-#include <TGeoMatrix.h>
-#include <TClonesArray.h>
 #include <Riostream.h>
-#include <TSystem.h>
-#include <TVirtualMC.h>
+#include <TClonesArray.h>
+#include <TGeoCompositeShape.h>
+#include <TGeoGlobalMagField.h>
 #include <TGeoManager.h>
-#include <TGeoVolume.h>
+#include <TGeoMatrix.h>
 #include <TGeoTube.h>
+#include <TGeoVolume.h>
 #include <TGeoXtru.h>
-#include <TGeoCompositeShape.h>
-
-#ifdef WITH_STL
-  #include <vector>
-#endif
-
-#ifdef WITH_ROOT
-  #include "TArrayI.h"
-#endif
+#include <TSystem.h>
+#include <TVector2.h>
+#include <TVector3.h>
+#include <TVirtualMC.h>
+#include <TArrayI.h>
 
 /// \cond CLASSIMP
 ClassImp(AliMUONSt1GeometryBuilderV2)
@@ -414,16 +406,12 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
     AliFatal("Mapping has to be loaded first !");
   }
        
-  const AliMpSectorSegmentation* kSegmentation1 
-    = dynamic_cast<const AliMpSectorSegmentation*>(
-        AliMpSegmentation::Instance()
-          ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kBendingPlane))); 
-  if ( ! kSegmentation1 ) {
+  const AliMpSector* kSector1 
+    = AliMpSegmentation::Instance()->GetSector(100, AliMpDEManager::GetCathod(100, AliMp::kBendingPlane));
+  if ( ! kSector1 ) {
     AliFatal("Could not access sector segmentation !");
   }
 
-  const AliMpSector* kSector1 = kSegmentation1->GetSector();
-
   //Bool_t reflectZ = true;
   Bool_t reflectZ = false;
   //TVector3 where = TVector3(2.5+0.1+0.56+0.001, 2.5+0.1+0.001, 0.);
@@ -433,8 +421,14 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
   
   Int_t nb = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
   TExMapIter it(&specialMap);
+#if ROOT_SVN_REVISION >= 29598
+  Long64_t key;
+  Long64_t value;
+#else
   Long_t key;
   Long_t value;
+#endif  
+  
   while ( it.Next(key,value) == kTRUE ) { 
     delete reinterpret_cast<AliMUONSt1SpecialMotif*>(value);
   }
@@ -448,19 +442,16 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
       // Fix (7) - overlap of SQ42 with MCHL (after moving the whole sector
       // in the true position)   
 
-  const AliMpSectorSegmentation* kSegmentation2 
-    = dynamic_cast<const AliMpSectorSegmentation*>(
-        AliMpSegmentation::Instance()
-          ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kNonBendingPlane))); 
-  if ( ! kSegmentation2 ) {
-    AliFatal("Could not access sector segmentation !");
+  const AliMpSector* kSector2 
+    = AliMpSegmentation::Instance()
+          ->GetSector(100, AliMpDEManager::GetCathod(100, AliMp::kNonBendingPlane));
+  if ( ! kSector2 ) {
+    AliFatal("Could not access sector !");
   }
-    
-  const AliMpSector* kSector2 = kSegmentation2->GetSector();
 
   //reflectZ = false;
   reflectZ = true;
-  TVector2 offset = kSector2->Position();
+  TVector2 offset = TVector2(kSector2->GetPositionX(), kSector2->GetPositionY());
   where = TVector3(where.X()+offset.X(), where.Y()+offset.Y(), 0.); 
       // Add the half-pad shift of the non-bending plane wrt bending plane
       // (The shift is defined in the mapping as sector offset)
@@ -1172,7 +1163,7 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     
     // TopAnode1 -  layer 2 of 2
     par[2] = kHzTA12;    
-    gMC->Gsvolu("SQ09","BOX",idFR4,par,11); 
+    gMC->Gsvolu("SQ09","BOX",idFR4,par,3); 
 
     // TopAnode2 -  layer 1 of 2
     par[0] = kHzTA21;
@@ -1645,6 +1636,8 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = kOUTX;
     posY = kTOPY+((kBl1OCTF+kTl1OCTF)/2.);
     posZ = 0.;     
+    // shift to solve overlap with SQ17to23 and SQ18to24
+    posX += 0.02;
     gMC->Gspos("SQ26",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY"); 
 
 // VertEarthFaceCu - 2 copies
@@ -1981,14 +1974,8 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
   
   GReal_t posX,posY,posZ;
   
-#ifdef WITH_STL  
-  vector<Int_t> alreadyDone;
-#endif
-
-#ifdef WITH_ROOT  
   TArrayI alreadyDone(20);
   Int_t nofAlreadyDone = 0;
-#endif  
 
   for (Int_t irow=0;irow<sector->GetNofRows();irow++){ // for each row
     AliMpRow* row = sector->GetRow(irow);
@@ -2002,10 +1989,11 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
       if ( value == 0 ){ //if this is a normal segment (ie. not part of <specialMap>)
       
         // create the cathode part
-        CreatePlaneSegment(segNum, seg->Dimensions(), seg->GetNofMotifs());
+        CreatePlaneSegment(segNum, TVector2(seg->GetDimensionX(),seg->GetDimensionY()), 
+                           seg->GetNofMotifs());
   
-        posX = where.X() + seg->Position().X();
-        posY = where.Y() + seg->Position().Y();
+        posX = where.X() + seg->GetPositionX();
+        posY = where.Y() + seg->GetPositionY();
         posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
         gMC->Gspos(PlaneSegmentName(segNum).Data(), 1, 
                   QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
@@ -2023,8 +2011,8 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
          if ( sector->GetDirection() == AliMp::kX) copyNo += fgkDaughterCopyNoOffset;
   
           // Position
-          posX = where.X() + motifPos->Position().X() + fgkOffsetX;
-          posY = where.Y() + motifPos->Position().Y() + fgkOffsetY;
+          posX = where.X() + motifPos->GetPositionX() + fgkOffsetX;
+          posY = where.Y() + motifPos->GetPositionY() + fgkOffsetY;
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
           gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
         }  
@@ -2040,12 +2028,6 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
 
           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
           
-#ifdef WITH_STL
-          if (find(alreadyDone.begin(),alreadyDone.end(),motifPosId)
-              != alreadyDone.end()) continue; // don't treat the same motif twice
-
-#endif
-#ifdef WITH_ROOT
           Bool_t isDone = false;
          Int_t i=0;
          while (i<nofAlreadyDone && !isDone) {
@@ -2053,7 +2035,6 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
            i++;
          }  
          if (isDone) continue; // don't treat the same motif twice
-#endif
 
           AliMUONSt1SpecialMotif spMot = *((AliMUONSt1SpecialMotif*)specialMap.GetValue(motifPosId));
          AliDebugStream(2) << chamber << " processing special motif: " << motifPosId << endl;  
@@ -2067,8 +2048,8 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
           // place the hole for the motif, wrt the requested rotation angle
           Int_t rot = ( spMot.GetRotAngle()<0.1 ) ? reflZ:rotMat;
 
-          posX = where.X() + motifPos->Position().X() + spMot.GetDelta().X();
-          posY = where.Y() + motifPos->Position().Y() + spMot.GetDelta().Y();
+          posX = where.X() + motifPos->GetPositionX() + spMot.GetDelta().X();
+          posY = where.Y() + motifPos->GetPositionY() + spMot.GetDelta().Y();
           posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
           // Shift the hole for special motif 46 to avoid debording into S047
           if ( copyNo == 2070 ) {
@@ -2088,14 +2069,10 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
           gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
 
-#ifdef WITH_STL
-          alreadyDone.push_back(motifPosId);// mark this motif as done
-#endif
-#ifdef WITH_ROOT
           if (nofAlreadyDone == alreadyDone.GetSize()) 
             alreadyDone.Set(2*nofAlreadyDone); 
           alreadyDone.AddAt(motifPosId, nofAlreadyDone++);               
-#endif
+
          AliDebugStream(2) << chamber << " processed motifPosId: " << motifPosId << endl;
        }               
 // COMMENT OUT END
@@ -2103,7 +2080,6 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
       }// end of special motif case
     }
   }
-/// \endcond
 } 
 
 //______________________________________________________________________________
@@ -2234,8 +2210,8 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
   GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
   // GReal_t maxStepGas   = fMUON->GetMaxStepGas();
-  Int_t iSXFLD   = gAlice->Field()->PrecInteg();
-  Float_t sXMGMX = gAlice->Field()->Max();
+  Int_t iSXFLD   = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->PrecInteg();
+  Float_t sXMGMX = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
 
   fMUON->AliMedium(21, "ALU_II$",    41, 0, iSXFLD, sXMGMX, 
                    tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);