]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometryEnvelopeStore.cxx
Update responsibles for MCH, MTR, HMP
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryEnvelopeStore.cxx
index c78e2a97b97d44db0f82969b484169541650c360..c9047286b6eb296d6f6992d2d4e7728bcbea292a 100644 (file)
@@ -1,35 +1,59 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
 // $Id$
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMUONGeometryEnvelopeStore
 // ----------------------------------
 // Class for definititon of the temporary volume envelopes
 // used in geometry construction
-//
 // Author: Ivana Hrivnacova, IPN Orsay
+//-----------------------------------------------------------------------------
+
+#include "AliMUONGeometryEnvelopeStore.h"
+#include "AliMUONGeometryEnvelope.h"
+#include "AliMUONGeometryDetElement.h"
+#include "AliMUONGeometryBuilder.h"
+
+#include "AliMpExMap.h"
+
+#include "AliLog.h"
 
-#include <TVirtualMC.h>
 #include <TGeoMatrix.h>
 #include <TObjArray.h>
-#include <TArrayI.h>
 #include <Riostream.h>
+#include <TString.h>
 
-#include "AliMUONGeometryEnvelopeStore.h"
-#include "AliMUONGeometryTransformStore.h"
-#include "AliMUONGeometryEnvelope.h"
-#include "AliMUONConstants.h"
-
+using std::cout;
+using std::endl;
+/// \cond CLASSIMP
 ClassImp(AliMUONGeometryEnvelopeStore)
+/// \endcond
 
 //______________________________________________________________________________
 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
-                                 AliMUONGeometryTransformStore* transforms)
+                                    AliMpExMap* detElements)
  : TObject(),
-   fDETransforms(transforms),
    fEnvelopes(0),
+   fDetElements(detElements),
+   fReferenceFrame(),
    fDebug(false),
    fAlign(false)
 {
-// Standard constructor
+/// Standard constructor
 
   fEnvelopes = new TObjArray(100);
 }
@@ -38,27 +62,20 @@ AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
 //______________________________________________________________________________
 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
  : TObject(),
-   fDETransforms(0),
    fEnvelopes(0),
+   fDetElements(0),
+   fReferenceFrame(),
    fDebug(false),
    fAlign(false)
 {
-// Default constructor
+/// Default constructor
 }
 
 
-//______________________________________________________________________________
-AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
-  : TObject(rhs)
-{
-  Fatal("Copy constructor", 
-        "Copy constructor is not implemented.");
-}
-
 //______________________________________________________________________________
 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore() 
 {
-//
+/// Destructor
 
   // Add deleting rotation matrices 
   
@@ -68,29 +85,29 @@ AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
   }  
 }
 
-//______________________________________________________________________________
-AliMUONGeometryEnvelopeStore& 
-AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs) 
-{
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  Fatal("operator=", 
-        "Assignment operator is not implemented.");
-    
-  return *this;  
-}
-
 //
 // private methods
 //
 
+//______________________________________________________________________________
+TGeoHMatrix 
+AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
+{
+/// Convert transformation into the reference frame
+
+  if ( fReferenceFrame.IsIdentity() )
+    return transform;
+  else  {
+    return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
+                                            transform );  
+  }                        
+}
+
 //______________________________________________________________________________
 AliMUONGeometryEnvelope* 
 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
 {
-// Finds the envelope specified by name.
-// ---
+/// Find the envelope specified by name.
 
   for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
     AliMUONGeometryEnvelope* envelope 
@@ -106,21 +123,26 @@ AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
                                           AliMUONGeometryEnvelope* envelope) const
 {
-// Find transformation by the detection element        Id (if not 0)
-// (= unique ID of enevelope) and set it to the envelope.
-// Return true if transformation is applied, false otherwise.
-// ---
+/// Find transformation by the detection element       Id (if not 0)
+/// (= unique ID of enevelope) and set it to the envelope.
+/// Return true if transformation is applied, false otherwise.
 
   Int_t detElemId = envelope->GetUniqueID();
   if (detElemId == 0) return false;
   
-  const TGeoCombiTrans* kTransform = fDETransforms->Get(detElemId);
-  if (!kTransform) {
-    Warning("AlignEnvelope", "Transformation not found.");
+  AliMUONGeometryDetElement* detElement 
+    = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
+  if (!detElement) {
+    AliWarning("Transformation not found.");
     return false;
   };
 
-  envelope->SetTransform(*kTransform);
+  // Apply frame transform
+  TGeoHMatrix newTransform 
+    = ConvertDETransform(*(detElement->GetLocalTransformation()));
+
+  envelope->SetTransform(newTransform);
+  
   return true;
 }  
 
@@ -134,16 +156,11 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           Bool_t isVirtual,
                                           const char* only) 
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
-  if (fDebug) {
-    cout << "... Adding ";
-    if (!isVirtual) cout << " non-";
-    cout << "virtual envelope " << name 
-         << "  id " << id << endl;
-  }  
+  if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
+//  else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
 
   AliMUONGeometryEnvelope* envelope 
     = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
@@ -160,9 +177,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           const TGeoTranslation& translation,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding ";
@@ -192,9 +208,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                          const TGeoRotation& rotation,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding ";
@@ -239,9 +254,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           const TGeoCombiTrans& transform,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding ";
@@ -272,9 +286,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           Int_t copyNo,
                                           const char* only) 
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding "
@@ -298,9 +311,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           const TGeoTranslation& translation,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding "
@@ -330,9 +342,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                          const TGeoRotation& rotation,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding "
@@ -366,9 +377,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
                                           const TGeoCombiTrans& transform,
                                          const char* only)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// to the list of envelopes.
 
   if (fDebug) {
     cout << "... Adding "
@@ -397,9 +407,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
 void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name, 
                                          const TString& envName, Int_t copyNo) 
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding constituent " << name
@@ -422,9 +431,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
                                           const TString& envName, Int_t copyNo,
                                           const TGeoTranslation& translation)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding constituent " << name
@@ -449,9 +457,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
                                           const TGeoTranslation& translation,
                                          const TGeoRotation& rotation)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding constituent " << name
@@ -475,9 +482,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
                                           const TString& envName, Int_t copyNo, 
                                           const TGeoCombiTrans& transform)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding constituent " << name
@@ -501,9 +507,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& n
                                          const TString& envName, Int_t copyNo,
                                         Int_t npar, Double_t* param) 
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding parameterised constituent " << name
@@ -527,9 +532,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& n
                                           const TGeoTranslation& translation,
                                          Int_t npar, Double_t* param)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding parameterised constituent " << name
@@ -555,9 +559,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& n
                                          const TGeoRotation& rotation,
                                          Int_t npar, Double_t* param)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding parameterised constituent " << name
@@ -582,9 +585,8 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& n
                                           const TGeoCombiTrans& transform,
                                          Int_t npar, Double_t* param)
 {
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
+/// Add the volume with the specified name and transformation
+/// as a constituent of the envelope envName.
 
   if (fDebug) {
     cout << "... Adding parameterised constituent " << name
@@ -603,3 +605,15 @@ void  AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& n
   envelope->AddConstituentParam(name, copyNo, transform, npar, param);
 }
 
+//______________________________________________________________________________
+Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
+{
+/// Return the number od envelopes with detElemId>0.
+
+  Int_t nofDetElems = 0;
+  
+  for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) 
+    if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;
+  
+  return nofDetElems;
+}