]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometrySegmentation.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometrySegmentation.cxx
index ec31a0763f5a2d3f76d25251608dc5d8cef7755a..16a908d3a3a2867a1e46765d89fb70966e49e889 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 //
 // Class AliMUONGeometrySegmentation
 // -------------------------------
 //
 // Author:Ivana Hrivnacova, IPN Orsay
 
-/* $Id$ */
+#include "AliMUONGeometrySegmentation.h"
+#include "AliMUONVGeometryDESegmentation.h"
+#include "AliMUONGeometryModuleTransformer.h"
+#include "AliMUONGeometryDetElement.h"
+
+#include "AliMpExMap.h"
+
+#include "AliLog.h"
 
 #include <Riostream.h>
 #include <TObjString.h>
 #include <TClass.h>
 
-#include "AliLog.h"
-
-#include "AliMUONGeometrySegmentation.h"
-#include "AliMUONVGeometryDESegmentation.h"
-#include "AliMUONGeometryModuleTransformer.h"
-#include "AliMUONGeometryDetElement.h"
-#include "AliMUONGeometryStore.h"
+const Float_t  AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e6;
 
+/// \cond CLASSIMP
 ClassImp(AliMUONGeometrySegmentation)
-
-const Float_t  AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e11;
+/// \endcond
 
 //______________________________________________________________________________
 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
@@ -54,9 +57,10 @@ AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
 {
 /// Standard constructor
 
-  fDESegmentations = new AliMUONGeometryStore(false);
+  fDESegmentations = new AliMpExMap(true);
+  fDESegmentations->SetOwner(false);
  
-  fDENames = new AliMUONGeometryStore(true);
+  fDENames = new AliMpExMap(true);
 
   AliDebug(1, Form("ctor this = %p", this) ); 
 }
@@ -77,17 +81,6 @@ AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
   AliDebug(1, Form("default (empty) ctor this = %p", this));
 }
 
-//______________________________________________________________________________
-AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
-                                  const AliMUONGeometrySegmentation& rhs) 
-  : TObject(rhs)
-{
-/// Protected copy constructor
-
-  AliFatal("Copy constructor is not implemented.");
-}
-
-#include <Riostream.h>
 //______________________________________________________________________________
 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation() 
 {
@@ -99,30 +92,12 @@ AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation()
   delete fDENames;
 } 
 
-//
-// operators
-//
-
-//______________________________________________________________________________
-AliMUONGeometrySegmentation& 
-AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
-{
-/// Protected assignment operator 
-
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  AliFatal("Assignment operator is not implemented.");
-    
-  return *this;  
-}
-
 //
 // private methods
 //
 
 //______________________________________________________________________________
-Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
+Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId, Bool_t warn) const
 {
 /// Update current detection element and segmentation,
 /// and checks if they exist.
@@ -132,17 +107,19 @@ Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
 
     // Find detection element and its segmentation
     AliMUONGeometryDetElement* detElement
-      = fkModuleTransformer->GetDetElement(detElemId);
+      = fkModuleTransformer->GetDetElement(detElemId, warn);
     if (!detElement) {
-      AliError(Form("Detection element %d not defined", detElemId));
+      if (warn)
+        AliError(Form("Detection element %d not defined", detElemId));
       return false;
     }     
 
     AliMUONVGeometryDESegmentation* segmentation 
-      = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
+      = (AliMUONVGeometryDESegmentation*) fDESegmentations->GetValue(detElemId);
     if (!segmentation) {
-      AliError(Form("Segmentation for detection element %d not defined",
-                     detElemId));
+      if (warn)
+        AliError(Form("Segmentation for detection element %d not defined",
+                       detElemId));
       return false;                 
     }
   
@@ -171,11 +148,11 @@ void AliMUONGeometrySegmentation::Add(Int_t detElemId, const TString& detElemNam
 
 //______________________________________________________________________________
 const AliMUONVGeometryDESegmentation* 
-AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
+AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId, Bool_t warn) const
 {
 /// Return the DE segmentation 
 
-  if (!OwnNotify(detElemId)) return 0;
+  if (!OwnNotify(detElemId, warn)) return 0;
 
   return fCurrentSegmentation;
 }
@@ -184,7 +161,7 @@ AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
 AliMUONGeometryDirection 
 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
 {
-/// Return direction with a constant pad size 
+/// Return direction with a constant pad size. 
 /// (Direction or coordinate where the resolution is the best)
 
   if (!OwnNotify(detElemId)) return kDirUndefined;
@@ -197,7 +174,7 @@ TString AliMUONGeometrySegmentation::GetDEName(Int_t detElemId) const
 {
 /// Return name of the given detection element
 
-  TObjString* deName = (TObjString*)fDENames->Get(detElemId, false);
+  TObjString* deName = (TObjString*)fDENames->GetValue(detElemId);
   
   if (deName)
     return deName->GetString();
@@ -211,11 +188,11 @@ TString AliMUONGeometrySegmentation::GetDEName(Int_t detElemId) const
 //______________________________________________________________________________
 void AliMUONGeometrySegmentation::Print(Option_t* opt) const
 {
-// Print DE segmentations
+/// Print DE segmentations
 
   std::cout << "fDESegmentations (class " 
            << fDESegmentations->Class()->GetName() << ") entries=" 
-           << fDESegmentations->GetNofEntries() 
+           << fDESegmentations->GetSize() 
            << std::endl;
   fDESegmentations->Print(opt);        
 }
@@ -225,9 +202,9 @@ void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
 {
 /// Set pad size Dx*Dy to all detection element segmentations 
 
-  for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
+  for (Int_t i=0; i<fDESegmentations->GetSize(); i++) {
      AliMUONVGeometryDESegmentation* segmentation
-       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
+       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetObject(i);
      segmentation->SetPadSize(p1, p2);
   }   
 }
@@ -237,9 +214,9 @@ void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
 {
 /// Set anod pitch to all detection element segmentations
 
-  for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
+  for (Int_t i=0; i<fDESegmentations->GetSize(); i++) {
      AliMUONVGeometryDESegmentation* segmentation
-       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
+       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetObject(i);
      segmentation->SetDAnod(d);
   }   
 }
@@ -279,13 +256,28 @@ Bool_t  AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
 Bool_t
 AliMUONGeometrySegmentation::HasPad(Int_t detElemId, Int_t ix, Int_t iy)
 {
-// Tells if a given pad exists in a given detector element
+/// Tell if a given pad exists in a given detector element
 
   if (!OwnNotify(detElemId)) return false;
        
   return fCurrentSegmentation->HasPad(ix,iy);
 }
                                     
+//______________________________________________________________________________
+Bool_t
+AliMUONGeometrySegmentation::HasPad(Int_t detElemId, 
+                                    Float_t xg, Float_t yg, Float_t zg)
+{
+/// Tell if a given pad exists in a given detector element
+
+  if (!OwnNotify(detElemId)) return false;
+       
+  Float_t xl, yl, zl;
+  fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl); 
+
+  return fCurrentSegmentation->HasPad(xl, yl, zl);
+}
+                                    
 //______________________________________________________________________________
 Bool_t  
 AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
@@ -315,21 +307,25 @@ void AliMUONGeometrySegmentation::Init(Int_t chamber)
 /// Check that all detection elements have segmanetation set
 
   // Loop over detection elements
-  AliMUONGeometryStore* detElements = fkModuleTransformer->GetDetElementStore();
+  AliMpExMap* detElements = fkModuleTransformer->GetDetElementStore();
+
+  for (Int_t i=0; i<detElements->GetSize(); i++) {
 
-  for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
+    // Skip not filled entries
+    if (!detElements->GetObject(i)) continue;
 
     // Get detction element Id
-    Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
+    Int_t detElemId = detElements->GetObject(i)->GetUniqueID();
 
     // Check segmentation
-    if (! fDESegmentations->Get(detElemId) ) {
-      AliError(Form("Detection element %d has not a segmentation set.",
-               detElements->GetEntry(i)->GetUniqueID()));
+    if (! fDESegmentations->GetValue(detElemId) ) {
+      AliErrorStream()
+        << "Detection element " << detElemId << " has not a segmentation set." 
+       << endl;
     }
     else {             
       // Initialize DE Segmentation
-      ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
+      ((AliSegmentation*)fDESegmentations->GetValue(detElemId))->Init(chamber);
     }                 
   }               
 }
@@ -367,7 +363,7 @@ Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
 //______________________________________________________________________________
 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
 {
-/// Pad size in x, y by Sector 
+/// Pad size in y by Sector 
 
   if (!OwnNotify(detElemId)) return 0.;
 
@@ -411,7 +407,7 @@ void  AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
 void  AliMUONGeometrySegmentation::SetHit(Int_t detElemId, 
                                         Float_t xghit, Float_t yghit, Float_t zghit)
 {
-/// Set hit position
+/// Set hit position.
 /// Sets virtual hit position, needed for evaluating pad response 
 /// outside the tracking program 
 /// From AliMUONGeometrySegmentationV01.
@@ -545,7 +541,7 @@ Int_t  AliMUONGeometrySegmentation::ISector()
 //______________________________________________________________________________
 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
 {
-/// Calculate sector from pad coordinates
+/// Calculate sector from pad indices
 
   if (!OwnNotify(detElemId)) return 0;
 
@@ -647,9 +643,9 @@ void AliMUONGeometrySegmentation::Draw(const char* opt)
 {
 /// Draw the segmentation zones for all detElemId 
 
-  for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
+  for (Int_t i=0; i<fDESegmentations->GetSize(); i++) {
      AliMUONVGeometryDESegmentation* segmentation
-       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
+       = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetObject(i);
      segmentation->Draw(opt);
   }   
 }