]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSegmentation.cxx
In PointSetArray: added member for default daughter PointSet capacity (fDefPointSetCa...
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentation.cxx
index 5a51ee0aefa8f06a42e87444ee4b1503cb001803..5f113282889c84341a3142887980e7e73585f980 100644 (file)
 
 // $Id$
 //
+// ----------------------------
 // Class AliMUONSegmentation
 // ----------------------------
 // Manager class for geometry construction via geometry builders.
-//
 // Author: Ivana Hrivnacova, IPN Orsay
 
 #include <iostream>
 #include "AliMUONSegmentation.h"
 #include "AliMUONVGeometryDESegmentation.h"
 #include "AliMUONGeometrySegmentation.h"
-#include "AliMUONGeometryDEIndexing.h"
+#include "AliMUONGeometryStore.h"
+
+#include "AliMpVSegmentation.h"
+
 #include "AliLog.h"
 
 
@@ -37,10 +40,15 @@ ClassImp(AliMUONSegmentation)
 //______________________________________________________________________________
 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
   : TObject(),
+    fMpSegmentations(0),
     fDESegmentations(0)
 {
 /// Standard constructor
 
+  // Create array for mapping segmentations
+  fMpSegmentations = new TObjArray();
+  fMpSegmentations->SetOwner(kTRUE);
+
   // Create array for DE segmentations
   fDESegmentations = new TObjArray();
   fDESegmentations->SetOwner(kTRUE);
@@ -60,6 +68,7 @@ AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
 //______________________________________________________________________________
 AliMUONSegmentation::AliMUONSegmentation() 
   : TObject(),
+    fMpSegmentations(0),
     fDESegmentations(0)
 {
 /// Default constructor
@@ -74,7 +83,7 @@ AliMUONSegmentation::AliMUONSegmentation()
 AliMUONSegmentation::AliMUONSegmentation(const AliMUONSegmentation& right) 
   : TObject(right) 
 {  
-/// Copy constructor (not implemented)
+/// Protected copy constructor (not implemented)
 
   AliFatal("Copy constructor not provided.");
 }
@@ -86,6 +95,7 @@ AliMUONSegmentation::~AliMUONSegmentation()
 
   AliDebug(1, Form("dtor this = %p", this));
 
+  delete fMpSegmentations;
   delete fDESegmentations;
   delete fModuleSegmentations[0];
   delete fModuleSegmentations[1];
@@ -95,7 +105,7 @@ AliMUONSegmentation::~AliMUONSegmentation()
 AliMUONSegmentation& 
 AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
 {
-/// Assignement operator (not implemented)
+/// Protected assignement operator (not implemented)
 
   // check assignement to self
   if (this == &right) return *this;
@@ -109,13 +119,38 @@ AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
 // public functions
 //
 
+//_____________________________________________________________________________
+void AliMUONSegmentation::AddMpSegmentation(AliMpVSegmentation* segmentation)
+{
+/// Add the mapping segmentation to the array if not present
+
+  Bool_t isPresent = false;
+  for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++) 
+    if ( (AliMpVSegmentation*)fMpSegmentations->At(i) == segmentation ) {
+      isPresent = true;
+      break;
+    }  
+
+  if (!isPresent) fMpSegmentations->Add(segmentation);
+}
+
 //_____________________________________________________________________________
 void AliMUONSegmentation::AddDESegmentation(
-                             AliMUONVGeometryDESegmentation* segmentation)
+                                AliMUONVGeometryDESegmentation* segmentation)
 {
 /// Add the DE segmentation to the array
 
   fDESegmentations->Add(segmentation);
+  
+  // Deregister the mapping segmentation contained in DE segmentation
+  // from fMpSegmentations, if present
+  const AliMpVSegmentation* kmpSeg = segmentation->GetMpSegmentation();
+  
+  for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++) 
+    if ( (const AliMpVSegmentation*)fMpSegmentations->At(i) == kmpSeg ) {
+      fMpSegmentations->RemoveAt(i);
+      break;
+    }  
 }
 
 //_____________________________________________________________________________
@@ -190,7 +225,7 @@ AliMUONSegmentation::GetModuleSegmentationByDEId(
 /// Return the geometry module specified by detElemId/cathod
 
   // Get moduleId 
-  Int_t moduleId = AliMUONGeometryDEIndexing::GetModuleId(detElemId);
+  Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
 
   return GetModuleSegmentation(moduleId, cathod, warn);
 }    
@@ -208,7 +243,7 @@ AliMUONSegmentation::GetDESegmentation(
     
   if ( !moduleSegmentation ) return 0; 
   
-  return moduleSegmentation->GetDESegmentation(detElemId);
+  return moduleSegmentation->GetDESegmentation(detElemId, warn);
 }    
 
 //_____________________________________________________________________________
@@ -232,11 +267,11 @@ AliMUONSegmentation::GetMpSegmentation(
 Bool_t 
 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
 {
-  // Get geometry segmentation 
-  AliMUONGeometrySegmentation* moduleSegmentation
-    = GetModuleSegmentationByDEId(detElemId, cathod, false);
+  // Get DE segmentation 
+  const AliMUONVGeometryDESegmentation* kdeSegmentation
+    = GetDESegmentation(detElemId, cathod, false);
     
-  return ( moduleSegmentation != 0 ); 
+  return ( kdeSegmentation != 0 ); 
   
 }