The array of enevelopes and AddEnvelope... functions separated into a new class AliMU...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Sep 2004 11:36:16 +0000 (11:36 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Sep 2004 11:36:16 +0000 (11:36 +0000)
MUON/AliMUONChamberGeometry.cxx
MUON/AliMUONChamberGeometry.h

index b0b81cb2c9ca895f694d001160f25b0c59344fad..93ef7d373b65a7be48ca46ced7545da0e5ab1153 100644 (file)
@@ -14,6 +14,9 @@
 
 #include "AliMUONChamberGeometry.h"
 #include "AliMUONGeometryEnvelope.h"
+#include "AliMUONGeometryEnvelopeStore.h"
+#include "AliMUONGeometryTransformStore.h"     
+#include "AliMUONConstants.h"
 
 ClassImp(AliMUONChamberGeometry)
 
@@ -22,18 +25,31 @@ AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId)
  : TObject(),
    fChamberId(chamberId),
    fMotherVolume("ALIC"),
+   fNofSVs(0),
+   fSVVolumeIds(0),
    fTransformation(0),
+   fDETransforms(0),
    fEnvelopes(0),
-   fNofSensVolumeIds(0),
-   fSensVolumeIds(0),
-   fDebug(kFALSE)
+   fSVMap(0)
 {
 // Standard constructor
 
-  // Create the chamber transformation
+  // Chamber transformation
   fTransformation = new TGeoCombiTrans("");
-  fEnvelopes = new TObjArray(20);
-  fSensVolumeIds = new TArrayI(20);
+
+  // Arrays of volumes Ids
+  fSVVolumeIds = new TArrayI(20);
+
+  // Sensitive volumes map
+  fSVMap = new AliMUONGeometrySVMap(100);
+
+  // Det elements transformation store
+  fDETransforms = new AliMUONGeometryTransformStore(
+                         AliMUONConstants::GetFirstDetElemId(chamberId), 
+                        AliMUONConstants::NofDetElements(chamberId),
+                        fSVMap);  
+  // Envelope store
+  fEnvelopes = new AliMUONGeometryEnvelopeStore(fDETransforms);  
 }
 
 
@@ -42,11 +58,12 @@ AliMUONChamberGeometry::AliMUONChamberGeometry()
  : TObject(),
    fChamberId(0),
    fMotherVolume(),
+   fNofSVs(0),
+   fSVVolumeIds(0),
    fTransformation(0),
+   fDETransforms(0),
    fEnvelopes(0),
-   fNofSensVolumeIds(0),
-   fSensVolumeIds(0),
-   fDebug(kFALSE)
+   fSVMap(0)
 {
 // Default constructor
 }
@@ -64,14 +81,11 @@ AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs
 AliMUONChamberGeometry::~AliMUONChamberGeometry() {
 //
 
-  // Add deleting rotation matrices 
-  
   delete fTransformation;
-  
-  if (fEnvelopes) {
-    fEnvelopes->Delete();
-    delete fEnvelopes;
-  }  
+  delete fSVVolumeIds;
+  delete fEnvelopes;
+  delete fDETransforms;
+  delete fSVMap;
 }
 
 //______________________________________________________________________________
@@ -92,325 +106,22 @@ AliMUONChamberGeometry::operator = (const AliMUONChamberGeometry& rhs)
 //
 
 //______________________________________________________________________________
-AliMUONGeometryEnvelope* 
-AliMUONChamberGeometry::FindEnvelope(const TString& name) const
+Int_t AliMUONChamberGeometry::GetSVIndex(Int_t svVolId) const
 {
-// Finds the envelope specified by name.
-// ---
-
-  for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
-    AliMUONGeometryEnvelope* envelope 
-      = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
-    
-    if (envelope->GetName() == name) return envelope;
+// Returns the index of the volume specified by volId
+// if it is present in the list of sensitive volumes 
+// (or -1 if not present).
+  for (Int_t i=0; i<fNofSVs; i++) {
+      if (fSVVolumeIds->At(i) == svVolId) return i;
   }
-  
-  return 0;    
-}  
+  return -1;
+}
 
 //
 // public methods
 //
 
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
-                                          const char* only) 
-{
-// Adds 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 << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, isVirtual, only);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
-                                          const TGeoTranslation& translation,
-                                         const char* only)
-{
-// Adds 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 
-         << " with translation" << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, isVirtual, only);
-  envelope->SetTranslation(translation);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, 
-                                          const TGeoTranslation& translation,
-                                         const TGeoRotation& rotation,
-                                         const char* only)
-{
-// Adds 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 
-         << " with translation and rotation" << endl;
-  }  
-
-  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
-           // would be nice to be so simple 
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, isVirtual, only);
-  envelope->SetRotation(rotation);
-  envelope->SetTranslation(translation);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
-                                          const char* only) 
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding "
-         << " non-virtual envelope " << name 
-         << " with copyNo " << copyNo << endl;
-   }  
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, copyNo, only);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
-                                          const TGeoTranslation& translation,
-                                         const char* only)
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding "
-         << " non-virtual envelope " << name 
-         << " with copyNo " << copyNo
-         << " with translation " << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, copyNo, only);
-  envelope->SetTranslation(translation);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, 
-                                          const TGeoTranslation& translation,
-                                         const TGeoRotation& rotation,
-                                         const char* only)
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding "
-         << " non-virtual envelope " << name 
-         << " with copyNo " << copyNo
-         << " with translation and rotation" << endl;
-  }  
-
-  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
-           // would be nice to be so simple 
-
-  AliMUONGeometryEnvelope* envelope 
-    = new AliMUONGeometryEnvelope(name, copyNo, only);
-  envelope->SetRotation(rotation);
-  envelope->SetTranslation(translation);
-
-  fEnvelopes->Add(envelope);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, 
-                                         const TString& envName, Int_t copyNo) 
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituent(name, copyNo);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::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.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo
-         << " with translation" << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituent(name, copyNo, translation);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, 
-                                          const TString& envName, Int_t copyNo, 
-                                          const TGeoTranslation& translation,
-                                         const TGeoRotation& rotation)
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo
-         << " with translation and rotation" << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituent(name, copyNo, translation, rotation);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, 
-                                         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.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding parameterised constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituentParam(name, copyNo, npar, param);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, 
-                                          const TString& envName, Int_t copyNo,
-                                          const TGeoTranslation& translation,
-                                         Int_t npar, Double_t* param)
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding parameterised constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo
-         << " with translation" << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituentParam(name, copyNo, translation, npar, param);
-}
-
-//______________________________________________________________________________
-void  AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, 
-                                          const TString& envName, Int_t copyNo, 
-                                          const TGeoTranslation& translation,
-                                         const TGeoRotation& rotation,
-                                         Int_t npar, Double_t* param)
-{
-// Adds the volume with the specified name and transformation
-// to the list of envelopes.
-// ---                                            
-
-  if (fDebug) {
-    cout << "... Adding parameterised constituent " << name
-         << " to envelope " << envName 
-         << " with copyNo " << copyNo
-         << " with translation and rotation" << endl;
-  }  
-
-  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
-  
-  if (!envelope) {
-    // add warning
-    return;
-  }  
-   
-  envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
-}
-
 //______________________________________________________________________________
 void  AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation)
 {
@@ -434,31 +145,56 @@ void  AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
 }  
 
 //______________________________________________________________________________
-void  AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId)
+void  AliMUONChamberGeometry::SetSensitiveVolume(Int_t svVolId)
 {
 // Adds the volume specified by volId to the list of sensitive
 // volumes
+// ---
   
-  fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++);
+  // Resize TArrayI if needed
+  if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
+
+  fSVVolumeIds->AddAt(svVolId, fNofSVs++);
 }      
 
 //______________________________________________________________________________
 void  AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
 {
-// Adds the volume specified by volId to the list of sensitive
+// Adds the volume specified by volName to the list of sensitive
 // volumes
+// ---
 
-  fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++);
+  SetSensitiveVolume(gMC->VolId(volName));
 }      
 
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::SetAlign(Bool_t align)
+{
+// Sets alignement option to enevelope store.
+// ---
+  
+  fEnvelopes->SetAlign(align);
+}  
+
 //______________________________________________________________________________
 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const
 {
 // Checks if the volume specified by volId is present in the list
 // of sensitive volumes.
+// ---
 
-  for (Int_t i=0; i<fNofSensVolumeIds; i++) {
-      if (fSensVolumeIds->At(i) == volId) return kTRUE;
+  for (Int_t i=0; i<fNofSVs; i++) {
+      if (fSVVolumeIds->At(i) == volId) return kTRUE;
   }
   return kFALSE;
 }
+
+//______________________________________________________________________________
+Bool_t AliMUONChamberGeometry::IsSensitiveVolume(const TString& volName) const
+{
+// Checks if the volume specified by volName  is present in the list
+// of sensitive volumes.
+// ---
+
+  return IsSensitiveVolume(gMC->VolId(volName));
+}
index 5131f39bf985c551ba50f09599093dd30d0679f1..dc34a3c91070ae78769cc6d9cc6c585d6eb6090a 100644 (file)
@@ -15,6 +15,7 @@
 #define ALI_MUON_CHAMBER_GEOMETRY_H
 
 #include <TObject.h>
+#include <TString.h>
 
 class TGeoTranslation;
 class TGeoRotation;
@@ -24,6 +25,9 @@ class TArrayI;
 
 class AliMUONChamber;
 class AliMUONGeometryEnvelope;
+class AliMUONGeometryEnvelopeStore;
+class AliMUONGeometryTransformStore;
+class AliMUONGeometrySVMap;
 
 class AliMUONChamberGeometry : public TObject
 {
@@ -33,73 +37,24 @@ class AliMUONChamberGeometry : public TObject
     virtual ~AliMUONChamberGeometry();
 
     // methods
-        
-          // adding virtual envelopes  
-          // (not placed in MC geometry, only logical assembly of volumes,
-         //  cannot have more copies)  
-    void  AddEnvelope(const TString& name, Bool_t isVirtual, 
-                      const char* only="ONLY"); 
-    void  AddEnvelope(const TString& name, Bool_t isVirtual, 
-                      const TGeoTranslation& translation, 
-                     const char* only="ONLY"); 
-    void  AddEnvelope(const TString& name, Bool_t isVirtual, 
-                      const TGeoTranslation& translation, 
-                     const TGeoRotation& rotation,
-                     const char* only="ONLY");
-                     
-          // adding non-virtual envelopes      
-          // (placed in MC geometry with transformation composed
-         //  of transformation of chamber and their transformation, 
-         //  can have more copies )    
-    void  AddEnvelope(const TString& name, Int_t copyNo, 
-                      const char* only="ONLY"); 
-    void  AddEnvelope(const TString& name, Int_t copyNo, 
-                      const TGeoTranslation& translation,
-                     const char* only="ONLY"); 
-    void  AddEnvelope(const TString& name, Int_t copyNo, 
-                      const TGeoTranslation& translation, 
-                     const TGeoRotation& rotation,
-                     const char* only="ONLY");
-
-          // adding constituents to virtual envelopes  
-          // (placed in MC geometry with transformation composed
-         //  of transformation of chamber, envelope and their own
-         //  transformation )  
-    void  AddEnvelopeConstituent(const TString& name, const TString& envName, 
-                      Int_t copyNo); 
-    void  AddEnvelopeConstituent(const TString& name, const TString& envName, 
-                      Int_t copyNo, const TGeoTranslation& translation); 
-    void  AddEnvelopeConstituent(const TString& name, const TString& envName, 
-                      Int_t copyNo, const TGeoTranslation& translation, 
-                     const TGeoRotation& rotation);
-                                     
-          // adding constituents to virtual envelopes with specified shape
-         // parameters
-          // (placed in MC geometry with transformation composed
-         //  of transformation of chamber, envelope and their own
-         //  transformation )  
-    void  AddEnvelopeConstituentParam(const TString& name, const TString& envName, 
-                      Int_t copyNo, Int_t npar, Double_t* param); 
-    void  AddEnvelopeConstituentParam(const TString& name, const TString& envName, 
-                      Int_t copyNo, const TGeoTranslation& translation,
-                     Int_t npar, Double_t* param); 
-    void  AddEnvelopeConstituentParam(const TString& name, const TString& envName, 
-                      Int_t copyNo, const TGeoTranslation& translation, 
-                     const TGeoRotation& rotation, Int_t npar, Double_t* param);
-                                     
     void  SetMotherVolume(const TString& motherVolumeName);
     void  SetTranslation(const TGeoTranslation& translation);
     void  SetRotation(const TGeoRotation& rotation);
     
     void  SetSensitiveVolume(Int_t volId);
     void  SetSensitiveVolume(const TString& name);
-    void  SetDebug(Bool_t debug);
-
+    void  SetAlign(Bool_t align);
     // get methods
     TString                GetMotherVolume() const;
-    const TGeoCombiTrans*  GetTransformation() const;
-    const TObjArray*       GetEnvelopes() const;
+    const TGeoCombiTrans*  GetTransformation() const;    
+    AliMUONGeometryEnvelopeStore*  GetEnvelopeStore() const;
+    AliMUONGeometryTransformStore* GetTransformStore() const;
+    AliMUONGeometrySVMap*          GetSVMap() const;
     Bool_t IsSensitiveVolume(Int_t volId) const; 
+    Bool_t IsSensitiveVolume(const TString& volName) const; 
+//
+//Int_t  GetDEVolId(Int_t svVolId) const; 
 
   protected:
     AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs);
@@ -108,37 +63,43 @@ class AliMUONChamberGeometry : public TObject
 
   private:
     // methods
-    AliMUONGeometryEnvelope* FindEnvelope(const TString& name) const;
+    Int_t  GetSVIndex(Int_t svVolId) const; 
   
     // data members
     Int_t            fChamberId;     // the chamber Id
     TString          fMotherVolume;  // mother volume name
+    Int_t            fNofSVs;        // number of sensitive volumes   
+    TArrayI*         fSVVolumeIds;   // densitive volumes IDs  
     TGeoCombiTrans*  fTransformation;// the chamber transformation wrt to mother
                                      // volume
-    TObjArray*       fEnvelopes;     // the envelopes names and transformations
-                                    // wrt to the chamber position in mother volume                                 
-    Int_t            fNofSensVolumeIds; // Number of sensitive volumes IDs    
-    TArrayI*         fSensVolumeIds; // Sensitive volumes IDs  
-    Bool_t           fDebug;         // Switch for debugging  
+    AliMUONGeometryTransformStore* fDETransforms; // det elements transformations
+    AliMUONGeometryEnvelopeStore*  fEnvelopes;    // envelopes                                 
+    AliMUONGeometrySVMap*          fSVMap;        // sensitive volumes map
  
   ClassDef(AliMUONChamberGeometry,1) // MUON chamber geometry base class
 };
 
 // inline functions
 
-inline void  AliMUONChamberGeometry::SetMotherVolume(const TString& motherVolumeName)
+inline void  
+AliMUONChamberGeometry::SetMotherVolume(const TString& motherVolumeName)
 { fMotherVolume = motherVolumeName; }
 
-inline void  AliMUONChamberGeometry::SetDebug(Bool_t debug)
-{ fDebug = debug; }
-
 inline TString  AliMUONChamberGeometry::GetMotherVolume() const
 { return fMotherVolume; }
 
 inline const TGeoCombiTrans* AliMUONChamberGeometry::GetTransformation() const 
 { return fTransformation; }
 
-inline const TObjArray* AliMUONChamberGeometry::GetEnvelopes() const
+inline  AliMUONGeometryEnvelopeStore*  
+AliMUONChamberGeometry::GetEnvelopeStore() const
 { return fEnvelopes; }
 
-#endif //ALI_MUON_V_CHAMBER_GEOMETRY_H
+inline AliMUONGeometryTransformStore*  
+AliMUONChamberGeometry::GetTransformStore() const
+{ return fDETransforms; }
+
+inline AliMUONGeometrySVMap* AliMUONChamberGeometry::GetSVMap() const
+{ return fSVMap; }
+
+#endif //ALI_MUON_CHAMBER_GEOMETRY_H