]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometryDetElement.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryDetElement.cxx
index d964282e25d25e61ebc0b52029df7f2d23f7ccd1..c4c7e2ed466f3b24cc2e1717c0c8f26a026e5212 100644 (file)
 
 // $Id$
 //
+// --------------------------------------
 // Class AliMUONGeometryDetElement
 // --------------------------------------
 // The class defines the detection element.
-//
 // Author: Ivana Hrivnacova, IPN Orsay
 
-#include <TGeoMatrix.h>
-#include <Riostream.h>
+#include "AliMUONGeometryDetElement.h"
 
 #include "AliLog.h"
 
-#include "AliMUONGeometryDetElement.h"
+#include <TGeoMatrix.h>
+#include <Riostream.h>
+
+#include <sstream>
 
+/// \cond CLASSIMP
 ClassImp(AliMUONGeometryDetElement)
+/// \endcond
+
+const TString AliMUONGeometryDetElement::fgkDENamePrefix = "DE";
 
 //______________________________________________________________________________
 AliMUONGeometryDetElement::AliMUONGeometryDetElement(
                                         Int_t detElemId,
-                                        const TString& alignedVolume, 
-                                       const TGeoCombiTrans& relTransform)
+                                        const TString& volumePath)
  : TObject(),
-   fAlignedVolume(alignedVolume),
+   fDEName(),
+   fVolumePath(volumePath),
    fLocalTransformation(0),
    fGlobalTransformation(0)
 { 
 /// Standard constructor
 
   SetUniqueID(detElemId);
-  fLocalTransformation = new TGeoCombiTrans(relTransform);
+  
+  fDEName = fgkDENamePrefix;
+  fDEName += detElemId;
 }
 
 //______________________________________________________________________________
 AliMUONGeometryDetElement::AliMUONGeometryDetElement()
  : TObject(),
-   fAlignedVolume(),
+   fDEName(),
+   fVolumePath(),
    fLocalTransformation(0),
    fGlobalTransformation(0)
 {
 /// Default constructor
 }
 
-//______________________________________________________________________________
-AliMUONGeometryDetElement::AliMUONGeometryDetElement(
-                                   const AliMUONGeometryDetElement& rhs)
-  : TObject(rhs)
-{
-/// Protected copy constructor
-
-  AliFatal("Copy constructor is not implemented.");
-}
-
 //______________________________________________________________________________
 AliMUONGeometryDetElement::~AliMUONGeometryDetElement() 
 {
@@ -75,32 +74,23 @@ AliMUONGeometryDetElement::~AliMUONGeometryDetElement()
   delete fGlobalTransformation;
 }
 
-//______________________________________________________________________________
-AliMUONGeometryDetElement& 
-AliMUONGeometryDetElement::operator = (const AliMUONGeometryDetElement& rhs) 
-{
-/// Protected assignement operator
-
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  AliFatal("Assignment operator is not implemented.");
-    
-  return *this;  
-}
-
 //
 // private methods
 //
 
 //______________________________________________________________________________
 void  AliMUONGeometryDetElement::PrintTransform(
-                                            const TGeoCombiTrans* transform) const
+                                            const TGeoHMatrix* transform) const
 {
-/// Prints the detection element transformation
+/// Print the detection element transformation
 
   cout << "DetElemId: " << GetUniqueID();
-  cout << "  name: " << fAlignedVolume << endl;
+  cout << "  name: " << fVolumePath << endl;
+
+  if ( !transform ) {
+    cout << "    Transformation not defined." << endl;
+    return;
+  }  
 
   const double* translation = transform->GetTranslation();
   cout << "   translation: "
@@ -143,9 +133,8 @@ void  AliMUONGeometryDetElement::Global2Local(
                                   Float_t xg, Float_t yg, Float_t zg, 
                                   Float_t& xl, Float_t& yl, Float_t& zl) const
 {
-/// Transforms point from the global reference frame (ALIC)
-/// to the local reference frame of the detection element specified
-/// by detElemId.
+/// Transform point from the global reference frame (ALIC)
+/// to the local reference frame of this detection element.
 
   Double_t dxg = xg;
   Double_t dyg = yg;
@@ -164,9 +153,8 @@ void  AliMUONGeometryDetElement::Global2Local(
                                   Double_t xg, Double_t yg, Double_t zg, 
                                   Double_t& xl, Double_t& yl, Double_t& zl) const
 {
-/// Transforms point from the global reference frame (ALIC)
-/// to the local reference frame of the detection element specified
-/// by detElemId.
+/// Transform point from the global reference frame (ALIC)
+/// to the local reference frame of this detection element
 
    // Check transformation
    if (!fGlobalTransformation) {
@@ -191,8 +179,8 @@ void  AliMUONGeometryDetElement::Local2Global(
                  Float_t xl, Float_t yl, Float_t zl, 
                  Float_t& xg, Float_t& yg, Float_t& zg) const
 {
-/// Transforms point from the local reference frame of the detection element 
-/// specified by detElemId to the global reference frame (ALIC).
+/// Transform point from the local reference frame of this detection element 
+/// to the global reference frame (ALIC).
 
   Double_t dxl = xl;
   Double_t dyl = yl;
@@ -211,8 +199,8 @@ void  AliMUONGeometryDetElement::Local2Global(
                  Double_t xl, Double_t yl, Double_t zl, 
                  Double_t& xg, Double_t& yg, Double_t& zg) const
 {
-/// Transforms point from the local reference frame of the detection element 
-/// specified by detElemId to the global reference frame (ALIC).
+/// Transform point from the local reference frame of this detection element 
+/// to the global reference frame (ALIC).
 
    // Check transformation
    if (!fGlobalTransformation) {
@@ -232,25 +220,40 @@ void  AliMUONGeometryDetElement::Local2Global(
    zg = pg[2];  
 }
 
+//______________________________________________________________________________
+void AliMUONGeometryDetElement::SetLocalTransformation(
+                                                const TGeoHMatrix& transform)
+{ 
+/// Set local transformation;
+/// give warning if the global transformation is already defined.
+  if (fLocalTransformation) {
+    delete fLocalTransformation;
+    AliWarning("Local transformation already defined was deleted.");
+  }  
+
+  fLocalTransformation = new TGeoHMatrix(transform);
+}  
+                                             
 //______________________________________________________________________________
 void AliMUONGeometryDetElement::SetGlobalTransformation(
-                                                const TGeoCombiTrans& transform)
+                                                const TGeoHMatrix& transform)
 { 
-/// Sets global transformation;
-/// gives warning if the global transformation is already defined.
+/// Set global transformation;
+/// give warning if the global transformation is already defined.
  
   if (fGlobalTransformation) {
     delete fGlobalTransformation;
     AliWarning("Global transformation already defined was deleted.");
   }  
 
-  fGlobalTransformation = new TGeoCombiTrans(transform);
+  fGlobalTransformation = new TGeoHMatrix(transform);
 }  
                                              
 //______________________________________________________________________________
 void AliMUONGeometryDetElement::PrintLocalTransform() const
 {
-/// Prints detection element relative transformation
+/// Print detection element relative transformation
 /// (the transformation wrt module frame)
 
   PrintTransform(fLocalTransformation);
@@ -259,8 +262,36 @@ void AliMUONGeometryDetElement::PrintLocalTransform() const
 //______________________________________________________________________________
 void AliMUONGeometryDetElement::PrintGlobalTransform() const
 {
-/// Prints detection element global transformation
+/// Print detection element global transformation
 /// (the transformation wrt global frame)
 
   PrintTransform(fGlobalTransformation);
 }  
+
+//______________________________________________________________________________
+TString AliMUONGeometryDetElement::GetVolumeName() const
+{ 
+/// Extract volume name from the path
+  
+  std::string volPath = fVolumePath.Data();
+  std::string::size_type first = volPath.rfind('/')+1;
+  std::string::size_type last = volPath.rfind('_');
+  
+  return volPath.substr(first, last-first );
+}
+
+//______________________________________________________________________________
+Int_t AliMUONGeometryDetElement::GetVolumeCopyNo() const
+{ 
+/// Extract volume copyNo from the path
+  
+  string volPath = fVolumePath.Data();
+  std::string::size_type first = volPath.rfind('_');
+  std::string copyNoStr = volPath.substr(first+1, volPath.length());
+  std::istringstream in(copyNoStr);
+  Int_t copyNo;
+  in >> copyNo;
+  
+  return copyNo;
+}
+