]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt1GeometryBuilderV2.cxx
Adding a commented line demsostrating how to switch off
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1GeometryBuilderV2.cxx
index 1234905961bdb2d8c8c2bfbe1a2226138b5edd91..8198a92d46d8b90a70c2f40cf40cf17703d8dd3c 100644 (file)
 #include "AliMUONGeometryModule.h"
 #include "AliMUONGeometryEnvelopeStore.h"
 
+#include "AliMpSegmentation.h"
+#include "AliMpDEManager.h"
 #include "AliMpContainers.h"
 #include "AliMpConstants.h"
-#include "AliMpFiles.h"
-#include "AliMpSectorReader.h"
+#include "AliMpCDB.h"
+#include "AliMpSectorSegmentation.h"
 #include "AliMpSector.h"
 #include "AliMpRow.h"
 #include "AliMpVRowSegment.h"
@@ -135,17 +137,6 @@ AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(AliMUON* muon)
     fMUON(muon)
 {
 /// Standard constructor
-
-   // set path to mapping data files
-   if (! gSystem->Getenv("MINSTALL")) {    
-     TString dirPath = gSystem->Getenv("ALICE_ROOT");
-     dirPath += "/MUON/mapping"; 
-     AliMpFiles::SetTopPath(dirPath);
-     gSystem->Setenv("MINSTALL", dirPath.Data());
-     //cout << "AliMpFiles top path set to " << dirPath << endl;         
-   }
-   //else
-   //  cout << gSystem->Getenv("MINSTALL") << endl;              
 }
  
 //______________________________________________________________________________
@@ -269,9 +260,9 @@ void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
 
 // Gas Medium
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099; 
-  //Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
+  Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
-  Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
+  //Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
   Int_t idCopper  = idtmed[1121]; // medium 22 = copper
 
   Float_t par[11];
@@ -478,6 +469,93 @@ void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
   gMC->Gsvolu("SK1C", "TRAP", idCopper,par, 11);
 }
 
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateSpacer0()
+{
+/// The spacer volumes are defined according to the input prepared by Nicole Willis
+/// without any modifications
+///                                                                       <pre>
+/// No.    Type  Material Center (mm)            Dimensions (mm) (half lengths)
+///  5     BOX   EPOXY    408.2  430.4 522.41    5.75  1.5   25.5
+///  5P    BOX   EPOXY    408.2  445.4 522.41    5.75  1.5   25.5
+///  6     BOX   EPOXY    408.2  437.9 519.76    5.75  15.0   1.0
+///  6P    BOX   EPOXY    408.2  437.9 525.06    5.75  15.0   1.0
+///  7     CYL   INOX     408.2  437.9 522.41    r=3.0  hz=20.63
+///                                                                      </pre>
+
+  // tracking medias
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
+  Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
+
+  GReal_t par[3];
+  par[0] = 0.575;
+  par[1] = 0.150;
+  par[2] = 2.550;
+  gMC->Gsvolu("Spacer05","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.575;
+  par[1] = 1.500;
+  par[2] = 0.100;
+  gMC->Gsvolu("Spacer06","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.000;
+  par[1] = 0.300;
+  par[2] = 2.063;
+  gMC->Gsvolu("Spacer07","TUBE",idInox,par,3);
+}  
+
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateSpacer()
+{
+/// The spacer volumes are defined according to the input prepared by Nicole Willis
+/// with modifications needed to fit into existing geometry.
+///                                                                       <pre>
+/// No.    Type  Material Center (mm)            Dimensions (mm) (half lengths)
+///  5     BOX   EPOXY    408.2  430.4 522.41    5.75  1.5   25.5
+///  5P    BOX   EPOXY    408.2  445.4 522.41    5.75  1.5   25.5
+///  6     BOX   EPOXY    408.2  437.9 519.76    5.75  15.0   1.0
+///  6P    BOX   EPOXY    408.2  437.9 525.06    5.75  15.0   1.0
+///  7     CYL   INOX     408.2  437.9 522.41    r=3.0  hz=20.63
+///                                                                      </pre>
+/// To fit in existing volumes the volumes 5 and 7 are represented by 2 volumes
+/// with half size in z (5A, &A); the dimensions of the volume 5A were also modified
+/// to avoid overlaps (x made smaller, y larger to abotain the identical volume)   
+
+  // tracking medias
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
+  Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
+
+  //GReal_t par[3];
+  //par[0] = 0.575;
+  //par[1] = 0.150;
+  //par[2] = 2.550;
+  //gMC->Gsvolu("Spacer5","BOX",idFrameEpoxy,par,3);
+
+  GReal_t par[3];
+  par[0] = 0.510;
+  par[1] = 0.170;
+  par[2] = 1.275;
+  gMC->Gsvolu("Spacer5A","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.575;
+  par[1] = 1.500;
+  par[2] = 0.100;
+  gMC->Gsvolu("Spacer6","BOX",idFrameEpoxy,par,3);
+
+  //par[0] = 0.000;
+  //par[1] = 0.300;
+  //par[2] = 2.063;
+  //gMC->Gsvolu("Spacer7","TUBE",idInox,par,3);
+
+  par[0] = 0.000;
+  par[1] = 0.300;
+  par[2] = 1.0315;
+  gMC->Gsvolu("Spacer7A","TUBE",idInox,par,3);
+}  
+
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
 {
@@ -500,15 +578,30 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
   specialMap.Add(47, (Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01, 0.36)));
 #endif
 
+  // Load mapping from OCDB
+  if ( ! AliMpSegmentation::Instance() ) {
+    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 ) {
+    AliFatal("Could not access sector segmentation !");
+  }
+    
+  const AliMpSector* kSector1 = kSegmentation1->GetSector();
+/*
   AliMpSectorReader reader1(AliMp::kStation1, AliMp::kBendingPlane);
-  AliMpSector* sector1 = reader1.BuildSector();
-
+  AliMpSector* kSector1 = reader1.BuildSector();
+*/
   //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.);
   TVector3 where = TVector3(fgkDeltaQuadLHC + fgkPadXOffsetBP, 
                             fgkDeltaQuadLHC + fgkPadYOffsetBP, 0.);
-  PlaceSector(sector1, specialMap, where, reflectZ, chamber);
+  PlaceSector(kSector1, specialMap, where, reflectZ, chamber);
   
 #ifdef WITH_STL
   specialMap.clear();
@@ -525,6 +618,12 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
 
 #ifdef WITH_ROOT
   Int_t nb = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
+  TExMapIter it(&specialMap);
+  Long_t key;
+  Long_t value;
+  while ( it.Next(key,value) == kTRUE ) { 
+    delete reinterpret_cast<AliMUONSt1SpecialMotif*>(value);
+  }
   specialMap.Delete();
   specialMap.Add(76 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.));
   specialMap.Add(75 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96, 0.17)));
@@ -536,20 +635,34 @@ void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
       // in the true position)   
       // Was: specialMap.Add(47,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.61,-1.18)));
 #endif
-
+/*
   AliMpSectorReader reader2(AliMp::kStation1, AliMp::kNonBendingPlane);
   AliMpSector* sector2 = reader2.BuildSector();
-  
+*/  
+  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 = kSegmentation2->GetSector();
+
   //reflectZ = false;
   reflectZ = true;
-  TVector2 offset = sector2->Position();
+  TVector2 offset = kSector2->Position();
   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)
       // Fix (4) - was TVector3(where.X()+0.63/2, ... - now it is -0.63/2
-  PlaceSector(sector2, specialMap, where, reflectZ, chamber);
+  PlaceSector(kSector2, specialMap, where, reflectZ, chamber);
 
 #ifdef WITH_ROOT
+  it.Reset();
+  while ( it.Next(key,value) == kTRUE ) {
+    delete reinterpret_cast<AliMUONSt1SpecialMotif*>(value);
+  }
   specialMap.Delete();
 #endif
 }
@@ -609,6 +722,41 @@ void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(Int_t segNumber,
 /// and the mother board.)
   
   CreateFoamBox(segNumber,dimensions);
+  
+  // Place spacer in the concrete plane segments:
+  // S225 (in S025), S267 (in S067) in chamber1 and S309 (in S109). S351(in S151) 
+  // in chamber2
+  // The segments were found as those which caused overlaps when we placed
+  // the spacer in global coordinates via PlaceSpacer0 
+  //
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.75000;   0.0000"> <volume name="Spacer5A"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;  -0.75000;   0.0000"> <volume name="Spacer5A"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.0000;    1.1515"> <volume name="Spacer6"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.0000;    0.0000"> <volume name="Spacer7A"/>
+
+  if ( FoamBoxName(segNumber) == "S225" || 
+       FoamBoxName(segNumber) == "S267" ||
+       FoamBoxName(segNumber) == "S309" ||
+       FoamBoxName(segNumber) == "S351"    )  
+  {
+    GReal_t posX = 12.6;
+    GReal_t posY = 0.75;
+    GReal_t posZ = 0.0;
+    gMC->Gspos("Spacer5A", 1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = -0.75;
+    gMC->Gspos("Spacer5A", 2, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = 0.0;
+    posZ = 1.1515;
+    if ( FoamBoxName(segNumber) == "S267" || 
+         FoamBoxName(segNumber) == "S351" ) posZ *= -1.0;    
+    gMC->Gspos("Spacer6",  1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = 0.0;
+    posZ = 0.0;
+    gMC->Gspos("Spacer7A", 1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+  }  
 
   for (Int_t holeNum=0;holeNum<nofHoles;holeNum++) {
     GReal_t posX = ((2.*holeNum+1.)/nofHoles-1.)*dimensions.X();
@@ -2134,8 +2282,53 @@ void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
   gMC->Gspos("SK1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,0,"ONLY");
 }
 
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::PlaceSpacer0(Int_t chamber)
+{
+/// Place the spacer defined in global positions
+/// !! This method should be used only to find out the right mother volume
+/// for the spacer if geometry is changed and the plane segment volumes
+/// will change their numbering
+
+  // Global position of mother volume for the QuadrantMLayer
+  // SQM1: (-2.6, -2.6, -522.41)
+  // SQM2: (-2.6, -2.6, -541.49)
+  GReal_t mx =  2.6;
+  GReal_t my = -2.6;
+  GReal_t mz =  522.41;
+  
+  GReal_t x, y, z;
+  x = 40.82  - mx;
+  y = 43.04  - my;
+  z = 522.41 - mz;
+  cout << "spacer05 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer05", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  y = 44.54  - my;
+  cout << "spacer05 pos2: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer05", 2, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  x = 40.82  - mx;
+  y = 43.79  - my;
+  z = 519.76 - mz;
+  cout << "spacer06 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer06", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  z = 525.06 - mz;
+  cout << "spacer06 pos2: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer06", 2, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  x = 40.82  - mx;
+  y = 43.79  - my;
+  z = 522.41 - mz;
+  cout << "spacer07 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer07", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+}
+
 //______________________________________________________________________________
-void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap specialMap, 
+void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
+                            SpecialMap specialMap, 
                             const TVector3& where, Bool_t reflectZ, Int_t chamber)
 {
 /// Place all the segments in the mother volume, at the position defined
@@ -2346,14 +2539,14 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   // --- Define mixtures for GEANT ---
   //
 
-  //     Ar-CO2 gas II (80%+20%)
-  Float_t ag1[2]   = { 39.95,  44.01};
-  Float_t zg1[2]   = { 18., 22.};
-  Float_t wg1[2]   = { .8, 0.2};
-  Float_t dg1      = .001821;
-  fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
-            // was id: 22
-            // use wg1 weighting factors (6th arg > 0)
+ //  //     Ar-CO2 gas II (80%+20%)   
+//   Float_t ag1[2]   = { 39.95,  44.01};
+//   Float_t zg1[2]   = { 18., 22.};
+//   Float_t wg1[2]   = { .8, 0.2};
+//   Float_t dg1      = .001821;
+//   fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
+//             // was id: 22
+//             // use wg1 weighting factors (6th arg > 0)
 
   // Rohacell 51  II - imide methacrylique
   Float_t aRohacell51[4] = { 12.01, 1.01, 16.00, 14.01}; 
@@ -2408,7 +2601,7 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   GReal_t stmin  = -.8;
   GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
   GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
-  GReal_t maxStepGas   = fMUON->GetMaxStepGas();
+  // GReal_t maxStepGas   = fMUON->GetMaxStepGas();
   Int_t iSXFLD   = gAlice->Field()->PrecInteg();
   Float_t sXMGMX = gAlice->Field()->Max();
 
@@ -2416,9 +2609,9 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
                    tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
 
                   // was med: 20  mat: 36
-  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
-                   tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
-                  // was med: 9   mat: 22
//  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
+//                    tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
+//                // was med: 9   mat: 22
   fMUON->AliMedium(26, "FOAM_CH$",   46, 0, iSXFLD, sXMGMX,
                    10.0,  0.1, 0.1, 0.1, 0.1, 0, 0) ;
                   // was med: 16  mat: 32
@@ -2454,6 +2647,8 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
   CreateHole();
   CreateDaughterBoard();
   CreateInnerLayers();
+  // CreateSpacer0();
+  CreateSpacer();
   
   // Create reflexion matrices
   //
@@ -2554,6 +2749,13 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
       GetEnvelopes(ich-1)
         ->AddEnvelopeConstituent(QuadrantFLayerName(ich), QuadrantEnvelopeName(ich,i), 
                     i+1, TGeoTranslation(posx2, posy2, posz2)); 
+    
+      // Place spacer in global coordinates in the first non rotated quadrant
+      // if ( detElemId[i] == 0 ) PlaceSpacer0(ich);
+               // !! This placement should be used only to find out the right mother volume
+               // for the spacer if geometry is changed and the plane segment volumes
+               // will change their numbering
+               // The call to the method CreateSpacer0(); above haa to be uncommented, too
    }
  }     
 }