**************************************************************************/
// $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>
+using std::cout;
+using std::endl;
+using std::string;
+/// \cond CLASSIMP
ClassImp(AliMUONGeometryDetElement)
+/// \endcond
+
+//
+// static methods
+//
//______________________________________________________________________________
-AliMUONGeometryDetElement::AliMUONGeometryDetElement(
- Int_t detElemId,
- const TString& alignedVolume,
- const TGeoCombiTrans& relTransform)
+const TString& AliMUONGeometryDetElement::GetDENamePrefix()
+{
+ ///< Geometry DE name prefix
+ static const TString kDENamePrefix = "DE";
+ return kDENamePrefix;
+}
+
+//______________________________________________________________________________
+TString AliMUONGeometryDetElement::GetDEName(Int_t detElemId)
+{
+/// Return the module name for given moduleId
+
+ TString deName(GetDENamePrefix());
+ deName += detElemId;
+ return deName;
+}
+
+//______________________________________________________________________________
+AliMUONGeometryDetElement::AliMUONGeometryDetElement(Int_t detElemId)
: TObject(),
- fAlignedVolume(alignedVolume),
+ fDEName(GetDEName(detElemId)),
+ fVolumePath(),
fLocalTransformation(0),
fGlobalTransformation(0)
{
/// Standard constructor
SetUniqueID(detElemId);
- fLocalTransformation = new TGeoCombiTrans(relTransform);
}
//______________________________________________________________________________
-AliMUONGeometryDetElement::AliMUONGeometryDetElement()
+AliMUONGeometryDetElement::AliMUONGeometryDetElement(
+ Int_t detElemId,
+ const TString& volumePath)
: TObject(),
- fAlignedVolume(),
+ fDEName(GetDEName(detElemId)),
+ fVolumePath(volumePath),
fLocalTransformation(0),
fGlobalTransformation(0)
-{
-/// Default constructor
+{
+/// Standard constructor
+
+ SetUniqueID(detElemId);
}
//______________________________________________________________________________
-AliMUONGeometryDetElement::AliMUONGeometryDetElement(
- const AliMUONGeometryDetElement& rhs)
- : TObject(rhs)
+AliMUONGeometryDetElement::AliMUONGeometryDetElement(TRootIOCtor* /*ioCtor*/)
+ : TObject(),
+ fDEName(),
+ fVolumePath(),
+ fLocalTransformation(0),
+ fGlobalTransformation(0)
{
-/// Protected copy constructor
-
- AliFatal("Copy constructor is not implemented.");
+/// Root IO constructor
}
//______________________________________________________________________________
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: "
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;
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) {
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;
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) {
zg = pg[2];
}
+//______________________________________________________________________________
+void AliMUONGeometryDetElement::SetLocalTransformation(
+ const TGeoHMatrix& transform,
+ Bool_t warn)
+{
+/// Set local transformation;
+/// give warning if the global transformation is already defined.
+
+ if ( fLocalTransformation ) {
+ delete fLocalTransformation;
+ if ( warn ) {
+ AliWarning("Local transformation already defined was deleted.");
+ }
+ }
+
+ fLocalTransformation = new TGeoHMatrix(transform);
+}
+
//______________________________________________________________________________
void AliMUONGeometryDetElement::SetGlobalTransformation(
- const TGeoCombiTrans& transform)
+ const TGeoHMatrix& transform,
+ Bool_t warn)
{
-/// 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.");
+ if ( warn ) {
+ 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);
//______________________________________________________________________________
void AliMUONGeometryDetElement::PrintGlobalTransform() const
{
-/// Prints detection element global transformation
+/// Print detection element global transformation
/// (the transformation wrt global frame)
- PrintTransform(fLocalTransformation);
+ 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;
+}
+