]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSv0.cxx
Overlaps and extrrusions in the volume PWTI are fixed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv0.cxx
index a6bd721703871bf92fcad878bcc7c5a65b276902..27a2bdaeb2058927828c6d1b32389068d4f94765 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.94  2007/10/18 08:40:02  kharlov
+ * Misalignment-related bug fixed
+ *
+ * Revision 1.93  2007/10/06 22:24:40  kharlov
+ * Bug in strip unit geometry is corrected
+ *
+ * Revision 1.92  2007/07/04 16:38:19  policheh
+ * Tracking2LocalCS matrices corrected for CPV.
+ *
  * Revision 1.91  2007/07/02 14:50:49  policheh
  * Tracking2LocalCS matrices corrected.
  *
@@ -80,6 +89,7 @@
 #include <TVirtualMC.h>
 #include <TGeoPhysicalNode.h>
 #include <TGeoManager.h>
+#include <TGeoMatrix.h>
 #include <TVector3.h>
 
 // --- Standard library ---
 #include "AliPHOSv0.h"
 #include "AliRun.h"
 #include "AliLog.h"
+#include "AliGeomManager.h"
 
 ClassImp(AliPHOSv0)
 
@@ -368,11 +379,15 @@ void AliPHOSv0::CreateGeometry()
   this->CreateGeometryforSupport() ; 
   
   // --- Position  PHOS mdules in ALICE setup ---
-  
   Int_t idrotm[99] ;
   Int_t iXYZ,iAngle;
-  for (Int_t iModule = 0; iModule < geom->GetNModules(); iModule++ ) {
-    
+  char im[5] ;
+  Bool_t anyModuleCreated=0 ;
+  for (Int_t iModule = 0; iModule < 5 ; iModule++ ) {
+    sprintf(im,"%d",iModule+1) ;
+    if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0)
+      continue ;
+    anyModuleCreated=1 ;
     Float_t angle[3][2];
     for (iXYZ=0; iXYZ<3; iXYZ++)
       for (iAngle=0; iAngle<2; iAngle++)
@@ -388,7 +403,8 @@ void AliPHOSv0::CreateGeometry()
     gMC->Gspos("PHOS", iModule+1, "ALIC", pos[0], pos[1], pos[2],
               idrotm[iModule], "ONLY") ;
   }
-
+  if(!anyModuleCreated)
+    AliError("No one PHOS module was created") ;
 }
 
 //____________________________________________________________________________
@@ -420,10 +436,11 @@ void AliPHOSv0::CreateGeometryforEMC()
 
   // ======= Define the strip ===============
 
-  gMC->Gsvolu("PSTR", "BOX ", idtmed[716], emcg->GetStripHalfSize(), 3) ;  //Made of stell
+  gMC->Gsvolu("PSTR", "BOX ", idtmed[716], emcg->GetStripHalfSize(), 3) ;  //Made of steel
    
       // --- define steel volume (cell of the strip unit)
-      gMC->Gsvolu("PCEL", "BOX ", idtmed[716], emcg->GetSteelCellHalfSize(), 3);
+//       gMC->Gsvolu("PCEL", "BOX ", idtmed[798], emcg->GetSteelCellHalfSize(), 3);
+      gMC->Gsvolu("PCEL", "BOX ", idtmed[798], emcg->GetAirCellHalfSize(), 3);
 
       // --- define wrapped crystal and put it into steel cell
 
@@ -454,7 +471,8 @@ void AliPHOSv0::CreateGeometryforEMC()
 
       Float_t* splate = emcg->GetSupportPlateHalfSize();  
       y = -splate[1] ;
-      Float_t* acel = emcg->GetSteelCellHalfSize() ;
+//       Float_t* acel = emcg->GetSteelCellHalfSize() ;
+      Float_t* acel = emcg->GetAirCellHalfSize() ;
 
       for(Int_t lev = 2, icel = 1; icel <= emcg->GetNCellsXInStrip()*emcg->GetNCellsZInStrip(); icel += 2, lev += 2){
          Float_t x = (2*(lev / 2) - 1 - emcg->GetNCellsXInStrip())* acel[0] ;
@@ -558,7 +576,7 @@ void AliPHOSv0::CreateGeometryforEMC()
        gMC->Gspos("PBE1", isup, "PCA1", x, 0.0, 0.0, 0, "ONLY") ;
       }
 
-      z = -warmthermo[2] + cbox[2] ;
+      z = -warmthermo[2] + cbox[2];
       gMC->Gspos("PCA1", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ;     
 
       gMC->Gsvolu("PCA2", "BOX ", idtmed[718], emcg->GetTCables2HalfSize(), 3) ; 
@@ -592,7 +610,7 @@ void AliPHOSv0::CreateGeometryforEMC()
       gMC->Gspos("PFG1", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ;
 
       gMC->Gsvolu("PFG2", "BOX ", idtmed[717], emcg->GetFGupZHalfSize(), 3) ; 
-      posit = emcg->GetFGupZPosition() ;
+      posit = emcg->GetFGupZPosition();
       gMC->Gspos("PFG2", 1, "PWTI",  posit[0], posit[1], posit[2], 0, "ONLY") ;
       gMC->Gspos("PFG2", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ;
 
@@ -916,28 +934,41 @@ void AliPHOSv0::AddAlignableVolumes() const
 
   // Alignable modules
   // Volume path /ALIC_1/PHOS_<i> => symbolic name /PHOS/Module<i>, <i>=1,2,3,4,5
-
+  
+  AliGeomManager::ELayerID idPHOS1 = AliGeomManager::kPHOS1;
+  AliGeomManager::ELayerID idPHOS2 = AliGeomManager::kPHOS2;
+  Int_t modUID, modnum = 0;
   TString physModulePath="/ALIC_1/PHOS_";
   TString symbModuleName="PHOS/Module";
   Int_t nModules = GetGeometry()->GetNModules();
   
+  char im[5] ;
   for(Int_t iModule=1; iModule<=nModules; iModule++){
+    sprintf(im,"%d",iModule) ;
+    if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0)
+      continue ;
+    modUID = AliGeomManager::LayerToVolUID(idPHOS1,modnum++);
     volpath = physModulePath;
     volpath += iModule;
-    volpath += "/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1";
-
+    //    volpath += "/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1";
+   // Check the volume path if not all 5 modules exist
+    if (!gGeoManager->CheckPath(volpath.Data())) {                                                                                         
+      AliError(Form("Volume path %s not valid!",volpath.Data()));                                                                          
+      continue;                                                                                                                            
+    }                                                                                                                                      
     symname = symbModuleName;
     symname += iModule;
-    gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data());
+    if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
+      continue ;
+//      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
 
     // Creates the Tracking to Local transformation matrix for PHOS modules
-    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data()) ;
-    const char *path = alignableEntry->GetTitle();
-    if (!gGeoManager->cd(path))
-       AliFatal(Form("Volume path %s not valid!",path));
+    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
 
     Float_t angle = GetGeometry()->GetPHOSAngle(iModule);
-    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
 
     TGeoHMatrix *matTtoL = new TGeoHMatrix;
     matTtoL->RotateZ(-90.+angle);
@@ -947,7 +978,14 @@ void AliPHOSv0::AddAlignableVolumes() const
 
   //Aligning of CPV should be done for volume PCPV_1
   symbModuleName="PHOS/Module";
+  modnum=0;
   for(Int_t iModule=1; iModule<=nModules; iModule++){
+    if(strstr(GetTitle(),"noCPV"))
+      continue ;
+    sprintf(im,"%d",iModule) ;
+    if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0)
+      continue ;
+    modUID = AliGeomManager::LayerToVolUID(idPHOS2,modnum++);
     volpath = physModulePath;
     volpath += iModule;
     volpath += "/PCPV_1";
@@ -960,16 +998,14 @@ void AliPHOSv0::AddAlignableVolumes() const
     symname = symbModuleName;
     symname += iModule;
     symname += "/CPV";
-    gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data());
+    if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
+      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
           
     // Creates the TGeo Local to Tracking transformation matrix ...
-    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data()) ;
-    const char *path = alignableEntry->GetTitle();
-    if (!gGeoManager->cd(path))
-       AliFatal(Form("Volume path %s not valid!",path));
+    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ;
 
     Float_t angle = GetGeometry()->GetPHOSAngle(iModule);
-    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
 
     TGeoHMatrix *matTtoL = new TGeoHMatrix;
     matTtoL->RotateZ(-90.+angle);
@@ -1019,6 +1055,19 @@ void AliPHOSv0::AddAlignableVolumes() const
   TString fullSymbStripName(100);
 
   for(Int_t module = 1; module <= nModules; ++module){
+
+    sprintf(im,"%d",module) ;
+    if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0)
+      continue ;
+
+    volpath = physModulePath;
+    volpath += module;
+    // Check the volume path if not all 5 modules exist
+    if (!gGeoManager->CheckPath(volpath.Data())) {
+      AliError(Form("Volume path %s does not exist",volpath.Data())) ;
+      continue;
+    }
+
     partialPhysStripName  = physModulePath;
     partialPhysStripName += module;
     partialPhysStripName += "/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_";