]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometryEnvelopeStore.cxx
AliTriggerAnalysis: added switch to disable FMD histograms (runs much faster) (consta...
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryEnvelopeStore.cxx
index 628bdda94f4187aaca7ffca3f7cb613aed008dda..d03e601a76379ed071d66c4a4e0a8d164aa532df 100644 (file)
@@ -1,36 +1,57 @@
+/**************************************************************************
+ * 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 <TVirtualMC.h>
-#include <TGeoMatrix.h>
-#include <TObjArray.h>
-#include <TArrayI.h>
-#include <Riostream.h>
+//-----------------------------------------------------------------------------
 
 #include "AliMUONGeometryEnvelopeStore.h"
-#include "AliMUONGeometryTransformStore.h"
 #include "AliMUONGeometryEnvelope.h"
-#include "AliMUONConstants.h"
+#include "AliMUONGeometryDetElement.h"
+#include "AliMUONGeometryBuilder.h"
+
+#include "AliMpExMap.h"
+
 #include "AliLog.h"
 
+#include <TGeoMatrix.h>
+#include <TObjArray.h>
+#include <Riostream.h>
+#include <TString.h>
+
+/// \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);
 }
@@ -39,26 +60,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)
-{
-  AliFatal("Copy constructor is not implemented.");
-}
-
 //______________________________________________________________________________
 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore() 
 {
-//
+/// Destructor
 
   // Add deleting rotation matrices 
   
@@ -68,28 +83,29 @@ AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
   }  
 }
 
-//______________________________________________________________________________
-AliMUONGeometryEnvelopeStore& 
-AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs) 
-{
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  AliFatal("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 
@@ -105,21 +121,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) {
+  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;
 }  
 
@@ -133,9 +154,8 @@ 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 (!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));
@@ -155,9 +175,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 ";
@@ -187,9 +206,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 ";
@@ -234,9 +252,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 ";
@@ -267,9 +284,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 "
@@ -293,9 +309,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 "
@@ -325,9 +340,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 "
@@ -361,9 +375,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 "
@@ -392,9 +405,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
@@ -417,9 +429,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
@@ -444,9 +455,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
@@ -470,9 +480,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
@@ -496,9 +505,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
@@ -522,9 +530,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
@@ -550,9 +557,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
@@ -577,9 +583,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
@@ -598,3 +603,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;
+}