]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometrySegmentation.cxx
12-sep-2006 NvE Memberfunctions GetNslots and AddNamedSlot introduced and various
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometrySegmentation.cxx
index 67f943276512fcd87cb630607e4fd73373f79748..fbf897cecade1d9ce049d3a66b4f677b90c93b54 100644 (file)
 
 /* $Id$ */
 
-#include <Riostream.h>
-#include "TClass.h"
-
-#include "AliLog.h"
-
 #include "AliMUONGeometrySegmentation.h"
 #include "AliMUONVGeometryDESegmentation.h"
-#include "AliMUONGeometryModule.h"
+#include "AliMUONGeometryModuleTransformer.h"
 #include "AliMUONGeometryDetElement.h"
 #include "AliMUONGeometryStore.h"
 
-ClassImp(AliMUONGeometrySegmentation)
+#include "AliLog.h"
 
-const Float_t  AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e11;
+#include <Riostream.h>
+#include <TObjString.h>
+#include <TClass.h>
+
+const Float_t  AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e6;
+
+/// \cond CLASSIMP
+ClassImp(AliMUONGeometrySegmentation)
+/// \endcond
 
 //______________________________________________________________________________
 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
-                                  AliMUONGeometryModule* geometry
+                             const AliMUONGeometryModuleTransformer* transformer
 : TObject(),
   fCurrentDetElemId(0),
   fCurrentDetElement(0),
   fCurrentSegmentation(0),
-  fGeometryModule(geometry),
-  fDESegmentations(0)
+  fkModuleTransformer(transformer),
+  fDESegmentations(0),
+  fDENames(0)
   
 {
 /// Standard constructor
 
-  fDESegmentations 
-    = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
+  fDESegmentations = new AliMUONGeometryStore(false);
+  fDENames = new AliMUONGeometryStore(true);
+
+  AliDebug(1, Form("ctor this = %p", this) ); 
 }
 
 //______________________________________________________________________________
@@ -62,20 +69,14 @@ AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
   fCurrentDetElemId(0),
   fCurrentDetElement(0),
   fCurrentSegmentation(0),
-  fGeometryModule(0),
-  fDESegmentations(0)
+  fkModuleTransformer(0),
+  fDESegmentations(0),
+  fDENames(0)
+  
 {
 /// Default Constructor
-}
-
-//______________________________________________________________________________
-AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
-                                  const AliMUONGeometrySegmentation& rhs) 
-  : TObject(rhs)
-{
-/// Protected copy constructor
 
-  AliFatal("Copy constructor is not implemented.");
+  AliDebug(1, Form("default (empty) ctor this = %p", this));
 }
 
 //______________________________________________________________________________
@@ -83,33 +84,18 @@ AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation()
 {
 /// Destructor
 
+  AliDebug(1, Form("dtor this = %p", this));
+
   delete fDESegmentations;
+  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.
@@ -119,17 +105,19 @@ Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
 
     // Find detection element and its segmentation
     AliMUONGeometryDetElement* detElement
-      = fGeometryModule->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->Get(detElemId, warn);
     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;                 
     }
   
@@ -146,22 +134,23 @@ Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
 //
 
 //______________________________________________________________________________
-void AliMUONGeometrySegmentation::Add(Int_t detElemId, 
+void AliMUONGeometrySegmentation::Add(Int_t detElemId, const TString& detElemName,
                                       AliMUONVGeometryDESegmentation* segmentation)
 {
 /// Add detection element segmentation
 
   fDESegmentations->Add(detElemId, segmentation); 
+  fDENames->Add(detElemId, new TObjString(detElemName)); 
 }  
 
 
 //______________________________________________________________________________
 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;
 }
@@ -170,7 +159,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;
@@ -178,10 +167,26 @@ AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
   return fCurrentSegmentation->GetDirection();
 }
 
+//______________________________________________________________________________
+TString AliMUONGeometrySegmentation::GetDEName(Int_t detElemId) const
+{
+/// Return name of the given detection element
+
+  TObjString* deName = (TObjString*)fDENames->Get(detElemId, false);
+  
+  if (deName)
+    return deName->GetString();
+  else {  
+    AliWarningStream()
+         << "Detection element " << detElemId  << " not defined. " << endl;
+    return "Undefined";
+  }
+}    
+
 //______________________________________________________________________________
 void AliMUONGeometrySegmentation::Print(Option_t* opt) const
 {
-// Print DE segmentations
+/// Print DE segmentations
 
   std::cout << "fDESegmentations (class " 
            << fDESegmentations->Class()->GetName() << ") entries=" 
@@ -249,13 +254,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,
@@ -274,7 +294,7 @@ AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
   Float_t xl, yl, zl;
   fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
 
-  fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg); 
+  fkModuleTransformer->Local2Global(detElemId, xl, yl, zl, xg, yg, zg); 
   return true;
 }
 
@@ -285,7 +305,7 @@ void AliMUONGeometrySegmentation::Init(Int_t chamber)
 /// Check that all detection elements have segmanetation set
 
   // Loop over detection elements
-  AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
+  AliMUONGeometryStore* detElements = fkModuleTransformer->GetDetElementStore();
 
   for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
 
@@ -337,7 +357,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.;
 
@@ -381,7 +401,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.
@@ -403,6 +423,9 @@ void  AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
 
   if (!OwnNotify(detElemId)) return;
 
+  AliDebug(1,Form("xghit, yghit, zghit, dx, dy = %e,%e,%e,%e, %e",
+                   xghit, yghit, zghit, dx, dy));
+  
   Float_t xl, yl, zl;
   fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl); 
 
@@ -512,7 +535,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;