]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSegFactory.cxx
Corrected access to the data file
[u/mrichter/AliRoot.git] / MUON / AliMUONSegFactory.cxx
index b2a2dddfc40fac215265460a69b112c2cf6ba128..e00661bad71973dc14c58c6b9c22c26caa39facc 100644 (file)
 #include "AliMUONGeometrySegmentation.h"
 #include "AliMUONSt12QuadrantSegmentation.h"
 #include "AliMUONSt345SlatSegmentation.h"
-#include "AliMUONSt345SlatSegmentationV2.h"
 #include "AliMUONTriggerSegmentation.h"
-#include "AliMUONTriggerSegmentationV2.h"
 
 #include "AliMpDEManager.h"
 #include "AliMpDEIterator.h"
+#include "AliMpSegmentation.h"
+#include "AliMpDetElement.h"
+#include "AliMpCathodType.h"
 
 #include "AliLog.h"
 
@@ -54,7 +55,6 @@ ClassImp(AliMUONSegFactory)
 //______________________________________________________________________________
 AliMUONSegFactory::AliMUONSegFactory(const AliMUONGeometryTransformer* geometry)
     : TObject(),
-      fMpSegFactory(),
       fDESegmentations(),
       fSegmentation(0),
       fkTransformer(geometry)
@@ -67,7 +67,6 @@ AliMUONSegFactory::AliMUONSegFactory(const AliMUONGeometryTransformer* geometry)
 AliMUONSegFactory::AliMUONSegFactory(const TString& volPathsFileName,
                                      const TString& transformsFileName)
     : TObject(),
-      fMpSegFactory(),
       fDESegmentations(),
       fSegmentation(0),
       fkTransformer(0)
@@ -83,7 +82,6 @@ AliMUONSegFactory::AliMUONSegFactory(const TString& volPathsFileName,
 //______________________________________________________________________________
   AliMUONSegFactory::AliMUONSegFactory()
     : TObject(),      
-      fMpSegFactory(),
       fDESegmentations(),
       fSegmentation(0),
       fkTransformer(0)
@@ -113,7 +111,7 @@ Bool_t AliMUONSegFactory::IsGeometryDefined(Int_t ichamberId)
 
   AliMpDEIterator it;
   it.First(ichamberId);
-  Int_t firstDE = it.CurrentDE(); 
+  Int_t firstDE = it.CurrentDEId(); 
   
   if ( ! fkTransformer ||
        ! fkTransformer->GetModuleTransformerByDEId(firstDE, false) )
@@ -138,29 +136,14 @@ AliMUONSegmentation* AliMUONSegFactory::Segmentation()
 // public methods
 //
 
-//______________________________________________________________________________
-AliMpVSegmentation* 
-AliMUONSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
-{
-/// Create mapping segmentation for given detElemId and cath
-/// using mapping manager
-
-  AliMpVSegmentation* mpSegmentation 
-    = fMpSegFactory.CreateMpSegmentation(detElemId, cath);
-
-  Segmentation()->AddMpSegmentation(mpSegmentation);
-  
-  return mpSegmentation;
-} 
-    
 //______________________________________________________________________________
 AliMUONVGeometryDESegmentation*  
-AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
+AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, AliMp::CathodType cath)
 { 
 /// Create DE segmentation, operating in local DE reference frame
 
   // Check detElemId & cath  
-  if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0;
+  if ( ! AliMpDEManager::IsValidDetElemId(detElemId, true) ) return 0;
   
   // Check if transformer is defined
   if ( ! fkTransformer) {
@@ -191,24 +174,29 @@ AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
   // Get DE segmentation for this DE type, create it if it does not exist 
   // 
   AliMUONVGeometryDESegmentation* deSegmentation = 0;
-  TString deName = AliMpDEManager::GetDEName(detElemId, cath);
-  TObject* objSegmentation = fDESegmentations.Get(deName);
+  AliMpDetElement* detElement = AliMpDEManager::GetDetElement(detElemId);
+  TString deSegName = detElement->GetSegName(cath);
+  TObject* objSegmentation = fDESegmentations.Get(deSegName);
   if ( objSegmentation ) 
     deSegmentation = (AliMUONVGeometryDESegmentation*)objSegmentation;  
     
   if ( !deSegmentation ) {
 
+    
+
     // Get/Create mapping segmentation via mapping manager
+    const AliMpVSegmentation* kmpSegmentation 
+      = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, cath);
     AliMpVSegmentation* mpSegmentation 
-      = CreateMpSegmentation(detElemId, cath);
-    AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
-    AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
+      = const_cast<AliMpVSegmentation*>(kmpSegmentation);
+
+    AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
+    AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
     
     switch (stationType) {
 
-      case kStation1:
-      case kStation2:
+      case AliMp::kStation1:
+      case AliMp::kStation2:
         deSegmentation = new AliMUONSt12QuadrantSegmentation(
                                 mpSegmentation, stationType, planeType);
         //cout << "   new AliMUONSt12QuadrantSegmentation "
@@ -218,8 +206,8 @@ AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
                                          
         break;
         
-      case kStation345:                  
-        deSegmentation = new AliMUONSt345SlatSegmentationV2(
+      case AliMp::kStation345:                   
+        deSegmentation = new AliMUONSt345SlatSegmentation(
                                 mpSegmentation, detElemId, planeType); 
         //cout << "   new AliMUONSt345SlatSegmentationV2 "                       
        //     << StationTypeName(stationType) << "  "  
@@ -227,10 +215,10 @@ AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
        //     << deName << endl;                                 
         break;
     
-      case kStationTrigger:              
-        deSegmentation = new AliMUONTriggerSegmentationV2(
+      case AliMp::kStationTrigger:               
+        deSegmentation = new AliMUONTriggerSegmentation(
                                 mpSegmentation, detElemId, planeType); 
-        //cout << "   new AliMUONTriggerSegmentationV2 "                         
+        //cout << "   new AliMUONTriggerSegmentation "                   
        //     << StationTypeName(stationType) << "  "  
        //     << PlaneTypeName(planeType) << "  "                        
        //     << deName << endl;                                 
@@ -238,13 +226,13 @@ AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
     }
     
     // Map new DE segmentation
-    fDESegmentations.Add(deName, deSegmentation);
+    fDESegmentations.Add(deSegName, deSegmentation);
     Segmentation()->AddDESegmentation(deSegmentation);
   }
   
   // Add  DE segmentation to module
   //
-  moduleSegmentation->Add(detElemId, deName, deSegmentation);  
+  moduleSegmentation->Add(detElemId, deSegName, deSegmentation);  
   
   return deSegmentation;
 }        
@@ -252,48 +240,29 @@ AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
 
 //______________________________________________________________________________
 void
-AliMUONSegFactory::CreateModuleSegmentations(Int_t chamberId, Int_t cath)
+AliMUONSegFactory::CreateModuleSegmentations(Int_t chamberId, AliMp::CathodType cath)
 { 
 /// Create module segmentation(s), operating in the global reference frame
 /// Detection elements are defined via DE names map.
 
-  // Check cathod & module Id 
-  if ( ! AliMpDEManager::IsValidCathod(cath, true) || 
-       ! AliMpDEManager::IsValidChamberId(chamberId, true) ) return;
+  // Check module Id 
+  if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) return;
 
   AliMpDEIterator it;
   for ( it.First(chamberId); ! it.IsDone(); it.Next() )
-    CreateDESegmentation(it.CurrentDE(), cath);
+    CreateDESegmentation(it.CurrentDEId(), cath);
 }  
     
 //______________________________________________________________________________
 AliMUONSegmentation*  
-AliMUONSegFactory::CreateSegmentation(const TString& option)
+AliMUONSegFactory::CreateSegmentation()
 {
 /// Create segmentations on all levels and return their container.
 
-  // Check options
-  if ( option != "default"   && 
-       option != "FactoryV2" && 
-       option != "FactoryV3" &&
-       option != "FactoryV4" &&
-       option != "new") {
-
-    AliErrorStream() << "Option " << option << " not defined." << endl;
-    return 0;
-  }         
-  if ( option == "FactoryV2" || option == "FactoryV3" ) { 
-
-    AliErrorStream() 
-      << "Option " << option << " not supported anymore." << endl;
-    return 0;
-  }         
-
   for (Int_t chamberId = 0; chamberId<AliMUONConstants::NCh(); chamberId++)
-    for (Int_t cath = 0; cath < 2; cath++) {
+    for (Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; cath++) {
       if ( IsGeometryDefined(chamberId) )
-        CreateModuleSegmentations( chamberId, cath);
+        CreateModuleSegmentations( chamberId, AliMp::GetCathodType(cath));
   }
 
   return Segmentation();