New definition of the geometry based on builders and usign Ivana's envelop method...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Jan 2004 10:23:10 +0000 (10:23 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Jan 2004 10:23:10 +0000 (10:23 +0000)
30 files changed:
MUON/AliMUON.cxx
MUON/AliMUON.h
MUON/AliMUONChamber.cxx
MUON/AliMUONChamber.h
MUON/AliMUONChamberGeometry.cxx [new file with mode: 0644]
MUON/AliMUONChamberGeometry.h [new file with mode: 0644]
MUON/AliMUONGeometryConstituent.cxx [new file with mode: 0644]
MUON/AliMUONGeometryConstituent.h [new file with mode: 0644]
MUON/AliMUONGeometryEnvelope.cxx [new file with mode: 0644]
MUON/AliMUONGeometryEnvelope.h [new file with mode: 0644]
MUON/AliMUONSlatGeometryBuilder.cxx [new file with mode: 0644]
MUON/AliMUONSlatGeometryBuilder.h [new file with mode: 0644]
MUON/AliMUONSt1GeometryBuilder.cxx [new file with mode: 0644]
MUON/AliMUONSt1GeometryBuilder.h [new file with mode: 0644]
MUON/AliMUONSt1GeometryBuilderV2.cxx [moved from MUON/AliMUONv2.cxx with 51% similarity]
MUON/AliMUONSt1GeometryBuilderV2.h [new file with mode: 0644]
MUON/AliMUONSt1Types.h
MUON/AliMUONSt2GeometryBuilder.cxx [new file with mode: 0644]
MUON/AliMUONSt2GeometryBuilder.h [new file with mode: 0644]
MUON/AliMUONTriggerGeometryBuilder.cxx [new file with mode: 0644]
MUON/AliMUONTriggerGeometryBuilder.h [new file with mode: 0644]
MUON/AliMUONVGeometryBuilder.cxx [new file with mode: 0644]
MUON/AliMUONVGeometryBuilder.h [new file with mode: 0644]
MUON/AliMUONv0.cxx
MUON/AliMUONv2.h [deleted file]
MUON/AliMUONv3.cxx [new file with mode: 0644]
MUON/AliMUONv3.h [new file with mode: 0644]
MUON/Config_MUON_test.C
MUON/MUONLinkDef.h
MUON/libMUON.pkg

index 7b328f2fef023418e02863347cae0cccbdffcf7e..3c3a9519916eb7d5fbdbcadd0f615ed5e983c406 100644 (file)
@@ -66,6 +66,7 @@
 #include "AliMUONTransientDigit.h"
 #include "AliMUONTriggerCircuit.h"
 #include "AliMUONTriggerDecision.h"
+#include "AliMUONVGeometryBuilder.h"   
 #include "AliRun.h"    
 #include "AliMUONDigitizerv1.h"
 
@@ -94,6 +95,7 @@ AliMUON::AliMUON()
     fNTrackingCh     = 0;
     fIshunt          = 0;
     fChambers        = 0;
+    fGeometryBuilders = 0; 
     fTriggerCircuits = 0;
     fAccMin          = 0.;
     fAccMax          = 0.;   
@@ -124,6 +126,8 @@ AliMUON::AliMUON(const char *name, const char *title)
 // Creating List of Chambers
     Int_t ch;
     fChambers = new TObjArray(AliMUONConstants::NCh());
+    fGeometryBuilders = new TObjArray(AliMUONConstants::NCh());
+
     // Loop over stations
     for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
       // Loop over 2 chambers in the station
@@ -138,7 +142,7 @@ AliMUON::AliMUON(const char *name, const char *title)
          fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
        }
        AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
-       chamber->SetGid(0);
+       //chamber->SetGid(0);
        // Default values for Z of chambers
        chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
        //
@@ -184,6 +188,19 @@ AliMUON::~AliMUON()
   if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
   fIshunt  = 0;
   if (fMerger) delete fMerger;
+
+  if (fGeometryBuilders){
+    fGeometryBuilders->Delete();
+    delete fGeometryBuilders;
+  } 
+}
+//_____________________________________________________________________________
+void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
+{
+// Adds the geometry builder to the list
+// ---
+
+  fGeometryBuilders->Add(geomBuilder);
 }
 //____________________________________________________________________
 void AliMUON::BuildGeometry()
@@ -313,6 +330,39 @@ void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
     } // station loop
   }
 }
+
+//____________________________________________________________________
+Float_t  AliMUON::GetMaxStepGas() const
+{
+// Return stepsize in gas
+  
+  return fMaxStepGas;
+}  
+
+//____________________________________________________________________
+Float_t  AliMUON::GetMaxStepAlu() const
+{
+// Return step size in Alu
+  
+  return fMaxStepAlu;
+}
+  
+//____________________________________________________________________
+Float_t  AliMUON::GetMaxDestepGas() const
+{
+// Return maximum step size in Gas
+  
+  return fMaxDestepGas;
+}
+  
+//____________________________________________________________________
+Float_t  AliMUON::GetMaxDestepAlu() const
+{
+// Return maximum step size in Gas
+  
+  return fMaxDestepAlu;
+}
+
 //____________________________________________________________________
 void   AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
 {
index a2bdb6eaf6c993bcf8042eccf72c14e6d654b7de..979d49470c01ee58add58b031e0179aacb252209 100644 (file)
@@ -28,6 +28,7 @@ class AliMUONRawCluster;
 class AliMUONClusterFinderVS;
 class AliMUONReconstHit;
 class AliMUONMerger;
+class AliMUONVGeometryBuilder;
 
 class TVector;
 #include "TObjArray.h"
@@ -42,6 +43,7 @@ class AliMUON : public  AliDetector {
     AliMUON(const AliMUON& rMUON);
     virtual       ~AliMUON();
    
+    void           AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder);
     virtual void   BuildGeometry();
     Int_t          DistancetoPrimitive(Int_t px, Int_t py);
     AliMUONData*   GetMUONData() {return fMUONData;}
@@ -94,6 +96,12 @@ class AliMUON : public  AliDetector {
     virtual void   SetMaxDestepAlu(Float_t p1);
     virtual void   SetAcceptance(Bool_t acc=0, Float_t angmin=2, Float_t angmax=9);
    
+    // Get Stepping Parameters
+    virtual Float_t  GetMaxStepGas() const;
+    virtual Float_t  GetMaxStepAlu() const;
+    virtual Float_t  GetMaxDestepGas() const;
+    virtual Float_t  GetMaxDestepAlu() const;
+   
     // get Trigger answer
     void   Trigger(Int_t nev);
     // Return reference to Chamber #id
@@ -118,6 +126,7 @@ class AliMUON : public  AliDetector {
     AliMUONData*          fMUONData;           // Data container for MUON subsystem  
     Int_t                 fSplitLevel;         // Splitlevel when making branches in outfiles.
     TObjArray*            fChambers;           // List of Tracking Chambers
+    TObjArray            *fGeometryBuilders;   // List of Geometry Builders
     TObjArray*            fTriggerCircuits;    // List of Trigger Circuits
    
     //
index e143e9ade5f39c0f038b641fe34b8b4557392b8e..557f345401e9a8ab2443b6de0c6e6c62e158f88d 100644 (file)
@@ -17,6 +17,7 @@
 
 // --- MUON includes ---
 #include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
 
 // --- ROOT includes ---
 
@@ -32,6 +33,8 @@ ClassImp(AliMUONChamber)
     fResponse=0;
     fnsec=1;
     fReconstruction=0;
+    fGeometry = 0;
+    
     fId=0;
     // to avoid mistakes if ChargeCorrelInit is not called
     fCurrentCorrel =1;
@@ -44,6 +47,7 @@ ClassImp(AliMUONChamber)
     fSegmentation->AddAt(0,0);
     fSegmentation->AddAt(0,1);
     fResponse=0;
+    fGeometry = new AliMUONChamberGeometry(fId);
     fnsec=1;
     fReconstruction=0;
     fId=id;
@@ -67,6 +71,14 @@ AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber):TObject(rChamber)
 }
 
 
+Bool_t  AliMUONChamber::IsSensId(Int_t volId) const 
+{
+// Returns true if the volume specified by volId is in the list
+// of sesitive volumes for this chamber
+
+  return fGeometry->IsSensitiveVolume(volId);
+}  
+
 void AliMUONChamber::Init()
 {
 // Initalisation ..
index 4020807ee1a398910a3bef6c625b392497353b19..3557cedced15325341bc105bfd3d8d1c7140f995 100644 (file)
@@ -12,6 +12,7 @@
 class AliMUONClusterFinderVS;
 //class AliMUONResponse ;
 //class AliSegmentation ;
+class AliMUONChamberGeometry;
 
 class AliMUONChamber:
 public TObject
@@ -23,11 +24,20 @@ public TObject
     virtual ~AliMUONChamber();
     
 //
+// Get chamber Id
+  virtual Int_t   GetId() {return fId;}
+//
+
+// Get chamber Id
+  virtual Bool_t  IsSensId(Int_t volId) const;
+/*
 // Get GEANT id of sensitive volume
   virtual Int_t   GetGid() {return fGid;}
 // Set GEANT id of sensitive volume
   virtual void    SetGid(Int_t id) {fGid=id;}
-//  
+//
+*/
+  
 // Initialisation
   virtual void    Init();
 // Set z-position of chamber  
@@ -113,6 +123,11 @@ public TObject
   virtual void SetDGas(Float_t DGas) {fdGas = DGas;}
   virtual void SetDAlu(Float_t DAlu) {fdAlu = DAlu;}  
   virtual void SetChargeCorrel(Float_t correl) {fResponse->SetChargeCorrel(correl);}
+
+// geometry  
+  void SetGeometry(AliMUONChamberGeometry* geometry) {fGeometry = geometry;}
+  AliMUONChamberGeometry* GetGeometry() const {return fGeometry; }
+
 // assignment operator  
   AliMUONChamber& operator =(const AliMUONChamber& rhs);
   
@@ -120,7 +135,8 @@ public TObject
   Int_t   fId;   // chamber number
   Float_t fdGas; // half gaz gap
   Float_t fdAlu; // half Alu width  
-  Int_t   fGid;  // GEANT volume if for sensitive volume of this chamber
+  //Int_t   fGid;  // GEANT volume if for sensitive volume of this chamber
+                   // moved to AliMUONChamberGeometry
   Float_t fZ;    // Z position (cm)
   Int_t   fnsec; // number of semented cathode planes
   Float_t frMin; // innermost sensitive radius
@@ -130,6 +146,7 @@ public TObject
   TObjArray              *fSegmentation;    // pointer to segmentation
   AliMUONClusterFinderVS *fReconstruction;  // pointer to reconstruction
   AliMUONResponse        *fResponse;        // pointer to response
+  AliMUONChamberGeometry *fGeometry;        // pointer to geometry
   ClassDef(AliMUONChamber,1) // Muon tracking chamber class
 };
 
diff --git a/MUON/AliMUONChamberGeometry.cxx b/MUON/AliMUONChamberGeometry.cxx
new file mode 100644 (file)
index 0000000..25aa13c
--- /dev/null
@@ -0,0 +1,458 @@
+// $Id$
+//
+// Class AliMUONChamberGeometry
+// -----------------------------
+// Class for definititon of the MUON chamber positions in ALIC.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#include <TVirtualMC.h>
+#include <TGeoMatrix.h>
+#include <TObjArray.h>
+#include <TArrayI.h>
+#include <Riostream.h>
+
+#include "AliMUONChamberGeometry.h"
+#include "AliMUONGeometryEnvelope.h"
+
+ClassImp(AliMUONChamberGeometry)
+
+//______________________________________________________________________________
+AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId)
+ : TObject(),
+   fChamberId(chamberId),
+   fMotherVolume("ALIC"),
+   fTransformation(0),
+   fEnvelopes(0),
+   fNofSensVolumeIds(0),
+   fSensVolumeIds(0),
+   fDebug(kFALSE)
+{
+// Standard constructor
+
+  // Create the chamber transformation
+  fTransformation = new TGeoCombiTrans("");
+  fEnvelopes = new TObjArray(20);
+  fSensVolumeIds = new TArrayI(20);
+}
+
+
+//______________________________________________________________________________
+AliMUONChamberGeometry::AliMUONChamberGeometry()
+ : TObject(),
+   fChamberId(0),
+   fMotherVolume(),
+   fTransformation(0),
+   fEnvelopes(0),
+   fNofSensVolumeIds(0),
+   fSensVolumeIds(0),
+   fDebug(kFALSE)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs)
+  : TObject(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONChamberGeometry::~AliMUONChamberGeometry() {
+//
+
+  // Add deleting rotation matrices 
+  
+  delete fTransformation;
+  
+  if (fEnvelopes) {
+    fEnvelopes->Delete();
+    delete fEnvelopes;
+  }  
+}
+
+//______________________________________________________________________________
+AliMUONChamberGeometry& 
+AliMUONChamberGeometry::operator = (const AliMUONChamberGeometry& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// private methods
+//
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope* 
+AliMUONChamberGeometry::FindEnvelope(const TString& name) 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;
+  }
+  
+  return 0;    
+}  
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual) 
+{
+// 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);
+
+  fEnvelopes->Add(envelope);
+}
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
+                                          const TGeoTranslation& translation)
+{
+// 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);
+  envelope->SetTranslation(translation);
+
+  fEnvelopes->Add(envelope);
+}
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, 
+                                          const TGeoTranslation& translation,
+                                         const TGeoRotation& rotation)
+{
+// 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);
+  envelope->SetRotation(rotation);
+  envelope->SetTranslation(translation);
+
+  fEnvelopes->Add(envelope);
+}
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo) 
+{
+// 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);
+
+  fEnvelopes->Add(envelope);
+}
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
+                                          const TGeoTranslation& translation)
+{
+// 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);
+  envelope->SetTranslation(translation);
+
+  fEnvelopes->Add(envelope);
+}
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::AddEnvelope(const TString& name, 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 "
+         << " 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);
+  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)
+{
+// Sets the chamber position wrt ALIC.
+// ---
+
+  fTransformation
+    ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
+}  
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
+{
+// Sets the chamber rotation wrt ALIC.
+// ---
+
+  TGeoRotation* rot = new TGeoRotation();
+  rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
+
+  fTransformation->SetRotation(rot);
+}  
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId)
+{
+// Adds the volume specified by volId to the list of sensitive
+// volumes
+  
+  fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++);
+}      
+
+//______________________________________________________________________________
+void  AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
+{
+// Adds the volume specified by volId to the list of sensitive
+// volumes
+
+  fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++);
+}      
+
+//______________________________________________________________________________
+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;
+  }
+  return kFALSE;
+}
diff --git a/MUON/AliMUONChamberGeometry.h b/MUON/AliMUONChamberGeometry.h
new file mode 100644 (file)
index 0000000..d45a8fe
--- /dev/null
@@ -0,0 +1,132 @@
+// $Id$
+//
+// Class AliMUONChamberGeometry
+// -----------------------------
+// Class for definititon of the MUON chamber positions in ALIC.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_CHAMBER_GEOMETRY_H
+#define ALI_MUON_CHAMBER_GEOMETRY_H
+
+#include <TObject.h>
+
+class TGeoTranslation;
+class TGeoRotation;
+class TGeoCombiTrans;
+class TObjArray;
+class TArrayI;
+
+class AliMUONChamber;
+class AliMUONGeometryEnvelope;
+
+class AliMUONChamberGeometry : public TObject
+{
+  public:
+    AliMUONChamberGeometry(Int_t chamberId);
+    AliMUONChamberGeometry();
+    AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs);
+    virtual ~AliMUONChamberGeometry();
+
+    // operators  
+    AliMUONChamberGeometry& operator = (const AliMUONChamberGeometry& rhs);
+  
+    // 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); 
+    void  AddEnvelope(const TString& name, Bool_t isVirtual, 
+                      const TGeoTranslation& translation); 
+    void  AddEnvelope(const TString& name, Bool_t isVirtual, 
+                      const TGeoTranslation& translation, 
+                     const TGeoRotation& rotation);
+                     
+          // 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); 
+    void  AddEnvelope(const TString& name, Int_t copyNo, 
+                      const TGeoTranslation& translation); 
+    void  AddEnvelope(const TString& name, Int_t copyNo, 
+                      const TGeoTranslation& translation, 
+                     const TGeoRotation& rotation);
+
+          // 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);
+
+    // get methods
+    TString                GetMotherVolume() const;
+    const TGeoCombiTrans*  GetTransformation() const;
+    const TObjArray*       GetEnvelopes() const;
+    Bool_t IsSensitiveVolume(Int_t volId) const; 
+
+  private:
+    // methods
+    AliMUONGeometryEnvelope* FindEnvelope(const TString& name) const;
+  
+    // data members
+    Int_t            fChamberId;     // the chamber Id
+    TString          fMotherVolume;  // mother volume name
+    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  
+  ClassDef(AliMUONChamberGeometry,1) // MUON chamber geometry base class
+};
+
+// inline functions
+
+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
+{ return fEnvelopes; }
+
+#endif //ALI_MUON_V_CHAMBER_GEOMETRY_H
diff --git a/MUON/AliMUONGeometryConstituent.cxx b/MUON/AliMUONGeometryConstituent.cxx
new file mode 100644 (file)
index 0000000..9f96d32
--- /dev/null
@@ -0,0 +1,120 @@
+// $Id$
+//
+// Class AliMUONGeometryConstituent
+// -----------------------------
+// Helper class for definititon of an assembly of volumes.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#include <TGeoMatrix.h>
+
+#include "AliMUONGeometryConstituent.h"
+
+ClassImp(AliMUONGeometryConstituent)
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
+                                   Int_t copyNo, Int_t npar, Double_t* param)
+  : TNamed(name, name),
+    fCopyNo(copyNo),
+    fNpar(npar),
+    fParam(0)                             
+{                                  
+  // fTransformation = new TGeoCombiTrans(name);
+           // would be nice to be so simple 
+
+  // Create the constituent transformation
+  fTransformation = new TGeoCombiTrans("");
+
+  // Volume parameters
+  if (npar > 0) {
+    fParam = new Double_t[npar];
+    for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
+  }  
+}
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
+                                   Int_t copyNo, const TGeoTranslation& translation,
+                                  Int_t npar, Double_t* param)
+  : TNamed(name, name),
+    fCopyNo(copyNo),
+    fNpar(npar),
+    fParam(0),                            
+    fTransformation(0) 
+{
+  // Create the constituent transformation
+  fTransformation = new TGeoCombiTrans(translation, TGeoRotation());
+
+  // Volume parameters
+  if (npar > 0) {
+    fParam = new Double_t[npar];
+    for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
+  }  
+}
+
+                        
+//______________________________________________________________________________
+AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
+                                   Int_t copyNo, const TGeoTranslation& translation, 
+                                  const TGeoRotation& rotation, 
+                                  Int_t npar, Double_t* param)
+                                  
+  : TNamed(name, name),
+    fCopyNo(copyNo),
+    fNpar(npar),
+    fParam(0),                            
+    fTransformation(0) 
+{
+  // Create the constituent transformation
+  fTransformation = new TGeoCombiTrans(translation, rotation);
+
+  // Volume parameters
+  if (npar > 0) {
+    fParam = new Double_t[npar];
+    for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
+  }  
+}
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent::AliMUONGeometryConstituent()
+  : TNamed(),
+    fCopyNo(0),
+    fNpar(0),
+    fParam(0),                            
+    fTransformation(0) 
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent::AliMUONGeometryConstituent(
+                                        const AliMUONGeometryConstituent& rhs)
+  : TNamed(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent::~AliMUONGeometryConstituent() 
+{
+//
+  delete fTransformation;
+  delete fParam;
+}
+
+//______________________________________________________________________________
+AliMUONGeometryConstituent& 
+AliMUONGeometryConstituent::operator = (const AliMUONGeometryConstituent& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
diff --git a/MUON/AliMUONGeometryConstituent.h b/MUON/AliMUONGeometryConstituent.h
new file mode 100644 (file)
index 0000000..678cb8b
--- /dev/null
@@ -0,0 +1,68 @@
+// $Id$
+//
+// Class AliMUONGeometryConstituent
+// --------------------------------
+// Helper class for definititon of an assembly of volumes.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_GEOMETRY_CONSTITUENT_H
+#define ALI_MUON_GEOMETRY_CONSTITUENT_H
+
+#include <TNamed.h>
+
+class TGeoTranslation;
+class TGeoRotation;
+class TGeoCombiTrans;
+class TObjArray;
+
+class AliMUONGeometryConstituent : public TNamed
+{
+  public:
+    AliMUONGeometryConstituent(const TString& name, Int_t copyNo, 
+                         Int_t npar, Double_t* param); 
+    AliMUONGeometryConstituent(const TString& name, Int_t copyNo, 
+                         const TGeoTranslation& translation,
+                        Int_t npar, Double_t* param); 
+    AliMUONGeometryConstituent(const TString& name, Int_t copyNo, 
+                         const TGeoTranslation& translation, 
+                        const TGeoRotation& rotation,
+                        Int_t npar, Double_t* param);
+    AliMUONGeometryConstituent();
+    AliMUONGeometryConstituent(const AliMUONGeometryConstituent& rhs);
+    virtual ~AliMUONGeometryConstituent();
+
+    // operators  
+    AliMUONGeometryConstituent& operator = (const AliMUONGeometryConstituent& rhs);
+  
+    // get methods
+    Int_t                  GetCopyNo() const;  
+    Int_t                  GetNpar() const;
+    Double_t*              GetParam() const;
+    const TGeoCombiTrans*  GetTransformation() const;
+
+  private:
+    Int_t            fCopyNo;        // copy number
+    Int_t            fNpar;          // number of shape parameters
+    Double_t*        fParam;         //[fNpar] shape parameters
+    TGeoCombiTrans*  fTransformation;// the constituent transformation wrt to the
+                                     // envelope
+  ClassDef(AliMUONGeometryConstituent,1) // MUON chamber geometry base class
+};
+
+// inline functions
+
+inline Int_t AliMUONGeometryConstituent::GetCopyNo() const
+{ return fCopyNo; }  
+
+inline Int_t AliMUONGeometryConstituent::GetNpar() const
+{ return fNpar; }
+
+inline Double_t* AliMUONGeometryConstituent::GetParam() const
+{ return fParam; }
+
+inline const TGeoCombiTrans* AliMUONGeometryConstituent::GetTransformation() const 
+{ return fTransformation; }
+
+#endif //ALI_MUON_GEOMETRY_CONSTITUENT_H
diff --git a/MUON/AliMUONGeometryEnvelope.cxx b/MUON/AliMUONGeometryEnvelope.cxx
new file mode 100644 (file)
index 0000000..ba59ab4
--- /dev/null
@@ -0,0 +1,199 @@
+// $Id$
+//
+// Class AliMUONGeometryEnvelope
+// -----------------------------
+// Helper class for definititon an assembly of volumes.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#include <TGeoMatrix.h>
+#include <TObjArray.h>
+
+#include "AliMUONGeometryEnvelope.h"
+#include "AliMUONGeometryConstituent.h"
+
+ClassImp(AliMUONGeometryEnvelope)
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(const TString& name, 
+                                                 Bool_t isVirtual)
+ : TNamed(name, name),
+   fIsVirtual(isVirtual),
+   fCopyNo(0),
+   fTransformation(0),
+   fConstituents(0)
+{
+// Standard constructor
+
+  // Create the envelope transformation
+  fTransformation = new TGeoCombiTrans("");
+  fConstituents = new TObjArray(20);
+}
+
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(const TString& name, 
+                                                 Int_t copyNo)
+ : TNamed(name, name),
+   fIsVirtual(false),
+   fCopyNo(copyNo),
+   fTransformation(0),
+   fConstituents(0)
+{
+// Standard constructor
+
+  // Create the envelope transformation
+  fTransformation = new TGeoCombiTrans("");
+  fConstituents = new TObjArray(20);
+}
+
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope::AliMUONGeometryEnvelope()
+ : TNamed(),
+   fIsVirtual(0),
+   fTransformation(0),
+   fConstituents(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(
+                                        const AliMUONGeometryEnvelope& rhs)
+  : TNamed(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope::~AliMUONGeometryEnvelope() 
+{
+//
+  // Add deleting rotation matrices 
+  
+  delete fTransformation;
+  
+  if (fConstituents) {
+    fConstituents->Delete();
+    delete fConstituents;
+  }  
+}
+
+//______________________________________________________________________________
+AliMUONGeometryEnvelope& 
+AliMUONGeometryEnvelope::operator = (const AliMUONGeometryEnvelope& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo) 
+{
+// Adds the volume with the specified name and transformation
+// to the list of envelopes.
+// ---                                            
+
+  fConstituents->Add(new AliMUONGeometryConstituent(name, copyNo, 0, 0));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo, 
+                                          const TGeoTranslation& translation)
+{
+// Adds the volume with the specified name and transformation
+// to the list of envelopes.
+// ---                                            
+
+  fConstituents
+    ->Add(new AliMUONGeometryConstituent(name, copyNo, translation, 0, 0));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo,
+                                          const TGeoTranslation& translation,
+                                         const TGeoRotation& rotation)
+{
+// Adds the volume with the specified name and transformation
+// to the list of envelopes.
+// ---                                            
+
+  fConstituents
+    ->Add(new AliMUONGeometryConstituent(
+                     name, copyNo, translation, rotation, 0, 0));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
+                                  Int_t copyNo, Int_t npar, Double_t* param) 
+{
+// Adds the volume with the specified name and transformation
+// to the list of envelopes.
+// ---                                            
+
+  fConstituents
+    ->Add(new AliMUONGeometryConstituent(name, copyNo, npar, param));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
+                                  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.
+// ---                                            
+
+  fConstituents
+    ->Add(new AliMUONGeometryConstituent(
+                     name, copyNo, translation, npar, param));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
+                                  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.
+// ---                                            
+
+  fConstituents
+    ->Add(new AliMUONGeometryConstituent(
+                     name, copyNo, translation, rotation, npar, param));
+}
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::SetTranslation(const TGeoTranslation& translation)
+{
+// Sets the chamber position wrt ALIC.
+// ---
+
+  fTransformation
+    ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
+}  
+
+//______________________________________________________________________________
+void  AliMUONGeometryEnvelope::SetRotation(const TGeoRotation& rotation)
+{
+// Sets the chamber rotation wrt ALIC.
+// ---
+
+  TGeoRotation* rot = new TGeoRotation();
+  rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
+
+  fTransformation->SetRotation(rot);
+}  
diff --git a/MUON/AliMUONGeometryEnvelope.h b/MUON/AliMUONGeometryEnvelope.h
new file mode 100644 (file)
index 0000000..ed09cec
--- /dev/null
@@ -0,0 +1,86 @@
+// $Id$
+//
+// Class AliMUONGeometryEnvelope
+// -----------------------------
+// Helper class for definititon an assembly of volumes.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_GEOMETRY_ENVELOPE_H
+#define ALI_MUON_GEOMETRY_ENVELOPE_H
+
+#include <TNamed.h>
+
+class TGeoTranslation;
+class TGeoRotation;
+class TGeoCombiTrans;
+class TObjArray;
+
+class AliMUONGeometryEnvelope : public TNamed
+{
+  public:
+    AliMUONGeometryEnvelope(const TString& name, Bool_t isVirtual);
+    AliMUONGeometryEnvelope(const TString& name, Int_t copyNo);
+    AliMUONGeometryEnvelope();
+    AliMUONGeometryEnvelope(const AliMUONGeometryEnvelope& rhs);
+    virtual ~AliMUONGeometryEnvelope();
+
+    // operators  
+    AliMUONGeometryEnvelope& operator = (const AliMUONGeometryEnvelope& rhs);
+  
+    // methods
+    void  AddConstituent(const TString& name, Int_t copyNo); 
+    void  AddConstituent(const TString& name, Int_t copyNo, 
+                         const TGeoTranslation& translation); 
+    void  AddConstituent(const TString& name, Int_t copyNo,
+                         const TGeoTranslation& translation, 
+                        const TGeoRotation& rotation);
+
+    void  AddConstituentParam(const TString& name, Int_t copyNo, 
+                         Int_t npar, Double_t* param);
+    void  AddConstituentParam(const TString& name, Int_t copyNo, 
+                         const TGeoTranslation& translation,
+                        Int_t npar, Double_t* param);
+    void  AddConstituentParam(const TString& name, Int_t copyNo, 
+                         const TGeoTranslation& translation, 
+                        const TGeoRotation& rotation,
+                        Int_t npar, Double_t* param);
+
+    void  SetTranslation(const TGeoTranslation& translation);
+    void  SetRotation(const TGeoRotation& rotation);
+
+    // get methods
+    Bool_t                 IsVirtual() const;  
+    Int_t                  GetCopyNo() const;  
+    const TGeoCombiTrans*  GetTransformation() const;
+    const TObjArray*       GetConstituents() const;
+
+  private:
+    Bool_t           fIsVirtual;     // true if envelope is not represented
+                                     // by a real volume
+    Int_t            fCopyNo;        // copy number 
+                                     // (only non virtual envelope can have 
+                                    //  more than one copy)
+    TGeoCombiTrans*  fTransformation;// the envelope transformation wrt to the
+                                     // mother frame (the chamber position)
+    TObjArray*       fConstituents;  // the constituents names and transformations
+                                    // wrt to the envelope position                                 
+  ClassDef(AliMUONGeometryEnvelope,1) // MUON chamber geometry base class
+};
+
+// inline functions
+
+inline Bool_t AliMUONGeometryEnvelope::IsVirtual() const
+{ return fIsVirtual; }  
+
+inline Int_t AliMUONGeometryEnvelope::GetCopyNo() const
+{ return fCopyNo; }  
+
+inline const TGeoCombiTrans* AliMUONGeometryEnvelope::GetTransformation() const 
+{ return fTransformation; }
+
+inline const TObjArray* AliMUONGeometryEnvelope::GetConstituents() const
+{ return fConstituents; }
+
+#endif //ALI_MUON_GEOMETRY_ENVELOPE_H
diff --git a/MUON/AliMUONSlatGeometryBuilder.cxx b/MUON/AliMUONSlatGeometryBuilder.cxx
new file mode 100644 (file)
index 0000000..49382dc
--- /dev/null
@@ -0,0 +1,1021 @@
+// $Id$
+//
+// Class AliMUONSlatGeometryBuilder
+// -------------------------------
+// Abstract base class for geometry construction per chamber.
+//
+// Author: Eric Dumonteil
+
+#include <TVirtualMC.h>
+#include <TArrayI.h>
+#include <TGeoMatrix.h>
+#include "AliRun.h"
+
+#include "AliMUONSlatGeometryBuilder.h"
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
+
+ClassImp(AliMUONSlatGeometryBuilder)
+
+    Int_t   ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq);
+
+
+
+//______________________________________________________________________________
+AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(AliMUON* muon)
+ : AliMUONVGeometryBuilder(&muon->Chamber(4), &muon->Chamber(5), &muon->Chamber(6), &muon->Chamber(7), &muon->Chamber(8), &muon->Chamber(9)),
+//  : AliMUONVGeometryBuilder(&muon->Chamber(4), &muon->Chamber(5)),
+   fMUON(muon)
+{
+// Standard constructor
+
+}
+
+//______________________________________________________________________________
+AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder() 
+ : AliMUONVGeometryBuilder(),
+   fMUON(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(const AliMUONSlatGeometryBuilder& rhs)
+  : AliMUONVGeometryBuilder(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONSlatGeometryBuilder::~AliMUONSlatGeometryBuilder() {
+//
+}
+
+//______________________________________________________________________________
+AliMUONSlatGeometryBuilder& 
+AliMUONSlatGeometryBuilder::operator = (const AliMUONSlatGeometryBuilder& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void AliMUONSlatGeometryBuilder::CreateGeometry()
+{
+     Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+
+     Float_t angle;
+     Float_t *dum=0;
+
+      // define the id of tracking media:
+     Int_t idCopper = idtmed[1110];
+     Int_t idGlass  = idtmed[1111];
+     Int_t idCarbon = idtmed[1112];
+     Int_t idRoha   = idtmed[1113];
+     Int_t idGas=idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
+     Int_t idAir= idtmed[1100]; // medium 1
+
+      // sensitive area: 40*40 cm**2
+     const Float_t sensLength = 40.; 
+     const Float_t sensHeight = 40.; 
+     const Float_t sensWidth  = 0.5; // according to TDR fig 2.120 
+     const Int_t sensMaterial = idGas;
+     const Float_t yOverlap   = 1.5; 
+
+     // PCB dimensions in cm; width: 30 mum copper   
+     const Float_t pcbLength  = sensLength; 
+     const Float_t pcbHeight  = 60.; 
+     const Float_t pcbWidth   = 0.003;   
+     const Int_t pcbMaterial  = idCopper;
+
+     // Insulating material: 200 mum glass fiber glued to pcb  
+     const Float_t insuLength = pcbLength; 
+     const Float_t insuHeight = pcbHeight; 
+     const Float_t insuWidth  = 0.020;   
+     const Int_t insuMaterial = idGlass;
+
+     // Carbon fiber panels: 200mum carbon/epoxy skin   
+     const Float_t panelLength = sensLength; 
+     const Float_t panelHeight = sensHeight; 
+     const Float_t panelWidth  = 0.020;      
+     const Int_t panelMaterial = idCarbon;
+
+     // rohacell between the two carbon panels   
+     const Float_t rohaLength = sensLength; 
+     const Float_t rohaHeight = sensHeight; 
+     const Float_t rohaWidth  = 0.5;
+     const Int_t rohaMaterial = idRoha;
+
+     // Frame around the slat: 2 sticks along length,2 along height  
+     // H: the horizontal ones 
+     const Float_t hFrameLength = pcbLength; 
+     const Float_t hFrameHeight = 1.5; 
+     const Float_t hFrameWidth  = sensWidth; 
+     const Int_t hFrameMaterial = idGlass;
+
+     // V: the vertical ones 
+     const Float_t vFrameLength = 4.0; 
+     const Float_t vFrameHeight = sensHeight + hFrameHeight; 
+     const Float_t vFrameWidth  = sensWidth;
+     const Int_t vFrameMaterial = idGlass;
+
+     // B: the horizontal border filled with rohacell 
+     const Float_t bFrameLength = hFrameLength; 
+     const Float_t bFrameHeight = (pcbHeight - sensHeight)/2. - hFrameHeight; 
+     const Float_t bFrameWidth  = hFrameWidth;
+     const Int_t bFrameMaterial = idRoha;
+
+     // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper)
+     const Float_t nulocLength = 2.5; 
+     const Float_t nulocHeight = 7.5; 
+     const Float_t nulocWidth  = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
+     const Int_t   nulocMaterial = idCopper;
+
+     const Float_t slatHeight = pcbHeight; 
+     const Float_t slatWidth = sensWidth + 2.*(pcbWidth + insuWidth + 
+                                              2.* panelWidth + rohaWidth);
+     const Int_t slatMaterial = idAir;
+     const Float_t dSlatLength = vFrameLength; // border on left and right 
+
+     Float_t spar[3];  
+     Int_t i, j;
+
+     // the panel volume contains the rohacell
+
+     Float_t twidth = 2 * panelWidth + rohaWidth; 
+     Float_t panelpar[3] = { panelLength/2., panelHeight/2., twidth/2. }; 
+     Float_t rohapar[3] = { rohaLength/2., rohaHeight/2., rohaWidth/2. }; 
+
+     // insulating material contains PCB-> gas-> 2 borders filled with rohacell
+
+     twidth = 2*(insuWidth + pcbWidth) + sensWidth;  
+     Float_t insupar[3] = { insuLength/2., insuHeight/2., twidth/2. }; 
+     twidth -= 2 * insuWidth; 
+     Float_t pcbpar[3] = { pcbLength/2., pcbHeight/2., twidth/2. }; 
+     Float_t senspar[3] = { sensLength/2., sensHeight/2., sensWidth/2. }; 
+     Float_t theight = 2*hFrameHeight + sensHeight;
+     Float_t hFramepar[3]={hFrameLength/2., theight/2., hFrameWidth/2.}; 
+     Float_t bFramepar[3]={bFrameLength/2., bFrameHeight/2., bFrameWidth/2.}; 
+     Float_t vFramepar[3]={vFrameLength/2., vFrameHeight/2., vFrameWidth/2.};
+     Float_t nulocpar[3]={nulocLength/2., nulocHeight/2., nulocWidth/2.}; 
+     Float_t xx;
+     Float_t xxmax = (bFrameLength - nulocLength)/2.; 
+     Int_t index=0;
+      
+    AliMUONChamber *iChamber, *iChamber1, *iChamber2;
+
+    Int_t* fStations = new Int_t[5];
+    for (Int_t i=0; i<5; i++) fStations[i] = 1;
+
+    if (fStations[2])
+    {
+       
+//********************************************************************
+//                            Station 3                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+
+     iChamber = GetChamber(4);
+     iChamber1 = iChamber;
+     iChamber2 = GetChamber(5);
+     
+     iChamber1->GetGeometry()->SetDebug(kTRUE);
+     //iChamber2->GetGeometry()->SetDebug(kTRUE);
+
+     if (gAlice->GetModule("DIPO")) {
+       // if DIPO is preset, the whole station will be placed in DDIP volume
+       iChamber1->GetGeometry()->SetMotherVolume("DDIP");
+       iChamber2->GetGeometry()->SetMotherVolume("DDIP");
+     }
+
+//      if (gAlice->GetModule("DIPO")) {
+//        slats5Mother="DDIP";
+//        slats6Mother="DDIP";
+
+//        zoffs5 = zpos1;
+//        zoffs6 = zpos2;
+//      }
+//      else {
+//        gMC->Gsvolu("S05M", "TUBE", idAir, tpar, 3);
+//        gMC->Gsvolu("S06M", "TUBE", idAir, tpar, 3);
+//        gMC->Gspos("S05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+
+//        gMC->Gspos("S06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+//      }
+
+     // volumes for slat geometry (xx=5,..,10 chamber id): 
+     // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
+     // SxxG                          -->   Sensitive volume (gas)
+     // SxxP                          -->   PCB (copper) 
+     // SxxI                          -->   Insulator (vetronite) 
+     // SxxC                          -->   Carbon panel 
+     // SxxR                          -->   Rohacell
+     // SxxH, SxxV                    -->   Horizontal and Vertical frames (vetronite)
+     // SB5x                          -->   Volumes for the 35 cm long PCB
+     // slat dimensions: slat is a MOTHER volume!!! made of air
+
+     // only for chamber 5: slat 1 has a PCB shorter by 5cm!
+
+     Float_t tlength = 35.;
+     Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
+     Float_t rohapar2[3]   = { tlength/2., rohapar[1],   rohapar[2]}; 
+     Float_t insupar2[3]   = { tlength/2., insupar[1],   insupar[2]}; 
+     Float_t pcbpar2[3]    = { tlength/2., pcbpar[1],    pcbpar[2]}; 
+     Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
+     Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
+     Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
+     Float_t *dum=0;
+
+     const Int_t nSlats3 = 5;  // number of slats per quadrant
+     const Int_t nPCB3[nSlats3] = {3,4,4,3,2}; // n PCB per slat
+     const Float_t xpos3[nSlats3] = {31., 0., 0., 0., 0.};
+     Float_t slatLength3[nSlats3]; 
+
+     // create and position the slat (mother) volumes 
+
+//      char volNam5[5];
+//      char volNam6[5];
+     char idSlatCh5[5];
+     char idSlatCh6[5];
+     Float_t xSlat3;
+     Float_t angle = 0.;
+     
+     Float_t spar2[3];
+     for (i = 0; i<nSlats3; i++){
+       slatLength3[i] = pcbLength * nPCB3[i] + 2. * dSlatLength; 
+       xSlat3 = slatLength3[i]/2. - vFrameLength/2. + xpos3[i]; 
+       if (i==1 || i==0) slatLength3[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
+       Float_t ySlat31 =  sensHeight * i - yOverlap * i; 
+       Float_t ySlat32 = -sensHeight * i + yOverlap * i; 
+       spar[0] = slatLength3[i]/2.; 
+       spar[1] = slatHeight/2.;
+       spar[2] = slatWidth/2. * 1.01; 
+       // take away 5 cm from the first slat in chamber 5
+       Float_t xSlat32 = 0;
+       if (i==1 || i==2) { // 1 pcb is shortened by 5cm
+        spar2[0] = spar[0]-5./2.;
+        xSlat32 = xSlat3 - 5/2.;
+       }
+       else {
+        spar2[0] = spar[0];
+        xSlat32 = xSlat3;
+       }
+       spar2[1] = spar[1];
+       spar2[2] = spar[2]; 
+       Float_t dzCh3=spar[2] * 1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
+//        sprintf(volNam5,"S05%d",i);
+//        gMC->Gsvolu(volNam5,"BOX",slatMaterial,spar2,3);
+//        gMC->Gspos(volNam5, i*4+1,slats5Mother, xSlat32, ySlat31, zoffs5+zSlat+2.*dzCh3, 0, "ONLY");
+//        gMC->Gspos(volNam5, i*4+2,slats5Mother,-xSlat32, ySlat31, zoffs5+zSlat-2.*dzCh3, 0, "ONLY");
+
+       sprintf(idSlatCh5,"LA%d",nSlats3-1+i);
+       gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
+       GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(xSlat32, ySlat31, zSlat+2.*dzCh3) ,TGeoRotation("rot1",90,angle,90,90+angle,0,0)
+          );
+
+       sprintf(idSlatCh5,"LA%d",3*nSlats3-2+i);
+       gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
+       GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(-xSlat32, ySlat31, zSlat-2.*dzCh3) ,TGeoRotation("rot2",90,180+angle,90,90+angle,180,0)
+          );
+
+       if (i>0) { 
+
+       sprintf(idSlatCh5,"LA%d",nSlats3-1-i);
+       gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
+       GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(xSlat32, ySlat32, zSlat+2.*dzCh3) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
+          );
+
+       sprintf(idSlatCh5,"LA%d",3*nSlats3-2-i);
+       gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
+       GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(-xSlat32, ySlat32, zSlat-2.*dzCh3) ,TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)
+          );
+       }
+
+       sprintf(idSlatCh6,"LB%d",nSlats3-1+i);       
+       gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
+       GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(xSlat3, ySlat31, zSlat+2.*dzCh3) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
+          );
+       sprintf(idSlatCh6,"LB%d",3*nSlats3-2+i);
+       gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
+       GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(-xSlat3, ySlat31, zSlat-2.*dzCh3) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
+          );
+
+     if (i>0) { 
+       sprintf(idSlatCh6,"LB%d",nSlats3-1-i);
+       gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
+       GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(xSlat3, ySlat32, zSlat+2.*dzCh3) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
+          );
+
+       sprintf(idSlatCh6,"LB%d",3*nSlats3-2-i);
+       gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
+       GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(-xSlat3, ySlat32, zSlat-2.*dzCh3) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
+          );
+      }
+        }
+     
+     // create the panel volume 
+     gMC->Gsvolu("S05C","BOX",panelMaterial,panelpar,3);
+     gMC->Gsvolu("SB5C","BOX",panelMaterial,panelpar2,3);
+     gMC->Gsvolu("S06C","BOX",panelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S05R","BOX",rohaMaterial,rohapar,3);
+     gMC->Gsvolu("SB5R","BOX",rohaMaterial,rohapar2,3);
+     gMC->Gsvolu("S06R","BOX",rohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S05I","BOX",insuMaterial,insupar,3);
+     gMC->Gsvolu("SB5I","BOX",insuMaterial,insupar2,3);
+     gMC->Gsvolu("S06I","BOX",insuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S05P","BOX",pcbMaterial,pcbpar,3);
+     gMC->Gsvolu("SB5P","BOX",pcbMaterial,pcbpar2,3);
+     gMC->Gsvolu("S06P","BOX",pcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+     gMC->Gsvolu("S05G","BOX",sensMaterial,dum,0);
+     gMC->Gsvolu("S06G","BOX",sensMaterial,dum,0);
+
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S05V","BOX",vFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S06V","BOX",vFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+
+     gMC->Gsvolu("S05H","BOX",hFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("SB5H","BOX",hFrameMaterial,hFramepar2,3);
+     gMC->Gsvolu("S06H","BOX",hFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S05B","BOX",bFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("SB5B","BOX",bFrameMaterial,bFramepar2,3);
+     gMC->Gsvolu("S06B","BOX",bFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<nSlats3; i++){
+        for (Int_t quadrant=1; quadrant<=4; quadrant++) {
+
+            if (i==0&&quadrant==2) continue;
+            if (i==0&&quadrant==4) continue;
+
+       sprintf(idSlatCh5,"LA%d",ConvertSlatNum(i,quadrant,4));
+       sprintf(idSlatCh6,"LB%d",ConvertSlatNum(i,quadrant,4));
+       Float_t xvFrame  = (slatLength3[i] - vFrameLength)/2.;
+       Float_t xvFrame2  = xvFrame;
+
+       if ( i==1 || i ==2 ) xvFrame2 -= 5./2.;
+
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05V", idSlatCh5, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05V", idSlatCh5, (2*i)*10+quadrant,TGeoTranslation(-xvFrame2,0.,0.));
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06V", idSlatCh6, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06V", idSlatCh6, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+
+       }       
+       // position the panels and the insulating material 
+       for (j=0; j<nPCB3[i]; j++){
+        if (i==1&&j==0) continue;
+        index++;
+        Float_t xx = sensLength * (-nPCB3[i]/2.+j+.5); 
+        Float_t xx2 = xx + 5/2.; 
+        
+        Float_t zPanel = spar[2] - panelpar[2]; 
+        if ( (i==1 || i==2) && j == nPCB3[i]-1) { // 1 pcb is shortened by 5cm 
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5C", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5C", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
+        }
+        else if ( (i==1 || i==2) && j < nPCB3[i]-1) {
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
+        }
+        else {
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
+        }
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06C", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06C", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
+       } 
+        }
+     }
+     
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S05R",1,"S05C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5R",1,"SB5C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06R",1,"S06C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3); 
+     gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
+     gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
+
+     // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S05N","BOX",nulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S06N","BOX",nulocMaterial,nulocpar,3);
+     index = 0;
+     Float_t xxmax2 = xxmax - 5./2.;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
+       index++; 
+       gMC->Gspos("S05N",2*index-1,"S05B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S05N",2*index  ,"S05B", xx, 0., bFrameWidth/4., 0, "ONLY");
+       if (xx > -xxmax2 && xx< xxmax2) {
+        gMC->Gspos("S05N",2*index-1,"SB5B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+        gMC->Gspos("S05N",2*index  ,"SB5B", xx, 0., bFrameWidth/4., 0, "ONLY");
+       }
+       gMC->Gspos("S06N",2*index-1,"S06B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S06N",2*index  ,"S06B", xx, 0., bFrameWidth/4., 0, "ONLY");
+     }
+
+     // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = sensHeight/2.-yOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Double_t divpar[3];
+     Double_t dydiv= sensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     imax = 1; 
+     Float_t rmin = 33.; 
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (pcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = sensWidth/2.; 
+       Float_t xvol=(pcbLength+xdiv)/2.;
+       Float_t yvol=ydiv + dydiv/2.; 
+
+       for (Int_t quadrant=1; quadrant<=4; quadrant++)
+       {
+          sprintf(idSlatCh5,"LA%d",ConvertSlatNum(1,quadrant,4));
+          sprintf(idSlatCh6,"LB%d",ConvertSlatNum(1,quadrant,4));
+          
+       GetChamber(4)->GetGeometry()->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-(pcbLength * (nPCB3[1]-1)/2. + 35./2.),yvol-pcbLength+yOverlap,0.),3,divpar);
+       GetChamber(5)->GetGeometry()->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB3[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
+       }
+       
+     }
+     cout << "Geometry for Station 3...... done" << endl;
+    }
+    
+    if (fStations[3]) {
+
+
+// //********************************************************************
+// //                            Station 4                             **
+// //********************************************************************
+//      // indices 1 and 2 for first and second chambers in the station
+//      // iChamber (first chamber) kept for other quanties than Z,
+//      // assumed to be the same in both chambers
+     iChamber = GetChamber(6);
+     iChamber1 = iChamber;
+     iChamber2 = GetChamber(7);
+
+     const Int_t nSlats4 = 6;  // number of slats per quadrant
+     const Int_t nPCB4[nSlats4] = {4,4,5,5,4,3}; // n PCB per slat
+     const Float_t xpos4[nSlats4] = {38.5, 40., 0., 0., 0., 0.};
+     Float_t slatLength4[nSlats4];     
+
+//      // create and position the slat (mother) volumes 
+
+     char idSlatCh7[5];
+     char idSlatCh8[5];
+     Float_t xSlat4;
+     Float_t ySlat4;
+     angle = 0.;
+
+     for (i = 0; i<nSlats4; i++){
+       slatLength4[i] = pcbLength * nPCB4[i] + 2. * dSlatLength; 
+       xSlat4 = slatLength4[i]/2. - vFrameLength/2. + xpos4[i]; 
+       if (i==1) slatLength4[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
+       ySlat4 =  sensHeight * i - yOverlap *i;
+       
+       spar[0] = slatLength4[i]/2.; 
+       spar[1] = slatHeight/2.;
+       spar[2] = slatWidth/2.*1.01; 
+       Float_t dzCh4=spar[2]*1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? spar[2] : -spar[2]; 
+
+       sprintf(idSlatCh7,"LC%d",nSlats4-1+i);
+       gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
+       GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(xSlat4, ySlat4, zSlat+2.*dzCh4));
+
+       sprintf(idSlatCh7,"LC%d",3*nSlats4-2+i);
+       gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
+       GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(-xSlat4, ySlat4, zSlat-2.*dzCh4));
+       if (i>0) { 
+
+       sprintf(idSlatCh7,"LC%d",nSlats4-1-i);
+       gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
+       GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(xSlat4, -ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
+          );
+
+       sprintf(idSlatCh7,"LC%d",3*nSlats4-2-i);
+       gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
+       GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(-xSlat4, -ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
+          );
+       }
+
+       sprintf(idSlatCh8,"LD%d",nSlats4-1+i);
+       gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
+       GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(xSlat4, ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
+          );
+       sprintf(idSlatCh8,"LD%d",3*nSlats4-2+i);
+       gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
+       GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(-xSlat4, ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
+          );
+       if (i>0) { 
+       sprintf(idSlatCh8,"LD%d",nSlats4-1-i);
+       gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
+       GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(xSlat4, -ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
+          );
+       sprintf(idSlatCh8,"LD%d",3*nSlats4-2-i);
+       gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
+       GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(-xSlat4, -ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
+                                                );
+       }
+     }
+     
+
+     // create the panel volume 
+     gMC->Gsvolu("S07C","BOX",panelMaterial,panelpar,3);
+     gMC->Gsvolu("S08C","BOX",panelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S07R","BOX",rohaMaterial,rohapar,3);
+     gMC->Gsvolu("S08R","BOX",rohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S07I","BOX",insuMaterial,insupar,3);
+     gMC->Gsvolu("S08I","BOX",insuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S07P","BOX",pcbMaterial,pcbpar,3);
+     gMC->Gsvolu("S08P","BOX",pcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+
+     gMC->Gsvolu("S07G","BOX",sensMaterial,dum,0);
+     gMC->Gsvolu("S08G","BOX",sensMaterial,dum,0);
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S07V","BOX",vFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S08V","BOX",vFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+     gMC->Gsvolu("S07H","BOX",hFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("S08H","BOX",hFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S07B","BOX",bFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("S08B","BOX",bFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<nSlats4; i++){
+        for (Int_t quadrant=1; quadrant<=4; quadrant++) {
+
+            if (i==0&&quadrant==2) continue;
+            if (i==0&&quadrant==4) continue;
+
+       sprintf(idSlatCh7,"LC%d",ConvertSlatNum(i,quadrant,5));
+       sprintf(idSlatCh8,"LD%d",ConvertSlatNum(i,quadrant,5));
+       Float_t xvFrame  = (slatLength4[i] - vFrameLength)/2.;
+
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+       }
+       // position the panels and the insulating material 
+       for (j=0; j<nPCB4[i]; j++){
+        index++;
+        Float_t xx = sensLength * (-nPCB4[i]/2.+j+.5); 
+
+        Float_t zPanel = spar[2] - panelpar[2]; 
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07C", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07C", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08C", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08C", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
+       }
+        } 
+     }
+
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S07R",1,"S07C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08R",1,"S08C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
+     gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
+
+//      // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S07N","BOX",nulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S08N","BOX",nulocMaterial,nulocpar,3);
+     index = 0;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
+       index++; 
+       gMC->Gspos("S07N",2*index-1,"S07B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S07N",2*index  ,"S07B", xx, 0., bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S08N",2*index-1,"S08B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S08N",2*index  ,"S08B", xx, 0., bFrameWidth/4., 0, "ONLY");
+     }
+
+//      // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = sensHeight/2. - yOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Double_t divpar[3];
+     Double_t dydiv= sensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     imax = 1; 
+     Float_t rmin = 40.;
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (pcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = sensWidth/2.; 
+       Float_t xvol=(pcbLength+xdiv)/2.+1.999;
+       Float_t yvol=ydiv + dydiv/2.;
+
+       for (Int_t quadrant=1; quadrant<=4; quadrant++)
+       {
+          sprintf(idSlatCh7,"LC%d",ConvertSlatNum(1,quadrant,5));
+          sprintf(idSlatCh8,"LD%d",ConvertSlatNum(1,quadrant,5));
+
+       GetChamber(6)->GetGeometry()->AddEnvelopeConstituentParam("S07G", idSlatCh7, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB4[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
+       GetChamber(7)->GetGeometry()->AddEnvelopeConstituentParam("S08G", idSlatCh8,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB4[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
+       }
+     }
+     cout << "Geometry for Station 4...... done" << endl;
+
+    }
+    
+    if (fStations[4]) {
+       
+
+// //********************************************************************
+// //                            Station 5                             **
+// //********************************************************************
+//      // indices 1 and 2 for first and second chambers in the station
+//      // iChamber (first chamber) kept for other quanties than Z,
+//      // assumed to be the same in both chambers
+
+     iChamber = GetChamber(8);
+     iChamber1 = iChamber;
+     iChamber2 = GetChamber(9);
+     const Int_t nSlats5 = 7;  // number of slats per quadrant
+     const Int_t nPCB5[nSlats5] = {5,5,6,6,5,4,3}; // n PCB per slat
+     const Float_t xpos5[nSlats5] = {38.5, 40., 0., 0., 0., 0., 0.};
+     Float_t slatLength5[nSlats5]; 
+
+//      // create and position the slat (mother) volumes 
+
+     char idSlatCh9[5];
+     char idSlatCh10[5];
+     Float_t xSlat5;
+     Float_t ySlat5;
+     angle = 0.;
+
+     for (i = 0; i<nSlats5; i++){
+       slatLength5[i] = pcbLength * nPCB5[i] + 2. * dSlatLength; 
+       xSlat5 = slatLength5[i]/2. - vFrameLength/2. +xpos5[i]; 
+       if (i==1 || i==0) slatLength5[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
+       ySlat5 = sensHeight * i - yOverlap * i;
+       spar[0] = slatLength5[i]/2.; 
+       spar[1] = slatHeight/2.;
+       spar[2] = slatWidth/2. * 1.01; 
+       Float_t dzCh5=spar[2]*1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
+
+       sprintf(idSlatCh9,"LE%d",nSlats5-1+i);
+       gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
+       GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(xSlat5, ySlat5, zSlat+2.*dzCh5));
+
+       sprintf(idSlatCh9,"LE%d",3*nSlats5-2+i);
+       gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
+       GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(-xSlat5, ySlat5, zSlat-2.*dzCh5));
+       if (i>0) { 
+
+       sprintf(idSlatCh9,"LE%d",nSlats5-1-i);
+       gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
+       GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(xSlat5, -ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
+          );
+
+       sprintf(idSlatCh9,"LE%d",3*nSlats5-2-i);
+       gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
+       GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
+          );
+       }
+
+       sprintf(idSlatCh10,"LF%d",nSlats5-1+i);
+       gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
+       GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(xSlat5, ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
+          );
+
+       sprintf(idSlatCh10,"LF%d",3*nSlats5-2+i);
+       gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
+       GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(-xSlat5, ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
+                  );
+
+            if (i>0) { 
+
+       sprintf(idSlatCh10,"LF%d",nSlats5-1-i);
+       gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
+       GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(xSlat5, -ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
+          );
+       sprintf(idSlatCh10,"LF%d",3*nSlats5-2-i);
+       gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
+       GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
+          );
+            }
+     }
+//      // create the panel volume 
+     gMC->Gsvolu("S09C","BOX",panelMaterial,panelpar,3);
+     gMC->Gsvolu("S10C","BOX",panelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S09R","BOX",rohaMaterial,rohapar,3);
+     gMC->Gsvolu("S10R","BOX",rohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S09I","BOX",insuMaterial,insupar,3);
+     gMC->Gsvolu("S10I","BOX",insuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S09P","BOX",pcbMaterial,pcbpar,3);
+     gMC->Gsvolu("S10P","BOX",pcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+
+     gMC->Gsvolu("S09G","BOX",sensMaterial,dum,0);
+     gMC->Gsvolu("S10G","BOX",sensMaterial,dum,0);
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S09V","BOX",vFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S10V","BOX",vFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+     gMC->Gsvolu("S09H","BOX",hFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("S10H","BOX",hFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S09B","BOX",bFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("S10B","BOX",bFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<nSlats5; i++){
+        for (Int_t quadrant=1; quadrant<=4; quadrant++) {
+
+            if (i==0&&quadrant==2) continue;
+            if (i==0&&quadrant==4) continue;
+
+       sprintf(idSlatCh9,"LE%d",ConvertSlatNum(i,quadrant,6));
+       sprintf(idSlatCh10,"LF%d",ConvertSlatNum(i,quadrant,6));
+       Float_t xvFrame  = (slatLength5[i] - vFrameLength)/2.;
+
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+       }
+       
+       // position the panels and the insulating material 
+       for (j=0; j<nPCB5[i]; j++){
+        index++;
+        Float_t xx = sensLength * (-nPCB5[i]/2.+j+.5); 
+
+        Float_t zPanel = spar[2] - panelpar[2]; 
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09C", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09C", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10C", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10C", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
+       }
+        } 
+     }
+
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S09R",1,"S09C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10R",1,"S10C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
+     gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
+
+//      // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S09N","BOX",nulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S10N","BOX",nulocMaterial,nulocpar,3);
+     index = 0;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
+       index++; 
+       gMC->Gspos("S09N",2*index-1,"S09B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S09N",2*index  ,"S09B", xx, 0., bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S10N",2*index-1,"S10B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S10N",2*index  ,"S10B", xx, 0., bFrameWidth/4., 0, "ONLY");
+     }
+
+//      // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = sensHeight/2. - yOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Double_t divpar[3];
+     Double_t dydiv= sensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     //     for (Int_t islat=0; islat<nSlats3; islat++) imax += nPCB3[islat]; 
+     imax = 1; 
+     Float_t rmin = 40.; 
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (pcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = sensWidth/2.; 
+       Float_t xvol=(pcbLength+xdiv)/2. + 1.999;
+       Float_t yvol=ydiv + dydiv/2.;
+
+       for (Int_t quadrant=1; quadrant<=4; quadrant++)
+       {
+          sprintf(idSlatCh9,"LE%d",ConvertSlatNum(1,quadrant,6));
+          sprintf(idSlatCh10,"LF%d",ConvertSlatNum(1,quadrant,6));
+
+       GetChamber(8)->GetGeometry()->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB5[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
+       GetChamber(9)->GetGeometry()->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB5[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
+       }
+     }
+     cout << "Geometry for Station 5...... done" << endl;
+
+    }
+}
+
+
+//______________________________________________________________________________
+void AliMUONSlatGeometryBuilder::SetTransformations()
+{
+// Defines the transformations for the station2 chambers.
+// ---
+
+  AliMUONChamber* iChamber1 = GetChamber(4);
+  Double_t zpos1 = - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+
+  AliMUONChamber* iChamber2 = GetChamber(5);
+  Double_t zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+
+ iChamber1 = GetChamber(6);
+  zpos1 = - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+
+  iChamber2 = GetChamber(7);
+  zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+
+ iChamber1 = GetChamber(8);
+  zpos1 = - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+
+  iChamber2 = GetChamber(9);
+  zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+
+}
+
+//______________________________________________________________________________
+void AliMUONSlatGeometryBuilder::SetSensitiveVolumes()
+{
+// Defines the sensitive volumes for slat stations chambers.
+// ---
+
+  GetChamber(4)->GetGeometry()->SetSensitiveVolume("S05G");
+  GetChamber(5)->GetGeometry()->SetSensitiveVolume("S06G");
+  GetChamber(6)->GetGeometry()->SetSensitiveVolume("S07G");
+  GetChamber(7)->GetGeometry()->SetSensitiveVolume("S08G");
+  GetChamber(8)->GetGeometry()->SetSensitiveVolume("S09G");
+  GetChamber(9)->GetGeometry()->SetSensitiveVolume("S10G");
+}
+
+//______________________________________________________________________________
+Int_t  AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
+{
+             numslat=numslat+1;
+             if (quadnum==2||quadnum==3) numslat=numslat+fspq;
+             else numslat=fspq+2-numslat;
+             numslat=numslat-1;
+             
+             if (quadnum==3||quadnum==4) numslat=numslat+2*fspq+1;
+             return numslat;
+}
diff --git a/MUON/AliMUONSlatGeometryBuilder.h b/MUON/AliMUONSlatGeometryBuilder.h
new file mode 100644 (file)
index 0000000..de7993a
--- /dev/null
@@ -0,0 +1,40 @@
+// $Id$
+//
+// Class AliMUONSlatGeometryBuilder
+// -----------------------------
+// MUON Station3 geometry construction class.
+//
+// Author: Eric Dumonteil, Philippe Crochet
+
+#ifndef ALI_MUON_SLAT_GEOMETRY_BUILDER_H
+#define ALI_MUON_SLAT_GEOMETRY_BUILDER_H
+
+#include "AliMUONVGeometryBuilder.h"
+
+class AliMUON;
+
+class AliMUONSlatGeometryBuilder : public AliMUONVGeometryBuilder
+{
+  public:
+    AliMUONSlatGeometryBuilder(AliMUON* muon);
+    AliMUONSlatGeometryBuilder(const AliMUONSlatGeometryBuilder& rhs);
+    AliMUONSlatGeometryBuilder();
+    virtual ~AliMUONSlatGeometryBuilder();
+
+    // operators  
+    AliMUONSlatGeometryBuilder& operator = (const AliMUONSlatGeometryBuilder& rhs);
+  
+    // methods
+    virtual void CreateGeometry();
+    virtual void SetTransformations();
+    virtual void SetSensitiveVolumes();
+    
+  private:
+    Int_t  ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const;
+
+    AliMUON*  fMUON; // the MUON detector class 
+        
+  ClassDef(AliMUONSlatGeometryBuilder,1) // MUON chamber geometry base class
+};
+
+#endif //ALI_MUON_SLAT_GEOMETRY_BUILDER_H
diff --git a/MUON/AliMUONSt1GeometryBuilder.cxx b/MUON/AliMUONSt1GeometryBuilder.cxx
new file mode 100644 (file)
index 0000000..b6c556e
--- /dev/null
@@ -0,0 +1,299 @@
+// $Id$
+//
+// Class AliMUONSt1GeometryBuilder
+// -------------------------------
+// MUON Station1 coarse geometry construction class.
+//
+// Extracted from AliMUONv1
+// by Ivana Hrivnacova, IPN Orsay
+
+#include <TVirtualMC.h>
+#include <TGeoMatrix.h>
+
+#include "AliMUONSt1GeometryBuilder.h"
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
+
+ClassImp(AliMUONSt1GeometryBuilder)
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilder::AliMUONSt1GeometryBuilder(AliMUON* muon)
+ : AliMUONVGeometryBuilder(&muon->Chamber(0), &muon->Chamber(1)),
+   fMUON(muon)
+{
+// Standard constructor
+
+}
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilder::AliMUONSt1GeometryBuilder()
+ : AliMUONVGeometryBuilder(),
+   fMUON(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilder::AliMUONSt1GeometryBuilder(const AliMUONSt1GeometryBuilder& rhs)
+  : AliMUONVGeometryBuilder(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilder::~AliMUONSt1GeometryBuilder() {
+//
+}
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilder& 
+AliMUONSt1GeometryBuilder::operator = (const AliMUONSt1GeometryBuilder& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilder::CreateGeometry()
+{
+// From AliMUONv1::CreateGeometry()
+// ---
+
+//********************************************************************
+//                            Station 1                             **
+//********************************************************************
+//  CONCENTRIC
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+
+     // Get tracking medias Ids     
+     Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+     Int_t idAir= idtmed[1100]; // medium 1
+     Int_t idAlu1=idtmed[1103]; // medium 4
+     Int_t idAlu2=idtmed[1104]; // medium 5
+     Int_t idGas=idtmed[1108];  // medium 9 = Ar-CO2 gas (80%+20%)
+     Bool_t frameCrosses=kTRUE;     
+
+     // Rotation matrices in the x-y plane  
+     // phi=   0 deg
+     Int_t irot1;
+     fMUON->AliMatrix(irot1,  90.,   0., 90.,  90., 0., 0.);
+     // phi=  90 deg
+     Int_t irot2;
+     fMUON->AliMatrix(irot2,  90.,  90., 90., 180., 0., 0.);
+
+     AliMUONChamber* iChamber1 = GetChamber(0);
+     AliMUONChamber* iChamber2 = GetChamber(1);
+     AliMUONChamber* iChamber = iChamber1;
+
+     // DGas decreased from standard one (0.5)
+     iChamber->SetDGas(0.4); 
+     iChamber2->SetDGas(0.4);
+
+     // DAlu increased from standard one (3% of X0),
+     // because more electronics with smaller pads
+     iChamber->SetDAlu(3.5 * 8.9 / 100.); 
+     iChamber2->SetDAlu(3.5 * 8.9 / 100.);
+
+     // Half of the total thickness of frame crosses (including DAlu)
+     // for each chamber in stations 1 and 2:
+     // 3% of X0 of composite material,
+     // but taken as Aluminium here, with same thickness in number of X0
+     Float_t dframez = 3. * 8.9 / 100;
+     Float_t zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+             // The same parameters are defined in builder for station 2 
+
+     // Mother volume
+     // Outer excess and inner recess for mother volume radius
+     // with respect to ROuter and RInner
+     Float_t dframep=.001; // Value for station 3 should be 6 ...
+     // Width (RdPhi) of the frame crosses for stations 1 and 2 (cm)
+     // Float_t dframep1=.001;
+     Float_t dframep1 = 11.0;
+     Float_t phi=2*TMath::Pi()/12/2;
+             // The same parameters are defined in builder for station 2 
+
+     Float_t tpar[3];
+     Float_t dstation = (-iChamber2->Z()) - (-iChamber1->Z());
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     gMC->Gsvolu("S01M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S02M", "TUBE", idAir, tpar, 3);
+
+     // CHANGED
+     //gMC->Gspos("S01M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     //gMC->Gspos("S02M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");     
+     GetChamber(0)->GetGeometry()->AddEnvelope("S01M", false);
+     GetChamber(1)->GetGeometry()->AddEnvelope("S02M", false);
+
+// // Aluminium frames
+// // Outer frames
+//      pgpar[0] = 360/12/2;
+//      pgpar[1] = 360.;
+//      pgpar[2] = 12.;
+//      pgpar[3] =   2;
+//      pgpar[4] = -dframez/2;
+//      pgpar[5] = iChamber->ROuter();
+//      pgpar[6] = pgpar[5]+dframep1;
+//      pgpar[7] = +dframez/2;
+//      pgpar[8] = pgpar[5];
+//      pgpar[9] = pgpar[6];
+//      gMC->Gsvolu("S01O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gsvolu("S02O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gspos("S01O",1,"S01M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S01O",2,"S01M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S02O",1,"S02M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S02O",2,"S02M", 0.,0.,+zfpos,  0,"ONLY");
+// //
+// // Inner frame
+//      tpar[0]= iChamber->RInner()-dframep1;
+//      tpar[1]= iChamber->RInner();
+//      tpar[2]= dframez/2;
+//      gMC->Gsvolu("S01I", "TUBE", idAlu1, tpar, 3);
+//      gMC->Gsvolu("S02I", "TUBE", idAlu1, tpar, 3);
+
+//      gMC->Gspos("S01I",1,"S01M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S01I",2,"S01M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S02I",1,"S02M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S02I",2,"S02M", 0.,0.,+zfpos,  0,"ONLY");
+//
+// Frame Crosses
+     if (frameCrosses) {
+         // outside gas
+         // security for inside mother volume
+         Float_t bpar[3];
+        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
+          * TMath::Cos(TMath::ASin(dframep1 /
+                                  (iChamber->ROuter() - iChamber->RInner())))
+          / 2.0;
+        bpar[1] = dframep1/2;
+        // total thickness will be (4 * bpar[2]) for each chamber,
+        // which has to be equal to (2 * dframez) - DAlu
+        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
+        gMC->Gsvolu("S01B", "BOX", idAlu1, bpar, 3);
+        gMC->Gsvolu("S02B", "BOX", idAlu1, bpar, 3);
+        
+        gMC->Gspos("S01B",1,"S01M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S01B",2,"S01M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S01B",3,"S01M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S01B",4,"S01M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S01B",5,"S01M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S01B",6,"S01M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S01B",7,"S01M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S01B",8,"S01M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        
+        gMC->Gspos("S02B",1,"S02M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S02B",2,"S02M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S02B",3,"S02M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S02B",4,"S02M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S02B",5,"S02M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S02B",6,"S02M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S02B",7,"S02M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S02B",8,"S02M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+     }
+//
+//   Chamber Material represented by Alu sheet
+     tpar[0]= iChamber->RInner();
+     tpar[1]= iChamber->ROuter();
+     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
+     gMC->Gsvolu("S01A", "TUBE",  idAlu2, tpar, 3);
+     gMC->Gsvolu("S02A", "TUBE",idAlu2, tpar, 3);
+     gMC->Gspos("S01A", 1, "S01M", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S02A", 1, "S02M", 0., 0., 0.,  0, "ONLY");
+//     
+//   Sensitive volumes
+     // tpar[2] = iChamber->DGas();
+     tpar[2] = iChamber->DGas()/2;
+     gMC->Gsvolu("S01G", "TUBE", idGas, tpar, 3);
+     gMC->Gsvolu("S02G", "TUBE", idGas, tpar, 3);
+     gMC->Gspos("S01G", 1, "S01A", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S02G", 1, "S02A", 0., 0., 0.,  0, "ONLY");
+//
+// Frame Crosses to be placed inside gas
+     // NONE: chambers are sensitive everywhere
+//      if (frameCrosses) {
+
+//      dr = (iChamber->ROuter() - iChamber->RInner());
+//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
+//      bpar[1] = dframep1/2;
+//      bpar[2] = iChamber->DGas()/2;
+//      gMC->Gsvolu("S01F", "BOX", idAlu1, bpar, 3);
+//      gMC->Gsvolu("S02F", "BOX", idAlu1, bpar, 3);
+        
+//      gMC->Gspos("S01F",1,"S01G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S01F",2,"S01G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S01F",3,"S01G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S01F",4,"S01G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+        
+//      gMC->Gspos("S02F",1,"S02G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S02F",2,"S02G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S02F",3,"S02G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S02F",4,"S02G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      }
+}
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilder::SetTransformations()
+{
+// Defines the transformations for the station2 chambers.
+// ---
+
+  AliMUONChamber* iChamber1 = GetChamber(0);
+  Double_t zpos1= - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+
+  AliMUONChamber* iChamber2 = GetChamber(1);
+  Double_t zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+}
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilder::SetSensitiveVolumes()
+{
+// Defines the sensitive volumes for station1 chambers.
+// ---
+
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("S01G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("S02G");
+}
diff --git a/MUON/AliMUONSt1GeometryBuilder.h b/MUON/AliMUONSt1GeometryBuilder.h
new file mode 100644 (file)
index 0000000..9f7e1a9
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// $Id$
+//
+// Class AliMUONSt1GeometryBuilder
+// -----------------------------
+// MUON Station1 coarse geometry construction class.
+//
+// Extracted from AliMUONv1
+// by Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_ST1_GEOMETRY_BUILDER_H
+#define ALI_MUON_ST1_GEOMETRY_BUILDER_H
+
+#include "AliMUONVGeometryBuilder.h"
+
+class AliMUON;
+
+class AliMUONSt1GeometryBuilder : public AliMUONVGeometryBuilder
+{
+  public:
+    AliMUONSt1GeometryBuilder(AliMUON* muon);
+    AliMUONSt1GeometryBuilder(const AliMUONSt1GeometryBuilder& rhs);
+    AliMUONSt1GeometryBuilder();
+    virtual ~AliMUONSt1GeometryBuilder();
+
+    // operators  
+    AliMUONSt1GeometryBuilder& operator = (const AliMUONSt1GeometryBuilder& rhs);
+  
+    // methods
+    virtual void CreateGeometry();
+    virtual void SetTransformations();
+    virtual void SetSensitiveVolumes();
+    
+  private:
+     AliMUON*  fMUON; // the MUON detector class 
+        
+  ClassDef(AliMUONSt1GeometryBuilder,1) // MUON chamber geometry base class
+};
+
+#endif //ALI_MUON_ST1_GEOMETRY_BUILDER_H
similarity index 51%
rename from MUON/AliMUONv2.cxx
rename to MUON/AliMUONSt1GeometryBuilderV2.cxx
index b3478f593f9ec9ceeb8e5993b58b9edd49f2fa79..d60b4390973837e67cd6ace724ec13a217ad1a3f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
-
-// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
+// $Id$
+//
+// Class AliMUONSt1GeometryBuilderV2
+// ---------------------------------
+// MUON Station1 detailed geometry construction class.
 //
-// Class AliMUONv2
-// ---------------
-// Inherits from AliMUONv1 but with a more detailed
-// geometrical description of station 1 
+// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
+
+#ifdef ST1_WITH_STL
+  #include <vector>
+#endif
 
-#include <algorithm>
-#include <string>
+#ifdef ST1_WITH_ROOT
+  #include "TArrayI.h"
+#endif
 
 #include <TVector2.h>
+#include <TVector3.h>
+#include <TGeoMatrix.h>
 #include <TClonesArray.h>
-#include <TLorentzVector.h>
-#include <TArrayI.h>
 #include <Riostream.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
 #include "AliMpMotifMap.h"
 #include "AliMpMotifPosition.h"
 
-#include "AliMUONv2.h"
+#include "AliMUONSt1GeometryBuilderV2.h"
+#include "AliMUONSt1SpecialMotif.h"
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
 #include "AliMUONConstants.h"
-#include "AliMUONHit.h"
 #include "AliRun.h"
 #include "AliMagF.h"
-#include "AliConst.h" 
-#include "AliMUONChamber.h"
 
-ClassImp(AliMUONv2)
+ClassImp(AliMUONSt1GeometryBuilderV2)
 
 // Thickness Constants
-const GReal_t AliMUONv2::fgkHzPadPlane=0.0148/2.;     //Pad plane
-const GReal_t AliMUONv2::fgkHzFoam = 2.083/2.;        //Foam of mechanicalplane
-const GReal_t AliMUONv2::fgkHzFR4 = 0.0031/2.;        //FR4 of mechanical plane
-const GReal_t AliMUONv2::fgkHzSnPb = 0.0091/2.;       //Pad/Kapton connection (66 pt)
-const GReal_t AliMUONv2::fgkHzKapton = 0.0122/2.;     //Kapton
-const GReal_t AliMUONv2::fgkHzBergPlastic = 0.3062/2.;//Berg connector
-const GReal_t AliMUONv2::fgkHzBergCopper = 0.1882/2.; //Berg connector
-const GReal_t AliMUONv2::fgkHzDaughter = 0.0156/2.;   //Daughter board
-const GReal_t AliMUONv2::fgkHzGas = 0.2/2.;           //Gas thickness
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzPadPlane=0.0148/2.;     //Pad plane
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFoam = 2.083/2.;        //Foam of mechanicalplane
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFR4 = 0.0031/2.;        //FR4 of mechanical plane
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzSnPb = 0.0091/2.;       //Pad/Kapton connection (66 pt)
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzKapton = 0.0122/2.;     //Kapton
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergPlastic = 0.3062/2.;//Berg connector
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergCopper = 0.1882/2.; //Berg connector
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzDaughter = 0.0156/2.;   //Daughter board
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzGas = 0.2/2.;           //Gas thickness
 
 // Quadrant Mother volume - TUBS1 - Middle layer of model
-const GReal_t AliMUONv2::fgkMotherIR1 = 18.3;
-const GReal_t AliMUONv2::fgkMotherOR1 = 105.673;   
-const GReal_t AliMUONv2::fgkMotherThick1 = 6.5/2;  
-const GReal_t AliMUONv2::fgkMotherPhiL1 = 0.; 
-const GReal_t AliMUONv2::fgkMotherPhiU1 = 90.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherIR1 = 18.3;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherOR1 = 105.673;   
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherThick1 = 6.5/2;  
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiL1 = 0.; 
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiU1 = 90.;
 
 // Quadrant Mother volume - TUBS2 - near and far layers of model
-const GReal_t AliMUONv2::fgkMotherIR2 = 20.7;   
-const GReal_t AliMUONv2::fgkMotherOR2 = 100.073;   
-const GReal_t AliMUONv2::fgkMotherThick2 = 3.0/2; 
-const GReal_t AliMUONv2::fgkMotherPhiL2 = 0.; 
-const GReal_t AliMUONv2::fgkMotherPhiU2 = 90.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherIR2 = 20.7;   
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherOR2 = 100.073;   
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherThick2 = 3.0/2; 
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiL2 = 0.; 
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiU2 = 90.;
 
 // Sensitive copper pads, foam layer, PCB and electronics model parameters
-const GReal_t AliMUONv2::fgkHxHole=1.5/2.;
-const GReal_t AliMUONv2::fgkHyHole=6./2.;
-const GReal_t AliMUONv2::fgkHxBergPlastic=0.74/2.;
-const GReal_t AliMUONv2::fgkHyBergPlastic=5.09/2.;
-const GReal_t AliMUONv2::fgkHxBergCopper=0.25/2.;
-const GReal_t AliMUONv2::fgkHyBergCopper=3.6/2.;
-const GReal_t AliMUONv2::fgkHxKapton=0.8/2.;
-const GReal_t AliMUONv2::fgkHyKapton=5.7/2.;
-const GReal_t AliMUONv2::fgkHxDaughter=2.3/2.;
-const GReal_t AliMUONv2::fgkHyDaughter=6.3/2.;
-const GReal_t AliMUONv2::fgkOffsetX=1.46;
-const GReal_t AliMUONv2::fgkOffsetY=0.71;
-const GReal_t AliMUONv2::fgkDeltaFilleEtamX=1.46;
-const GReal_t AliMUONv2::fgkDeltaFilleEtamY=0.051;
-
-const GReal_t AliMUONv2::fgkDeltaQuadLHC=2.6;  // LHC Origin wrt Quadrant Origin
-const GReal_t AliMUONv2::fgkFrameOffset=5.0;  
-
-const char* AliMUONv2::fgkHoleName="MCHL";      
-const char* AliMUONv2::fgkDaughterName="MCDB";  
-const char  AliMUONv2::fgkFoamLayerSuffix='F';  // prefix for automatic volume naming
-const char* AliMUONv2::fgkQuadrantMLayerName="SQM";
-const char* AliMUONv2::fgkQuadrantNLayerName="SQN";
-const char* AliMUONv2::fgkQuadrantFLayerName="SQF";
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxHole=1.5/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyHole=6./2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxBergPlastic=0.74/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyBergPlastic=5.09/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxBergCopper=0.25/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyBergCopper=3.6/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxKapton=0.8/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyKapton=5.7/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxDaughter=2.3/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyDaughter=6.3/2.;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetX=1.46;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetY=0.71;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamX=1.46;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamY=0.051;
+
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaQuadLHC=2.6;  // LHC Origin wrt Quadrant Origin
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkFrameOffset=5.0;  
+
+const char* AliMUONSt1GeometryBuilderV2::fgkHoleName="MCHL";      
+const char* AliMUONSt1GeometryBuilderV2::fgkDaughterName="MCDB";  
+const char  AliMUONSt1GeometryBuilderV2::fgkFoamLayerSuffix='F';  // prefix for automatic volume naming
+const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantMLayerName="SQM";
+const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantNLayerName="SQN";
+const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantFLayerName="SQF";
 
 //______________________________________________________________________________
-AliMUONv2::AliMUONv2()
-  : AliMUONv1()
+AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(AliMUON* muon)
+  : AliMUONVGeometryBuilder(&muon->Chamber(0), &muon->Chamber(1)),
+    fMUON(muon)
 {
-// Default Constructor
-// --
-   fChamberV2[0] = 0;
-   fChamberV2[1] = 0;
-   
-   // keep secondaries
-   SetIshunt(0);
    // set path to mapping data files
    if (! gSystem->Getenv("MINSTALL")) {    
      TString dirPath = gSystem->Getenv("ALICE_ROOT");
@@ -123,55 +121,61 @@ AliMUONv2::AliMUONv2()
      //cout << "AliMpFiles top path set to " << dirPath << endl;         
    }
    //else
-   //  cout << gSystem->Getenv("MINSTALL") << endl;      
+   //  cout << gSystem->Getenv("MINSTALL") << endl;              
 }
  
 //______________________________________________________________________________
-AliMUONv2::AliMUONv2(const char *name, const char *title)
-  : AliMUONv1(name,title)
+AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2()
+  : AliMUONVGeometryBuilder(),
+    fMUON(0)
 {
-   fChamberV2[0] = 0;
-   fChamberV2[1] = 0;
-   
-   // keep secondaries
-   SetIshunt(0);
-   
-   // set path to mapping data files
-   if (! gSystem->Getenv("MINSTALL")) {    
-     TString dirPath = gSystem->Getenv("ALICE_ROOT");
-     dirPath += "/MUON/mapping"; 
-     AliMpFiles::Instance()->SetTopPath(dirPath);
-     gSystem->Setenv("MINSTALL", dirPath.Data());
-     //cout << "AliMpFiles top path set to " << dirPath << endl;         
-   }
-   //else
-   //  cout << gSystem->Getenv("MINSTALL") << endl;              
+// Default Constructor
+// --
 }
  
 //______________________________________________________________________________
-AliMUONv2::AliMUONv2(const AliMUONv2& rMUON):AliMUONv1(rMUON)
+AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(const AliMUONSt1GeometryBuilderV2& rhs)
+  : AliMUONVGeometryBuilder(rhs)
 {
 // Dummy copy constructor
+
+ Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
 }
 
 //______________________________________________________________________________
-AliMUONv2::~AliMUONv2()
+AliMUONSt1GeometryBuilderV2::~AliMUONSt1GeometryBuilderV2()
 {
 // Destructor
 }
 
+
+//______________________________________________________________________________
+AliMUONSt1GeometryBuilderV2& 
+AliMUONSt1GeometryBuilderV2::operator = (const AliMUONSt1GeometryBuilderV2& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
 //
 //  Private methods
 //
 
 //______________________________________________________________________________
-void AliMUONv2::CreateHole()
+void AliMUONSt1GeometryBuilderV2::CreateHole()
 {
 // Create all the elements found inside a foam hole
 // --
-  Int_t* idtmed = fIdtmed->GetArray()-1099;
-  Int_t idAir  = idtmed[1100];    // medium 1
-  Int_t idCopper  = idtmed[1109]; // medium 10 = copper
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idAir  = idtmed[1100];      // medium 1
+  //Int_t idCopper  = idtmed[1109]; // medium 10 = copper 
+  Int_t idCopper  = idtmed[1121]; // medium 22 = copper 
 
   GReal_t par[3];
   GReal_t posX,posY,posZ;
@@ -201,14 +205,16 @@ void AliMUONv2::CreateHole()
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateDaughterBoard()
+void AliMUONSt1GeometryBuilderV2::CreateDaughterBoard()
 {
 // Create all the elements in a daughter board
 // --
-  Int_t* idtmed = fIdtmed->GetArray()-1099;
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   Int_t idAir  = idtmed[1100]; // medium 1
-  Int_t idCopper  = idtmed[1109]; // medium 10 = copper
-  Int_t idPlastic  =idtmed[1116]; // medium 17 = Plastic
+  //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
+  //Int_t idPlastic  =idtmed[1116]; // medium 17 = Plastic
+  Int_t idCopper  = idtmed[1121]; // medium 22 = copper
+  Int_t idPlastic  =idtmed[1127]; // medium 28 = Plastic
 
   GReal_t par[3];
   GReal_t posX,posY,posZ;
@@ -247,16 +253,18 @@ void AliMUONv2::CreateDaughterBoard()
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateInnerLayers()
+void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
 {
 // Create the layer of sensitive volumes with gas
 // and the copper layer.
 // --
 
 // Gas Medium
-  Int_t* idtmed = fIdtmed->GetArray()-1099; 
-  Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
-  Int_t idCopper  = idtmed[1109]; // medium 10 = copper
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099; 
+  //Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
+  //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
+  Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
+  Int_t idCopper  = idtmed[1121]; // medium 22 = copper
 
   Float_t par[11];
 
@@ -463,7 +471,7 @@ void AliMUONv2::CreateInnerLayers()
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateQuadrant(Int_t chamber)
+void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
 {
 // create the quadrant (bending and non-bending planes)
 // for the given chamber
@@ -471,10 +479,20 @@ void AliMUONv2::CreateQuadrant(Int_t chamber)
 
   CreateFrame(chamber);
 
-  TSpecialMap specialMap;
+#ifdef ST1_WITH_STL
+  SpecialMap specialMap;
   specialMap[1001] = AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.);
   specialMap[1002] = AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36));
   specialMap[1003] = AliMUONSt1SpecialMotif(TVector2(1.01, 0.36));
+#endif
+  
+#ifdef ST1_WITH_ROOT
+  SpecialMap specialMap;
+  specialMap.Add(1001, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.));
+  specialMap.Add(1002, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36)));
+  specialMap.Add(1003, (Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01, 0.36)));
+#endif
+
   AliMpReader reader1(kStation1, kBendingPlane);
   AliMpSector* sector1 = reader1.BuildSector();
 
@@ -482,6 +500,7 @@ void AliMUONv2::CreateQuadrant(Int_t chamber)
   TVector3 where = TVector3(2.5+0.1+0.56+0.001, 2.5+0.1+0.001, 0.);
   PlaceSector(sector1, specialMap, where, reflectZ, chamber);
   
+#ifdef ST1_WITH_STL
   specialMap.clear();
   specialMap[4001] = AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.);
   specialMap[4002] = AliMUONSt1SpecialMotif(TVector2(1.96, 0.17));
@@ -489,24 +508,42 @@ void AliMUONv2::CreateQuadrant(Int_t chamber)
   specialMap[4004] = AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08));
   specialMap[4005] = AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25));
   specialMap[4006] = AliMUONSt1SpecialMotif(TVector2(0.28, 0.21));
+#endif
+
+#ifdef ST1_WITH_ROOT
+  specialMap.Delete();
+  specialMap.Add(4001,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.));
+  specialMap.Add(4002,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96, 0.17)));
+  specialMap.Add(4003,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.61,-1.18)));
+  specialMap.Add(4004,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08)));
+  specialMap.Add(4005,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25)));
+  specialMap.Add(4006,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.28, 0.21)));
+#endif
+
   AliMpReader reader2(kStation1, kNonBendingPlane);
   AliMpSector* sector2 = reader2.BuildSector();
 
   reflectZ = false;
   where = TVector3(where.X()+0.63/2.,where.Y()+0.42/2., 0.); //add a half pad shift
   PlaceSector(sector2, specialMap, where, reflectZ, chamber);
+
+#ifdef ST1_WITH_ROOT
+  specialMap.Delete();
+#endif
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateFoamBox(const char* name,const  TVector2& dimensions)
+void AliMUONSt1GeometryBuilderV2::CreateFoamBox(const char* name,const  TVector2& dimensions)
 {
 // create all the elements in the copper plane
 // --
 
-  Int_t* idtmed = fIdtmed->GetArray()-1099;
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   Int_t idAir  = idtmed[1100]; // medium 1
-  Int_t idFoam = idtmed[1115]; // medium 16 = Foam
-  Int_t idFR4  = idtmed[1114]; // medium 15 = FR4
+  //Int_t idFoam = idtmed[1115]; // medium 16 = Foam
+  //Int_t idFR4  = idtmed[1114]; // medium 15 = FR4
+  Int_t idFoam = idtmed[1125]; // medium 26 = Foam
+  Int_t idFR4  = idtmed[1122]; // medium 23 = FR4
 
   // mother volume
   GReal_t par[3];
@@ -542,7 +579,7 @@ void AliMUONv2::CreateFoamBox(const char* name,const  TVector2& dimensions)
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreatePlaneSegment(const char* name,const  TVector2& dimensions,
+void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(const char* name,const  TVector2& dimensions,
                                   Int_t nofHoles)
 {
 // Create a segment of a plane (this includes a foam layer, 
@@ -566,7 +603,7 @@ void AliMUONv2::CreatePlaneSegment(const char* name,const  TVector2& dimensions,
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateFrame(Int_t chamber)
+void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
 {
 // Create the non-sensitive elements of the frame for the  <chamber>
 //
@@ -597,71 +634,77 @@ void AliMUONv2::CreateFrame(Int_t chamber)
 // SQFx is the Quadrant Far side layer for chamber <x> ( posZ in (3.25,6.25] ).
 //---
 
-const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
+  const Float_t kNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 
   // tracking medias
-  Int_t* idtmed = fIdtmed->GetArray()-1099;
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   
   Int_t idAir  = idtmed[1100];       // medium 1
-  Int_t idFrameEpoxy = idtmed[1115]; // medium 16 = Frame Epoxy ME730
-  Int_t idInox = idtmed[1116];       // medium 17 Stainless Steel (18%Cr,9%Ni,Fe)
-  Int_t idFR4 = idtmed[1110];        // medium 11 FR4
-  Int_t idCopper = idtmed[1109];     // medium 10 Copper
-  Int_t idAlu = idtmed[1103];        // medium 4 Aluminium
+  //Int_t idFrameEpoxy = idtmed[1115]; // medium 16 = Frame Epoxy ME730
+  //Int_t idInox = idtmed[1116];       // medium 17 Stainless Steel (18%Cr,9%Ni,Fe)
+  //Int_t idFR4 = idtmed[1110];        // medium 11 FR4
+  //Int_t idCopper = idtmed[1109];     // medium 10 Copper
+  //Int_t idAlu = idtmed[1103];        // medium 4 Aluminium
+  Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
+  Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
+  Int_t idFR4 = idtmed[1122];        // medium 23 FR4  // was 15 not 11
+  Int_t idCopper = idtmed[1121];     // medium 22 Copper
+  Int_t idAlu = idtmed[1120];        // medium 21 Aluminium
   
   
 // Rotation Matrices  
       Int_t rot1, rot2, rot3;    
       
 //   Rotation matrices  
-     AliMatrix(rot1,  90.,  90., 90., 180.,  0., 0.); // +90 deg in x-y plane
-     AliMatrix(rot2,  90.,  45., 90., 135.,  0., 0.); // +45 deg in x-y plane 
-     AliMatrix(rot3,  90.,  45., 90., 315.,180., 0.); // +45 deg in x-y + rotation 180° around y
+     fMUON->AliMatrix(rot1,  90.,  90., 90., 180.,  0., 0.); // +90 deg in x-y plane
+     fMUON->AliMatrix(rot2,  90.,  45., 90., 135.,  0., 0.); // +45 deg in x-y plane 
+     fMUON->AliMatrix(rot3,  90.,  45., 90., 315.,180., 0.); // +45 deg in x-y + rotation 180° around y
 
 //   Translation matrices ... NOT USED  
-//     AliMatrix(trans1, 90.,   0., 90.,  90.,   0., 0.); // X-> X; Y -> Y; Z -> Z
-//     AliMatrix(trans2, 90., 180., 90.,  90., 180., 0.); // X->-X; Y -> Y; Z ->-Z
-//     AliMatrix(trans3, 90., 180., 90., 270.,   0., 0.); // X->-X; Y ->-Y; Z -> Z
-//     AliMatrix(trans4, 90.,   0., 90., 270., 180., 0.); // X-> X; Y ->-Y; Z ->-Z
+//     fMUON->AliMatrix(trans1, 90.,   0., 90.,  90.,   0., 0.); // X-> X; Y -> Y; Z -> Z
+//     fMUON->AliMatrix(trans2, 90., 180., 90.,  90., 180., 0.); // X->-X; Y -> Y; Z ->-Z
+//     fMUON->AliMatrix(trans3, 90., 180., 90., 270.,   0., 0.); // X->-X; Y ->-Y; Z -> Z
+//     fMUON->AliMatrix(trans4, 90.,   0., 90., 270., 180., 0.); // X-> X; Y ->-Y; Z ->-Z
 //  
       // ___________________Volume thicknesses________________________
 
-  Float_t hzFrameThickness = 1.59/2.;     //equivalent thickness
-  Float_t hzOuterFrameEpoxy = 1.19/2.;    //equivalent thickness
-  Float_t hzOuterFrameInox = 0.1/2.;      //equivalent thickness
-  Float_t hzFoam = 2.083/2.;              //evaluated elsewhere
+  const Float_t kHzFrameThickness = 1.59/2.;     //equivalent thickness
+  const Float_t kHzOuterFrameEpoxy = 1.19/2.;    //equivalent thickness
+  const Float_t kHzOuterFrameInox = 0.1/2.;      //equivalent thickness
+  const Float_t kHzFoam = 2.083/2.;              //evaluated elsewhere
+                                                 // CHECK with fgkHzFoam
   
 // Pertaining to the top outer area 
-  Float_t hzTopAnodeSteel1 = 0.185/2.;    //equivalent thickness
-  Float_t hzTopAnodeSteel2 = 0.51/2.;     //equivalent thickness  
-  Float_t hzAnodeFR4 = 0.08/2.;           //equivalent thickness
-  Float_t hzTopEarthFaceCu = 0.364/2.;    //equivalent thickness
-  Float_t hzTopEarthProfileCu = 1.1/2.;   //equivalent thickness
-  Float_t hzTopPositionerSteel = 1.45/2.; //should really be 2.125/2.; 
-  Float_t hzTopGasSupportAl = 0.85/2.;    //equivalent thickness
+  const Float_t kHzTopAnodeSteel1 = 0.185/2.;    //equivalent thickness
+  const Float_t kHzTopAnodeSteel2 = 0.51/2.;     //equivalent thickness  
+  const Float_t kHzAnodeFR4 = 0.08/2.;           //equivalent thickness
+  const Float_t kHzTopEarthFaceCu = 0.364/2.;    //equivalent thickness
+  const Float_t kHzTopEarthProfileCu = 1.1/2.;   //equivalent thickness
+  const Float_t kHzTopPositionerSteel = 1.45/2.; //should really be 2.125/2.; 
+  const Float_t kHzTopGasSupportAl = 0.85/2.;    //equivalent thickness
   
 // Pertaining to the vertical outer area  
-  Float_t hzVerticalCradleAl = 0.8/2.;     //equivalent thickness
-  Float_t hzLateralSightAl = 0.975/2.;     //equivalent thickness
-  Float_t hzLateralPosnInoxFace = 2.125/2.;//equivalent thickness
-  Float_t hzLatPosInoxProfM = 6.4/2.;      //equivalent thickness
-  Float_t hzLatPosInoxProfNF = 1.45/2.;    //equivalent thickness
-  Float_t hzLateralPosnAl = 0.5/2.;        //equivalent thickness
-  Float_t hzVertEarthFaceCu = 0.367/2.;    //equivalent thickness
-  Float_t hzVertBarSteel = 0.198/2.;       //equivalent thickness
-  Float_t hzVertEarthProfCu = 1.1/2.;      //equivalent thickness
+  const Float_t kHzVerticalCradleAl = 0.8/2.;     //equivalent thickness
+  const Float_t kHzLateralSightAl = 0.975/2.;     //equivalent thickness
+  const Float_t kHzLateralPosnInoxFace = 2.125/2.;//equivalent thickness
+  const Float_t kHzLatPosInoxProfM = 6.4/2.;      //equivalent thickness
+  const Float_t kHzLatPosInoxProfNF = 1.45/2.;    //equivalent thickness
+  const Float_t kHzLateralPosnAl = 0.5/2.;        //equivalent thickness
+  const Float_t kHzVertEarthFaceCu = 0.367/2.;    //equivalent thickness
+  const Float_t kHzVertBarSteel = 0.198/2.;       //equivalent thickness
+  const Float_t kHzVertEarthProfCu = 1.1/2.;      //equivalent thickness
 
       //_______________Parameter definitions in sequence _________
 
 // InVFrame parameters
-  Float_t hxInVFrame  = 1.85/2.;
-  Float_t hyInVFrame  = 73.95/2.;
-  Float_t hzInVFrame  = hzFrameThickness;
+  const Float_t kHxInVFrame  = 1.85/2.;
+  const Float_t kHyInVFrame  = 73.95/2.;
+  const Float_t kHzInVFrame  = kHzFrameThickness;
 
 //Flat 7.5mm vertical section
-  Float_t hxV1mm  = 0.75/2.;
-  Float_t hyV1mm  = 1.85/2.;
-  Float_t hzV1mm  = hzFrameThickness;
+  const Float_t kHxV1mm  = 0.75/2.;
+  const Float_t kHyV1mm  = 1.85/2.;
+  const Float_t kHzV1mm  = kHzFrameThickness;
 
 // OuterTopFrame Structure 
 //
@@ -689,164 +732,164 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //---
   
 //TopFrameAnode parameters - cuboid, 2 layers
-  Float_t hxTFA = 34.1433/2.;
-  Float_t hyTFA = 7.75/2.;
-  Float_t hzTFAE = hzOuterFrameEpoxy;     // layer 1 thickness
-  Float_t hzTFAI = hzOuterFrameInox;      // layer 3 thickness
+  const Float_t kHxTFA = 34.1433/2.;
+  const Float_t kHyTFA = 7.75/2.;
+  const Float_t kHzTFAE = kHzOuterFrameEpoxy;     // layer 1 thickness
+  const Float_t kHzTFAI = kHzOuterFrameInox;      // layer 3 thickness
   
 // TopFrameAnodeA parameters - trapezoid, 2 layers
-  Float_t hzFAAE = hzOuterFrameEpoxy;     // layer 1 thickness
-  Float_t hzFAAI = hzOuterFrameInox;      // layer 3 thickness
-  Float_t tetFAA = 0.;
-  Float_t phiFAA = 0.;
-  Float_t h1FAA = 8.7/2.;
-  Float_t bl1FAA = 4.35/2.;
-  Float_t tl1FAA =  7.75/2.;
-  Float_t alp1FAA = 11.06; 
-  Float_t h2FAA = 8.7/2.;
-  Float_t bl2FAA = 4.35/2.;
-  Float_t tl2FAA = 7.75/2.;
-  Float_t alp2FAA = 11.06;  
+  const Float_t kHzFAAE = kHzOuterFrameEpoxy;     // layer 1 thickness
+  const Float_t kHzFAAI = kHzOuterFrameInox;      // layer 3 thickness
+  const Float_t kTetFAA = 0.;
+  const Float_t kPhiFAA = 0.;
+  const Float_t kH1FAA = 8.7/2.;
+  const Float_t kBl1FAA = 4.35/2.;
+  const Float_t kTl1FAA =  7.75/2.;
+  const Float_t kAlp1FAA = 11.06; 
+  const Float_t kH2FAA = 8.7/2.;
+  const Float_t kBl2FAA = 4.35/2.;
+  const Float_t kTl2FAA = 7.75/2.;
+  const Float_t kAlp2FAA = 11.06;  
   
 // TopFrameAnodeB parameters - trapezoid, 2 layers
-  Float_t hzFABE = hzOuterFrameEpoxy;     // layer 1 thickness
-  Float_t hzFABI = hzOuterFrameInox;      // layer 3 thickness
-  Float_t tetFAB = 0.;
-  Float_t phiFAB = 0.;
-  Float_t h1FAB = 8.70/2.;
-  Float_t bl1FAB = 0.;
-  Float_t tl1FAB = 4.35/2.;
-  Float_t alp1FAB = 14.03; 
-  Float_t h2FAB = 8.70/2.;
-  Float_t bl2FAB = 0.;
-  Float_t tl2FAB = 4.35/2.;
-  Float_t alp2FAB = 14.03;  
+  const Float_t kHzFABE = kHzOuterFrameEpoxy;     // layer 1 thickness
+  const Float_t kHzFABI = kHzOuterFrameInox;      // layer 3 thickness
+  const Float_t kTetFAB = 0.;
+  const Float_t kPhiFAB = 0.;
+  const Float_t kH1FAB = 8.70/2.;
+  const Float_t kBl1FAB = 0.;
+  const Float_t kTl1FAB = 4.35/2.;
+  const Float_t kAlp1FAB = 14.03; 
+  const Float_t kH2FAB = 8.70/2.;
+  const Float_t kBl2FAB = 0.;
+  const Float_t kTl2FAB = 4.35/2.;
+  const Float_t kAlp2FAB = 14.03;  
   
 // TopAnode parameters - cuboid (part 1 of 3 parts)
-  Float_t hxTA1 = 16.2/2.;
-  Float_t hyTA1 = 3.5/2.;
-  Float_t hzTA11 = hzTopAnodeSteel1;   // layer 1
-  Float_t hzTA12 = hzAnodeFR4;         // layer 2 
+  const Float_t kHxTA1 = 16.2/2.;
+  const Float_t kHyTA1 = 3.5/2.;
+  const Float_t kHzTA11 = kHzTopAnodeSteel1;   // layer 1
+  const Float_t kHzTA12 = kHzAnodeFR4;         // layer 2 
 
 // TopAnode parameters - trapezoid 1 (part 2 of 3 parts)
-  Float_t hzTA21 = hzTopAnodeSteel2;   // layer 1 
-  Float_t hzTA22 = hzAnodeFR4;         // layer 2 
-  Float_t tetTA2 = 0.;
-  Float_t phiTA2= 0.;
-  Float_t h1TA2 = 7.268/2.;
-  Float_t bl1TA2 = 2.03/2.;
-  Float_t tl1TA2 = 3.5/2.;
-  Float_t alp1TA2 = 5.78; 
-  Float_t h2TA2 = 7.268/2.;
-  Float_t bl2TA2 = 2.03/2.;
-  Float_t tl2TA2 = 3.5/2.;
-  Float_t alp2TA2 = 5.78;  
+  const Float_t kHzTA21 = kHzTopAnodeSteel2;   // layer 1 
+  const Float_t kHzTA22 = kHzAnodeFR4;         // layer 2 
+  const Float_t kTetTA2 = 0.;
+  const Float_t kPhiTA2= 0.;
+  const Float_t kH1TA2 = 7.268/2.;
+  const Float_t kBl1TA2 = 2.03/2.;
+  const Float_t kTl1TA2 = 3.5/2.;
+  const Float_t kAlp1TA2 = 5.78; 
+  const Float_t kH2TA2 = 7.268/2.;
+  const Float_t kBl2TA2 = 2.03/2.;
+  const Float_t kTl2TA2 = 3.5/2.;
+  const Float_t kAlp2TA2 = 5.78;  
 
 // TopAnode parameters - trapezoid 2 (part 3 of 3 parts)
-  Float_t hzTA3 = hzAnodeFR4;       // layer 1 
-  Float_t tetTA3 = 0.;
-  Float_t phiTA3 = 0.;
-  Float_t h1TA3 = 7.268/2.;
-  Float_t bl1TA3 = 0.;
-  Float_t tl1TA3 = 2.03/2.;
-  Float_t alp1TA3 = 7.95; 
-  Float_t h2TA3 = 7.268/2.;
-  Float_t bl2TA3 = 0.;
-  Float_t tl2TA3 = 2.03/2.;
-  Float_t alp2TA3 = 7.95;  
+  const Float_t kHzTA3 = kHzAnodeFR4;       // layer 1 
+  const Float_t kTetTA3 = 0.;
+  const Float_t kPhiTA3 = 0.;
+  const Float_t kH1TA3 = 7.268/2.;
+  const Float_t kBl1TA3 = 0.;
+  const Float_t kTl1TA3 = 2.03/2.;
+  const Float_t kAlp1TA3 = 7.95; 
+  const Float_t kH2TA3 = 7.268/2.;
+  const Float_t kBl2TA3 = 0.;
+  const Float_t kTl2TA3 = 2.03/2.;
+  const Float_t kAlp2TA3 = 7.95;  
   
 // TopEarthFace parameters - single trapezoid
-  Float_t hzTEF = hzTopEarthFaceCu;
-  Float_t tetTEF = 0.;
-  Float_t phiTEF = 0.;
-  Float_t h1TEF = 1.200/2.;
-  Float_t bl1TEF = 21.323/2.;
-  Float_t tl1TEF = 17.963/2.;
-  Float_t alp1TEF = -54.46; 
-  Float_t h2TEF = 1.200/2.;
-  Float_t bl2TEF = 21.323/2.;
-  Float_t tl2TEF = 17.963/2.;
-  Float_t alp2TEF = -54.46;
+  const Float_t kHzTEF = kHzTopEarthFaceCu;
+  const Float_t kTetTEF = 0.;
+  const Float_t kPhiTEF = 0.;
+  const Float_t kH1TEF = 1.200/2.;
+  const Float_t kBl1TEF = 21.323/2.;
+  const Float_t kTl1TEF = 17.963/2.;
+  const Float_t kAlp1TEF = -54.46; 
+  const Float_t kH2TEF = 1.200/2.;
+  const Float_t kBl2TEF = 21.323/2.;
+  const Float_t kTl2TEF = 17.963/2.;
+  const Float_t kAlp2TEF = -54.46;
 
 // TopEarthProfile parameters - single trapezoid
-  Float_t hzTEP = hzTopEarthProfileCu;
-  Float_t tetTEP = 0.;
-  Float_t phiTEP = 0.;
-  Float_t h1TEP = 0.40/2.;
-  Float_t bl1TEP = 31.766/2.;
-  Float_t tl1TEP = 30.535/2.;
-  Float_t alp1TEP = -56.98; 
-  Float_t h2TEP = 0.40/2.;
-  Float_t bl2TEP = 31.766/2.;
-  Float_t tl2TEP = 30.535/2.;
-  Float_t alp2TEP = -56.98;
+  const Float_t kHzTEP = kHzTopEarthProfileCu;
+  const Float_t kTetTEP = 0.;
+  const Float_t kPhiTEP = 0.;
+  const Float_t kH1TEP = 0.40/2.;
+  const Float_t kBl1TEP = 31.766/2.;
+  const Float_t kTl1TEP = 30.535/2.;
+  const Float_t kAlp1TEP = -56.98; 
+  const Float_t kH2TEP = 0.40/2.;
+  const Float_t kBl2TEP = 31.766/2.;
+  const Float_t kTl2TEP = 30.535/2.;
+  const Float_t kAlp2TEP = -56.98;
 
 // TopPositioner parameters - single Stainless Steel trapezoid 
-  Float_t hzTP = hzTopPositionerSteel;
-  Float_t tetTP = 0.;
-  Float_t phiTP = 0.;
-  Float_t h1TP = 3.00/2.;
-  Float_t bl1TP = 7.023/2.;
-  Float_t tl1TP = 7.314/2.;
-  Float_t alp1TP = 2.78; 
-  Float_t h2TP = 3.00/2.;
-  Float_t bl2TP = 7.023/2.;
-  Float_t tl2TP = 7.314/2.;
-  Float_t alp2TP = 2.78;
+  const Float_t kHzTP = kHzTopPositionerSteel;
+  const Float_t kTetTP = 0.;
+  const Float_t kPhiTP = 0.;
+  const Float_t kH1TP = 3.00/2.;
+  const Float_t kBl1TP = 7.023/2.;
+  const Float_t kTl1TP = 7.314/2.;
+  const Float_t kAlp1TP = 2.78; 
+  const Float_t kH2TP = 3.00/2.;
+  const Float_t kBl2TP = 7.023/2.;
+  const Float_t kTl2TP = 7.314/2.;
+  const Float_t kAlp2TP = 2.78;
 
 // TopGasSupport parameters - single cuboid 
-  Float_t hxTGS  = 8.50/2.;
-  Float_t hyTGS  = 3.00/2.;
-  Float_t hzTGS  = hzTopGasSupportAl;
+  const Float_t kHxTGS  = 8.50/2.;
+  const Float_t kHyTGS  = 3.00/2.;
+  const Float_t kHzTGS  = kHzTopGasSupportAl;
     
 // OutEdgeFrame parameters - 4 trapezoidal sections, 2 layers of material
 //
 //---
 
 // Trapezoid 1
-  Float_t hzOETFE = hzOuterFrameEpoxy;    // layer 1 
-  Float_t hzOETFI = hzOuterFrameInox;     // layer 3
+  const Float_t kHzOETFE = kHzOuterFrameEpoxy;    // layer 1 
+  const Float_t kHzOETFI = kHzOuterFrameInox;     // layer 3
    
-  Float_t tetOETF = 0.;            // common to all 4 trapezoids
-  Float_t phiOETF = 0.;            // common to all 4 trapezoids
+  const Float_t kTetOETF = 0.;            // common to all 4 trapezoids
+  const Float_t kPhiOETF = 0.;            // common to all 4 trapezoids
 
-  Float_t h1OETF = 7.196/2.;       // common to all 4 trapezoids
-  Float_t h2OETF = 7.196/2.;       // common to all 4 trapezoids   
+  const Float_t kH1OETF = 7.196/2.;       // common to all 4 trapezoids
+  const Float_t kH2OETF = 7.196/2.;       // common to all 4 trapezoids   
   
-  Float_t bl1OETF1 = 3.75/2; 
-  Float_t tl1OETF1 = 3.996/2.;
-  Float_t alp1OETF1 = 0.98;
+  const Float_t kBl1OETF1 = 3.75/2; 
+  const Float_t kTl1OETF1 = 3.996/2.;
+  const Float_t kAlp1OETF1 = 0.98;
 
-  Float_t bl2OETF1 = 3.75/2;
-  Float_t tl2OETF1 = 3.996/2.;
-  Float_t alp2OETF1 = 0.98;
+  const Float_t kBl2OETF1 = 3.75/2;
+  const Float_t kTl2OETF1 = 3.996/2.;
+  const Float_t kAlp2OETF1 = 0.98;
   
 // Trapezoid 2
-  Float_t bl1OETF2 = 3.01/2.;
-  Float_t tl1OETF2 = 3.75/2;
-  Float_t alp1OETF2 = 2.94;
+  const Float_t kBl1OETF2 = 3.01/2.;
+  const Float_t kTl1OETF2 = 3.75/2;
+  const Float_t kAlp1OETF2 = 2.94;
       
-  Float_t bl2OETF2 = 3.01/2.;
-  Float_t tl2OETF2 = 3.75/2;
-  Float_t alp2OETF2 = 2.94; 
+  const Float_t kBl2OETF2 = 3.01/2.;
+  const Float_t kTl2OETF2 = 3.75/2;
+  const Float_t kAlp2OETF2 = 2.94; 
  
 // Trapezoid 3
-  Float_t bl1OETF3 = 1.767/2.;
-  Float_t tl1OETF3 = 3.01/2.;
-  Float_t alp1OETF3 = 4.94;
+  const Float_t kBl1OETF3 = 1.767/2.;
+  const Float_t kTl1OETF3 = 3.01/2.;
+  const Float_t kAlp1OETF3 = 4.94;
       
-  Float_t bl2OETF3 = 1.767/2.;
-  Float_t tl2OETF3 = 3.01/2.; 
-  Float_t alp2OETF3 = 4.94; 
+  const Float_t kBl2OETF3 = 1.767/2.;
+  const Float_t kTl2OETF3 = 3.01/2.; 
+  const Float_t kAlp2OETF3 = 4.94; 
   
 // Trapezoid 4
-  Float_t bl1OETF4 = 0.;
-  Float_t tl1OETF4 = 1.77/2.;
-  Float_t alp1OETF4 = 7.01;
+  const Float_t kBl1OETF4 = 0.;
+  const Float_t kTl1OETF4 = 1.77/2.;
+  const Float_t kAlp1OETF4 = 7.01;
       
-  Float_t bl2OETF4 = 0.;
-  Float_t tl2OETF4 = 1.77/2.;
-  Float_t alp2OETF4 =  7.01;   
+  const Float_t kBl2OETF4 = 0.;
+  const Float_t kTl2OETF4 = 1.77/2.;
+  const Float_t kAlp2OETF4 =  7.01;   
   
 // Frame Structure (OutVFrame):
 //
@@ -859,184 +902,184 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //---
 
 // OutVFrame parameters - cuboid
-  Float_t hxOutVFrame = 1.85/2.;
-  Float_t hyOutVFrame = 46.23/2.;
-  Float_t hzOutVFrame = hzFrameThickness;
+  const Float_t kHxOutVFrame = 1.85/2.;
+  const Float_t kHyOutVFrame = 46.23/2.;
+  const Float_t kHzOutVFrame = kHzFrameThickness;
 
 // OutVFrame corner parameters - trapezoid
-  Float_t hzOCTF = hzFrameThickness;
-  Float_t tetOCTF = 0.;
-  Float_t phiOCTF = 0.;
-  Float_t h1OCTF = 1.85/2.;
-  Float_t bl1OCTF = 0.;
-  Float_t tl1OCTF = 3.66/2.;
-  Float_t alp1OCTF = 44.67; 
-  Float_t h2OCTF = 1.85/2.;
-  Float_t bl2OCTF = 0.;
-  Float_t tl2OCTF = 3.66/2.;
-  Float_t alp2OCTF = 44.67;  
+  const Float_t kHzOCTF = kHzFrameThickness;
+  const Float_t kTetOCTF = 0.;
+  const Float_t kPhiOCTF = 0.;
+  const Float_t kH1OCTF = 1.85/2.;
+  const Float_t kBl1OCTF = 0.;
+  const Float_t kTl1OCTF = 3.66/2.;
+  const Float_t kAlp1OCTF = 44.67; 
+  const Float_t kH2OCTF = 1.85/2.;
+  const Float_t kBl2OCTF = 0.;
+  const Float_t kTl2OCTF = 3.66/2.;
+  const Float_t kAlp2OCTF = 44.67;  
   
 // VertEarthFaceCu parameters - single trapezoid
-  Float_t hzVFC = hzVertEarthFaceCu;
-  Float_t tetVFC = 0.;
-  Float_t phiVFC = 0.;
-  Float_t h1VFC = 1.200/2.;
-  Float_t bl1VFC = 46.11/2.;
-  Float_t tl1VFC = 48.236/2.;
-  Float_t alp1VFC = 41.54; 
-  Float_t h2VFC = 1.200/2.;
-  Float_t bl2VFC = 46.11/2.;
-  Float_t tl2VFC = 48.236/2.;
-  Float_t alp2VFC = 41.54;
+  const Float_t kHzVFC = kHzVertEarthFaceCu;
+  const Float_t kTetVFC = 0.;
+  const Float_t kPhiVFC = 0.;
+  const Float_t kH1VFC = 1.200/2.;
+  const Float_t kBl1VFC = 46.11/2.;
+  const Float_t kTl1VFC = 48.236/2.;
+  const Float_t kAlp1VFC = 41.54; 
+  const Float_t kH2VFC = 1.200/2.;
+  const Float_t kBl2VFC = 46.11/2.;
+  const Float_t kTl2VFC = 48.236/2.;
+  const Float_t kAlp2VFC = 41.54;
     
 // VertEarthSteel parameters - single trapezoid
-  Float_t hzVES = hzVertBarSteel;
-  Float_t tetVES = 0.;
-  Float_t phiVES = 0.;
-  Float_t h1VES = 1.200/2.;
-  Float_t bl1VES = 30.486/2.;
-  Float_t tl1VES = 32.777/2.;
-  Float_t alp1VES = 43.67; 
-  Float_t h2VES = 1.200/2.;
-  Float_t bl2VES = 30.486/2.;
-  Float_t tl2VES = 32.777/2.;
-  Float_t alp2VES = 43.67;
+  const Float_t kHzVES = kHzVertBarSteel;
+  const Float_t kTetVES = 0.;
+  const Float_t kPhiVES = 0.;
+  const Float_t kH1VES = 1.200/2.;
+  const Float_t kBl1VES = 30.486/2.;
+  const Float_t kTl1VES = 32.777/2.;
+  const Float_t kAlp1VES = 43.67; 
+  const Float_t kH2VES = 1.200/2.;
+  const Float_t kBl2VES = 30.486/2.;
+  const Float_t kTl2VES = 32.777/2.;
+  const Float_t kAlp2VES = 43.67;
 
 // VertEarthProfCu parameters - single trapezoid
-  Float_t hzVPC = hzVertEarthProfCu;
-  Float_t tetVPC = 0.;
-  Float_t phiVPC = 0.;
-  Float_t h1VPC = 0.400/2.;
-  Float_t bl1VPC = 29.287/2.;
-  Float_t tl1VPC = 30.091/2.;
-  Float_t alp1VPC = 45.14; 
-  Float_t h2VPC = 0.400/2.;
-  Float_t bl2VPC = 29.287/2.;
-  Float_t tl2VPC = 30.091/2.;
-  Float_t alp2VPC = 45.14;
+  const Float_t kHzVPC = kHzVertEarthProfCu;
+  const Float_t kTetVPC = 0.;
+  const Float_t kPhiVPC = 0.;
+  const Float_t kH1VPC = 0.400/2.;
+  const Float_t kBl1VPC = 29.287/2.;
+  const Float_t kTl1VPC = 30.091/2.;
+  const Float_t kAlp1VPC = 45.14; 
+  const Float_t kH2VPC = 0.400/2.;
+  const Float_t kBl2VPC = 29.287/2.;
+  const Float_t kTl2VPC = 30.091/2.;
+  const Float_t kAlp2VPC = 45.14;
 
 // SuppLateralPositionner - single cuboid
-  Float_t hxSLP  = 2.80/2.;
-  Float_t hySLP  = 5.00/2.;
-  Float_t hzSLP  = hzLateralPosnAl;
+  const Float_t kHxSLP  = 2.80/2.;
+  const Float_t kHySLP  = 5.00/2.;
+  const Float_t kHzSLP  = kHzLateralPosnAl;
   
 // LateralPositionner - squared off U bend, face view
-  Float_t hxLPF  = 5.2/2.;
-  Float_t hyLPF  = 3.0/2.;
-  Float_t hzLPF  = hzLateralPosnInoxFace;
+  const Float_t kHxLPF  = 5.2/2.;
+  const Float_t kHyLPF  = 3.0/2.;
+  const Float_t kHzLPF  = kHzLateralPosnInoxFace;
   
 // LateralPositionner - squared off U bend, profile view
-  Float_t hxLPP  = 0.425/2.;
-  Float_t hyLPP  = 3.0/2.;
-  Float_t hzLPP  = hzLatPosInoxProfM;  // middle layer
-  Float_t hzLPNF  = hzLatPosInoxProfNF; // near and far layers
+  const Float_t kHxLPP  = 0.425/2.;
+  const Float_t kHyLPP  = 3.0/2.;
+  const Float_t kHzLPP  = kHzLatPosInoxProfM;  // middle layer
+  const Float_t kHzLPNF  = kHzLatPosInoxProfNF; // near and far layers
            
 // VertCradle, 3 layers (copies), each composed of 4 trapezoids
 // VertCradleA
-  Float_t hzVC1 = hzVerticalCradleAl;
-  Float_t tetVC1 = 0.;
-  Float_t phiVC1 = 0.;
-  Float_t h1VC1 = 10.25/2.;
-  Float_t bl1VC1 = 3.70/2.;
-  Float_t tl1VC1 = 0.;
-  Float_t alp1VC1 = -10.23; 
-  Float_t h2VC1 = 10.25/2.;
-  Float_t bl2VC1 = 3.70/2.;
-  Float_t tl2VC1 = 0.;
-  Float_t alp2VC1 = -10.23;
+  const Float_t kHzVC1 = kHzVerticalCradleAl;
+  const Float_t kTetVC1 = 0.;
+  const Float_t kPhiVC1 = 0.;
+  const Float_t kH1VC1 = 10.25/2.;
+  const Float_t kBl1VC1 = 3.70/2.;
+  const Float_t kTl1VC1 = 0.;
+  const Float_t kAlp1VC1 = -10.23; 
+  const Float_t kH2VC1 = 10.25/2.;
+  const Float_t kBl2VC1 = 3.70/2.;
+  const Float_t kTl2VC1 = 0.;
+  const Float_t kAlp2VC1 = -10.23;
         
 // VertCradleB
-  Float_t hzVC2 = hzVerticalCradleAl;
-  Float_t tetVC2 = 0.;
-  Float_t phiVC2 = 0.;
-  Float_t h1VC2 = 10.25/2.;
-  Float_t bl1VC2 = 6.266/2.;
-  Float_t tl1VC2 = 3.70/2.;
-  Float_t alp1VC2 = -7.13; 
-  Float_t h2VC2 = 10.25/2.;
-  Float_t bl2VC2 = 6.266/2.;
-  Float_t tl2VC2 = 3.70/2.;
-  Float_t alp2VC2 = -7.13;
+  const Float_t kHzVC2 = kHzVerticalCradleAl;
+  const Float_t kTetVC2 = 0.;
+  const Float_t kPhiVC2 = 0.;
+  const Float_t kH1VC2 = 10.25/2.;
+  const Float_t kBl1VC2 = 6.266/2.;
+  const Float_t kTl1VC2 = 3.70/2.;
+  const Float_t kAlp1VC2 = -7.13; 
+  const Float_t kH2VC2 = 10.25/2.;
+  const Float_t kBl2VC2 = 6.266/2.;
+  const Float_t kTl2VC2 = 3.70/2.;
+  const Float_t kAlp2VC2 = -7.13;
   
 // VertCradleC
-  Float_t hzVC3 = hzVerticalCradleAl;
-  Float_t tetVC3 = 0.;
-  Float_t phiVC3 = 0.;
-  Float_t h1VC3 = 10.25/2.;
-  Float_t bl1VC3 = 7.75/2.;
-  Float_t tl1VC3 = 6.266/2.;
-  Float_t alp1VC3 = -4.14; 
-  Float_t h2VC3 = 10.25/2.;
-  Float_t bl2VC3 = 7.75/2.;
-  Float_t tl2VC3 = 6.266/2.;
-  Float_t alp2VC3 = -4.14;
+  const Float_t kHzVC3 = kHzVerticalCradleAl;
+  const Float_t kTetVC3 = 0.;
+  const Float_t kPhiVC3 = 0.;
+  const Float_t kH1VC3 = 10.25/2.;
+  const Float_t kBl1VC3 = 7.75/2.;
+  const Float_t kTl1VC3 = 6.266/2.;
+  const Float_t kAlp1VC3 = -4.14; 
+  const Float_t kH2VC3 = 10.25/2.;
+  const Float_t kBl2VC3 = 7.75/2.;
+  const Float_t kTl2VC3 = 6.266/2.;
+  const Float_t kAlp2VC3 = -4.14;
 
 // VertCradleD
-  Float_t hzVC4 = hzVerticalCradleAl;
-  Float_t tetVC4 = 0.;
-  Float_t phiVC4 = 0.;
-  Float_t h1VC4 = 10.27/2.;
-  Float_t bl1VC4 = 8.273/2.;
-  Float_t tl1VC4 = 7.75/2.;
-  Float_t alp1VC4 = -1.46; 
-  Float_t h2VC4 = 10.27/2.;
-  Float_t bl2VC4 = 8.273/2.;
-  Float_t tl2VC4 = 7.75/2.;
-  Float_t alp2VC4 = -1.46;
+  const Float_t kHzVC4 = kHzVerticalCradleAl;
+  const Float_t kTetVC4 = 0.;
+  const Float_t kPhiVC4 = 0.;
+  const Float_t kH1VC4 = 10.27/2.;
+  const Float_t kBl1VC4 = 8.273/2.;
+  const Float_t kTl1VC4 = 7.75/2.;
+  const Float_t kAlp1VC4 = -1.46; 
+  const Float_t kH2VC4 = 10.27/2.;
+  const Float_t kBl2VC4 = 8.273/2.;
+  const Float_t kTl2VC4 = 7.75/2.;
+  const Float_t kAlp2VC4 = -1.46;
   
 // LateralSightSupport - single trapezoid
-  Float_t hzVSS = hzLateralSightAl;
-  Float_t tetVSS = 0.;
-  Float_t phiVSS = 0.;
-  Float_t h1VSS = 5.00/2.;
-  Float_t bl1VSS = 7.747/2;
-  Float_t tl1VSS = 7.188/2.;
-  Float_t alp1VSS = -3.20; 
-  Float_t h2VSS = 5.00/2.;
-  Float_t bl2VSS = 7.747/2.;
-  Float_t tl2VSS = 7.188/2.;
-  Float_t alp2VSS = -3.20;  
+  const Float_t kHzVSS = kHzLateralSightAl;
+  const Float_t kTetVSS = 0.;
+  const Float_t kPhiVSS = 0.;
+  const Float_t kH1VSS = 5.00/2.;
+  const Float_t kBl1VSS = 7.747/2;
+  const Float_t kTl1VSS = 7.188/2.;
+  const Float_t kAlp1VSS = -3.20; 
+  const Float_t kH2VSS = 5.00/2.;
+  const Float_t kBl2VSS = 7.747/2.;
+  const Float_t kTl2VSS = 7.188/2.;
+  const Float_t kAlp2VSS = -3.20;  
   
 // LateralSight (reference point) - 3 per quadrant, only 1 programmed for now
-  Float_t vSInRad  = 0.6;
-  Float_t vSOutRad  = 1.3;
-  Float_t vSLen  = hzFrameThickness; 
+  const Float_t kVSInRad  = 0.6;
+  const Float_t kVSOutRad  = 1.3;
+  const Float_t kVSLen  = kHzFrameThickness; 
   
 //---
 
 // InHFrame parameters
-  Float_t hxInHFrame  = 75.8/2.;
-  Float_t hyInHFrame  = 1.85/2.;
-  Float_t hzInHFrame  = hzFrameThickness;
+  const Float_t kHxInHFrame  = 75.8/2.;
+  const Float_t kHyInHFrame  = 1.85/2.;
+  const Float_t kHzInHFrame  = kHzFrameThickness;
  
 //Flat 7.5mm horizontal section
-  Float_t hxH1mm  = 1.85/2.;
-  Float_t hyH1mm  = 0.75/2.;
-  Float_t hzH1mm  = hzFrameThickness;
+  const Float_t kHxH1mm  = 1.85/2.;
+  const Float_t kHyH1mm  = 0.75/2.;
+  const Float_t kHzH1mm  = kHzFrameThickness;
 
 //---
 
 // InArcFrame parameters
-  Float_t iAF  = 15.70;
-  Float_t oAF  = 17.55;
-  Float_t hzAF  = hzFrameThickness;
-  Float_t aFphi1  = 0.0;
-  Float_t aFphi2  = 90.0;
+  const Float_t kIAF  = 15.70;
+  const Float_t kOAF  = 17.55;
+  const Float_t kHzAF  = kHzFrameThickness;
+  const Float_t kAFphi1  = 0.0;
+  const Float_t kAFphi2  = 90.0;
 
 //---
 
 // ScrewsInFrame parameters HEAD
-  Float_t sCRUHMI  = 0.;
-  Float_t sCRUHMA  = 0.690/2.;
-  Float_t sCRUHLE  = 0.4/2.;
+  const Float_t kSCRUHMI  = 0.;
+  const Float_t kSCRUHMA  = 0.690/2.;
+  const Float_t kSCRUHLE  = 0.4/2.;
 // ScrewsInFrame parameters MIDDLE
-  Float_t sCRUMMI  = 0.;
-  Float_t sCRUMMA  = 0.39/2.;
-  Float_t sCRUMLE  = hzFrameThickness;
+  const Float_t kSCRUMMI  = 0.;
+  const Float_t kSCRUMMA  = 0.39/2.;
+  const Float_t kSCRUMLE  = kHzFrameThickness;
 // ScrewsInFrame parameters NUT
-  Float_t sCRUNMI  = 0.;
-  Float_t sCRUNMA  = 0.78/2.;
-  Float_t sCRUNLE  = 0.8/2.;   
+  const Float_t kSCRUNMI  = 0.;
+  const Float_t kSCRUNMA  = 0.78/2.;
+  const Float_t kSCRUNLE  = 0.8/2.;   
   
        // ___________________Make volumes________________________
 
@@ -1063,15 +1106,15 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 
    if (chamber==1) {   
     // InVFrame  
-    par[0] = hxInVFrame;
-    par[1] = hyInVFrame;
-    par[2] = hzInVFrame;
+    par[0] = kHxInVFrame;
+    par[1] = kHyInVFrame;
+    par[2] = kHzInVFrame;
     gMC->Gsvolu("SQ00","BOX",idFrameEpoxy,par,3);
 
     //Flat 1mm vertical section
-    par[0] = hxV1mm;
-    par[1] = hyV1mm;
-    par[2] = hzV1mm;
+    par[0] = kHxV1mm;
+    par[1] = kHyV1mm;
+    par[2] = kHzV1mm;
     gMC->Gsvolu("SQ01","BOX",idFrameEpoxy,par,3); 
  
 // OutTopFrame 
@@ -1081,139 +1124,139 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //---
 
     // TopFrameAnode - layer 1 of 2 
-    par[0] = hxTFA;
-    par[1] = hyTFA;
-    par[2] = hzTFAE;
+    par[0] = kHxTFA;
+    par[1] = kHyTFA;
+    par[2] = kHzTFAE;
     gMC->Gsvolu("SQ02","BOX",idFrameEpoxy,par,3);
     
     // TopFrameAnode - layer 2 of 2 
-    par[2] = hzTFAI;
+    par[2] = kHzTFAI;
     gMC->Gsvolu("SQ03","BOX",idInox,par,3);
             
     // TopFrameAnodeA - layer 1 of 2  
-    par[0] = hzFAAE;
-    par[1] = tetFAA;
-    par[2] = phiFAA;
-    par[3] = h1FAA;
-    par[4] = bl1FAA;
-    par[5] = tl1FAA;
-    par[6] = alp1FAA;
-    par[7] = h2FAA;
-    par[8] = bl2FAA;
-    par[9] = tl2FAA;
-    par[10] = alp2FAA;    
+    par[0] = kHzFAAE;
+    par[1] = kTetFAA;
+    par[2] = kPhiFAA;
+    par[3] = kH1FAA;
+    par[4] = kBl1FAA;
+    par[5] = kTl1FAA;
+    par[6] = kAlp1FAA;
+    par[7] = kH2FAA;
+    par[8] = kBl2FAA;
+    par[9] = kTl2FAA;
+    par[10] = kAlp2FAA;    
     gMC->Gsvolu("SQ04","TRAP",idFrameEpoxy,par,11);    
 
     // TopFrameAnodeA - layer 2 of 2
-    par[0] = hzFAAI;    
+    par[0] = kHzFAAI;    
     gMC->Gsvolu("SQ05","TRAP",idInox,par,11); 
       
     // TopFrameAnodeB - layer 1 of 2
-    par[0] = hzFABE;
-    par[1] = tetFAB;
-    par[2] = phiFAB;
-    par[3] = h1FAB;
-    par[4] = bl1FAB;
-    par[5] = tl1FAB;
-    par[6] = alp1FAB;
-    par[7] = h2FAB;
-    par[8] = bl2FAB;
-    par[9] = tl2FAB;
-    par[10] = alp2FAB;
+    par[0] = kHzFABE;
+    par[1] = kTetFAB;
+    par[2] = kPhiFAB;
+    par[3] = kH1FAB;
+    par[4] = kBl1FAB;
+    par[5] = kTl1FAB;
+    par[6] = kAlp1FAB;
+    par[7] = kH2FAB;
+    par[8] = kBl2FAB;
+    par[9] = kTl2FAB;
+    par[10] = kAlp2FAB;
     gMC->Gsvolu("SQ06","TRAP",idFrameEpoxy,par,11);     
 
     // OutTopTrapFrameB - layer 2 of 2
-    par[0] = hzFABI;   
+    par[0] = kHzFABI;   
     gMC->Gsvolu("SQ07","TRAP",idInox,par,11);
 
     // TopAnode1 -  layer 1 of 2
-    par[0] = hxTA1;
-    par[1] = hyTA1;
-    par[2] = hzTA11;    
+    par[0] = kHxTA1;
+    par[1] = kHyTA1;
+    par[2] = kHzTA11;    
     gMC->Gsvolu("SQ08","BOX",idInox,par,3); 
     
     // TopAnode1 -  layer 2 of 2
-    par[2] = hzTA12;    
+    par[2] = kHzTA12;    
     gMC->Gsvolu("SQ09","BOX",idFR4,par,11); 
 
     // TopAnode2 -  layer 1 of 2
-    par[0] = hzTA21;
-    par[1] = tetTA2;
-    par[2] = phiTA2;
-    par[3] = h1TA2;
-    par[4] = bl1TA2;
-    par[5] = tl1TA2;
-    par[6] = alp1TA2;
-    par[7] = h2TA2;
-    par[8] = bl2TA2;
-    par[9] = tl2TA2;
-    par[10] = alp2TA2;    
+    par[0] = kHzTA21;
+    par[1] = kTetTA2;
+    par[2] = kPhiTA2;
+    par[3] = kH1TA2;
+    par[4] = kBl1TA2;
+    par[5] = kTl1TA2;
+    par[6] = kAlp1TA2;
+    par[7] = kH2TA2;
+    par[8] = kBl2TA2;
+    par[9] = kTl2TA2;
+    par[10] = kAlp2TA2;    
     gMC->Gsvolu("SQ10","TRAP",idInox,par,11); 
  
     // TopAnode2 -  layer 2 of 2
-    par[0] = hzTA22;    
+    par[0] = kHzTA22;    
     gMC->Gsvolu("SQ11","TRAP",idFR4,par,11);   
 
     // TopAnode3 -  layer 1 of 1 
-    par[0] = hzTA3;
-    par[1] = tetTA3;
-    par[2] = phiTA3;
-    par[3] = h1TA3;
-    par[4] = bl1TA3;
-    par[5] = tl1TA3;
-    par[6] = alp1TA3;
-    par[7] = h2TA3;
-    par[8] = bl2TA3;
-    par[9] = tl2TA3;
-    par[10] = alp2TA3;    
+    par[0] = kHzTA3;
+    par[1] = kTetTA3;
+    par[2] = kPhiTA3;
+    par[3] = kH1TA3;
+    par[4] = kBl1TA3;
+    par[5] = kTl1TA3;
+    par[6] = kAlp1TA3;
+    par[7] = kH2TA3;
+    par[8] = kBl2TA3;
+    par[9] = kTl2TA3;
+    par[10] = kAlp2TA3;    
     gMC->Gsvolu("SQ12","TRAP",idFR4,par,11); 
 
     // TopEarthFace 
-    par[0] = hzTEF;
-    par[1] = tetTEF;
-    par[2] = phiTEF;
-    par[3] = h1TEF;
-    par[4] = bl1TEF;
-    par[5] = tl1TEF;
-    par[6] = alp1TEF;
-    par[7] = h2TEF;
-    par[8] = bl2TEF;
-    par[9] = tl2TEF;
-    par[10] = alp2TEF;    
+    par[0] = kHzTEF;
+    par[1] = kTetTEF;
+    par[2] = kPhiTEF;
+    par[3] = kH1TEF;
+    par[4] = kBl1TEF;
+    par[5] = kTl1TEF;
+    par[6] = kAlp1TEF;
+    par[7] = kH2TEF;
+    par[8] = kBl2TEF;
+    par[9] = kTl2TEF;
+    par[10] = kAlp2TEF;    
     gMC->Gsvolu("SQ13","TRAP",idCopper,par,11);   
 
     // TopEarthProfile 
-    par[0] = hzTEP;
-    par[1] = tetTEP;
-    par[2] = phiTEP;
-    par[3] = h1TEP;
-    par[4] = bl1TEP;
-    par[5] = tl1TEP;
-    par[6] = alp1TEP;
-    par[7] = h2TEP;
-    par[8] = bl2TEP;
-    par[9] = tl2TEP;
-    par[10] = alp2TEP;
+    par[0] = kHzTEP;
+    par[1] = kTetTEP;
+    par[2] = kPhiTEP;
+    par[3] = kH1TEP;
+    par[4] = kBl1TEP;
+    par[5] = kTl1TEP;
+    par[6] = kAlp1TEP;
+    par[7] = kH2TEP;
+    par[8] = kBl2TEP;
+    par[9] = kTl2TEP;
+    par[10] = kAlp2TEP;
     gMC->Gsvolu("SQ14","TRAP",idCopper,par,11);       
 
     // TopGasSupport  
-    par[0] = hxTGS;
-    par[1] = hyTGS;
-    par[2] = hzTGS;
+    par[0] = kHxTGS;
+    par[1] = kHyTGS;
+    par[2] = kHzTGS;
     gMC->Gsvolu("SQ15","BOX",idAlu,par,3);
 
     // TopPositioner parameters - single Stainless Steel trapezoid 
-    par[0] = hzTP;
-    par[1] = tetTP; 
-    par[2] = phiTP;
-    par[3] = h1TP;
-    par[4] = bl1TP; 
-    par[5] = tl1TP; 
-    par[6] = alp1TP;
-    par[7] = h2TP;
-    par[8] = bl2TP; 
-    par[9] = tl2TP; 
-    par[10] = alp2TP;     
+    par[0] = kHzTP;
+    par[1] = kTetTP; 
+    par[2] = kPhiTP;
+    par[3] = kH1TP;
+    par[4] = kBl1TP; 
+    par[5] = kTl1TP; 
+    par[6] = kAlp1TP;
+    par[7] = kH2TP;
+    par[8] = kBl2TP; 
+    par[9] = kTl2TP; 
+    par[10] = kAlp2TP;     
     gMC->Gsvolu("SQ16","TRAP",idInox,par,11);       
 
 //
@@ -1221,323 +1264,328 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //
 //---
     // Trapezoid 1 - 2 layers
-    par[1] = tetOETF;
-    par[2] = phiOETF;
-    par[3] = h1OETF;
-    par[4] = bl1OETF1;
-    par[5] = tl1OETF1;
-    par[6] = alp1OETF1;
-    par[7] = h2OETF;
-    par[8] = bl2OETF1;
-    par[9] = tl2OETF1;
-    par[10] = alp2OETF1; 
+    par[1] = kTetOETF;
+    par[2] = kPhiOETF;
+    par[3] = kH1OETF;
+    par[4] = kBl1OETF1;
+    par[5] = kTl1OETF1;
+    par[6] = kAlp1OETF1;
+    par[7] = kH2OETF;
+    par[8] = kBl2OETF1;
+    par[9] = kTl2OETF1;
+    par[10] = kAlp2OETF1; 
            
-    par[0] = hzOETFE;             
+    par[0] = kHzOETFE;             
     gMC->Gsvolu("SQ17","TRAP",idFrameEpoxy,par,11); 
-    par[0] = hzOETFI;
+    par[0] = kHzOETFI;
     gMC->Gsvolu("SQ18","TRAP",idInox,par,11);
     
     // Trapezoid 2 - 2 layers
-    par[4] = bl1OETF2;
-    par[5] = tl1OETF2;
-    par[6] = alp1OETF2;
+    par[4] = kBl1OETF2;
+    par[5] = kTl1OETF2;
+    par[6] = kAlp1OETF2;
 
-    par[8] = bl2OETF2;
-    par[9] = tl2OETF2;
-    par[10] = alp2OETF2; 
+    par[8] = kBl2OETF2;
+    par[9] = kTl2OETF2;
+    par[10] = kAlp2OETF2; 
     
-    par[0] = hzOETFE;    
+    par[0] = kHzOETFE;    
     gMC->Gsvolu("SQ19","TRAP",idFrameEpoxy,par,11);    
-    par[0] = hzOETFI;    
+    par[0] = kHzOETFI;    
     gMC->Gsvolu("SQ20","TRAP",idInox,par,11);     
     
     // Trapezoid 3 - 2 layers
-    par[4] = bl1OETF3;
-    par[5] = tl1OETF3;
-    par[6] = alp1OETF3;
+    par[4] = kBl1OETF3;
+    par[5] = kTl1OETF3;
+    par[6] = kAlp1OETF3;
 
-    par[8] = bl2OETF3;
-    par[9] = tl2OETF3;
-    par[10] = alp2OETF3; 
+    par[8] = kBl2OETF3;
+    par[9] = kTl2OETF3;
+    par[10] = kAlp2OETF3; 
  
-    par[0] = hzOETFE;    
+    par[0] = kHzOETFE;    
     gMC->Gsvolu("SQ21","TRAP",idFrameEpoxy,par,11);   
-    par[0] = hzOETFI;    
+    par[0] = kHzOETFI;    
     gMC->Gsvolu("SQ22","TRAP",idInox,par,11);     
     
     // Trapezoid 4 - 2 layers
 
-    par[4] = bl1OETF4;
-    par[5] = tl1OETF4;
-    par[6] = alp1OETF4;
+    par[4] = kBl1OETF4;
+    par[5] = kTl1OETF4;
+    par[6] = kAlp1OETF4;
 
-    par[8] = bl2OETF4;
-    par[9] = tl2OETF4;
-    par[10] = alp2OETF4;  
+    par[8] = kBl2OETF4;
+    par[9] = kTl2OETF4;
+    par[10] = kAlp2OETF4;  
    
-    par[0] = hzOETFE;    
+    par[0] = kHzOETFE;    
     gMC->Gsvolu("SQ23","TRAP",idFrameEpoxy,par,11);    
-    par[0] = hzOETFI;    
+    par[0] = kHzOETFI;    
     gMC->Gsvolu("SQ24","TRAP",idInox,par,11);     
              
 //---
     // OutVFrame    
-    par[0] = hxOutVFrame;
-    par[1] = hyOutVFrame;
-    par[2] = hzOutVFrame;
+    par[0] = kHxOutVFrame;
+    par[1] = kHyOutVFrame;
+    par[2] = kHzOutVFrame;
     gMC->Gsvolu("SQ25","BOX",idFrameEpoxy,par,3);
-    
+        
     // OutVFrame corner  
-    par[0] = hzOCTF;
-    par[1] = tetOCTF;
-    par[2] = phiOCTF;
-    par[3] = h1OCTF;
-    par[4] = bl1OCTF;
-    par[5] = tl1OCTF;
-    par[6] = alp1OCTF;
-    par[7] = h2OCTF;
-    par[8] = bl2OCTF;
-    par[9] = tl2OCTF;
-    par[10] = alp2OCTF;    
+    par[0] = kHzOCTF;
+    par[1] = kTetOCTF;
+    par[2] = kPhiOCTF;
+    par[3] = kH1OCTF;
+    par[4] = kBl1OCTF;
+    par[5] = kTl1OCTF;
+    par[6] = kAlp1OCTF;
+    par[7] = kH2OCTF;
+    par[8] = kBl2OCTF;
+    par[9] = kTl2OCTF;
+    par[10] = kAlp2OCTF;    
     gMC->Gsvolu("SQ26","TRAP",idFrameEpoxy,par,11);
  
     // EarthFaceCu trapezoid
-    par[0] = hzVFC;
-    par[1] = tetVFC;
-    par[2] = phiVFC;
-    par[3] = h1VFC;
-    par[4] = bl1VFC;
-    par[5] = tl1VFC;
-    par[6] = alp1VFC;
-    par[7] = h2VFC;
-    par[8] = bl2VFC;
-    par[9] = tl2VFC;
-    par[10] = alp2VFC;   
+    par[0] = kHzVFC;
+    par[1] = kTetVFC;
+    par[2] = kPhiVFC;
+    par[3] = kH1VFC;
+    par[4] = kBl1VFC;
+    par[5] = kTl1VFC;
+    par[6] = kAlp1VFC;
+    par[7] = kH2VFC;
+    par[8] = kBl2VFC;
+    par[9] = kTl2VFC;
+    par[10] = kAlp2VFC;   
     gMC->Gsvolu("SQ27","TRAP",idCopper,par,11);     
 
     // VertEarthSteel trapezoid
-    par[0] = hzVES;
-    par[1] = tetVES;
-    par[2] = phiVES;
-    par[3] = h1VES;
-    par[4] = bl1VES;
-    par[5] = tl1VES;
-    par[6] = alp1VES;
-    par[7] = h2VES;
-    par[8] = bl2VES;
-    par[9] = tl2VES;
-    par[10] = alp2VES;    
+    par[0] = kHzVES;
+    par[1] = kTetVES;
+    par[2] = kPhiVES;
+    par[3] = kH1VES;
+    par[4] = kBl1VES;
+    par[5] = kTl1VES;
+    par[6] = kAlp1VES;
+    par[7] = kH2VES;
+    par[8] = kBl2VES;
+    par[9] = kTl2VES;
+    par[10] = kAlp2VES;    
     gMC->Gsvolu("SQ28","TRAP",idInox,par,11); 
 
     // VertEarthProfCu trapezoid       
-    par[0] = hzVPC;
-    par[1] = tetVPC;
-    par[2] = phiVPC;
-    par[3] = h1VPC;
-    par[4] = bl1VPC;
-    par[5] = tl1VPC;
-    par[6] = alp1VPC;
-    par[7] = h2VPC;
-    par[8] = bl2VPC;
-    par[9] = tl2VPC;
-    par[10] = alp2VPC;
+    par[0] = kHzVPC;
+    par[1] = kTetVPC;
+    par[2] = kPhiVPC;
+    par[3] = kH1VPC;
+    par[4] = kBl1VPC;
+    par[5] = kTl1VPC;
+    par[6] = kAlp1VPC;
+    par[7] = kH2VPC;
+    par[8] = kBl2VPC;
+    par[9] = kTl2VPC;
+    par[10] = kAlp2VPC;
     gMC->Gsvolu("SQ29","TRAP",idCopper,par,11);
 
     // SuppLateralPositionner cuboid    
-    par[0] = hxSLP;
-    par[1] = hySLP;
-    par[2] = hzSLP;
+    par[0] = kHxSLP;
+    par[1] = kHySLP;
+    par[2] = kHzSLP;
     gMC->Gsvolu("SQ30","BOX",idAlu,par,3);
 
     // LateralPositionerFace
-    par[0] = hxLPF;
-    par[1] = hyLPF;
-    par[2] = hzLPF;
+    par[0] = kHxLPF;
+    par[1] = kHyLPF;
+    par[2] = kHzLPF;
     gMC->Gsvolu("SQ31","BOX",idInox,par,3);
 
     // LateralPositionerProfile
-    par[0] = hxLPP;
-    par[1] = hyLPP;
-    par[2] = hzLPP;
+    par[0] = kHxLPP;
+    par[1] = kHyLPP;
+    par[2] = kHzLPP;
     gMC->Gsvolu("SQ32","BOX",idInox,par,3); // middle layer
     
-    par[0] = hxLPP;
-    par[1] = hyLPP;
-    par[2] = hzLPNF;
+    par[0] = kHxLPP;
+    par[1] = kHyLPP;
+    par[2] = kHzLPNF;
     gMC->Gsvolu("SQ33","BOX",idInox,par,3); // near and far layers
 
     // VertCradleA - 1st trapezoid
-    par[0] = hzVC1;
-    par[1] = tetVC1;
-    par[2] = phiVC1;
-    par[3] = h1VC1;
-    par[4] = bl1VC1;
-    par[5] = tl1VC1;
-    par[6] = alp1VC1;
-    par[7] = h2VC1;
-    par[8] = bl2VC1;
-    par[9] = tl2VC1;
-    par[10] = alp2VC1;
+    par[0] = kHzVC1;
+    par[1] = kTetVC1;
+    par[2] = kPhiVC1;
+    par[3] = kH1VC1;
+    par[4] = kBl1VC1;
+    par[5] = kTl1VC1;
+    par[6] = kAlp1VC1;
+    par[7] = kH2VC1;
+    par[8] = kBl2VC1;
+    par[9] = kTl2VC1;
+    par[10] = kAlp2VC1;
     gMC->Gsvolu("SQ34","TRAP",idAlu,par,11); 
     
     // VertCradleB - 2nd trapezoid
-    par[0] = hzVC2;
-    par[1] = tetVC2;
-    par[2] = phiVC2;
-    par[3] = h1VC2;
-    par[4] = bl1VC2;
-    par[5] = tl1VC2;
-    par[6] = alp1VC2;
-    par[7] = h2VC2;
-    par[8] = bl2VC2;
-    par[9] = tl2VC2;
-    par[10] = alp2VC2;
+    par[0] = kHzVC2;
+    par[1] = kTetVC2;
+    par[2] = kPhiVC2;
+    par[3] = kH1VC2;
+    par[4] = kBl1VC2;
+    par[5] = kTl1VC2;
+    par[6] = kAlp1VC2;
+    par[7] = kH2VC2;
+    par[8] = kBl2VC2;
+    par[9] = kTl2VC2;
+    par[10] = kAlp2VC2;
     gMC->Gsvolu("SQ35","TRAP",idAlu,par,11);  
        
     // VertCradleC - 3rd trapezoid
-    par[0] = hzVC3;
-    par[1] = tetVC3;
-    par[2] = phiVC3;
-    par[3] = h1VC3;
-    par[4] = bl1VC3;
-    par[5] = tl1VC3;
-    par[6] = alp1VC3;
-    par[7] = h2VC3;
-    par[8] = bl2VC3;
-    par[9] = tl2VC3;
-    par[10] = alp2VC3;    
+    par[0] = kHzVC3;
+    par[1] = kTetVC3;
+    par[2] = kPhiVC3;
+    par[3] = kH1VC3;
+    par[4] = kBl1VC3;
+    par[5] = kTl1VC3;
+    par[6] = kAlp1VC3;
+    par[7] = kH2VC3;
+    par[8] = kBl2VC3;
+    par[9] = kTl2VC3;
+    par[10] = kAlp2VC3;    
     gMC->Gsvolu("SQ36","TRAP",idAlu,par,11);  
 
     // VertCradleD - 4th trapezoid
-    par[0] = hzVC4;
-    par[1] = tetVC4;
-    par[2] = phiVC4;
-    par[3] = h1VC4;
-    par[4] = bl1VC4;
-    par[5] = tl1VC4;
-    par[6] = alp1VC4;
-    par[7] = h2VC4;
-    par[8] = bl2VC4;
-    par[9] = tl2VC4;
-    par[10] = alp2VC4;    
+    par[0] = kHzVC4;
+    par[1] = kTetVC4;
+    par[2] = kPhiVC4;
+    par[3] = kH1VC4;
+    par[4] = kBl1VC4;
+    par[5] = kTl1VC4;
+    par[6] = kAlp1VC4;
+    par[7] = kH2VC4;
+    par[8] = kBl2VC4;
+    par[9] = kTl2VC4;
+    par[10] = kAlp2VC4;    
     gMC->Gsvolu("SQ37","TRAP",idAlu,par,11);  
           
     // LateralSightSupport trapezoid
-    par[0] = hzVSS;
-    par[1] = tetVSS;
-    par[2] = phiVSS;
-    par[3] = h1VSS;
-    par[4] = bl1VSS;
-    par[5] = tl1VSS;
-    par[6] = alp1VSS;
-    par[7] = h2VSS;
-    par[8] = bl2VSS;
-    par[9] = tl2VSS;
-    par[10] = alp2VSS;
+    par[0] = kHzVSS;
+    par[1] = kTetVSS;
+    par[2] = kPhiVSS;
+    par[3] = kH1VSS;
+    par[4] = kBl1VSS;
+    par[5] = kTl1VSS;
+    par[6] = kAlp1VSS;
+    par[7] = kH2VSS;
+    par[8] = kBl2VSS;
+    par[9] = kTl2VSS;
+    par[10] = kAlp2VSS;
     gMC->Gsvolu("SQ38","TRAP",idAlu,par,11);
 
     // LateralSight
-    par[0] = vSInRad;
-    par[1] = vSOutRad;
-    par[2] = vSLen;       
+    par[0] = kVSInRad;
+    par[1] = kVSOutRad;
+    par[2] = kVSLen;       
     gMC->Gsvolu("SQ39","TUBE",idFrameEpoxy,par,3);   
 
 //---
     // InHFrame
-    par[0] = hxInHFrame;
-    par[1] = hyInHFrame;
-    par[2] = hzInHFrame;
+    par[0] = kHxInHFrame;
+    par[1] = kHyInHFrame;
+    par[2] = kHzInHFrame;
     gMC->Gsvolu("SQ40","BOX",idFrameEpoxy,par,3);
 
     //Flat 7.5mm horizontal section
-    par[0] = hxH1mm;
-    par[1] = hyH1mm;
-    par[2] = hzH1mm;
+    par[0] = kHxH1mm;
+    par[1] = kHyH1mm;
+    par[2] = kHzH1mm;
     gMC->Gsvolu("SQ41","BOX",idFrameEpoxy,par,3);
 
     // InArcFrame 
-    par[0] = iAF;
-    par[1] = oAF; 
-    par[2] = hzAF;  
-    par[3] = aFphi1; 
-    par[4] = aFphi2;
+    par[0] = kIAF;
+    par[1] = kOAF; 
+    par[2] = kHzAF;  
+    par[3] = kAFphi1; 
+    par[4] = kAFphi2;
 
     gMC->Gsvolu("SQ42","TUBS",idFrameEpoxy,par,5);
 
 //---
     // ScrewsInFrame - 3 sections in order to avoid overlapping volumes
     // Screw Head, in air
-    par[0] = sCRUHMI;
-    par[1] = sCRUHMA; 
-    par[2] = sCRUHLE;  
+    par[0] = kSCRUHMI;
+    par[1] = kSCRUHMA; 
+    par[2] = kSCRUHLE;  
 
     gMC->Gsvolu("SQ43","TUBE",idInox,par,3);
     
     // Middle part, in the Epoxy
-    par[0] = sCRUMMI;
-    par[1] = sCRUMMA;
-    par[2] = sCRUMLE;
+    par[0] = kSCRUMMI;
+    par[1] = kSCRUMMA;
+    par[2] = kSCRUMLE;
     gMC->Gsvolu("SQ44","TUBE",idInox,par,3);
     
     // Screw nut, in air
-    par[0] = sCRUNMI;
-    par[1] = sCRUNMA;
-    par[2] = sCRUNLE;   
+    par[0] = kSCRUNMI;
+    par[1] = kSCRUNMA;
+    par[2] = kSCRUNLE;   
     gMC->Gsvolu("SQ45","TUBE",idInox,par,3);     
    }
               
 // __________________Place volumes in the quadrant ____________ 
         
     // InVFrame  
-    posX = hxInVFrame;
-    posY = 2.0*hyInHFrame+2.*hyH1mm+iAF+hyInVFrame;        
+    posX = kHxInVFrame;
+    posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyInVFrame;        
     posZ = 0.;
     gMC->Gspos("SQ00",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
 
+// keep memory of the mid position. Used for placing screws
+    const GReal_t kMidVposX = posX;
+    const GReal_t kMidVposY = posY;
+    const GReal_t kMidVposZ = posZ;
+
     //Flat 7.5mm vertical section
-    posX = 2.0*hxInVFrame+hxV1mm;
-    posY = 2.0*hyInHFrame+2.*hyH1mm+iAF+hyV1mm;
+    posX = 2.0*kHxInVFrame+kHxV1mm;
+    posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyV1mm;
     posZ = 0.;
     gMC->Gspos("SQ01",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
     
     // TopFrameAnode place 2 layers of TopFrameAnode cuboids  
-    posX = hxTFA;
-    posY = 2.*hyInHFrame+2.*hyH1mm+iAF+2.*hyInVFrame+hyTFA;   
-    posZ = hzOuterFrameInox;
+    posX = kHxTFA;
+    posY = 2.*kHyInHFrame+2.*kHyH1mm+kIAF+2.*kHyInVFrame+kHyTFA;   
+    posZ = kHzOuterFrameInox;
     gMC->Gspos("SQ02",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY"); 
-    posZ = posZ+hzOuterFrameInox;
+    posZ = posZ+kHzOuterFrameInox;
     gMC->Gspos("SQ03",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY");
     
     // place 2 layers of TopFrameAnodeA trapezoids 
     posX = 35.8932+fgkDeltaQuadLHC;
     posY = 92.6745+fgkDeltaQuadLHC;
-    posZ = hzOuterFrameInox; 
+    posZ = kHzOuterFrameInox; 
     gMC->Gspos("SQ04",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
-    posZ = posZ+hzOuterFrameInox;
+    posZ = posZ+kHzOuterFrameInox;
     gMC->Gspos("SQ05",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
     
     // place 2 layers of TopFrameAnodeB trapezoids 
     posX = 44.593+fgkDeltaQuadLHC;
     posY = 90.737+fgkDeltaQuadLHC;
-    posZ = hzOuterFrameInox; 
+    posZ = kHzOuterFrameInox; 
     gMC->Gspos("SQ06",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
-    posZ = posZ+hzOuterFrameInox;
+    posZ = posZ+kHzOuterFrameInox;
     gMC->Gspos("SQ07",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");    
 
     // TopAnode1 place 2 layers  
     posX = 6.8+fgkDeltaQuadLHC;
     posY = 99.85+fgkDeltaQuadLHC;
-    posZ = -1.*hzAnodeFR4;
+    posZ = -1.*kHzAnodeFR4;
     gMC->Gspos("SQ08",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");  
-    posZ = posZ+hzTopAnodeSteel1;
+    posZ = posZ+kHzTopAnodeSteel1;
     gMC->Gspos("SQ09",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");    
          
     // TopAnode2 place 2 layers
     posX = 18.534+fgkDeltaQuadLHC;
     posY = 99.482+fgkDeltaQuadLHC; 
-    posZ = -1.*hzAnodeFR4;    
+    posZ = -1.*kHzAnodeFR4;    
     gMC->Gspos("SQ10",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
-    posZ = posZ+hzTopAnodeSteel2;    
+    posZ = posZ+kHzTopAnodeSteel2;    
     gMC->Gspos("SQ11",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");       
     
     // TopAnode3 place 1 layer
@@ -1549,7 +1597,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     // TopEarthFace - 2 copies
     posX = 23.122+fgkDeltaQuadLHC;
     posY = 96.90+fgkDeltaQuadLHC;
-    posZ = hzOuterFrameEpoxy+hzOuterFrameInox+hzTopEarthFaceCu;
+    posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopEarthFaceCu;
     gMC->Gspos("SQ13",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
     posZ = -1.*posZ;
     gMC->Gspos("SQ13",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
@@ -1557,7 +1605,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     // TopEarthProfile 
     posX = 14.475+fgkDeltaQuadLHC;
     posY = 97.900+fgkDeltaQuadLHC; 
-    posZ = hzTopEarthProfileCu;
+    posZ = kHzTopEarthProfileCu;
     gMC->Gspos("SQ14",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
     posZ = -1.0*posZ;
     gMC->Gspos("SQ14",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
@@ -1565,7 +1613,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     // TopGasSupport - 2 copies                            
     posX = 4.9500+fgkDeltaQuadLHC;
     posY = 96.200+fgkDeltaQuadLHC;
-    posZ = hzOuterFrameEpoxy+hzOuterFrameInox+hzTopGasSupportAl;
+    posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopGasSupportAl;
     gMC->Gspos("SQ15",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
     posZ = -1.*posZ;
     gMC->Gspos("SQ15",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
@@ -1573,7 +1621,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     // TopPositioner parameters - single Stainless Steel trapezoid - 2 copies
     posX = 7.60+fgkDeltaQuadLHC;
     posY = 98.98+fgkDeltaQuadLHC;   
-    posZ = hzOuterFrameEpoxy+hzOuterFrameInox+2.*hzTopGasSupportAl+hzTopPositionerSteel;
+    posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+2.*kHzTopGasSupportAl+kHzTopPositionerSteel;
     gMC->Gspos("SQ16",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
     posZ = -1.*posZ;
     gMC->Gspos("SQ16",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
@@ -1602,7 +1650,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     yCenter[6] = 82.862 + fgkDeltaQuadLHC;
     yCenter[7] = 87.418 + fgkDeltaQuadLHC; 
       
-    posZ = -1.0*hzOuterFrameInox;     
+    posZ = -1.0*kHzOuterFrameInox;     
     gMC->Gspos("SQ17",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
     gMC->Gspos("SQ17",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
 
@@ -1615,7 +1663,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     gMC->Gspos("SQ23",1,QuadrantMLayerName(chamber), xCenter[3], yCenter[3], posZ, rot2,"ONLY");
     gMC->Gspos("SQ23",2,QuadrantMLayerName(chamber), xCenter[7], yCenter[7], posZ, rot3,"ONLY");
      
-    posZ = posZ+hzOuterFrameEpoxy;
+    posZ = posZ+kHzOuterFrameEpoxy;
    
     gMC->Gspos("SQ18",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
     gMC->Gspos("SQ18",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
@@ -1632,24 +1680,29 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //---    
         
 // OutVFrame
-    posX = 2.*hxInVFrame+iAF+2.*hxInHFrame-hxOutVFrame+2.*hxV1mm;
-    posY = 2.*hyInHFrame+hyOutVFrame;    
+    posX = 2.*kHxInVFrame+kIAF+2.*kHxInHFrame-kHxOutVFrame+2.*kHxV1mm;
+    posY = 2.*kHyInHFrame+kHyOutVFrame;    
     posZ = 0.;              
     gMC->Gspos("SQ25",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
 
-    Float_t tOPY = posY+hyOutVFrame;
-    Float_t oUTX = posX;
+ // keep memory of the mid position. Used for placing screws
+    const GReal_t kMidOVposX = posX;
+    const GReal_t kMidOVposY = posY;
+    const GReal_t kMidOVposZ = posZ;
+
+    const Float_t kTOPY = posY+kHyOutVFrame;
+    const Float_t kOUTX = posX;
 
 // OutVFrame corner
-    posX = oUTX;
-    posY = tOPY+((bl1OCTF+tl1OCTF)/2.);
+    posX = kOUTX;
+    posY = kTOPY+((kBl1OCTF+kTl1OCTF)/2.);
     posZ = 0.;     
     gMC->Gspos("SQ26",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
 
 // VertEarthFaceCu - 2 copies
     posX = 89.4000+fgkDeltaQuadLHC;
     posY = 25.79+fgkDeltaQuadLHC;    
-    posZ = hzFrameThickness+2.0*hzFoam+hzVertEarthFaceCu;              
+    posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertEarthFaceCu;              
     gMC->Gspos("SQ27",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ; 
     gMC->Gspos("SQ27",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
@@ -1657,7 +1710,7 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 // VertEarthSteel - 2 copies
     posX = 91.00+fgkDeltaQuadLHC;
     posY = 30.616+fgkDeltaQuadLHC;    
-    posZ = hzFrameThickness+2.0*hzFoam+hzVertBarSteel;              
+    posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertBarSteel;              
     gMC->Gspos("SQ28",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ;              
     gMC->Gspos("SQ28",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY");
@@ -1665,36 +1718,36 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 // VertEarthProfCu - 2 copies
     posX = 92.000+fgkDeltaQuadLHC;
     posY = 29.64+fgkDeltaQuadLHC;    
-    posZ = hzFrameThickness;              
+    posZ = kHzFrameThickness;              
     gMC->Gspos("SQ29",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ;    
     gMC->Gspos("SQ29",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
 
 // SuppLateralPositionner - 2 copies 
-    posX = 90.2-kfgkNearFarLHC;
-    posY = 5.00-kfgkNearFarLHC;    
-    posZ = hzLateralPosnAl-fgkMotherThick2;             
+    posX = 90.2-kNearFarLHC;
+    posY = 5.00-kNearFarLHC;    
+    posZ = kHzLateralPosnAl-fgkMotherThick2;             
     gMC->Gspos("SQ30",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;            
     gMC->Gspos("SQ30",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
 
 // LateralPositionner - 2 copies - Face view
-    posX = 92.175-kfgkNearFarLHC-2.*hxLPP;
-    posY = 5.00-kfgkNearFarLHC;   
-    posZ =2.0*hzLateralPosnAl+hzLateralPosnInoxFace-fgkMotherThick2;              
+    posX = 92.175-kNearFarLHC-2.*kHxLPP;
+    posY = 5.00-kNearFarLHC;   
+    posZ =2.0*kHzLateralPosnAl+kHzLateralPosnInoxFace-fgkMotherThick2;              
     gMC->Gspos("SQ31",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;             
     gMC->Gspos("SQ31",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
 
 // LateralPositionner -  Profile view   
-    posX = 92.175+fgkDeltaQuadLHC+hxLPF-hxLPP;
+    posX = 92.175+fgkDeltaQuadLHC+kHxLPF-kHxLPP;
     posY = 5.00+fgkDeltaQuadLHC;    
     posZ = 0.;              
     gMC->Gspos("SQ32",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // middle layer
 
-    posX = 92.175-kfgkNearFarLHC+hxLPF-hxLPP; 
-    posY = 5.0000-kfgkNearFarLHC;    
-    posZ = fgkMotherThick2-hzLPNF;              
+    posX = 92.175-kNearFarLHC+kHxLPF-kHxLPP; 
+    posY = 5.0000-kNearFarLHC;    
+    posZ = fgkMotherThick2-kHzLPNF;              
     gMC->Gspos("SQ33",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // near layer
     posZ = -1.*posZ;
     gMC->Gspos("SQ33",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // far layer
@@ -1705,9 +1758,9 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     posZ = 0.;              
     gMC->Gspos("SQ34",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
 
-    posX = 95.73-kfgkNearFarLHC;
-    posY = 33.26-kfgkNearFarLHC;
-    posZ = 2.0*hzLateralSightAl+hzVerticalCradleAl-fgkMotherThick2;               
+    posX = 95.73-kNearFarLHC;
+    posY = 33.26-kNearFarLHC;
+    posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;               
     gMC->Gspos("SQ34",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");
     posZ = -1.0*posZ;              
     gMC->Gspos("SQ34",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
@@ -1718,9 +1771,9 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     posZ = 0.;              
     gMC->Gspos("SQ35",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
 
-    posX = 97.29-kfgkNearFarLHC;
-    posY = 23.02-kfgkNearFarLHC;   
-    posZ = 2.0*hzLateralSightAl+hzVerticalCradleAl-fgkMotherThick2;          
+    posX = 97.29-kNearFarLHC;
+    posY = 23.02-kNearFarLHC;   
+    posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;          
     gMC->Gspos("SQ35",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");    
     posZ = -1.0*posZ;          
     gMC->Gspos("SQ35",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
@@ -1731,10 +1784,10 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     posZ = 0.;              
     gMC->Gspos("SQ36",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
 
-    posX = 98.31-kfgkNearFarLHC;
-    posY = 12.77-kfgkNearFarLHC;        
+    posX = 98.31-kNearFarLHC;
+    posY = 12.77-kNearFarLHC;        
 
-    posZ = 2.0*hzLateralSightAl+hzVerticalCradleAl-fgkMotherThick2;         
+    posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;         
     gMC->Gspos("SQ36",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");       
     posZ = -1.0*posZ;
     gMC->Gspos("SQ36",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
@@ -1745,15 +1798,15 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     posZ = 0.;              
     gMC->Gspos("SQ37",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
    
-    posZ = fgkMotherThick1-hzVerticalCradleAl;                
+    posZ = fgkMotherThick1-kHzVerticalCradleAl;                
     gMC->Gspos("SQ37",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
     posZ = -1.0*posZ;          
     gMC->Gspos("SQ37",3,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");          
              
 // LateralSightSupport - 2 copies
-    posX = 98.53-kfgkNearFarLHC;
-    posY = 10.00-kfgkNearFarLHC;    
-    posZ = hzLateralSightAl-fgkMotherThick2;
+    posX = 98.53-kNearFarLHC;
+    posY = 10.00-kNearFarLHC;    
+    posZ = kHzLateralSightAl-fgkMotherThick2;
     gMC->Gspos("SQ38",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;             
     gMC->Gspos("SQ38",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
@@ -1767,23 +1820,33 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 //---
 
 // InHFrame
-    posX = 2.0*hxInVFrame+2.*hxV1mm+iAF+hxInHFrame;
-    posY = hyInHFrame;
+    posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxInHFrame;
+    posY = kHyInHFrame;
     posZ = 0.;       
     gMC->Gspos("SQ40",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
  
+ // keep memory of the mid position. Used for placing screws
+    const GReal_t kMidHposX = posX;
+    const GReal_t kMidHposY = posY;
+    const GReal_t kMidHposZ = posZ;
+
 // Flat 7.5mm horizontal section
-    posX = 2.0*hxInVFrame+2.*hxV1mm+iAF+hxH1mm;
-    posY = 2.0*hyInHFrame+hyH1mm;
+    posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxH1mm;
+    posY = 2.0*kHyInHFrame+kHyH1mm;
     posZ = 0.;
     gMC->Gspos("SQ41",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
         
 // InArcFrame 
-    posX = 2.0*hxInVFrame+2.*hxV1mm;
-    posY = 2.0*hyInHFrame+2.*hyH1mm;
+    posX = 2.0*kHxInVFrame+2.*kHxV1mm;
+    posY = 2.0*kHyInHFrame+2.*kHyH1mm;
     posZ = 0.;    
     gMC->Gspos("SQ42",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
 
+// keep memory of the mid position. Used for placing screws
+    const GReal_t kMidArcposX = posX;
+    const GReal_t kMidArcposY = posY;
+    const GReal_t kMidArcposZ = posZ;
+
 // ScrewsInFrame - in sensitive volume
 
      Float_t scruX[64];
@@ -1791,25 +1854,26 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
          
 // Screws on IHEpoxyFrame
 
-     const Int_t knumberOfScrewsIH = 14;    // no. of screws on the IHEpoxyFrame
-     const Float_t koffX = 5.;              // inter-screw distance 
+     const Int_t kNumberOfScrewsIH = 14;    // no. of screws on the IHEpoxyFrame
+     const Float_t kOffX = 5.;              // inter-screw distance 
 
      // first screw coordinates 
      scruX[0] = 21.07;                  
      scruY[0] = -2.23; 
      // other screw coordinates      
-     for (Int_t i = 1;i<knumberOfScrewsIH;i++){   
-     scruX[i] = scruX[i-1]+koffX; 
+     for (Int_t i = 1;i<kNumberOfScrewsIH;i++){   
+     scruX[i] = scruX[i-1]+kOffX; 
      scruY[i] = scruY[0];
      }    
      // Position the volumes on the frames
-     for (Int_t i = 0;i<knumberOfScrewsIH;i++){
+     for (Int_t i = 0;i<kNumberOfScrewsIH;i++){
      posX = fgkDeltaQuadLHC + scruX[i];
      posY = fgkDeltaQuadLHC + scruY[i];
      posZ = 0.;   
-     gMC->Gspos("SQ43",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-hzInHFrame-sCRUHLE, 0, "ONLY");      
-     gMC->Gspos("SQ44",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ, 0, "ONLY");
-     gMC->Gspos("SQ45",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+hzInHFrame+sCRUNLE, 0, "ONLY"); 
+     gMC->Gspos("SQ43",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");      
+     if (chamber==1)
+       gMC->Gspos("SQ44",i+1,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY");
+     gMC->Gspos("SQ45",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
      }
      // special screw coordinates
      scruX[63] = 16.3;  
@@ -1817,14 +1881,15 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
      posX = fgkDeltaQuadLHC + scruX[63];
      posY = fgkDeltaQuadLHC + scruY[63];
      posZ = 0.;            
-     gMC->Gspos("SQ43",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-hzInHFrame-sCRUHLE, 0, "ONLY");
-     gMC->Gspos("SQ44",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ, 0, "ONLY"); 
-     gMC->Gspos("SQ45",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+hzInHFrame+sCRUNLE, 0, "ONLY");  
+     gMC->Gspos("SQ43",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");
+     if (chamber==1)
+       gMC->Gspos("SQ44",64,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY"); 
+     gMC->Gspos("SQ45",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");  
      
 // Screws on the IVEpoxyFrame
   
-    const Int_t knumberOfScrewsIV = 15;     // no. of screws on the IVEpoxyFrame
-    const Float_t koffY = 5.;               // inter-screw distance 
+    const Int_t kNumberOfScrewsIV = 15;     // no. of screws on the IVEpoxyFrame
+    const Float_t kOffY = 5.;               // inter-screw distance 
     Int_t firstScrew = 58;
     Int_t lastScrew = 44;
  
@@ -1837,43 +1902,53 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     // other screw coordinates      
     for (Int_t i = firstScrew-3;i>lastScrew-2;i--){   
     scruX[i] = scruX[firstScrew-2];
-    scruY[i] = scruY[i+1]+koffY;
+    scruY[i] = scruY[i+1]+kOffY;
     }
     
-    for (Int_t i = 0;i<knumberOfScrewsIV;i++){
+    for (Int_t i = 0;i<kNumberOfScrewsIV;i++){
     posX = fgkDeltaQuadLHC + scruX[i+lastScrew-1];
     posY = fgkDeltaQuadLHC + scruY[i+lastScrew-1];
     posZ = 0.;       
-    gMC->Gspos("SQ43",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-hzInHFrame-sCRUHLE, 0, "ONLY");     
-    gMC->Gspos("SQ44",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ, 0, "ONLY"); 
-    gMC->Gspos("SQ45",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+hzInHFrame+sCRUNLE, 0, "ONLY");
+    gMC->Gspos("SQ43",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
+    if (chamber==1)
+      gMC->Gspos("SQ44",i+lastScrew,"SQ00",posX+0.1-kMidVposX, posY+0.1-kMidVposY, posZ-kMidVposZ, 0, "ONLY"); 
+    gMC->Gspos("SQ45",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
     }    
     
 // Screws on the OVEpoxyFrame
   
-    const Int_t knumberOfScrewsOV = 10;     // no. of screws on the OVEpoxyFrame
+    const Int_t kNumberOfScrewsOV = 10;     // no. of screws on the OVEpoxyFrame
 
     firstScrew = 15;
     lastScrew = 25;
  
     // first (repetitive) screw coordinates
+    // notes: 1st screw should be placed in volume 40 (InnerHorizFrame)
     scruX[firstScrew-1] = 90.9; 
     scruY[firstScrew-1] = -2.23;  // true value
  
     // other screw coordinates      
     for (Int_t i = firstScrew; i<lastScrew; i++ ){   
     scruX[i] = scruX[firstScrew-1];
-    scruY[i] = scruY[i-1]+koffY;
+    scruY[i] = scruY[i-1]+kOffY;
     }
-    for (Int_t i = 0;i<knumberOfScrewsOV;i++){
+    for (Int_t i = 1;i<kNumberOfScrewsOV;i++){
     posX = fgkDeltaQuadLHC + scruX[i+firstScrew-1];
     posY = fgkDeltaQuadLHC + scruY[i+firstScrew-1];
     posZ = 0.;   
-    gMC->Gspos("SQ43",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-hzInHFrame-sCRUHLE, 0, "ONLY");     
-    gMC->Gspos("SQ44",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ, 0, "ONLY"); 
-    gMC->Gspos("SQ45",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+hzInHFrame+sCRUNLE, 0, "ONLY"); 
+    gMC->Gspos("SQ43",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
+    // ??
+    if (chamber==1)
+      gMC->Gspos("SQ44",i+firstScrew,"SQ25",posX+0.1-kMidOVposX, posY+0.1-kMidOVposY, posZ-kMidOVposZ, 0, "ONLY"); 
+    gMC->Gspos("SQ45",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
     }
-      
+    // special case for 1st screw, inside the horizontal frame (volume 40)
+    posX = fgkDeltaQuadLHC + scruX[firstScrew-1];
+    posY = fgkDeltaQuadLHC + scruY[firstScrew-1];
+    posZ = 0.;   
+    if (chamber==1)
+      gMC->Gspos("SQ44",firstScrew,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY"); 
+          
 // Inner Arc of Frame, screw positions and numbers-1
    scruX[62] = 16.009; scruY[62]  = 1.401;
    scruX[61] = 14.564; scruY[61]  = 6.791;
@@ -1885,14 +1960,15 @@ const Float_t kfgkNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
     posX = fgkDeltaQuadLHC + scruX[i+58];
     posY = fgkDeltaQuadLHC + scruY[i+58];
     posZ = 0.;   
-    gMC->Gspos("SQ43",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-hzInHFrame-sCRUHLE, 0, "ONLY");    
-    gMC->Gspos("SQ44",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ, 0, "ONLY");
-    gMC->Gspos("SQ45",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+hzInHFrame+sCRUNLE, 0, "ONLY");
+    gMC->Gspos("SQ43",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");    
+    if (chamber==1)
+      gMC->Gspos("SQ44",i+58+1,"SQ42",posX+0.1-kMidArcposX, posY+0.1-kMidArcposY, posZ-kMidArcposZ, 0, "ONLY");
+    gMC->Gspos("SQ45",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
     }
 }
 
 //______________________________________________________________________________
-void AliMUONv2::PlaceInnerLayers(Int_t chamber)
+void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
 {
 // Place the gas and copper layers for the specified chamber.
 // --
@@ -1900,10 +1976,10 @@ void AliMUONv2::PlaceInnerLayers(Int_t chamber)
 // Rotation Matrices 
   Int_t rot1, rot2, rot3, rot4;   
 
-  AliMatrix(rot1,  90., 315., 90.,  45., 0., 0.); // -45 deg
-  AliMatrix(rot2,  90.,  90., 90., 180., 0., 0.); //  90 deg
-  AliMatrix(rot3,  90., 270., 90.,   0., 0., 0.); // -90 deg 
-  AliMatrix(rot4,  90.,  45., 90., 135., 0., 0.); //  deg 
+  fMUON->AliMatrix(rot1,  90., 315., 90.,  45., 0., 0.); // -45 deg
+  fMUON->AliMatrix(rot2,  90.,  90., 90., 180., 0., 0.); //  90 deg
+  fMUON->AliMatrix(rot3,  90., 270., 90.,   0., 0., 0.); // -90 deg 
+  fMUON->AliMatrix(rot4,  90.,  45., 90., 135., 0., 0.); //  deg 
 
   GReal_t x;
   GReal_t y;
@@ -1991,7 +2067,7 @@ void AliMUONv2::PlaceInnerLayers(Int_t chamber)
 }
 
 //______________________________________________________________________________
-void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap, 
+void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap specialMap, 
                             const TVector3& where, Bool_t reflectZ, Int_t chamber)
 {
 // Place all the segments in the mother volume, at the position defined
@@ -2006,16 +2082,24 @@ void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap,
   if (!reflectZ) {
     sgn= 1;
     reflZ=0;                                     // no reflection along z... nothing
-    AliMatrix(rotMat,  90.,90.,90,180.,0.,0.);   // 90° rotation around z, NO reflection along z
+    fMUON->AliMatrix(rotMat,  90.,90.,90,180.,0.,0.);   // 90° rotation around z, NO reflection along z
   } else  {
     sgn=-1;
-    AliMatrix(reflZ,  90.,0.,90,90.,180.,0.);    // reflection along z
-    AliMatrix(rotMat,  90.,90.,90,180.,180.,0.); // 90° rotation around z AND reflection along z
+    fMUON->AliMatrix(reflZ,  90.,0.,90,90.,180.,0.);    // reflection along z
+    fMUON->AliMatrix(rotMat,  90.,90.,90,180.,180.,0.); // 90° rotation around z AND reflection along z
   }
   
   GReal_t posX,posY,posZ;
   
-  IntVector alreadydone;
+#ifdef ST1_WITH_STL  
+  vector<Int_t> alreadyDone;
+#endif
+
+#ifdef ST1_WITH_ROOT  
+  TArrayI alreadyDone(20);
+  Int_t nofAlreadyDone = 0;
+#endif  
+
   for (Int_t irow=0;irow<sector->GetNofRows();irow++){ // for each row
     AliMpRow* row = sector->GetRow(irow);
 
@@ -2024,10 +2108,18 @@ void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap,
       AliMpVRowSegment* seg = row->GetRowSegment(iseg);
       char segName[5];
       
-      TSpecialMap::iterator iter 
+#ifdef ST1_WITH_STL 
+      SpecialMap::iterator iter 
         = specialMap.find(seg->GetMotifPositionId(0));
 
       if ( iter == specialMap.end()){ //if this is a normal segment (ie. not part of <specialMap>)
+#endif  
+      
+#ifdef ST1_WITH_ROOT  
+      Long_t value = specialMap.GetValue(seg->GetMotifPositionId(0));
+
+      if ( value == 0 ){ //if this is a normal segment (ie. not part of <specialMap>)
+#endif  
       
         // create the cathode part
         sprintf(segName,"%.3dM", segNum);
@@ -2058,10 +2150,26 @@ void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap,
 
           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
           
-          if (find(alreadydone.begin(),alreadydone.end(),motifPosId)
-              != alreadydone.end()) continue; // don't treat the same motif twice
-          
+#ifdef ST1_WITH_STL
+          if (find(alreadyDone.begin(),alreadyDone.end(),motifPosId)
+              != alreadyDone.end()) continue; // don't treat the same motif twice
+
           AliMUONSt1SpecialMotif spMot = specialMap[motifPosId];
+#endif
+#ifdef ST1_WITH_ROOT
+          Bool_t isDone = false;
+         Int_t i=0;
+         while (i<nofAlreadyDone && !isDone) {
+           if (alreadyDone.At(i) == motifPosId) isDone=true;
+           i++;
+         }  
+         if (isDone) continue; // don't treat the same motif twice
+
+          AliMUONSt1SpecialMotif spMot = *((AliMUONSt1SpecialMotif*)specialMap.GetValue(motifPosId));
+#endif
+          // check
+         // cout << chamber << " processing special motif: " << motifPosId << endl;  
+
           AliMpMotifPosition* motifPos = sector->GetMotifMap()->FindMotifPosition(motifPosId);
 
           // place the hole for the motif, wrt the requested rotation angle
@@ -2078,7 +2186,16 @@ void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap,
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
           gMC->Gspos(fgkDaughterName, motifPosId, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
 
-          alreadydone.push_back(motifPosId);// mark this motif as done
+#ifdef ST1_WITH_STL
+          alreadyDone.push_back(motifPosId);// mark this motif as done
+#endif
+#ifdef ST1_WITH_ROOT
+          if (nofAlreadyDone == alreadyDone.GetSize()) 
+            alreadyDone.Set(2*nofAlreadyDone); 
+          alreadyDone.AddAt(motifPosId, nofAlreadyDone++);               
+#endif
+          // check
+         // cout << chamber << " processed motifPosId: " << motifPosId << endl;
        }               
       }// end of special motif case
     }
@@ -2086,7 +2203,7 @@ void AliMUONv2::PlaceSector(AliMpSector* sector,TSpecialMap specialMap,
 } 
 
 //______________________________________________________________________________
-TString AliMUONv2::GasVolumeName(const TString& name, Int_t chamber) const
+TString AliMUONSt1GeometryBuilderV2::GasVolumeName(const TString& name, Int_t chamber) const
 {
 // Inserts the chamber number into the name.
 // ---
@@ -2101,8 +2218,9 @@ TString AliMUONv2::GasVolumeName(const TString& name, Int_t chamber) const
   return newString;
 }
 
+/*
 //______________________________________________________________________________
-Bool_t AliMUONv2::IsInChamber(Int_t ich, Int_t volGid) const
+Bool_t AliMUONSt1GeometryBuilderV2::IsInChamber(Int_t ich, Int_t volGid) const
 {
 // True if volume <volGid> is part of the sensitive 
 // volumes of chamber <ich> 
@@ -2112,13 +2230,15 @@ Bool_t AliMUONv2::IsInChamber(Int_t ich, Int_t volGid) const
   }
   return kFALSE;
 }
+*/
 
 //
 // protected methods
 //
 
+/*
 //______________________________________________________________________________
-Int_t  AliMUONv2::GetChamberId(Int_t volId) const
+Int_t  AliMUONSt1GeometryBuilderV2::GetChamberId(Int_t volId) const
 {
 // Check if the volume with specified  volId is a sensitive volume (gas) 
 // of some chamber and returns the chamber number;
@@ -2133,161 +2253,177 @@ Int_t  AliMUONv2::GetChamberId(Int_t volId) const
 
   return 0;
 }
+*/
 
 //
 // public methods
 //
 
 //______________________________________________________________________________
-void AliMUONv2::CreateMaterials()
+void AliMUONSt1GeometryBuilderV2::CreateMaterials()
 {
-// --- Define the various mixtures for GEANT ---
+// Materials and medias defined in MUONv1:
+//
+//  AliMaterial( 9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
+//  AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
+//  AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500);
+//  AliMixture( 19, "Bakelite$", abak, zbak, dbak, -3, wbak);
+//  AliMixture( 20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
+//  AliMixture( 21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
+//  AliMixture( 22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
+//  AliMixture( 23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
+//  AliMixture( 24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
+//  AliMaterial(31, "COPPER$",   63.54,    29.,   8.96,  1.4, 0.);
+//  AliMixture( 32, "Vetronite$",aglass, zglass, dglass,    5, wglass);
+//  AliMaterial(33, "Carbon$",   12.01,     6.,  2.265, 18.8, 49.9);
+//  AliMixture( 34, "Rohacell$", arohac, zrohac, drohac,   -4, wrohac); 
+
+//  AliMedium( 1, "AIR_CH_US         ",  15, 1, iSXFLD, ...
+//  AliMedium( 4, "ALU_CH_US          ",  9, 0, iSXFLD, ... 
+//  AliMedium( 5, "ALU_CH_US          ", 10, 0, iSXFLD, ... 
+//  AliMedium( 6, "AR_CH_US          ",  20, 1, iSXFLD, ... 
+//  AliMedium( 7, "GAS_CH_TRIGGER    ",  21, 1, iSXFLD, ... 
+//  AliMedium( 8, "BAKE_CH_TRIGGER   ",  19, 0, iSXFLD, ... 
+//  AliMedium( 9, "ARG_CO2   ",          22, 1, iSXFLD, ... 
+//  AliMedium(11, "PCB_COPPER        ",  31, 0, iSXFLD, ... 
+//  AliMedium(12, "VETRONITE         ",  32, 0, iSXFLD, ... 
+//  AliMedium(13, "CARBON            ",  33, 0, iSXFLD, ... 
+//  AliMedium(14, "Rohacell          ",  34, 0, iSXFLD, ... 
+
+  //
+  // --- Define materials for GEANT ---
+  //
+
+  fMUON->AliMaterial(41, "Aluminium II$", 26.98, 13., 2.7, -8.9, 26.1);
+       // was id: 9
+       // from PDG and "The Particle Detector BriefBook", Bock and Vasilescu, P.18  
+        // ??? same but the last but one argument < 0 
   
-  //     Ar-CO2 gas (80%+20%)
-  Float_t ag1[2]   = { 39.95,44.01};
-  Float_t zg1[2]   = { 18.,22.};
-  Float_t dg1      = .001821;
-  Float_t wg1[2]   = { .8,0.2};
-  // use wg1 weighting factors (6th arg > 0)
-  AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 2, wg1);  
+  fMUON->AliMaterial(42, "Copper$", 63.546,29.,8.96,-1.43,9.6);
+       // was id: 30
+
+  fMUON->AliMaterial(43, "FR4$", 17.749, 8.875, 1.7, -19.4, 999.);    // from DPG
+       // was id: 31
+
+  fMUON->AliMaterial(44, "FrameEpoxy",12.24,6.0,1.85,-19.14,999);// use 16.75cm
+        // was id: 36
+        // Density of FrameEpoxy only from manufacturer's specifications
+        // Frame composite epoxy , X0 in g/cm**2 (guestimation!)
   
-  // Ar-buthane-freon gas -- trigger chambers 
-  Float_t atr1[4]  = { 39.95,12.01,1.01,19. };
-  Float_t ztr1[4]  = { 18.,6.,1.,9. };
-  Float_t wtr1[4]  = { .56,.1262857,.2857143,.028 };
-  Float_t dtr1     = .002599;
-  AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
-
-  // Rohacell 51  - imide methacrylique
-  Float_t aRohacell51[4] = {12.01,1.01,16.00,14.01}; 
-  Float_t zRohacell51[4] = {6.,1.,8.,7.}; 
+  //
+  // --- Define mixtures for GEANT ---
+  //
+
+  //     Ar-CO2 gas II (80%+20%)
+  Float_t ag1[2]   = { 39.95,  44.01};
+  Float_t zg1[2]   = { 18., 22.};
+  Float_t wg1[2]   = { .8, 0.2};
+  Float_t dg1      = .001821;
+  fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
+            // was id: 22
+            // use wg1 weighting factors (6th arg > 0)
+
+  // Rohacell 51  II - imide methacrylique
+  Float_t aRohacell51[4] = { 12.01, 1.01, 16.00, 14.01}; 
+  Float_t zRohacell51[4] = { 6., 1., 8., 7.}; 
+  Float_t wRohacell51[4] = { 9., 13., 2., 1.};  
   Float_t dRohacell51 = 0.052;
-  Float_t wRohacell51[4] = {9.,13.,2.,1.};  
-  // use relative A (molecular) values (6th arg < 0)
-  AliMixture(32, "FOAM$",aRohacell51,zRohacell51,dRohacell51,-4,wRohacell51);  
+  fMUON->AliMixture(46, "FOAM$",aRohacell51,zRohacell51,dRohacell51,-4,wRohacell51);  
+            // was id: 32
+            // use relative A (molecular) values (6th arg < 0)
    
-  Float_t aSnPb[2] = {118.69,207.19};
-  Float_t zSnPb[2] = {50,82};
+  Float_t aSnPb[2] = { 118.69, 207.19};
+  Float_t zSnPb[2] = { 50, 82};
+  Float_t wSnPb[2] = { 0.6, 0.4} ;
   Float_t dSnPb = 8.926;
-  Float_t wSnPb[2] = {0.6, 0.4} ;
-  // use wSnPb weighting factors (6th arg > 0)
-  AliMixture(35, "SnPb$", aSnPb,zSnPb,dSnPb,2,wSnPb);
+  fMUON->AliMixture(47, "SnPb$", aSnPb,zSnPb,dSnPb,2,wSnPb);
+            // was id: 35
+            // use wSnPb weighting factors (6th arg > 0)
 
   // plastic definition from K5, Freiburg (found on web)
-  Float_t aPlastic[2]={1.01,12.01};
-  Float_t zPlastic[2]={1,6};
+  Float_t aPlastic[2]={ 1.01, 12.01};
+  Float_t zPlastic[2]={ 1, 6};
+  Float_t wPlastic[2]={ 1, 1};
   Float_t denPlastic=1.107;
-  Float_t wPlastic[2]={1,1};
-  // use relative A (molecular) values (6th arg < 0)...no other info...
-  AliMixture( 33, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
+  fMUON->AliMixture(48, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
+            // was id: 33
+            // use relative A (molecular) values (6th arg < 0)...no other info...
  
-  // from CERN note NUFACT Note023, Oct.2000 
+  // Not used, to be removed
+  //
+  fMUON->AliMaterial(49, "Kapton$", 12.01,6,1.42,-28.6,999);          // from DPG
+       // was id: 34
+
   // Inox/Stainless Steel (18%Cr, 9%Ni)
-  Float_t aInox[3] = {55.847,51.9961,58.6934};  
-  Float_t zInox[3] = {26.,24.,28.};
+  Float_t aInox[3] = {55.847, 51.9961, 58.6934};  
+  Float_t zInox[3] = {26., 24., 28.};
+  Float_t wInox[3] = {0.73, 0.18, 0.09}; 
   Float_t denInox = 7.930;
-  Float_t wInox[3] = {0.73,0.18,0.09}; 
-  // use wInox weighting factors (6th arg > 0) 
-  AliMixture(37, "StainlessSteel$",aInox,zInox,denInox,3,wInox);   
-
-  // bakelite 
-  Float_t abak[3] = {12.01 , 1.01 , 16.};
-  Float_t zbak[3] = {6.     , 1.   , 8.};
-  Float_t wbak[3] = {6.     , 6.   , 1.}; 
-  Float_t dbak = 1.4;
-  AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
-  
-  // Ar-Isobutane gas (80%+20%) 
-  Float_t ag[3]    = { 39.95,12.01,1.01 };
-  Float_t zg[3]    = { 18.,6.,1. };
-  Float_t wg[3]    = { .8,.057,.143 };
-  Float_t dg       = .0019596;
-  AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
-
-  //     Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger 
-  Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
-  Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
-  Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
-  Float_t dtrig    = .0031463;
-  AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
-      
-// --- Define the various AliMaterials for GEANT ---
-  // from PDG and "The Particle Detector BriefBook", Bock and Vasilescu, P.18  
-  AliMaterial( 9, "Aluminium$", 26.98, 13., 2.7, -8.9, 26.1);
-  AliMaterial(10, "Aluminium$", 26.98, 13., 2.7, -8.9, 26.1);
-  AliMaterial(15, "air$", 14.61, 7.3, .001205, -30423.24, 67500);
-  AliMaterial(30, "Copper$", 63.546,29.,8.96,-1.43,9.6);
-  AliMaterial(31, "FR4$", 17.749, 8.875, 1.7, -19.4, 999.);    // from DPG
-  AliMaterial(34, "Kapton$", 12.01,6,1.42,-28.6,999);          // from DPG
- // Density of FrameEpoxy only from manufacturer's specifications
- // Frame composite epoxy , X0 in g/cm**2 (guestimation!)
-  AliMaterial(36, "FrameEpoxy",12.24,6.0,1.85,-19.14,999);// use 16.75cm
-  
-// --- Define the tracking medias (AliMediums) for GEANT ---
+  fMUON->AliMixture(50, "StainlessSteel$",aInox,zInox,denInox,3,wInox);   
+            // was id: 37
+            // use wInox weighting factors (6th arg > 0) 
+            // from CERN note NUFACT Note023, Oct.2000 
+  //
+  // End - Not used, to be removed
+
+  //
+  // --- Define the tracking medias for GEANT ---
+  // 
+
   GReal_t epsil  = .001;       // Tracking precision,
-  GReal_t stemax = -1.;        // Maximum displacement for multiple scat
+  //GReal_t stemax = -1.;        // Maximum displacement for multiple scat
   GReal_t tmaxfd = -20.;       // Maximum angle due to field deflection
-  GReal_t deemax = -.3;        // Maximum fractional energy loss, DLS
+  //GReal_t deemax = -.3;        // Maximum fractional energy loss, DLS
   GReal_t stmin  = -.8;
-  GReal_t maxStepAlu = 0.001;  // from AliMUON.cxx
-  GReal_t maxDestepAlu = -1.;  // from AliMUON.cxx
-  GReal_t maxStepGas=0.01;     // from AliMUON.cxx
-
+  GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
+  GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
+  GReal_t maxStepGas   = fMUON->GetMaxStepGas();
   Int_t iSXFLD   = gAlice->Field()->Integ();
   Float_t sXMGMX = gAlice->Field()->Max();
 
-  AliMedium(1, "AIR_CH_US$", 15, 1, iSXFLD, sXMGMX, tmaxfd,
-           stemax, deemax, epsil, stmin);
-  AliMedium(4, "ALU_CH_US$", 9, 0, iSXFLD, sXMGMX, tmaxfd,
-           maxStepAlu, maxDestepAlu, epsil, stmin);
-  AliMedium(5, "ALU_CH_US$", 10, 0, iSXFLD, sXMGMX, tmaxfd,
-           maxStepAlu,maxDestepAlu, epsil, stmin);  
-  AliMedium(6, "AR_CH_US          ", 20, 1, iSXFLD, sXMGMX, 
-              tmaxfd, fMaxStepGas,fMaxDestepGas, epsil, stmin);
-              
-  //    Ar-Isobuthane-Forane-SF6 gas 
-  AliMedium(7, "GAS_CH_TRIGGER    ", 21, 1, iSXFLD, sXMGMX, 
-               tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(8, "BAKE_CH_TRIGGER   ", 19, 0, iSXFLD, sXMGMX, 
-               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
-
-  AliMedium(9, "ArCO2 80%$", 22, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
-             maxDestepAlu, epsil, stmin);
-  AliMedium(10, "COPPER_CH$", 30, 0, iSXFLD, sXMGMX, tmaxfd,
-             maxStepAlu, maxDestepAlu, epsil, stmin);
-  AliMedium(11, "PCB_COPPER        ", 31, 0, iSXFLD, sXMGMX, tmaxfd, 
-                fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
-  AliMedium(12, "VETRONITE         ", 32, 0, iSXFLD, sXMGMX, tmaxfd, 
-                fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
-  AliMedium(13, "CARBON            ", 33, 0, iSXFLD, sXMGMX, tmaxfd, 
-                fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
-  AliMedium(14, "Rohacell          ", 34, 0, iSXFLD, sXMGMX, tmaxfd, 
-             fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
-  AliMedium(15, "FR4_CH$",  31, 0,iSXFLD, sXMGMX, 10., .01,.1, .003, .003);
-  AliMedium(16, "FOAM_CH$", 32, 0,
-             iSXFLD, sXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
-  AliMedium(17, "Plastic$", 33, 0,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
-  AliMedium(18, "Kapton$", 34, 0,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
-  AliMedium(19, "SnPb$", 35, 0,iSXFLD, sXMGMX,  10., .01,  1., .003, .003);
-  AliMedium(20, "FrameCH$", 36, 1,iSXFLD, sXMGMX,  10., .001, 0.001, .001, .001);
-  AliMedium(21, "InoxBolts$", 37,1,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
-
-// store the parameters
-  Float_t a, z, dens, absl;
-  char matName[5];
-  AliGetMaterial(30,matName,a,z,dens,fRadlCopper,absl);
-  AliGetMaterial(31,matName,a,z,dens,fRadlFR4,absl);
-  AliGetMaterial(32,matName,a,z,dens,fRadlFoam,absl);
+  fMUON->AliMedium(21, "ALU_II$",    41, 0, iSXFLD, sXMGMX, 
+                   tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
+                  // was med: 4  mat: 9
+  fMUON->AliMedium(22, "COPPER_II$", 42, 0, iSXFLD, sXMGMX, 
+                   tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
+                  // was med: 10  mat: 30
+  fMUON->AliMedium(23, "FR4_CH$",    43, 0, iSXFLD, sXMGMX, 
+                   10.0, 0.01, 0.1, 0.003, 0.003);
+                  // was med: 15  mat: 31 
+  fMUON->AliMedium(24, "FrameCH$",   44, 1, iSXFLD, sXMGMX, 
+                   10.0, 0.001, 0.001, 0.001, 0.001);
+                  // was med: 20  mat: 36
+  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
+                   tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
+                  // was med: 9   mat: 22
+  fMUON->AliMedium(26, "FOAM_CH$",   46, 0, iSXFLD, sXMGMX,
+                   10.0,  0.1, 0.1, 0.1, 0.1, 0, 0) ;
+                  // was med: 16  mat: 32
+  fMUON->AliMedium(27, "SnPb$",      47, 0, iSXFLD, sXMGMX,  
+                   10.0, 0.01, 1.0, 0.003, 0.003);
+                  // was med: 19  mat: 35
+  fMUON->AliMedium(28, "Plastic$",   48, 0, iSXFLD, sXMGMX,
+                   10.0, 0.01, 1.0, 0.003, 0.003);
+                  // was med: 17  mat: 33
+
+  // Not used, to be romoved
+  //
+  fMUON->AliMedium(29, "Kapton$",    49, 0, iSXFLD, sXMGMX,  
+                   10.0, 0.01, 1.0, 0.003, 0.003);
+                  // was med: 18  mat: 34 
+  fMUON->AliMedium(30, "InoxBolts$", 50, 1, iSXFLD, sXMGMX, 
+                   10.0, 0.01, 1.0, 0.003, 0.003);
+                  // was med: 21  mat: 37
+  //
+  // End - Not used, to be removed
 }
 
 //______________________________________________________________________________
-void AliMUONv2::CreateGeometry()
+void AliMUONSt1GeometryBuilderV2::CreateGeometry()
 {
-// Create the GEANT geometry for the dimuon arm.
-// Use the parent's method for stations 2, 3, 4 and 5.
-// Use the detailed code for the first station.
+// Create the detailed GEANT geometry for the dimuon arm station1
 // --
-  cout << "AliMUONv2::CreateGeometry()" << endl;
+  cout << "AliMUONSt1GeometryBuilderV2::CreateGeometry()" << endl;
   cout << "_________________________________________" << endl;
 
   // Create basic volumes
@@ -2298,11 +2434,12 @@ void AliMUONv2::CreateGeometry()
   
   // Create reflexion matrices
   //
+/*
   Int_t reflXZ, reflYZ, reflXY;
-  AliMatrix(reflXZ,  90.,  180., 90., 90., 180., 0.);
-  AliMatrix(reflYZ,  90., 0., 90.,-90., 180., 0.);
-  AliMatrix(reflXY,  90., 180., 90., 270., 0., 0.);
-
+  fMUON->AliMatrix(reflXZ,  90.,  180., 90., 90., 180., 0.);
+  fMUON->AliMatrix(reflYZ,  90., 0., 90.,-90., 180., 0.);
+  fMUON->AliMatrix(reflXY,  90., 180., 90., 270., 0., 0.);
+*/
   // Define transformations for each quadrant
   // 
   //     II. |  I.
@@ -2310,11 +2447,18 @@ void AliMUONv2::CreateGeometry()
   //         |
   //    III. |  IV.
   // 
+/*
   Int_t rotm[4];
   rotm[0]=0;       // quadrant I
   rotm[1]=reflXZ;  // quadrant II
   rotm[2]=reflXY;  // quadrant III
   rotm[3]=reflYZ;  // quadrant IV
+*/
+  TGeoRotation rotm[4]; 
+  rotm[0] = TGeoRotation("identity");
+  rotm[1] = TGeoRotation("reflXZ", 90.,  180., 90., 90., 180., 0.);
+  rotm[2] = TGeoRotation("reflXY", 90., 180., 90., 270., 0., 0.);
+  rotm[3] = TGeoRotation("reflYZ", 90., 0., 90.,-90., 180., 0.);
   
   TVector3 scale[4];  
   scale[0] = TVector3( 1,  1,  1);  // quadrant I
@@ -2348,87 +2492,73 @@ void AliMUONv2::CreateGeometry()
       // Middle layer
       GReal_t posx = pos0.X() * scale[i].X();
       GReal_t posy = pos0.Y() * scale[i].Y();
-      GReal_t posz = pos0.Z() * scale[i].Z() + AliMUONConstants::DefaultChamberZ(ich-1);
-      gMC->Gspos(QuadrantMLayerName(ich), i+1, "ALIC", posx, posy, posz, rotm[i], "ONLY");
+      //GReal_t posz = pos0.Z() * scale[i].Z() + AliMUONConstants::DefaultChamberZ(ich-1);
+      //gMC->Gspos(QuadrantMLayerName(ich), i+1, "ALIC", posx, posy, posz, rotm[i], "ONLY");
+      GReal_t posz = pos0.Z() * scale[i].Z();
+      GetChamber(ich-1)->GetGeometry()
+        ->AddEnvelope(QuadrantMLayerName(ich), i+1, TGeoTranslation(posx, posy, posz), rotm[i]); 
 
       // Near/far layers
       Real_t  posx2 = posx + shiftXY * scale[i].X();
       Real_t  posy2 = posy + shiftXY * scale[i].Y();
       Real_t  posz2 = posz - scale[i].Z()*shiftZ;
-      gMC->Gspos(QuadrantNLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
+      //gMC->Gspos(QuadrantNLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
+      GetChamber(ich-1)->GetGeometry()
+        ->AddEnvelope(QuadrantNLayerName(ich), i+1, TGeoTranslation(posx2, posy2, posz2), rotm[i]); 
     
-      posz2 = posz + scale[i].Z()*shiftZ;
-      gMC->Gspos(QuadrantFLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
+      posz2 = posz + scale[i].Z()*shiftZ;      
+      //gMC->Gspos(QuadrantFLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
+      GetChamber(ich-1)->GetGeometry()
+        ->AddEnvelope(QuadrantFLayerName(ich), i+1, TGeoTranslation(posx2, posy2, posz2), rotm[i]); 
    }
  }     
-
-  static Int_t stations[5]={0,1,1,1,1};
-  fStations=stations;
-  AliMUONv1::CreateGeometry();
 }
 
 //______________________________________________________________________________
-void AliMUONv2::Init() 
+void AliMUONSt1GeometryBuilderV2::SetTransformations() 
 {
-   // Initialize Station 1 Tracking Chambers
-   //
-   // Set the chamber (sensitive region) GEANT identifier
-    fChamberV2[0] = new TArrayI(11);             // Chamber 1 sensitive volume Id array
-    fChamberV2[1] = new TArrayI(11);             // Chamber 2 sensitive volume Id array
-
-    AddChamberGid(0,gMC->VolId("SA1G"),0);
-    AddChamberGid(0,gMC->VolId("SB1G"),1);
-    AddChamberGid(0,gMC->VolId("SC1G"),2);
-    AddChamberGid(0,gMC->VolId("SD1G"),3);
-    AddChamberGid(0,gMC->VolId("SE1G"),4);
-    AddChamberGid(0,gMC->VolId("SF1G"),5);
-    AddChamberGid(0,gMC->VolId("SG1G"),6);
-    AddChamberGid(0,gMC->VolId("SH1G"),7);
-    AddChamberGid(0,gMC->VolId("SI1G"),8);
-    AddChamberGid(0,gMC->VolId("SJ1G"),9);
-    AddChamberGid(0,gMC->VolId("SK1G"),10);
-
-    
-    AddChamberGid(1,gMC->VolId("SA2G"),0);
-    AddChamberGid(1,gMC->VolId("SB2G"),1);
-    AddChamberGid(1,gMC->VolId("SC2G"),2);
-    AddChamberGid(1,gMC->VolId("SD2G"),3);
-    AddChamberGid(1,gMC->VolId("SE2G"),4);
-    AddChamberGid(1,gMC->VolId("SF2G"),5);
-    AddChamberGid(1,gMC->VolId("SG2G"),6);
-    AddChamberGid(1,gMC->VolId("SH2G"),7);
-    AddChamberGid(1,gMC->VolId("SI2G"),8);
-    AddChamberGid(1,gMC->VolId("SJ2G"),9);
-    AddChamberGid(1,gMC->VolId("SK2G"),10);
-
-  Int_t i;
-// now do the other stations as in AliMUONv1
-   for (i=0; i<AliMUONConstants::NCh(); i++) {
-       ( (AliMUONChamber*) (*fChambers)[i])->Init();
-   }
-   
-   //
-   // Set the chamber (sensitive region) GEANT identifier
-   ((AliMUONChamber*)(*fChambers)[0])->SetGid(-1);  // joker
-   ((AliMUONChamber*)(*fChambers)[1])->SetGid(-1);  // joker
-
-   ((AliMUONChamber*)(*fChambers)[2])->SetGid(gMC->VolId("S03G"));
-   ((AliMUONChamber*)(*fChambers)[3])->SetGid(gMC->VolId("S04G"));
-
-   ((AliMUONChamber*)(*fChambers)[4])->SetGid(gMC->VolId("S05G"));
-   ((AliMUONChamber*)(*fChambers)[5])->SetGid(gMC->VolId("S06G"));
+// Defines the transformations for the station2 chambers.
+// ---
 
-   ((AliMUONChamber*)(*fChambers)[6])->SetGid(gMC->VolId("S07G"));
-   ((AliMUONChamber*)(*fChambers)[7])->SetGid(gMC->VolId("S08G"));
+  AliMUONChamber* iChamber1 = GetChamber(0);
+  Double_t zpos1 = - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
 
-   ((AliMUONChamber*)(*fChambers)[8])->SetGid(gMC->VolId("S09G"));
-   ((AliMUONChamber*)(*fChambers)[9])->SetGid(gMC->VolId("S10G"));
+  AliMUONChamber* iChamber2 = GetChamber(1);
+  Double_t zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+}
 
-   ((AliMUONChamber*)(*fChambers)[10])->SetGid(gMC->VolId("SG1A"));
-   ((AliMUONChamber*)(*fChambers)[11])->SetGid(gMC->VolId("SG2A"));
-   ((AliMUONChamber*)(*fChambers)[12])->SetGid(gMC->VolId("SG3A"));
-   ((AliMUONChamber*)(*fChambers)[13])->SetGid(gMC->VolId("SG4A"));
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::SetSensitiveVolumes()
+{
+// Defines the sensitive volumes for station2 chambers.
+// ---
 
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SA1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SB1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SC1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SD1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SE1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SF1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SG1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SH1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SI1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SJ1G");
+  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SK1G");
+    
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SA2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SB2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SC2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SD2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SE2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SF2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SG2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SH2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SI2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SJ2G");
+  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SK2G");
 }
 
diff --git a/MUON/AliMUONSt1GeometryBuilderV2.h b/MUON/AliMUONSt1GeometryBuilderV2.h
new file mode 100644 (file)
index 0000000..696e0c3
--- /dev/null
@@ -0,0 +1,179 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// $Id$
+//
+// Class AliMUONSt1GeometryBuilderV2
+// ---------------------------------
+// MUON Station1 detailed geometry construction class.
+//
+// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
+
+#ifndef ALI_MUON_ST1_GEOMETRY_BUILDER_V2_H
+#define ALI_MUON_ST1_GEOMETRY_BUILDER_V2_H
+
+//#include "AliMUONSt1Containers.h"
+#include "AliMUONSt1Types.h"
+
+/*
+#ifdef ST1_WITH_STL
+  #include <map>
+  #ifdef __HP_aCC
+    using std::map;
+  #endif
+#endif
+
+#ifdef ST1_WITH_ROOT
+  #include "TExMap.h"
+#endif
+*/
+#include "AliMUONVGeometryBuilder.h"
+
+//typedef Float_t GReal_t; // for AliGeant3
+typedef Double_t GReal_t;  // for VirtualMC
+
+class TTree;
+class TVector2;
+class TVector3;
+
+class AliMpSector;
+class AliMUON;
+
+class AliMUONSt1GeometryBuilderV2 : public AliMUONVGeometryBuilder 
+{
+  public:
+    AliMUONSt1GeometryBuilderV2(AliMUON* muon);
+    AliMUONSt1GeometryBuilderV2(const AliMUONSt1GeometryBuilderV2& rMUON);
+    AliMUONSt1GeometryBuilderV2();
+    virtual ~AliMUONSt1GeometryBuilderV2();
+
+    virtual void CreateMaterials();
+    virtual void CreateGeometry();
+    virtual void SetTransformations();
+    virtual void SetSensitiveVolumes();
+   
+  protected:
+    AliMUONSt1GeometryBuilderV2& operator = (const AliMUONSt1GeometryBuilderV2& rhs);    
+  private:
+    // Typedefs
+    //
+/*
+#ifdef ST1_WITH_STL
+    typedef map<Int_t , AliMUONSt1SpecialMotif> SpecialMap;
+#endif
+#ifdef ST1_WITH_ROOT
+    typedef  TExMap  SpecialMap;
+#endif
+*/
+    // Constants
+    //
+    static const GReal_t fgkHzPadPlane;    // Pad plane
+    static const GReal_t fgkHzFoam;        // Foam of mechanicalplane
+    static const GReal_t fgkHzFR4;         // FR4 of mechanical plane
+    static const GReal_t fgkHzSnPb;        // Pad/Kapton connection (66 pt)
+    static const GReal_t fgkHzKapton;      // Kapton
+    static const GReal_t fgkHzBergPlastic; // Berg connector 
+    static const GReal_t fgkHzBergCopper;  // Berg connector (80 pt)
+    static const GReal_t fgkHzDaughter;    // Daughter board
+    static const GReal_t fgkHzGas;         // ArCO2 Gas
+        
+    // Sensitive copper pads, foam layer, PCB and electronics model parameters
+    static const GReal_t fgkHxHole;          // foam hole paremeter
+    static const GReal_t fgkHyHole;          // foam hole paremeter
+    static const GReal_t fgkHxBergPlastic;   // Berg connector parameter
+    static const GReal_t fgkHyBergPlastic;   // Berg connector parameter
+    static const GReal_t fgkHxBergCopper;    // Berg connector parameter
+    static const GReal_t fgkHyBergCopper;    // Berg connector parameter
+    static const GReal_t fgkHxKapton;        // Kapton parameter
+    static const GReal_t fgkHyKapton;        // Kapton parameter
+    static const GReal_t fgkHxDaughter;      // Electronics parameter
+    static const GReal_t fgkHyDaughter;      // Electronics parameter
+    static const GReal_t fgkOffsetX;         // Offset X
+    static const GReal_t fgkOffsetY;         // Offset Y
+    static const GReal_t fgkDeltaFilleEtamX; // Electronics parameter
+    static const GReal_t fgkDeltaFilleEtamY; // Electronics parameter
+
+    static const GReal_t fgkDeltaQuadLHC; // LHC Origin wrt Quadrant Origin
+    static const GReal_t fgkFrameOffset;  // Frame offset
+
+    // Quadrant Mother volume - TUBS1   
+    static const GReal_t fgkMotherIR1;    // Middle Layer Rin
+    static const GReal_t fgkMotherOR1;    // Middle Layer Rout
+    static const GReal_t fgkMotherThick1; // Middle Layer Hz 
+    static const GReal_t fgkMotherPhiL1;  // Middle Layer Sphi
+    static const GReal_t fgkMotherPhiU1;  // Middle Layer Endphi
+
+    // Quadrant Mother volume - TUBS2 (2 copies at different Z's)   
+    static const GReal_t fgkMotherIR2;    // Near and Far Layer Rin
+    static const GReal_t fgkMotherOR2;    // Near and Far Layer Rout
+    static const GReal_t fgkMotherThick2; // Near and Far Layer Hz 
+    static const GReal_t fgkMotherPhiL2;  // Near and Far Layer Sphi
+    static const GReal_t fgkMotherPhiU2;  // Near and Far Layer Endphi  
+
+    static const char* fgkHoleName;          // prefix for automatic volume naming
+    static const char* fgkQuadrantMLayerName;// prefix for automatic volume naming
+    static const char* fgkQuadrantNLayerName;// prefix for automatic volume naming
+    static const char* fgkQuadrantFLayerName;// prefix for automatic volume naming
+    static const char* fgkDaughterName;      // prefix for automatic volume naming
+    static const char  fgkFoamLayerSuffix;   // suffix for automatic volume naming
+
+    // Methods
+    //
+    void CreateHole();
+    void CreateDaughterBoard();
+    void CreateInnerLayers();
+    void CreateQuadrant(Int_t chamber);
+    void CreateFoamBox(const char* name,const TVector2& dimensions);
+    void CreatePlaneSegment(const char* name,const TVector2& dimensions,
+                     Int_t nofHoles);
+    void CreateFrame(Int_t chamber);
+
+    void PlaceInnerLayers(Int_t chamber);
+    void PlaceSector(AliMpSector* sector, SpecialMap specialMap,
+                     const TVector3& where, Bool_t reflectZ, Int_t chamber);
+                    
+    TString QuadrantMLayerName(Int_t chamber) const;
+    TString QuadrantNLayerName(Int_t chamber) const;
+    TString QuadrantFLayerName(Int_t chamber) const;
+    TString GasVolumeName(const TString& name, Int_t chamber) const;
+
+    void   AddChamberGid(Int_t id,Int_t volName,Int_t idx);
+    //Bool_t IsInChamber(Int_t ich, Int_t volGid) const;   
+
+    GReal_t TotalHzPlane() const ;         // Total mechanical plane half Size
+    GReal_t TotalHzDaughter() const ;      // Total daughter plane half Size
+    GReal_t TotalHz() const ;              // Total plane half Size
+       
+    // Data members
+    //
+    //Float_t  fRadlCopper;  //! copper computed radiation length
+    //Float_t  fRadlFoam;    //! foam   computed radiation length
+    //Float_t  fRadlFR4;     //! FR4    computed radiation length
+    AliMUON*  fMUON; // the MUON detector class 
+    
+  ClassDef(AliMUONSt1GeometryBuilderV2,1)  // MUON Detector base class
+};
+
+// inline functions
+
+inline GReal_t AliMUONSt1GeometryBuilderV2::TotalHzPlane() const 
+//{ return fgkHzPadPlane + fgkHzFoam + fgkHzFR4; }
+{ return fgkHzFoam + fgkHzFR4; }
+
+inline GReal_t AliMUONSt1GeometryBuilderV2::TotalHzDaughter() const 
+{ return fgkHzBergPlastic + fgkHzDaughter; }
+
+inline GReal_t AliMUONSt1GeometryBuilderV2::TotalHz() const 
+{ return TotalHzPlane() + TotalHzDaughter(); }
+
+inline TString AliMUONSt1GeometryBuilderV2::QuadrantMLayerName(Int_t chamber) const
+{ return Form("%s%d",fgkQuadrantMLayerName,chamber); }
+
+inline TString AliMUONSt1GeometryBuilderV2::QuadrantNLayerName(Int_t chamber) const
+{ return Form("%s%d",fgkQuadrantNLayerName,chamber); }
+
+inline TString AliMUONSt1GeometryBuilderV2::QuadrantFLayerName(Int_t chamber) const
+{ return Form("%s%d",fgkQuadrantFLayerName,chamber); }
+
+#endif //ALI_MUON_ST1_GEOMETRY_BUILDER_V2_H
index 36b6feafaad4a3451b8c7982b09aee1ac792a34a..ee38338f37b63ff1442fe8a16a1b4ab1fec6bad9 100644 (file)
@@ -17,6 +17,7 @@
 #include <vector>
 #include <fstream>
 
+#include "AliMUONSt1Containers.h"
 #include "AliMUONSt1SpecialMotif.h"
 
 class TString;
@@ -39,4 +40,22 @@ class AliMUONSt1ResponseParameter;
   typedef std::map<std::string,TList*> TListMap;
 #endif
 
+#ifdef ST1_WITH_STL
+  #include <map>
+  #ifdef __HP_aCC
+    using std::map;
+  #endif
+#endif
+
+#ifdef ST1_WITH_ROOT
+  #include "TExMap.h"
+#endif
+
+#ifdef ST1_WITH_STL
+    typedef map<Int_t , AliMUONSt1SpecialMotif> SpecialMap;
+#endif
+#ifdef ST1_WITH_ROOT
+    typedef  TExMap  SpecialMap;
+#endif
+
 #endif //ALI_MUON_ST1_TYPES_H
diff --git a/MUON/AliMUONSt2GeometryBuilder.cxx b/MUON/AliMUONSt2GeometryBuilder.cxx
new file mode 100644 (file)
index 0000000..456a6d9
--- /dev/null
@@ -0,0 +1,455 @@
+// $Id$
+//
+// Class AliMUONSt2GeometryBuilder
+// -------------------------------
+// Abstract base class for geometry construction per chamber.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#include <TVirtualMC.h>
+#include <TGeoMatrix.h>
+
+#include "AliMUONSt2GeometryBuilder.h"
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
+
+ClassImp(AliMUONSt2GeometryBuilder)
+
+//______________________________________________________________________________
+AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder(AliMUON* muon)
+ : AliMUONVGeometryBuilder(&muon->Chamber(2), &muon->Chamber(3)),
+   fMUON(muon)
+{
+// Standard constructor
+
+}
+
+//______________________________________________________________________________
+AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder()
+ : AliMUONVGeometryBuilder(),
+   fMUON(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder(const AliMUONSt2GeometryBuilder& rhs)
+  : AliMUONVGeometryBuilder(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONSt2GeometryBuilder::~AliMUONSt2GeometryBuilder() {
+//
+}
+
+//______________________________________________________________________________
+AliMUONSt2GeometryBuilder& 
+AliMUONSt2GeometryBuilder::operator = (const AliMUONSt2GeometryBuilder& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void AliMUONSt2GeometryBuilder::CreateGeometry() 
+{
+// From AliMUONv1::CreateGeometry()
+
+//
+//********************************************************************
+//                            Station 2                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+
+     // Get tracking medias Ids     
+     Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+     Int_t idAir= idtmed[1100]; // medium 1
+     Int_t idAlu1=idtmed[1103]; // medium 4
+     Int_t idAlu2=idtmed[1104]; // medium 5
+     Int_t idGas=idtmed[1108];  // medium 9 = Ar-CO2 gas (80%+20%)
+     Bool_t frameCrosses=kTRUE;     
+
+     // Rotation matrices in the x-y plane  
+     // phi= 0 deg
+     Int_t irot1;
+     fMUON->AliMatrix(irot1,  90.,   0., 90.,  90., 0., 0.);
+     // phi= 90 deg
+     Int_t irot2;
+     fMUON->AliMatrix(irot2,  90.,  90., 90., 180., 0., 0.);
+
+     AliMUONChamber* iChamber = GetChamber(2);
+     AliMUONChamber* iChamber1 = iChamber;
+     AliMUONChamber* iChamber2 = GetChamber(3);
+     
+     // Half of the total thickness of frame crosses (including DAlu)
+     // for each chamber in stations 1 and 2:
+     // 3% of X0 of composite material,
+     // but taken as Aluminium here, with same thickness in number of X0
+     Float_t dframez = 3. * 8.9 / 100;
+     // DGas and DAlu not changed from standard values
+     Double_t zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+             // The same parameters are defined in builder for station 1 
+     
+     // Mother volume
+     // Outer excess and inner recess for mother volume radius
+     // with respect to ROuter and RInner
+     Float_t dframep=.001; // Value for station 3 should be 6 ...
+     // Width (RdPhi) of the frame crosses for stations 1 and 2 (cm)
+     // Float_t dframep1=.001;
+     Float_t phi=2*TMath::Pi()/12/2;
+             // The same parameters are defined in builder for station 1 
+
+     Float_t tpar[3];
+     Double_t dstation = (-iChamber2->Z()) - (-iChamber1->Z());
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     gMC->Gsvolu("S03M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S04M", "TUBE", idAir, tpar, 3);
+
+     // CHANGED
+     //gMC->Gspos("S03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     //gMC->Gspos("S04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+     GetChamber(2)->GetGeometry()->AddEnvelope("S03M", false);
+     GetChamber(3)->GetGeometry()->AddEnvelope("S04M", false);
+     
+     gMC->Gsbool("S03M", "L3DO");
+     gMC->Gsbool("S03M", "L3O1");
+     gMC->Gsbool("S03M", "L3O2");
+     gMC->Gsbool("S04M", "L3DO");
+     gMC->Gsbool("S04M", "L3O1");
+     gMC->Gsbool("S04M", "L3O2");
+
+// // Aluminium frames
+// // Outer frames
+//      pgpar[0] = 360/12/2;
+//      pgpar[1] = 360.;
+//      pgpar[2] = 12.;
+//      pgpar[3] =   2;
+//      pgpar[4] = -dframez/2;
+//      pgpar[5] = iChamber->ROuter();
+//      pgpar[6] = pgpar[5]+dframep;
+//      pgpar[7] = +dframez/2;
+//      pgpar[8] = pgpar[5];
+//      pgpar[9] = pgpar[6];
+//      gMC->Gsvolu("S03O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gsvolu("S04O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gspos("S03O",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03O",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+// //
+// // Inner frame
+//      tpar[0]= iChamber->RInner()-dframep;
+//      tpar[1]= iChamber->RInner();
+//      tpar[2]= dframez/2;
+//      gMC->Gsvolu("S03I", "TUBE", idAlu1, tpar, 3);
+//      gMC->Gsvolu("S04I", "TUBE", idAlu1, tpar, 3);
+
+//      gMC->Gspos("S03I",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03I",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+//
+// Frame Crosses
+     if (frameCrosses) {
+         // outside gas
+         // security for inside mother volume
+         // ADDED !! Repeated     
+         Float_t dframep1 = 11.0;
+         Float_t dframez = 3. * 8.9 / 100;
+
+         Float_t bpar[3];
+        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
+          * TMath::Cos(TMath::ASin(dframep1 /
+                                  (iChamber->ROuter() - iChamber->RInner())))
+          / 2.0;
+        bpar[1] = dframep1/2;
+        // total thickness will be (4 * bpar[2]) for each chamber,
+        // which has to be equal to (2 * dframez) - DAlu
+        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
+        gMC->Gsvolu("S03B", "BOX", idAlu1, bpar, 3);
+        gMC->Gsvolu("S04B", "BOX", idAlu1, bpar, 3);
+        
+        gMC->Gspos("S03B",1,"S03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",2,"S03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",3,"S03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",4,"S03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",5,"S03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",6,"S03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",7,"S03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",8,"S03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        
+        gMC->Gspos("S04B",1,"S04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",2,"S04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",3,"S04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",4,"S04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",5,"S04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",6,"S04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",7,"S04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",8,"S04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+     }
+//
+//   Chamber Material represented by Alu sheet
+     tpar[0]= iChamber->RInner();
+     tpar[1]= iChamber->ROuter();
+     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
+     gMC->Gsvolu("S03A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gsvolu("S04A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gspos("S03A", 1, "S03M", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04A", 1, "S04M", 0., 0., 0.,  0, "ONLY");
+//     
+//   Sensitive volumes
+     // tpar[2] = iChamber->DGas();
+     tpar[2] = iChamber->DGas()/2;
+     gMC->Gsvolu("S03G", "TUBE", idGas, tpar, 3);
+     gMC->Gsvolu("S04G", "TUBE", idGas, tpar, 3);
+     gMC->Gspos("S03G", 1, "S03A", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04G", 1, "S04A", 0., 0., 0.,  0, "ONLY");
+//
+// Frame Crosses to be placed inside gas 
+     // NONE: chambers are sensitive everywhere
+//      if (frameCrosses) {
+
+//      dr = (iChamber->ROuter() - iChamber->RInner());
+//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
+//      bpar[1] = dframep1/2;
+//      bpar[2] = iChamber->DGas()/2;
+//      gMC->Gsvolu("S03F", "BOX", idAlu1, bpar, 3);
+//      gMC->Gsvolu("S04F", "BOX", idAlu1, bpar, 3);
+        
+//      gMC->Gspos("S03F",1,"S03G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S03F",2,"S03G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S03F",3,"S03G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S03F",4,"S03G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+        
+//      gMC->Gspos("S04F",1,"S04G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S04F",2,"S04G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S04F",3,"S04G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S04F",4,"S04G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      }
+/*
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[2];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[3];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = zpos2 - zpos1;
+     // DGas and DAlu not changed from standard values
+     zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+     
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     gMC->Gsvolu("S03M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S04M", "TUBE", idAir, tpar, 3);
+     gMC->Gspos("S03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     gMC->Gspos("S04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+     gMC->Gsbool("S03M", "L3DO");
+     gMC->Gsbool("S03M", "L3O1");
+     gMC->Gsbool("S03M", "L3O2");
+     gMC->Gsbool("S04M", "L3DO");
+     gMC->Gsbool("S04M", "L3O1");
+     gMC->Gsbool("S04M", "L3O2");
+
+// // Aluminium frames
+// // Outer frames
+//      pgpar[0] = 360/12/2;
+//      pgpar[1] = 360.;
+//      pgpar[2] = 12.;
+//      pgpar[3] =   2;
+//      pgpar[4] = -dframez/2;
+//      pgpar[5] = iChamber->ROuter();
+//      pgpar[6] = pgpar[5]+dframep;
+//      pgpar[7] = +dframez/2;
+//      pgpar[8] = pgpar[5];
+//      pgpar[9] = pgpar[6];
+//      gMC->Gsvolu("S03O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gsvolu("S04O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gspos("S03O",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03O",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+// //
+// // Inner frame
+//      tpar[0]= iChamber->RInner()-dframep;
+//      tpar[1]= iChamber->RInner();
+//      tpar[2]= dframez/2;
+//      gMC->Gsvolu("S03I", "TUBE", idAlu1, tpar, 3);
+//      gMC->Gsvolu("S04I", "TUBE", idAlu1, tpar, 3);
+
+//      gMC->Gspos("S03I",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03I",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+//
+// Frame Crosses
+     if (frameCrosses) {
+         // outside gas
+         // security for inside mother volume
+        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
+          * TMath::Cos(TMath::ASin(dframep1 /
+                                  (iChamber->ROuter() - iChamber->RInner())))
+          / 2.0;
+        bpar[1] = dframep1/2;
+        // total thickness will be (4 * bpar[2]) for each chamber,
+        // which has to be equal to (2 * dframez) - DAlu
+        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
+        gMC->Gsvolu("S03B", "BOX", idAlu1, bpar, 3);
+        gMC->Gsvolu("S04B", "BOX", idAlu1, bpar, 3);
+        
+        gMC->Gspos("S03B",1,"S03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",2,"S03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",3,"S03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",4,"S03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",5,"S03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",6,"S03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S03B",7,"S03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S03B",8,"S03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        
+        gMC->Gspos("S04B",1,"S04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",2,"S04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",3,"S04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",4,"S04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",5,"S04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",6,"S04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
+                   irot1,"ONLY");
+        gMC->Gspos("S04B",7,"S04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+        gMC->Gspos("S04B",8,"S04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
+                   irot2,"ONLY");
+     }
+//
+//   Chamber Material represented by Alu sheet
+     tpar[0]= iChamber->RInner();
+     tpar[1]= iChamber->ROuter();
+     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
+     gMC->Gsvolu("S03A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gsvolu("S04A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gspos("S03A", 1, "S03M", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04A", 1, "S04M", 0., 0., 0.,  0, "ONLY");
+//     
+//   Sensitive volumes
+     // tpar[2] = iChamber->DGas();
+     tpar[2] = iChamber->DGas()/2;
+     gMC->Gsvolu("S03G", "TUBE", idGas, tpar, 3);
+     gMC->Gsvolu("S04G", "TUBE", idGas, tpar, 3);
+     gMC->Gspos("S03G", 1, "S03A", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04G", 1, "S04A", 0., 0., 0.,  0, "ONLY");
+//
+// Frame Crosses to be placed inside gas 
+     // NONE: chambers are sensitive everywhere
+//      if (frameCrosses) {
+
+//      dr = (iChamber->ROuter() - iChamber->RInner());
+//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
+//      bpar[1] = dframep1/2;
+//      bpar[2] = iChamber->DGas()/2;
+//      gMC->Gsvolu("S03F", "BOX", idAlu1, bpar, 3);
+//      gMC->Gsvolu("S04F", "BOX", idAlu1, bpar, 3);
+        
+//      gMC->Gspos("S03F",1,"S03G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S03F",2,"S03G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S03F",3,"S03G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S03F",4,"S03G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+        
+//      gMC->Gspos("S04F",1,"S04G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S04F",2,"S04G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 irot1,"ONLY");
+//      gMC->Gspos("S04F",3,"S04G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      gMC->Gspos("S04F",4,"S04G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 irot2,"ONLY");
+//      }
+     }
+*/
+}
+
+//______________________________________________________________________________
+void AliMUONSt2GeometryBuilder::SetTransformations()
+{
+// Defines the transformations for the station2 chambers.
+// ---
+
+  AliMUONChamber* iChamber1 = GetChamber(2);
+  Double_t zpos1 = - iChamber1->Z(); 
+  iChamber1->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+
+  AliMUONChamber* iChamber2 = GetChamber(3);
+  Double_t zpos2 = - iChamber2->Z(); 
+  iChamber2->GetGeometry()
+    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+}
+
+//______________________________________________________________________________
+void AliMUONSt2GeometryBuilder::SetSensitiveVolumes()
+{
+// Defines the sensitive volumes for station2 chambers.
+// ---
+
+  GetChamber(2)->GetGeometry()->SetSensitiveVolume("S03G");
+  GetChamber(3)->GetGeometry()->SetSensitiveVolume("S04G");
+}
diff --git a/MUON/AliMUONSt2GeometryBuilder.h b/MUON/AliMUONSt2GeometryBuilder.h
new file mode 100644 (file)
index 0000000..0189537
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+//
+// Class AliMUONSt2GeometryBuilder
+// -----------------------------
+// MUON Station2 geometry construction class.
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_ST2_GEOMETRY_BUILDER_H
+#define ALI_MUON_ST2_GEOMETRY_BUILDER_H
+
+#include "AliMUONVGeometryBuilder.h"
+
+class AliMUON;
+
+class AliMUONSt2GeometryBuilder : public AliMUONVGeometryBuilder
+{
+  public:
+    AliMUONSt2GeometryBuilder(AliMUON* muon);
+    AliMUONSt2GeometryBuilder(const AliMUONSt2GeometryBuilder& rhs);
+    AliMUONSt2GeometryBuilder();
+    virtual ~AliMUONSt2GeometryBuilder();
+
+    // operators  
+    AliMUONSt2GeometryBuilder& operator = (const AliMUONSt2GeometryBuilder& rhs);
+  
+    // methods
+    virtual void CreateGeometry();
+    virtual void SetTransformations();
+    virtual void SetSensitiveVolumes();
+    
+  private:
+     AliMUON*  fMUON; // the MUON detector class 
+        
+  ClassDef(AliMUONSt2GeometryBuilder,1) // MUON chamber geometry base class
+};
+
+#endif //ALI_MUON_ST2_GEOMETRY_BUILDER_H
diff --git a/MUON/AliMUONTriggerGeometryBuilder.cxx b/MUON/AliMUONTriggerGeometryBuilder.cxx
new file mode 100644 (file)
index 0000000..f778e8f
--- /dev/null
@@ -0,0 +1,323 @@
+// $Id$
+//
+// Class AliMUONTriggerGeometryBuilder
+// -----------------------------------
+// MUON Trigger stations geometry construction class.
+//
+// Author: Philippe Crochette, LPC Clermont-Ferrand
+
+#include <TVirtualMC.h>
+#include <TGeoMatrix.h>
+
+#include "AliMUONTriggerGeometryBuilder.h"
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
+
+ClassImp(AliMUONTriggerGeometryBuilder)
+
+//______________________________________________________________________________
+AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder(AliMUON* muon)
+ : AliMUONVGeometryBuilder(&muon->Chamber(10), &muon->Chamber(11),&muon->Chamber(12),&muon->Chamber(13)),
+   fMUON(muon)
+{
+// Standard constructor
+
+}
+
+//______________________________________________________________________________
+AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder()
+ : AliMUONVGeometryBuilder(),
+   fMUON(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder(const AliMUONTriggerGeometryBuilder& rhs)
+  : AliMUONVGeometryBuilder(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONTriggerGeometryBuilder::~AliMUONTriggerGeometryBuilder() {
+//
+}
+
+//______________________________________________________________________________
+AliMUONTriggerGeometryBuilder& 
+AliMUONTriggerGeometryBuilder::operator = (const AliMUONTriggerGeometryBuilder& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+void AliMUONTriggerGeometryBuilder::CreateGeometry()
+{
+// From AliMUONv1::CreateGeometry()
+
+    /* 
+       zpos1 and zpos2 are the middle of the first and second
+       planes of station 1 (+1m for second station):
+       zpos1=(zpos1m+zpos1p)/2=(15999+16071)/2=16035 mm, thick/2=40 mm
+       zpos2=(zpos2m+zpos2p)/2=(16169+16241)/2=16205 mm, thick/2=40 mm
+       zposxm and zposxp= middles of gaz gaps within a detection plane
+       rem: the total thickness accounts for 1 mm of al on both
+       side of the RPCs (see zpos1 and zpos2)
+    */
+    
+    Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+    Int_t idAir= idtmed[1100]; // medium 1
+    Int_t idAlu1=idtmed[1103]; // medium 4
+    Float_t tpar[3];
+    Double_t dpar[3];    
+    
+// vertical gap between right and left chambers (kDXZERO*2=4cm)
+    const Float_t kDXZERO=2.; 
+// main distances for chamber definition in first plane/first station
+    const Float_t kXMIN=34.;       
+    const Float_t kXMED=51.;                                
+    const Float_t kXMAX=272.; 
+// kXMAX will become 255. in real life. segmentation to be updated accordingly
+// (see fig.2-4 & 2-5 of Local Trigger Board PRR)
+    const Float_t kYMIN=34.;                              
+    const Float_t kYMAX=51.;                              
+// inner/outer radius of flange between beam shield. and chambers (1/station)
+    const Float_t kRMIN[2]={50.,50.};
+    const Float_t kRMAX[2]={64.,68.};
+// z position of the middle of the gas gap in mother vol 
+    const Float_t kZm=-3.6;
+    const Float_t kZp=+3.6;     
+
+    AliMUONChamber *iChamber, *iChamber1;
+    iChamber1 = GetChamber(10);
+    Float_t zpos1=-iChamber1->Z(); 
+    
+// ratio of zpos1m/zpos1p and inverse for first plane
+    Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
+    Float_t zpm=1./zmp;
+    
+    Int_t icount=0;  // chamber counter (0 1 2 3)
+    
+    for (Int_t istation=0; istation<2; istation++) { // loop on stations
+       for (Int_t iplane=0; iplane<2; iplane++) { // loop on detection planes
+           
+           Int_t iVolNum=1; // counter Volume Number
+           icount = Int_t(iplane*TMath::Power(2,0))+
+               Int_t(istation*TMath::Power(2,1));
+           
+           iChamber = GetChamber(10+icount);
+           Float_t zpos = - iChamber->Z();          
+           
+// Flange between beam shielding and RPC 
+           tpar[0]= kRMIN[istation];
+           tpar[1]= kRMAX[istation];
+           tpar[2]= 4.0;           
+           char volFlange[5];
+           sprintf(volFlange,"SF%dA",icount+1);         
+           gMC->Gsvolu(volFlange,"TUBE",idAlu1,tpar,3);     // Al
+            // changed by ivana
+           //gMC->Gspos(volFlange,1,"ALIC",0.,0.,zpos,0,"MANY");
+           iChamber->GetGeometry()->AddEnvelope(volFlange, false);
+           
+// scaling factor
+           Float_t zRatio = zpos / zpos1;
+           
+// envelopes (same size except line 5, all virtual)
+           char volEnv[18][5];
+           tpar[1] = kYMIN * zRatio; 
+           tpar[2] = 0.4;
+           Int_t i=0;    // counter
+           for (Int_t icolumn=0; icolumn<2; icolumn++) {
+               for (Int_t iline=1; iline<10; iline++){
+                   tpar[0] = (kXMAX/2.) * zRatio;
+                   if (iline==5) tpar[0] = ((kXMAX-kXMED)/2.)*zRatio;
+                   if (icolumn==0) 
+                       sprintf(volEnv[i],"S%dL%d",icount,iline);
+                   else
+                       sprintf(volEnv[i],"S%dR%d",icount,iline);
+                   gMC->Gsvolu(volEnv[i],"BOX",idAir,tpar,0); 
+                   i++;
+               }
+           }
+
+// chamber prototype
+           tpar[0]= 0.;
+           tpar[1]= 0.;
+           tpar[2]= 0.;            
+           char volAlu[5];     // Alu 
+           char volBak[5];     // Bakelite
+           char volGaz[5];     // Gas streamer     
+           sprintf(volAlu,"SC%dA",icount+1);
+           sprintf(volBak,"SB%dA",icount+1);
+           sprintf(volGaz,"SG%dA",icount+1);
+           gMC->Gsvolu(volAlu,"BOX",idAlu1,tpar,0);         // Al
+           gMC->Gsvolu(volBak,"BOX",idtmed[1107],tpar,0);   // Bakelite
+           gMC->Gsvolu(volGaz,"BOX",idtmed[1106],tpar,0);   // Gas streamer
+           tpar[0] = -1.;
+           tpar[1] = -1.;
+           tpar[2] = 0.1;    
+           gMC->Gsposp(volGaz,1,volBak,0.,0.,0.,0,"ONLY",tpar,3);
+           tpar[2] = 0.3;
+           gMC->Gsposp(volBak,1,volAlu,0.,0.,0.,0,"ONLY",tpar,3);
+
+// chamber type A
+           Float_t xEnv = (kDXZERO+kXMED+(kXMAX-kXMED)/2.)*zRatio;
+           Float_t yEnvM = 0.;  // y low position of envelope in chamber
+           Float_t yEnvP = 0.;  // y up position of envelope in chamber
+           Float_t yEnvPsave = 0.; // tmp data
+           Float_t yEnvMsave = 0.; // tmp data
+           Float_t xpos = 0.; // x position of RPC in envelope     
+           Float_t ypos = 0.; // y position of RPC in envelope
+           dpar[2] = 0.4;          
+           dpar[0] = ((kXMAX-kXMED)/2.)*zRatio;
+           dpar[1] = kYMIN * zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[4], true, TGeoTranslation(xEnv,yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[13], true, TGeoTranslation(-xEnv,yEnvP,kZp));
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[4],iVolNum++,3, dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[13],iVolNum++,3, dpar);         
+
+// chamber type B (plus envelope chambers B & C)   
+           xEnv = (kDXZERO+kXMAX/2.)*zRatio;
+           yEnvPsave = yEnvP;
+           yEnvMsave = yEnvM;
+           yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
+           yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
+           dpar[0] = ((kXMAX-kXMIN)/2.) * zRatio;
+           dpar[1] = ((kYMAX-kYMIN)/2.) * zRatio;
+           xpos = kXMIN/2. * zRatio;
+           ypos = (kYMIN - kYMIN/4.) * zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[3], true, TGeoTranslation( xEnv,-yEnvP,kZp));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[5], true, TGeoTranslation( xEnv, yEnvP,kZp));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[12], true, TGeoTranslation(-xEnv,-yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[14], true, TGeoTranslation(-xEnv, yEnvM,kZm));
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[3],iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[5],iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[12],iVolNum++,TGeoTranslation(-xpos, ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[14],iVolNum++,TGeoTranslation(-xpos,-ypos,0.),3,dpar);
+
+// chamber type C (note: same Z than type B)
+           dpar[0] = (kXMAX/2)*zRatio;
+           dpar[1] = (kYMAX/2)*zRatio;
+           xpos = 0.;      
+           ypos = ((kYMAX - kYMIN)/2.) * zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[3],iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[5],iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[12],iVolNum++,TGeoTranslation(-xpos,-ypos,0.),3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[14],iVolNum++,TGeoTranslation(-xpos, ypos,0.),3,dpar);
+    
+// chamber type D, E and F (same size)
+// D       
+           yEnvPsave = yEnvP;
+           yEnvMsave = yEnvM;
+           yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
+           yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
+           dpar[0] = (kXMAX/2.)*zRatio;
+           dpar[1] =  kYMIN*zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[2], true, TGeoTranslation(xEnv, yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[6], true, TGeoTranslation(-xEnv, yEnvP,kZp));          
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[11], true, TGeoTranslation(xEnv,-yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[15], true, TGeoTranslation(-xEnv,-yEnvP,kZp));
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[2],iVolNum++,3, dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[6],iVolNum++,3, dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[11],iVolNum++,3, dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[15],iVolNum++,3, dpar);
+
+// E
+           yEnvPsave = yEnvP;
+           yEnvMsave = yEnvM;
+           yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
+           yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[1], true, TGeoTranslation(xEnv, yEnvP,kZp));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[7], true, TGeoTranslation(-xEnv, yEnvM,kZm));          
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[10], true, TGeoTranslation(xEnv,-yEnvP,kZp));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[16], true, TGeoTranslation(-xEnv,-yEnvM,kZm));
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[1],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[7],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[10],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[16],iVolNum++,3,dpar);
+
+
+// F
+           yEnvPsave = yEnvP;
+           yEnvMsave = yEnvM;
+           yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
+           yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[0], true, TGeoTranslation(xEnv, yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[8], true, TGeoTranslation(-xEnv, yEnvP,kZp));          
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[9], true, TGeoTranslation(xEnv,-yEnvM,kZm));
+           GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[17], true, TGeoTranslation(-xEnv,-yEnvP,kZp));
+
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[0],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[8],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[9],iVolNum++,3,dpar);
+           GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[17],iVolNum++,3,dpar);
+
+       } // end loop on detection planes
+    } // end loop on stations    
+}
+
+//______________________________________________________________________________
+void AliMUONTriggerGeometryBuilder::SetTransformations() 
+{
+// Defines the transformations for the trigger chambers.
+// ---
+    Double_t zpos1, zpos2;    
+    AliMUONChamber *iChamber1, *iChamber2;
+
+    iChamber1 = GetChamber(10);
+    zpos1= - iChamber1->Z(); 
+    iChamber1->GetGeometry()
+       ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+    
+    iChamber2 = GetChamber(11);
+    zpos2 = - iChamber2->Z(); 
+    iChamber2->GetGeometry()
+       ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+
+    iChamber1 = GetChamber(12);
+    zpos1 = - iChamber1->Z(); 
+    iChamber1->GetGeometry()
+       ->SetTranslation(TGeoTranslation(0., 0., zpos1));
+    
+    iChamber2 = GetChamber(13);
+    zpos2 = - iChamber2->Z(); 
+    iChamber2->GetGeometry()
+       ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+}
+
+//______________________________________________________________________________
+void AliMUONTriggerGeometryBuilder::SetSensitiveVolumes()
+{
+// Defines the sensitive volumes for trigger station chambers.
+// ---
+
+  GetChamber(10)->GetGeometry()->SetSensitiveVolume("SG1A");
+  GetChamber(11)->GetGeometry()->SetSensitiveVolume("SG2A");
+  GetChamber(12)->GetGeometry()->SetSensitiveVolume("SG3A");
+  GetChamber(13)->GetGeometry()->SetSensitiveVolume("SG4A");
+}
+
diff --git a/MUON/AliMUONTriggerGeometryBuilder.h b/MUON/AliMUONTriggerGeometryBuilder.h
new file mode 100644 (file)
index 0000000..2600fd5
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+//
+// Class AliMUONTriggerGeometryBuilder
+// -----------------------------------
+// MUON Trigger stations geometry construction class.
+//
+// Author: Philippe Crochette, LPC Clermont-Ferrand
+
+#ifndef ALI_MUON_TRIGGER_GEOMETRY_BUILDER_H
+#define ALI_MUON_TRIGGER_GEOMETRY_BUILDER_H
+
+#include "AliMUONVGeometryBuilder.h"
+
+class AliMUON;
+
+class AliMUONTriggerGeometryBuilder : public AliMUONVGeometryBuilder
+{
+  public:
+    AliMUONTriggerGeometryBuilder(AliMUON* muon);
+    AliMUONTriggerGeometryBuilder(const AliMUONTriggerGeometryBuilder& rhs);
+    AliMUONTriggerGeometryBuilder();
+    virtual ~AliMUONTriggerGeometryBuilder();
+
+    // operators  
+    AliMUONTriggerGeometryBuilder& operator = (const AliMUONTriggerGeometryBuilder& rhs);
+  
+    // methods
+    virtual void CreateGeometry();
+    virtual void SetTransformations();
+    virtual void SetSensitiveVolumes();
+    
+  private:
+     AliMUON*  fMUON; // the MUON detector class 
+        
+  ClassDef(AliMUONTriggerGeometryBuilder,1) // MUON chamber geometry base class
+};
+
+#endif //ALI_MUON_TRIGGER_GEOMETRY_BUILDER_H
diff --git a/MUON/AliMUONVGeometryBuilder.cxx b/MUON/AliMUONVGeometryBuilder.cxx
new file mode 100644 (file)
index 0000000..3132c17
--- /dev/null
@@ -0,0 +1,92 @@
+// $Id$
+//
+// Class AliMUONVGeometryBuilder
+// -----------------------------
+// Abstract base class for geometry construction per chamber(s).
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#include <TObjArray.h>
+
+#include "AliMUONVGeometryBuilder.h"
+#include "AliMUONChamber.h"
+
+ClassImp(AliMUONVGeometryBuilder)
+
+//______________________________________________________________________________
+AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(
+                                AliMUONChamber* ch1, AliMUONChamber* ch2,
+                                AliMUONChamber* ch3, AliMUONChamber* ch4,
+                                AliMUONChamber* ch5, AliMUONChamber* ch6)
+ : TObject(),
+   fChambers(0)
+ {
+// Standard constructor
+
+  // Create the chambers array
+  fChambers = new TObjArray();
+  
+  if (ch1) fChambers->Add(ch1);
+  if (ch2) fChambers->Add(ch2);
+  if (ch3) fChambers->Add(ch3);
+  if (ch4) fChambers->Add(ch4);
+  if (ch5) fChambers->Add(ch5);
+  if (ch6) fChambers->Add(ch6);
+
+}
+
+
+//______________________________________________________________________________
+AliMUONVGeometryBuilder::AliMUONVGeometryBuilder()
+ : TObject(),
+   fChambers(0)
+{
+// Default constructor
+}
+
+
+//______________________________________________________________________________
+AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs)
+  : TObject(rhs)
+{
+  Fatal("Copy constructor", 
+        "Copy constructor is not implemented.");
+}
+
+//______________________________________________________________________________
+AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder() {
+//
+
+  delete fChambers;
+}
+
+//______________________________________________________________________________
+AliMUONVGeometryBuilder& 
+AliMUONVGeometryBuilder::operator = (const AliMUONVGeometryBuilder& rhs) 
+{
+  // check assignement to self
+  if (this == &rhs) return *this;
+
+  Fatal("operator=", 
+        "Assignment operator is not implemented.");
+    
+  return *this;  
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+AliMUONChamber*  AliMUONVGeometryBuilder::GetChamber(Int_t chamberId) const
+{
+// Returns the chamber specified by chamberId
+// ---
+
+  for (Int_t i=0; i<fChambers->GetEntriesFast(); i++) {
+    AliMUONChamber* chamber = (AliMUONChamber*)fChambers->At(i);
+    if ( chamber->GetId() == chamberId) return chamber;
+  }   
+  
+  return 0;
+}  
diff --git a/MUON/AliMUONVGeometryBuilder.h b/MUON/AliMUONVGeometryBuilder.h
new file mode 100644 (file)
index 0000000..081114a
--- /dev/null
@@ -0,0 +1,76 @@
+// $Id$
+//
+// Class AliMUONVGeometryBuilder
+// -----------------------------
+// Abstract base class for geometry construction per chamber(s).
+//
+// Author: Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MUON_V_GEOMETRY_BUILDER_H
+#define ALI_MUON_V_GEOMETRY_BUILDER_H
+
+#include <TObject.h>
+
+class TGeoTranslation;
+class TGeoRotation;
+class TGeoCombiTrans;
+class TObjArray;
+
+class AliMUONChamber;
+class AliMUONChamberGeometry;
+
+class AliMUONVGeometryBuilder : public TObject
+{
+  public:
+    AliMUONVGeometryBuilder(AliMUONChamber* ch1,
+                            AliMUONChamber* ch2 = 0,
+                            AliMUONChamber* ch3 = 0,
+                            AliMUONChamber* ch4 = 0,
+                            AliMUONChamber* ch5 = 0,
+                            AliMUONChamber* ch6 = 0);
+    AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs);
+    AliMUONVGeometryBuilder();
+    virtual ~AliMUONVGeometryBuilder();
+
+    // operators  
+    AliMUONVGeometryBuilder& operator = (const AliMUONVGeometryBuilder& rhs);
+  
+    // methods
+    virtual void CreateMaterials() {}  // make = 0; ?
+                  // Function to be overriden in a concrete chamber/station
+                 // geometry builder class.
+                 // Only materials that are not defined in the common
+                 // functions should be defined here.
+    virtual void CreateGeometry() = 0;
+                  // Function to be overriden in a concrete chamber/station
+                 // geometry builder class.
+                 // The geometry built there should not be placed
+                 // in ALIC; but all volumes going to ALIC
+                 // have to be added as envelopes to the chamber
+                 // geometries
+                 // (They will be then placed automatically 
+                 // usind the provided transformation.
+    virtual void SetTransformations() = 0;
+                  // Function to be overriden in a concrete chamber/station
+                 // geometry class.
+                 // The transformation of each chamber(s) wrt ALICE
+                 // should be defined and set to its geometry class. 
+    virtual void SetSensitiveVolumes() = 0;
+                  // Function to be overriden in a concrete chamber/station
+                 // geometry class.
+                 // The sensitive volumes Ids for each chamber
+                 // should be defined and set to its geometry class. 
+                  
+  protected:
+    // methods
+    AliMUONChamber* GetChamber(Int_t chamberId) const;
+    
+  private:
+    // data members
+    TObjArray*  fChambers; // the chambers which geometry will be built
+                           // by this builder
+    
+  ClassDef(AliMUONVGeometryBuilder,1) // MUON chamber geometry base class
+};
+
+#endif //ALI_MUON_V_GEOMETRY_BUILDER_H
index 6ce42ba69a839b3f791e2500b7802bd64417bca1..b2234211305123c652cf071836e3dd8df47db6a9 100644 (file)
@@ -30,6 +30,7 @@
 #include "AliCallf77.h"
 #include "AliConst.h" 
 #include "AliMUONChamber.h"
+#include "AliMUONChamberGeometry.h"
 #include "AliMUONConstants.h"
 #include "AliMUONFactory.h"
 #include "AliMUONHit.h"
@@ -152,7 +153,9 @@ void AliMUONv0::Init()
            // trigger chambers
            sprintf(vName,"SG%2d",i);    
        }
-       ((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
+       //((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
+       ((AliMUONChamber*) (*fChambers)[i])
+          ->GetGeometry()->SetSensitiveVolume(gMC->VolId(vName));
     }
 }
 
@@ -179,7 +182,8 @@ void AliMUONv0::StepManager()
   id=gMC->CurrentVolID(copy);
   
     for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
-      if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
+      //if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
+      if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(id) ) {
          vol[0]=i; 
          idvol=i-1;
       }
diff --git a/MUON/AliMUONv2.h b/MUON/AliMUONv2.h
deleted file mode 100644 (file)
index 503b69c..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-#ifndef ALI_MUON_V2_H
-#define ALI_MUON_V2_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/* $Id$ */
-
-// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
-//
-// Class AliMUONv2
-// ---------------
-// Inherits from AliMUONv1 but with a more detailed
-// geometrical description of station 1 
-
-#include <TVector2.h>
-#include <TVector3.h>
-
-#include "AliMUONv1.h"
-#include "AliMUONSt1Types.h"
-#include "AliMUONSt1SpecialMotif.h"
-
-//typedef Float_t GReal_t; // for AliGeant3
-typedef Double_t GReal_t; // for VirtualMC
-
-class TTree;
-class TArrayI;
-class AliMpSector;
-
-class AliMUONv2 : public  AliMUONv1 
-{
-  public:
-    AliMUONv2();
-    AliMUONv2(const char* name, const char* title);
-    AliMUONv2(const AliMUONv2& rMUON);
-    virtual ~AliMUONv2();
-
-    virtual Int_t IsVersion() const;
-    virtual void  CreateMaterials();
-    virtual void  CreateGeometry();
-    virtual void  Init();
-   
-  protected:
-    // Copy Operator
-    AliMUONv2& operator = (const AliMUONv2& rhs);    
-    virtual Int_t  GetChamberId(Int_t volId) const;
-
-  private:
-    // Methods
-    //
-    void CreateHole();
-    void CreateDaughterBoard();
-    void CreateInnerLayers();
-    void CreateQuadrant(Int_t chamber);
-    void CreateFoamBox(const char* name,const TVector2& dimensions);
-    void CreatePlaneSegment(const char* name,const TVector2& dimensions,
-                     Int_t nofHoles);
-    void CreateFrame(Int_t chamber);
-
-    void PlaceInnerLayers(Int_t chamber);
-    void PlaceSector(AliMpSector* sector, TSpecialMap specialMap,
-                     const TVector3& where, Bool_t reflectZ, Int_t chamber);
-                    
-    TString QuadrantMLayerName(Int_t chamber) const;
-    TString QuadrantNLayerName(Int_t chamber) const;
-    TString QuadrantFLayerName(Int_t chamber) const;
-    TString GasVolumeName(const TString& name, Int_t chamber) const;
-
-    void   AddChamberGid(Int_t id,Int_t volName,Int_t idx);
-    Bool_t IsInChamber(Int_t ich, Int_t volGid) const;   
-
-    GReal_t TotalHzPlane() const ;         // Total mechanical plane half Size
-    GReal_t TotalHzDaughter() const ;      // Total daughter plane half Size
-    GReal_t TotalHz() const ;              // Total plane half Size
-       
-    // Constants
-    //
-    static const GReal_t fgkHzPadPlane;    // Pad plane
-    static const GReal_t fgkHzFoam;        // Foam of mechanicalplane
-    static const GReal_t fgkHzFR4;         // FR4 of mechanical plane
-    static const GReal_t fgkHzSnPb;        // Pad/Kapton connection (66 pt)
-    static const GReal_t fgkHzKapton;      // Kapton
-    static const GReal_t fgkHzBergPlastic; // Berg connector 
-    static const GReal_t fgkHzBergCopper;  // Berg connector (80 pt)
-    static const GReal_t fgkHzDaughter;    // Daughter board
-    static const GReal_t fgkHzGas;         // ArCO2 Gas
-        
-    // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHxHole;   // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHyHole;   // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHxBergPlastic; // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHyBergPlastic; // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHxBergCopper;  // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHyBergCopper;  // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHxKapton;      // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHyKapton;      // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHxDaughter;    // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkHyDaughter;    // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkOffsetX;       // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkOffsetY;       // Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkDeltaFilleEtamX;// Sensitive copper pads, foam layer, PCB and electronics model parameters
-    static const GReal_t fgkDeltaFilleEtamY;// Sensitive copper pads, foam layer, PCB and electronics model parameters
-
-    static const GReal_t fgkDeltaQuadLHC; //LHC Origin wrt Quadrant Origin
-    static const GReal_t fgkFrameOffset;  
-
-    // Quadrant Mother volume - TUBS1   
-    static const GReal_t fgkMotherIR1;
-    static const GReal_t fgkMotherOR1; 
-    static const GReal_t fgkMotherThick1;  
-    static const GReal_t fgkMotherPhiL1; 
-    static const GReal_t fgkMotherPhiU1;
-
-    // Quadrant Mother volume - TUBS2 (2 copies at different Z's)   
-    static const GReal_t fgkMotherIR2;
-    static const GReal_t fgkMotherOR2; 
-    static const GReal_t fgkMotherThick2;  
-    static const GReal_t fgkMotherPhiL2; 
-    static const GReal_t fgkMotherPhiU2;    
-
-    static const char* fgkHoleName;          // prefix for automatic volume naming
-    static const char* fgkQuadrantMLayerName;// prefix for automatic volume naming
-    static const char* fgkQuadrantNLayerName;// prefix for automatic volume naming
-    static const char* fgkQuadrantFLayerName;// prefix for automatic volume naming
-    static const char* fgkDaughterName;      // prefix for automatic volume naming
-    static const char  fgkFoamLayerSuffix;   // suffix for automatic volume naming
-
-    // Data members
-    //
-    Float_t  fRadlCopper;  //! copper computed radiation length
-    Float_t  fRadlFoam;    //! foam   computed radiation length
-    Float_t  fRadlFR4;     //! FR4    computed radiation length
-    TArrayI* fChamberV2[2];// Sensitive volumes IDs    
-    
-  ClassDef(AliMUONv2,1)  // MUON Detector base class
-};
-
-// inline functions
-
-inline Int_t AliMUONv2::IsVersion () const 
-{ return 2; }
-
-inline GReal_t AliMUONv2::TotalHzPlane() const 
-//{ return fgkHzPadPlane + fgkHzFoam + fgkHzFR4; }
-{ return fgkHzFoam + fgkHzFR4; }
-
-inline GReal_t AliMUONv2::TotalHzDaughter() const 
-{ return fgkHzBergPlastic + fgkHzDaughter; }
-
-inline GReal_t AliMUONv2::TotalHz() const 
-{ return TotalHzPlane() + TotalHzDaughter(); }
-
-inline TString AliMUONv2::QuadrantMLayerName(Int_t chamber) const
-{ return Form("%s%d",fgkQuadrantMLayerName,chamber); }
-
-inline TString AliMUONv2::QuadrantNLayerName(Int_t chamber) const
-{ return Form("%s%d",fgkQuadrantNLayerName,chamber); }
-
-inline TString AliMUONv2::QuadrantFLayerName(Int_t chamber) const
-{ return Form("%s%d",fgkQuadrantFLayerName,chamber); }
-
-inline void AliMUONv2::AddChamberGid(Int_t id,Int_t volName,Int_t idx)
-{ fChamberV2[id]->AddAt(volName,idx); }
-
-
-#endif //ALI_MUON_V2_H
diff --git a/MUON/AliMUONv3.cxx b/MUON/AliMUONv3.cxx
new file mode 100644 (file)
index 0000000..a29e3e8
--- /dev/null
@@ -0,0 +1,1950 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *      SigmaEffect_thetadegrees                                                                  *
+ * 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 purpeateose. It is      *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/////////////////////////////////////////////////////////
+//  Manager and hits classes for set:MUON version 3    //
+/////////////////////////////////////////////////////////
+
+// Old MUONv1 class
+// (AliMUONv1.h 1.11, AliMUONv1.cxx 1.60)
+// - now replaced with a new one where geometry and materials
+// are created using new geometry builders
+// (See ALIMUON*GeometryBuilder classes)
+// To be removed later
+
+#include <TRandom.h>
+#include <TF1.h>
+#include <TClonesArray.h>
+#include <TLorentzVector.h>   
+#include <TVirtualMC.h>
+#include <TParticle.h>
+
+#include "AliConst.h" 
+#include "AliMUONChamber.h"
+#include "AliMUONConstants.h"
+#include "AliMUONFactory.h"
+#include "AliMUONHit.h"
+#include "AliMUONTriggerCircuit.h"
+#include "AliMUONChamberGeometry.h"
+#include "AliMUONv3.h"
+#include "AliMagF.h"
+#include "AliRun.h"
+#include "AliMC.h"
+
+ClassImp(AliMUONv3)
+//___________________________________________
+AliMUONv3::AliMUONv3() : AliMUON()
+  ,fTrackMomentum(), fTrackPosition()
+{
+// Constructor
+    fChambers   = 0;
+    fStations   = 0;
+    fStepManagerVersionOld  = kFALSE;
+    fAngleEffect = kTRUE;
+    fStepMaxInActiveGas     = 0.6;
+    fStepSum    =  0x0;
+    fDestepSum  =  0x0;
+    fElossRatio =  0x0;
+    fAngleEffect10   = 0x0;
+    fAngleEffectNorma= 0x0;
+} 
+//___________________________________________
+AliMUONv3::AliMUONv3(const char *name, const char *title)
+  : AliMUON(name,title), fTrackMomentum(), fTrackPosition()
+{
+// Constructor
+    // By default include all stations
+    fStations = new Int_t[5];
+    for (Int_t i=0; i<5; i++) fStations[i] = 1;
+
+    AliMUONFactory factory;
+    factory.Build(this, title);
+
+    fStepManagerVersionOld = kFALSE;
+    fAngleEffect = kTRUE;
+    fStepMaxInActiveGas = 0.6;
+
+    fStepSum   = new Float_t [AliMUONConstants::NCh()];
+    fDestepSum = new Float_t [AliMUONConstants::NCh()];
+    for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
+      fStepSum[i] =0.0;
+      fDestepSum[i]=0.0;
+    }
+    // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
+    fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.); 
+    fElossRatio->SetParameter(0,1.02138);
+    fElossRatio->SetParameter(1,-9.54149e-02);
+    fElossRatio->SetParameter(2,+7.83433e-02); 
+    fElossRatio->SetParameter(3,-9.98208e-03);
+    fElossRatio->SetParameter(4,+3.83279e-04);
+
+    // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
+    fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
+    fAngleEffect10->SetParameter(0, 1.90691e+02);
+    fAngleEffect10->SetParameter(1,-6.62258e+01);
+    fAngleEffect10->SetParameter(2,+1.28247e+01);
+    // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)  
+    // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
+    fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
+    fAngleEffectNorma->SetParameter(0,4.148);
+    fAngleEffectNorma->SetParameter(1,-6.809e-01);
+    fAngleEffectNorma->SetParameter(2,5.151e-02);
+    fAngleEffectNorma->SetParameter(3,-1.490e-03);
+}
+
+//___________________________________________
+void AliMUONv3::CreateGeometry()
+{
+//
+//   Note: all chambers have the same structure, which could be 
+//   easily parameterised. This was intentionally not done in order
+//   to give a starting point for the implementation of the actual 
+//   design of each station. 
+  Int_t *idtmed = fIdtmed->GetArray()-1099;
+
+//   Distance between Stations
+//
+     Float_t bpar[3];
+     Float_t tpar[3];
+//      Float_t pgpar[10];
+     Float_t zpos1, zpos2, zfpos;
+     // Outer excess and inner recess for mother volume radius
+     // with respect to ROuter and RInner
+     Float_t dframep=.001; // Value for station 3 should be 6 ...
+     // Width (RdPhi) of the frame crosses for stations 1 and 2 (cm)
+//      Float_t dframep1=.001;
+     Float_t dframep1 = 11.0;
+//      Bool_t frameCrosses=kFALSE;     
+     Bool_t frameCrosses=kTRUE;     
+     Float_t *dum=0;
+     
+//      Float_t dframez=0.9;
+     // Half of the total thickness of frame crosses (including DAlu)
+     // for each chamber in stations 1 and 2:
+     // 3% of X0 of composite material,
+     // but taken as Aluminium here, with same thickness in number of X0
+     Float_t dframez = 3. * 8.9 / 100;
+//      Float_t dr;
+     Float_t dstation;
+
+//
+//   Rotation matrices in the x-y plane  
+     Int_t idrotm[1199];
+//   phi=   0 deg
+     AliMatrix(idrotm[1100],  90.,   0., 90.,  90., 0., 0.);
+//   phi=  90 deg
+     AliMatrix(idrotm[1101],  90.,  90., 90., 180., 0., 0.);
+//   phi= 180 deg
+     AliMatrix(idrotm[1102],  90., 180., 90., 270., 0., 0.);
+//   phi= 270 deg
+     AliMatrix(idrotm[1103],  90., 270., 90.,   0., 0., 0.);
+//
+     Float_t phi=2*TMath::Pi()/12/2;
+
+//
+//   pointer to the current chamber
+//   pointer to the current chamber
+     Int_t idAlu1=idtmed[1103]; // medium 4
+     Int_t idAlu2=idtmed[1104]; // medium 5
+//     Int_t idAlu1=idtmed[1100];
+//     Int_t idAlu2=idtmed[1100];
+     Int_t idAir=idtmed[1100]; // medium 1
+//      Int_t idGas=idtmed[1105]; // medium 6 = Ar-isoC4H10 gas
+     Int_t idGas=idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
+     
+
+     AliMUONChamber *iChamber, *iChamber1, *iChamber2;
+
+     if (fStations[0]) {
+        
+//********************************************************************
+//                            Station 1                             **
+//********************************************************************
+//  CONCENTRIC
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[0];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[1];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = TMath::Abs(zpos2 - zpos1);
+     // DGas decreased from standard one (0.5)
+     iChamber->SetDGas(0.4); iChamber2->SetDGas(0.4);
+     // DAlu increased from standard one (3% of X0),
+     // because more electronics with smaller pads
+     iChamber->SetDAlu(3.5 * 8.9 / 100.); iChamber2->SetDAlu(3.5 * 8.9 / 100.);
+     zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+     
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     gMC->Gsvolu("S01M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S02M", "TUBE", idAir, tpar, 3);
+     gMC->Gspos("S01M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     gMC->Gspos("S02M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");     
+// // Aluminium frames
+// // Outer frames
+//      pgpar[0] = 360/12/2;
+//      pgpar[1] = 360.;
+//      pgpar[2] = 12.;
+//      pgpar[3] =   2;
+//      pgpar[4] = -dframez/2;
+//      pgpar[5] = iChamber->ROuter();
+//      pgpar[6] = pgpar[5]+dframep1;
+//      pgpar[7] = +dframez/2;
+//      pgpar[8] = pgpar[5];
+//      pgpar[9] = pgpar[6];
+//      gMC->Gsvolu("S01O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gsvolu("S02O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gspos("S01O",1,"S01M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S01O",2,"S01M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S02O",1,"S02M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S02O",2,"S02M", 0.,0.,+zfpos,  0,"ONLY");
+// //
+// // Inner frame
+//      tpar[0]= iChamber->RInner()-dframep1;
+//      tpar[1]= iChamber->RInner();
+//      tpar[2]= dframez/2;
+//      gMC->Gsvolu("S01I", "TUBE", idAlu1, tpar, 3);
+//      gMC->Gsvolu("S02I", "TUBE", idAlu1, tpar, 3);
+
+//      gMC->Gspos("S01I",1,"S01M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S01I",2,"S01M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S02I",1,"S02M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S02I",2,"S02M", 0.,0.,+zfpos,  0,"ONLY");
+//
+// Frame Crosses
+     if (frameCrosses) {
+         // outside gas
+         // security for inside mother volume
+        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
+          * TMath::Cos(TMath::ASin(dframep1 /
+                                  (iChamber->ROuter() - iChamber->RInner())))
+          / 2.0;
+        bpar[1] = dframep1/2;
+        // total thickness will be (4 * bpar[2]) for each chamber,
+        // which has to be equal to (2 * dframez) - DAlu
+        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
+        gMC->Gsvolu("S01B", "BOX", idAlu1, bpar, 3);
+        gMC->Gsvolu("S02B", "BOX", idAlu1, bpar, 3);
+        
+        gMC->Gspos("S01B",1,"S01M", -iChamber->RInner()-bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S01B",2,"S01M",  iChamber->RInner()+bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S01B",3,"S01M", 0, -iChamber->RInner()-bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S01B",4,"S01M", 0,  iChamber->RInner()+bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S01B",5,"S01M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S01B",6,"S01M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S01B",7,"S01M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S01B",8,"S01M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        
+        gMC->Gspos("S02B",1,"S02M", -iChamber->RInner()-bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S02B",2,"S02M",  iChamber->RInner()+bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S02B",3,"S02M", 0, -iChamber->RInner()-bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S02B",4,"S02M", 0,  iChamber->RInner()+bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S02B",5,"S02M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S02B",6,"S02M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S02B",7,"S02M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S02B",8,"S02M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+     }
+//
+//   Chamber Material represented by Alu sheet
+     tpar[0]= iChamber->RInner();
+     tpar[1]= iChamber->ROuter();
+     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
+     gMC->Gsvolu("S01A", "TUBE",  idAlu2, tpar, 3);
+     gMC->Gsvolu("S02A", "TUBE",idAlu2, tpar, 3);
+     gMC->Gspos("S01A", 1, "S01M", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S02A", 1, "S02M", 0., 0., 0.,  0, "ONLY");
+//     
+//   Sensitive volumes
+     // tpar[2] = iChamber->DGas();
+     tpar[2] = iChamber->DGas()/2;
+     gMC->Gsvolu("S01G", "TUBE", idGas, tpar, 3);
+     gMC->Gsvolu("S02G", "TUBE", idGas, tpar, 3);
+     gMC->Gspos("S01G", 1, "S01A", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S02G", 1, "S02A", 0., 0., 0.,  0, "ONLY");
+//
+// Frame Crosses to be placed inside gas
+     // NONE: chambers are sensitive everywhere
+//      if (frameCrosses) {
+
+//      dr = (iChamber->ROuter() - iChamber->RInner());
+//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
+//      bpar[1] = dframep1/2;
+//      bpar[2] = iChamber->DGas()/2;
+//      gMC->Gsvolu("S01F", "BOX", idAlu1, bpar, 3);
+//      gMC->Gsvolu("S02F", "BOX", idAlu1, bpar, 3);
+        
+//      gMC->Gspos("S01F",1,"S01G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S01F",2,"S01G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S01F",3,"S01G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      gMC->Gspos("S01F",4,"S01G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+        
+//      gMC->Gspos("S02F",1,"S02G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S02F",2,"S02G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S02F",3,"S02G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      gMC->Gspos("S02F",4,"S02G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      }
+     }
+     if (fStations[1]) {
+        
+//********************************************************************
+//                            Station 2                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[2];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[3];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = TMath::Abs(zpos2 - zpos1);
+     // DGas and DAlu not changed from standard values
+     zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+     
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     gMC->Gsvolu("S03M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S04M", "TUBE", idAir, tpar, 3);
+     gMC->Gspos("S03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     gMC->Gspos("S04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+     gMC->Gsbool("S03M", "L3DO");
+     gMC->Gsbool("S03M", "L3O1");
+     gMC->Gsbool("S03M", "L3O2");
+     gMC->Gsbool("S04M", "L3DO");
+     gMC->Gsbool("S04M", "L3O1");
+     gMC->Gsbool("S04M", "L3O2");
+
+// // Aluminium frames
+// // Outer frames
+//      pgpar[0] = 360/12/2;
+//      pgpar[1] = 360.;
+//      pgpar[2] = 12.;
+//      pgpar[3] =   2;
+//      pgpar[4] = -dframez/2;
+//      pgpar[5] = iChamber->ROuter();
+//      pgpar[6] = pgpar[5]+dframep;
+//      pgpar[7] = +dframez/2;
+//      pgpar[8] = pgpar[5];
+//      pgpar[9] = pgpar[6];
+//      gMC->Gsvolu("S03O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gsvolu("S04O", "PGON", idAlu1, pgpar, 10);
+//      gMC->Gspos("S03O",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03O",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04O",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+// //
+// // Inner frame
+//      tpar[0]= iChamber->RInner()-dframep;
+//      tpar[1]= iChamber->RInner();
+//      tpar[2]= dframez/2;
+//      gMC->Gsvolu("S03I", "TUBE", idAlu1, tpar, 3);
+//      gMC->Gsvolu("S04I", "TUBE", idAlu1, tpar, 3);
+
+//      gMC->Gspos("S03I",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S03I",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
+//      gMC->Gspos("S04I",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
+//
+// Frame Crosses
+     if (frameCrosses) {
+         // outside gas
+         // security for inside mother volume
+        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
+          * TMath::Cos(TMath::ASin(dframep1 /
+                                  (iChamber->ROuter() - iChamber->RInner())))
+          / 2.0;
+        bpar[1] = dframep1/2;
+        // total thickness will be (4 * bpar[2]) for each chamber,
+        // which has to be equal to (2 * dframez) - DAlu
+        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
+        gMC->Gsvolu("S03B", "BOX", idAlu1, bpar, 3);
+        gMC->Gsvolu("S04B", "BOX", idAlu1, bpar, 3);
+        
+        gMC->Gspos("S03B",1,"S03M", -iChamber->RInner()-bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S03B",2,"S03M", +iChamber->RInner()+bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S03B",3,"S03M", 0, -iChamber->RInner()-bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S03B",4,"S03M", 0, +iChamber->RInner()+bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S03B",5,"S03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S03B",6,"S03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S03B",7,"S03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S03B",8,"S03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        
+        gMC->Gspos("S04B",1,"S04M", -iChamber->RInner()-bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S04B",2,"S04M", +iChamber->RInner()+bpar[0] , 0, zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S04B",3,"S04M", 0, -iChamber->RInner()-bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S04B",4,"S04M", 0, +iChamber->RInner()+bpar[0] , zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S04B",5,"S04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S04B",6,"S04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
+                   idrotm[1100],"ONLY");
+        gMC->Gspos("S04B",7,"S04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+        gMC->Gspos("S04B",8,"S04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
+                   idrotm[1101],"ONLY");
+     }
+//
+//   Chamber Material represented by Alu sheet
+     tpar[0]= iChamber->RInner();
+     tpar[1]= iChamber->ROuter();
+     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
+     gMC->Gsvolu("S03A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gsvolu("S04A", "TUBE", idAlu2, tpar, 3);
+     gMC->Gspos("S03A", 1, "S03M", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04A", 1, "S04M", 0., 0., 0.,  0, "ONLY");
+//     
+//   Sensitive volumes
+     // tpar[2] = iChamber->DGas();
+     tpar[2] = iChamber->DGas()/2;
+     gMC->Gsvolu("S03G", "TUBE", idGas, tpar, 3);
+     gMC->Gsvolu("S04G", "TUBE", idGas, tpar, 3);
+     gMC->Gspos("S03G", 1, "S03A", 0., 0., 0.,  0, "ONLY");
+     gMC->Gspos("S04G", 1, "S04A", 0., 0., 0.,  0, "ONLY");
+//
+// Frame Crosses to be placed inside gas 
+     // NONE: chambers are sensitive everywhere
+//      if (frameCrosses) {
+
+//      dr = (iChamber->ROuter() - iChamber->RInner());
+//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
+//      bpar[1] = dframep1/2;
+//      bpar[2] = iChamber->DGas()/2;
+//      gMC->Gsvolu("S03F", "BOX", idAlu1, bpar, 3);
+//      gMC->Gsvolu("S04F", "BOX", idAlu1, bpar, 3);
+        
+//      gMC->Gspos("S03F",1,"S03G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S03F",2,"S03G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S03F",3,"S03G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      gMC->Gspos("S03F",4,"S03G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+        
+//      gMC->Gspos("S04F",1,"S04G", +iChamber->RInner()+bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S04F",2,"S04G", -iChamber->RInner()-bpar[0] , 0, 0, 
+//                 idrotm[1100],"ONLY");
+//      gMC->Gspos("S04F",3,"S04G", 0, +iChamber->RInner()+bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      gMC->Gspos("S04F",4,"S04G", 0, -iChamber->RInner()-bpar[0] , 0, 
+//                 idrotm[1101],"ONLY");
+//      }
+     }
+     // define the id of tracking media:
+     Int_t idCopper = idtmed[1110];
+     Int_t idGlass  = idtmed[1111];
+     Int_t idCarbon = idtmed[1112];
+     Int_t idRoha   = idtmed[1113];
+
+      // sensitive area: 40*40 cm**2
+     const Float_t ksensLength = 40.; 
+     const Float_t ksensHeight = 40.; 
+     const Float_t ksensWidth  = 0.5; // according to TDR fig 2.120 
+     const Int_t ksensMaterial = idGas;
+     const Float_t kyOverlap   = 1.5; 
+
+     // PCB dimensions in cm; width: 30 mum copper   
+     const Float_t kpcbLength  = ksensLength; 
+     const Float_t kpcbHeight  = 60.; 
+     const Float_t kpcbWidth   = 0.003;   
+     const Int_t   kpcbMaterial= idCopper;
+
+     // Insulating material: 200 mum glass fiber glued to pcb  
+     const Float_t kinsuLength = kpcbLength; 
+     const Float_t kinsuHeight = kpcbHeight; 
+     const Float_t kinsuWidth  = 0.020;   
+     const Int_t kinsuMaterial = idGlass;
+
+     // Carbon fiber panels: 200mum carbon/epoxy skin   
+     const Float_t kpanelLength = ksensLength; 
+     const Float_t kpanelHeight = ksensHeight; 
+     const Float_t kpanelWidth  = 0.020;      
+     const Int_t kpanelMaterial = idCarbon;
+
+     // rohacell between the two carbon panels   
+     const Float_t krohaLength = ksensLength; 
+     const Float_t krohaHeight = ksensHeight; 
+     const Float_t krohaWidth  = 0.5;
+     const Int_t krohaMaterial = idRoha;
+
+     // Frame around the slat: 2 sticks along length,2 along height  
+     // H: the horizontal ones 
+     const Float_t khFrameLength = kpcbLength; 
+     const Float_t khFrameHeight = 1.5; 
+     const Float_t khFrameWidth  = ksensWidth; 
+     const Int_t khFrameMaterial = idGlass;
+
+     // V: the vertical ones 
+     const Float_t kvFrameLength = 4.0; 
+     const Float_t kvFrameHeight = ksensHeight + khFrameHeight; 
+     const Float_t kvFrameWidth  = ksensWidth;
+     const Int_t kvFrameMaterial = idGlass;
+
+     // B: the horizontal border filled with rohacell 
+     const Float_t kbFrameLength = khFrameLength; 
+     const Float_t kbFrameHeight = (kpcbHeight - ksensHeight)/2. - khFrameHeight; 
+     const Float_t kbFrameWidth  = khFrameWidth;
+     const Int_t kbFrameMaterial = idRoha;
+
+     // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper)
+     const Float_t knulocLength = 2.5; 
+     const Float_t knulocHeight = 7.5; 
+     const Float_t knulocWidth  = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
+     const Int_t   knulocMaterial = idCopper;
+
+     const Float_t kslatHeight = kpcbHeight; 
+     const Float_t kslatWidth = ksensWidth + 2.*(kpcbWidth + kinsuWidth + 
+                                              2.* kpanelWidth + krohaWidth);
+     const Int_t kslatMaterial = idAir;
+     const Float_t kdSlatLength = kvFrameLength; // border on left and right 
+
+     Float_t spar[3];  
+     Int_t i, j;
+
+     // the panel volume contains the rohacell
+
+     Float_t twidth = 2 * kpanelWidth + krohaWidth; 
+     Float_t panelpar[3] = { kpanelLength/2., kpanelHeight/2., twidth/2. }; 
+     Float_t rohapar[3] = { krohaLength/2., krohaHeight/2., krohaWidth/2. }; 
+
+     // insulating material contains PCB-> gas-> 2 borders filled with rohacell
+
+     twidth = 2*(kinsuWidth + kpcbWidth) + ksensWidth;  
+     Float_t insupar[3] = { kinsuLength/2., kinsuHeight/2., twidth/2. }; 
+     twidth -= 2 * kinsuWidth; 
+     Float_t pcbpar[3] = { kpcbLength/2., kpcbHeight/2., twidth/2. }; 
+     Float_t senspar[3] = { ksensLength/2., ksensHeight/2., ksensWidth/2. }; 
+     Float_t theight = 2*khFrameHeight + ksensHeight;
+     Float_t hFramepar[3]={khFrameLength/2., theight/2., khFrameWidth/2.}; 
+     Float_t bFramepar[3]={kbFrameLength/2., kbFrameHeight/2., kbFrameWidth/2.}; 
+     Float_t vFramepar[3]={kvFrameLength/2., kvFrameHeight/2., kvFrameWidth/2.}; 
+     Float_t nulocpar[3]={knulocLength/2., knulocHeight/2., knulocWidth/2.}; 
+     Float_t xx;
+     Float_t xxmax = (kbFrameLength - knulocLength)/2.; 
+     Int_t index=0;
+     
+     if (fStations[2]) {
+        
+//********************************************************************
+//                            Station 3                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[4];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[5];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = TMath::Abs(zpos2 - zpos1);
+
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5;
+
+     char *slats5Mother = "S05M";
+     char *slats6Mother = "S06M";
+     Float_t zoffs5 = 0;
+     Float_t zoffs6 = 0;
+
+     if (gAlice->GetModule("DIPO")) {
+       slats5Mother="DDIP";
+       slats6Mother="DDIP";
+
+       zoffs5 = TMath::Abs(zpos1);
+       zoffs6 = TMath::Abs(zpos2);
+     }
+
+     else {
+       gMC->Gsvolu("S05M", "TUBE", idAir, tpar, 3);
+       gMC->Gsvolu("S06M", "TUBE", idAir, tpar, 3);
+       gMC->Gspos("S05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+       gMC->Gspos("S06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+     }
+
+     // volumes for slat geometry (xx=5,..,10 chamber id): 
+     // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
+     // SxxG                          -->   Sensitive volume (gas)
+     // SxxP                          -->   PCB (copper) 
+     // SxxI                          -->   Insulator (vetronite) 
+     // SxxC                          -->   Carbon panel 
+     // SxxR                          -->   Rohacell
+     // SxxH, SxxV                    -->   Horizontal and Vertical frames (vetronite)
+     // SB5x                          -->   Volumes for the 35 cm long PCB
+     // slat dimensions: slat is a MOTHER volume!!! made of air
+
+     // only for chamber 5: slat 1 has a PCB shorter by 5cm!
+
+     Float_t tlength = 35.;
+     Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
+     Float_t rohapar2[3]   = { tlength/2., rohapar[1],   rohapar[2]}; 
+     Float_t insupar2[3]   = { tlength/2., insupar[1],   insupar[2]}; 
+     Float_t pcbpar2[3]    = { tlength/2., pcbpar[1],    pcbpar[2]}; 
+     Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
+     Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
+     Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
+
+     const Int_t knSlats3 = 5;  // number of slats per quadrant
+     const Int_t knPCB3[knSlats3] = {3,3,4,3,2}; // n PCB per slat
+     const Float_t kxpos3[knSlats3] = {31., 40., 0., 0., 0.};
+     Float_t slatLength3[knSlats3]; 
+
+     // create and position the slat (mother) volumes 
+
+     char volNam5[5];
+     char volNam6[5];
+     Float_t xSlat3;
+
+     Float_t spar2[3];
+     for (i = 0; i<knSlats3; i++){
+       slatLength3[i] = kpcbLength * knPCB3[i] + 2. * kdSlatLength; 
+       xSlat3 = slatLength3[i]/2. - kvFrameLength/2. + kxpos3[i]; 
+       if (i==1 || i==0) slatLength3[i] -=  2. *kdSlatLength; // frame out in PCB with circular border 
+       Float_t ySlat31 =  ksensHeight * i - kyOverlap * i; 
+       Float_t ySlat32 = -ksensHeight * i + kyOverlap * i; 
+       spar[0] = slatLength3[i]/2.; 
+       spar[1] = kslatHeight/2.;
+       spar[2] = kslatWidth/2. * 1.01; 
+       // take away 5 cm from the first slat in chamber 5
+       Float_t xSlat32 = 0;
+       if (i==1 || i==2) { // 1 pcb is shortened by 5cm
+        spar2[0] = spar[0]-5./2.;
+        xSlat32 = xSlat3 - 5/2.;
+       }
+       else {
+        spar2[0] = spar[0];
+        xSlat32 = xSlat3;
+       }
+       spar2[1] = spar[1];
+       spar2[2] = spar[2]; 
+       Float_t dzCh3=spar[2] * 1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2];
+
+       if (gAlice->GetModule("DIPO")) {zSlat*=-1.;}
+
+       sprintf(volNam5,"S05%d",i);
+       gMC->Gsvolu(volNam5,"BOX",kslatMaterial,spar2,3);
+       gMC->Gspos(volNam5, i*4+1,slats5Mother, -xSlat32, ySlat31, zoffs5-zSlat-2.*dzCh3, 0, "ONLY");
+       gMC->Gspos(volNam5, i*4+2,slats5Mother, +xSlat32, ySlat31, zoffs5-zSlat+2.*dzCh3, 0, "ONLY");
+       
+       if (i>0) { 
+        gMC->Gspos(volNam5, i*4+3,slats5Mother,-xSlat32, ySlat32, zoffs5-zSlat-2.*dzCh3, 0, "ONLY");
+        gMC->Gspos(volNam5, i*4+4,slats5Mother,+xSlat32, ySlat32, zoffs5-zSlat+2.*dzCh3, 0, "ONLY");
+       }
+       sprintf(volNam6,"S06%d",i);
+       gMC->Gsvolu(volNam6,"BOX",kslatMaterial,spar,3);
+       gMC->Gspos(volNam6, i*4+1,slats6Mother,-xSlat3, ySlat31, zoffs6-zSlat-2.*dzCh3, 0, "ONLY");
+       gMC->Gspos(volNam6, i*4+2,slats6Mother,+xSlat3, ySlat31, zoffs6-zSlat+2.*dzCh3, 0, "ONLY");
+       if (i>0) { 
+        gMC->Gspos(volNam6, i*4+3,slats6Mother,-xSlat3, ySlat32, zoffs6-zSlat-2.*dzCh3, 0, "ONLY");
+        gMC->Gspos(volNam6, i*4+4,slats6Mother,+xSlat3, ySlat32, zoffs6-zSlat+2.*dzCh3, 0, "ONLY");
+       }
+     }
+
+     // create the panel volume 
+     gMC->Gsvolu("S05C","BOX",kpanelMaterial,panelpar,3);
+     gMC->Gsvolu("SB5C","BOX",kpanelMaterial,panelpar2,3);
+     gMC->Gsvolu("S06C","BOX",kpanelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S05R","BOX",krohaMaterial,rohapar,3);
+     gMC->Gsvolu("SB5R","BOX",krohaMaterial,rohapar2,3);
+     gMC->Gsvolu("S06R","BOX",krohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S05I","BOX",kinsuMaterial,insupar,3);
+     gMC->Gsvolu("SB5I","BOX",kinsuMaterial,insupar2,3);
+     gMC->Gsvolu("S06I","BOX",kinsuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S05P","BOX",kpcbMaterial,pcbpar,3);
+     gMC->Gsvolu("SB5P","BOX",kpcbMaterial,pcbpar2,3);
+     gMC->Gsvolu("S06P","BOX",kpcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+     gMC->Gsvolu("S05G","BOX",ksensMaterial,dum,0);
+     gMC->Gsvolu("S06G","BOX",ksensMaterial,dum,0);
+
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S05V","BOX",kvFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S06V","BOX",kvFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+     gMC->Gsvolu("S05H","BOX",khFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("SB5H","BOX",khFrameMaterial,hFramepar2,3);
+     gMC->Gsvolu("S06H","BOX",khFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S05B","BOX",kbFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("SB5B","BOX",kbFrameMaterial,bFramepar2,3);
+     gMC->Gsvolu("S06B","BOX",kbFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<knSlats3; i++){
+       sprintf(volNam5,"S05%d",i);
+       sprintf(volNam6,"S06%d",i);
+       Float_t xvFrame  = (slatLength3[i] - kvFrameLength)/2.;
+       Float_t xvFrame2  = xvFrame;
+       if ( i==1 || i ==2 ) xvFrame2 -= 5./2.;
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+        gMC->Gspos("S05V",2*i-1,volNam5, xvFrame2, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S05V",2*i  ,volNam5,-xvFrame2, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S06V",2*i-1,volNam6, xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S06V",2*i  ,volNam6,-xvFrame, 0., 0. , 0, "ONLY");
+       }       
+       // position the panels and the insulating material 
+       for (j=0; j<knPCB3[i]; j++){
+        index++;
+        Float_t xx = ksensLength * (-knPCB3[i]/2.+j+.5); 
+        Float_t xx2 = xx + 5/2.; 
+        
+        Float_t zPanel = spar[2] - panelpar[2]; 
+        if ( (i==1 || i==2) && j == knPCB3[i]-1) { // 1 pcb is shortened by 5cm 
+          gMC->Gspos("SB5C",2*index-1,volNam5, xx, 0., zPanel , 0, "ONLY");
+          gMC->Gspos("SB5C",2*index  ,volNam5, xx, 0.,-zPanel , 0, "ONLY");
+          gMC->Gspos("SB5I",index    ,volNam5, xx, 0., 0      , 0, "ONLY");
+        }
+        else if ( (i==1 || i==2) && j < knPCB3[i]-1) {
+          gMC->Gspos("S05C",2*index-1,volNam5, xx2, 0., zPanel , 0, "ONLY");
+          gMC->Gspos("S05C",2*index  ,volNam5, xx2, 0.,-zPanel , 0, "ONLY");
+          gMC->Gspos("S05I",index    ,volNam5, xx2, 0., 0 , 0, "ONLY");
+        }
+        else {
+          gMC->Gspos("S05C",2*index-1,volNam5, xx, 0., zPanel , 0, "ONLY");
+          gMC->Gspos("S05C",2*index  ,volNam5, xx, 0.,-zPanel , 0, "ONLY");
+          gMC->Gspos("S05I",index    ,volNam5, xx, 0., 0 , 0, "ONLY");
+        }
+        gMC->Gspos("S06C",2*index-1,volNam6, xx, 0., zPanel , 0, "ONLY");
+        gMC->Gspos("S06C",2*index  ,volNam6, xx, 0.,-zPanel , 0, "ONLY");
+        gMC->Gspos("S06I",index,volNam6, xx, 0., 0 , 0, "ONLY");
+       } 
+     }
+     
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S05R",1,"S05C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5R",1,"SB5C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06R",1,"S06C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3); 
+     gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( kpcbHeight - kbFrameHeight ) / 2.; 
+     gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
+
+     // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S05N","BOX",knulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S06N","BOX",knulocMaterial,nulocpar,3);
+     index = 0;
+     Float_t xxmax2 = xxmax - 5./2.;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*knulocLength) { 
+       index++; 
+       gMC->Gspos("S05N",2*index-1,"S05B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S05N",2*index  ,"S05B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+       if (xx > -xxmax2 && xx< xxmax2) {
+        gMC->Gspos("S05N",2*index-1,"SB5B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+        gMC->Gspos("S05N",2*index  ,"SB5B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+       }
+       gMC->Gspos("S06N",2*index-1,"S06B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S06N",2*index  ,"S06B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+     }
+     
+     // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = ksensHeight/2. - kyOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Float_t divpar[3];
+     Double_t dydiv= ksensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     imax = 1; 
+     Float_t rmin = 33.; 
+     Float_t z1 = spar[2], z2=2*spar[2]*1.01; 
+     if (gAlice->GetModule("DIPO")) {z1*=-1.;}
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (kpcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = ksensWidth/2.; 
+       Float_t xvol=(kpcbLength+xdiv)/2.+1.999;
+       Float_t yvol=ydiv + dydiv/2.; 
+       //printf ("y ll = %f y ur = %f \n",yvol - divpar[1], yvol + divpar[1]); 
+       gMC->Gsposp("S05G",imax+4*idiv+1,slats5Mother,-xvol, yvol, zoffs5-z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S06G",imax+4*idiv+1,slats6Mother,-xvol, yvol, zoffs6-z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S05G",imax+4*idiv+2,slats5Mother,-xvol,-yvol, zoffs5-z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S06G",imax+4*idiv+2,slats6Mother,-xvol,-yvol, zoffs6-z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S05G",imax+4*idiv+3,slats5Mother,+xvol, yvol, zoffs5-z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S06G",imax+4*idiv+3,slats6Mother,+xvol, yvol, zoffs6-z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S05G",imax+4*idiv+4,slats5Mother,+xvol,-yvol, zoffs5-z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S06G",imax+4*idiv+4,slats6Mother,+xvol,-yvol, zoffs6-z1+z2, 0, "ONLY",divpar,3);
+     }
+     }
+     
+ if (fStations[3]) {
+
+//********************************************************************
+//                            Station 4                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[6];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[7];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = TMath::Abs(zpos2 - zpos1);
+//      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2; // not used any more
+     
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/4;
+
+     gMC->Gsvolu("S07M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S08M", "TUBE", idAir, tpar, 3);
+     gMC->Gspos("S07M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     gMC->Gspos("S08M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+     
+
+     const Int_t knSlats4 = 6;  // number of slats per quadrant
+     const Int_t knPCB4[knSlats4] = {4,4,5,5,4,3}; // n PCB per slat
+     const Float_t kxpos4[knSlats4] = {38.5, 40., 0., 0., 0., 0.};
+     Float_t slatLength4[knSlats4];     
+
+     // create and position the slat (mother) volumes 
+
+     char volNam7[5];
+     char volNam8[5];
+     Float_t xSlat4;
+     Float_t ySlat4;
+
+     for (i = 0; i<knSlats4; i++){
+       slatLength4[i] = kpcbLength * knPCB4[i] + 2. * kdSlatLength; 
+       xSlat4 = slatLength4[i]/2. - kvFrameLength/2. + kxpos4[i]; 
+       if (i==1) slatLength4[i] -=  2. *kdSlatLength; // frame out in PCB with circular border 
+       ySlat4 =  ksensHeight * i - kyOverlap *i;
+       
+       spar[0] = slatLength4[i]/2.; 
+       spar[1] = kslatHeight/2.;
+       spar[2] = kslatWidth/2.*1.01; 
+       Float_t dzCh4=spar[2]*1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? spar[2] : -spar[2]; 
+       sprintf(volNam7,"S07%d",i);
+       gMC->Gsvolu(volNam7,"BOX",kslatMaterial,spar,3);
+       gMC->Gspos(volNam7, i*4+1,"S07M",-xSlat4, ySlat4, -zSlat-2.*dzCh4, 0, "ONLY");
+       gMC->Gspos(volNam7, i*4+2,"S07M",+xSlat4, ySlat4, -zSlat+2.*dzCh4, 0, "ONLY");
+       if (i>0) { 
+        gMC->Gspos(volNam7, i*4+3,"S07M",-xSlat4,-ySlat4, -zSlat-2.*dzCh4, 0, "ONLY");
+        gMC->Gspos(volNam7, i*4+4,"S07M",+xSlat4,-ySlat4, -zSlat+2.*dzCh4, 0, "ONLY");
+       }
+       sprintf(volNam8,"S08%d",i);
+       gMC->Gsvolu(volNam8,"BOX",kslatMaterial,spar,3);
+       gMC->Gspos(volNam8, i*4+1,"S08M",-xSlat4, ySlat4, -zSlat-2.*dzCh4, 0, "ONLY");
+       gMC->Gspos(volNam8, i*4+2,"S08M",+xSlat4, ySlat4, -zSlat+2.*dzCh4, 0, "ONLY");
+       if (i>0) { 
+        gMC->Gspos(volNam8, i*4+3,"S08M",-xSlat4,-ySlat4, -zSlat-2.*dzCh4, 0, "ONLY");
+        gMC->Gspos(volNam8, i*4+4,"S08M",+xSlat4,-ySlat4, -zSlat+2.*dzCh4, 0, "ONLY");
+       }
+     }
+     
+
+     // create the panel volume 
+     gMC->Gsvolu("S07C","BOX",kpanelMaterial,panelpar,3);
+     gMC->Gsvolu("S08C","BOX",kpanelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S07R","BOX",krohaMaterial,rohapar,3);
+     gMC->Gsvolu("S08R","BOX",krohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S07I","BOX",kinsuMaterial,insupar,3);
+     gMC->Gsvolu("S08I","BOX",kinsuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S07P","BOX",kpcbMaterial,pcbpar,3);
+     gMC->Gsvolu("S08P","BOX",kpcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+
+     gMC->Gsvolu("S07G","BOX",ksensMaterial,dum,0);
+     gMC->Gsvolu("S08G","BOX",ksensMaterial,dum,0);
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S07V","BOX",kvFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S08V","BOX",kvFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+     gMC->Gsvolu("S07H","BOX",khFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("S08H","BOX",khFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S07B","BOX",kbFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("S08B","BOX",kbFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<knSlats4; i++){
+       sprintf(volNam7,"S07%d",i);
+       sprintf(volNam8,"S08%d",i);
+       Float_t xvFrame  = (slatLength4[i] - kvFrameLength)/2.;
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+        gMC->Gspos("S07V",2*i-1,volNam7, xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S07V",2*i  ,volNam7,-xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S08V",2*i-1,volNam8, xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S08V",2*i  ,volNam8,-xvFrame, 0., 0. , 0, "ONLY");
+       }
+       // position the panels and the insulating material 
+       for (j=0; j<knPCB4[i]; j++){
+        index++;
+        Float_t xx = ksensLength * (-knPCB4[i]/2.+j+.5); 
+
+        Float_t zPanel = spar[2] - panelpar[2]; 
+        gMC->Gspos("S07C",2*index-1,volNam7, xx, 0., zPanel , 0, "ONLY");
+        gMC->Gspos("S07C",2*index  ,volNam7, xx, 0.,-zPanel , 0, "ONLY");
+        gMC->Gspos("S08C",2*index-1,volNam8, xx, 0., zPanel , 0, "ONLY");
+        gMC->Gspos("S08C",2*index  ,volNam8, xx, 0.,-zPanel , 0, "ONLY");
+
+        gMC->Gspos("S07I",index,volNam7, xx, 0., 0 , 0, "ONLY");
+        gMC->Gspos("S08I",index,volNam8, xx, 0., 0 , 0, "ONLY");
+       } 
+     }
+
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S07R",1,"S07C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08R",1,"S08C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( kpcbHeight - kbFrameHeight ) / 2.; 
+     gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
+
+     // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S07N","BOX",knulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S08N","BOX",knulocMaterial,nulocpar,3);
+     index = 0;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*knulocLength) { 
+       index++; 
+       gMC->Gspos("S07N",2*index-1,"S07B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S07N",2*index  ,"S07B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S08N",2*index-1,"S08B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S08N",2*index  ,"S08B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+     }
+
+     // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = ksensHeight/2. - kyOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Float_t divpar[3];
+     Double_t dydiv= ksensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     imax = 1; 
+     Float_t rmin = 40.; 
+     Float_t z1 = -spar[2], z2=2*spar[2]*1.01; 
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (kpcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = ksensWidth/2.; 
+       Float_t xvol=(kpcbLength+xdiv)/2.+1.999;
+       Float_t yvol=ydiv + dydiv/2.;
+       gMC->Gsposp("S07G",imax+4*idiv+1,"S07M", -xvol, yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S08G",imax+4*idiv+1,"S08M", -xvol, yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S07G",imax+4*idiv+2,"S07M", -xvol,-yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S08G",imax+4*idiv+2,"S08M", -xvol,-yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S07G",imax+4*idiv+3,"S07M", xvol, yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S08G",imax+4*idiv+3,"S08M", xvol, yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S07G",imax+4*idiv+4,"S07M", xvol,-yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S08G",imax+4*idiv+4,"S08M", xvol,-yvol, -z1+z2, 0, "ONLY",divpar,3);
+     }
+
+
+
+
+
+ }
+
+ if (fStations[4]) {
+     
+
+//********************************************************************
+//                            Station 5                             **
+//********************************************************************
+     // indices 1 and 2 for first and second chambers in the station
+     // iChamber (first chamber) kept for other quanties than Z,
+     // assumed to be the same in both chambers
+     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[8];
+     iChamber2 =(AliMUONChamber*) (*fChambers)[9];
+     zpos1=iChamber1->Z(); 
+     zpos2=iChamber2->Z();
+     dstation = TMath::Abs(zpos2 - zpos1);
+//      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2; // not used any more
+     
+//
+//   Mother volume
+     tpar[0] = iChamber->RInner()-dframep; 
+     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
+     tpar[2] = dstation/5.;
+
+     gMC->Gsvolu("S09M", "TUBE", idAir, tpar, 3);
+     gMC->Gsvolu("S10M", "TUBE", idAir, tpar, 3);
+     gMC->Gspos("S09M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
+     gMC->Gspos("S10M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
+
+
+     const Int_t knSlats5 = 7;  // number of slats per quadrant
+     const Int_t knPCB5[knSlats5] = {5,5,6,6,5,4,3}; // n PCB per slat
+     const Float_t kxpos5[knSlats5] = {38.5, 40., 0., 0., 0., 0., 0.};
+     Float_t slatLength5[knSlats5]; 
+     char volNam9[5];
+     char volNam10[5];
+     Float_t xSlat5;
+     Float_t ySlat5;
+
+     for (i = 0; i<knSlats5; i++){
+       slatLength5[i] = kpcbLength * knPCB5[i] + 2. * kdSlatLength; 
+       xSlat5 = slatLength5[i]/2. - kvFrameLength/2. +kxpos5[i]; 
+       if (i==1 || i==0) slatLength5[i] -=  2. *kdSlatLength; // frame out in PCB with circular border 
+       ySlat5 = ksensHeight * i - kyOverlap * i; 
+       spar[0] = slatLength5[i]/2.; 
+       spar[1] = kslatHeight/2.;
+       spar[2] = kslatWidth/2. * 1.01; 
+       Float_t dzCh5=spar[2]*1.01;
+       // zSlat to be checked (odd downstream or upstream?)
+       Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
+       sprintf(volNam9,"S09%d",i);
+       gMC->Gsvolu(volNam9,"BOX",kslatMaterial,spar,3);
+       gMC->Gspos(volNam9, i*4+1,"S09M",-xSlat5, ySlat5, -zSlat-2.*dzCh5, 0, "ONLY");
+       gMC->Gspos(volNam9, i*4+2,"S09M",+xSlat5, ySlat5, -zSlat+2.*dzCh5, 0, "ONLY");
+       if (i>0) { 
+          gMC->Gspos(volNam9, i*4+3,"S09M",-xSlat5,-ySlat5, -zSlat-2.*dzCh5, 0, "ONLY");
+          gMC->Gspos(volNam9, i*4+4,"S09M",+xSlat5,-ySlat5, -zSlat+2.*dzCh5, 0, "ONLY");
+       }
+       sprintf(volNam10,"S10%d",i);
+       gMC->Gsvolu(volNam10,"BOX",kslatMaterial,spar,3);
+       gMC->Gspos(volNam10, i*4+1,"S10M",-xSlat5, ySlat5, -zSlat-2.*dzCh5, 0, "ONLY");
+       gMC->Gspos(volNam10, i*4+2,"S10M",+xSlat5, ySlat5, -zSlat+2.*dzCh5, 0, "ONLY");
+       if (i>0) { 
+          gMC->Gspos(volNam10, i*4+3,"S10M",-xSlat5,-ySlat5, -zSlat-2.*dzCh5, 0, "ONLY");
+          gMC->Gspos(volNam10, i*4+4,"S10M",+xSlat5,-ySlat5, -zSlat+2.*dzCh5, 0, "ONLY");
+       }
+     }
+
+     // create the panel volume 
+     gMC->Gsvolu("S09C","BOX",kpanelMaterial,panelpar,3);
+     gMC->Gsvolu("S10C","BOX",kpanelMaterial,panelpar,3);
+
+     // create the rohacell volume 
+
+     gMC->Gsvolu("S09R","BOX",krohaMaterial,rohapar,3);
+     gMC->Gsvolu("S10R","BOX",krohaMaterial,rohapar,3);
+
+     // create the insulating material volume 
+
+     gMC->Gsvolu("S09I","BOX",kinsuMaterial,insupar,3);
+     gMC->Gsvolu("S10I","BOX",kinsuMaterial,insupar,3);
+
+     // create the PCB volume 
+
+     gMC->Gsvolu("S09P","BOX",kpcbMaterial,pcbpar,3);
+     gMC->Gsvolu("S10P","BOX",kpcbMaterial,pcbpar,3);
+     // create the sensitive volumes,
+
+     gMC->Gsvolu("S09G","BOX",ksensMaterial,dum,0);
+     gMC->Gsvolu("S10G","BOX",ksensMaterial,dum,0);
+
+     // create the vertical frame volume 
+
+     gMC->Gsvolu("S09V","BOX",kvFrameMaterial,vFramepar,3);
+     gMC->Gsvolu("S10V","BOX",kvFrameMaterial,vFramepar,3);
+
+     // create the horizontal frame volume 
+
+     gMC->Gsvolu("S09H","BOX",khFrameMaterial,hFramepar,3);
+     gMC->Gsvolu("S10H","BOX",khFrameMaterial,hFramepar,3);
+
+     // create the horizontal border volume 
+
+     gMC->Gsvolu("S09B","BOX",kbFrameMaterial,bFramepar,3);
+     gMC->Gsvolu("S10B","BOX",kbFrameMaterial,bFramepar,3);
+
+     index=0; 
+     for (i = 0; i<knSlats5; i++){
+       sprintf(volNam9,"S09%d",i);
+       sprintf(volNam10,"S10%d",i);
+       Float_t xvFrame  = (slatLength5[i] - kvFrameLength)/2.;
+       // position the vertical frames 
+       if (i!=1 && i!=0) { 
+        gMC->Gspos("S09V",2*i-1,volNam9, xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S09V",2*i  ,volNam9,-xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S10V",2*i-1,volNam10, xvFrame, 0., 0. , 0, "ONLY");
+        gMC->Gspos("S10V",2*i  ,volNam10,-xvFrame, 0., 0. , 0, "ONLY");
+       }
+       
+       // position the panels and the insulating material 
+       for (j=0; j<knPCB5[i]; j++){
+        index++;
+        Float_t xx = ksensLength * (-knPCB5[i]/2.+j+.5); 
+
+        Float_t zPanel = spar[2] - panelpar[2]; 
+        gMC->Gspos("S09C",2*index-1,volNam9, xx, 0., zPanel , 0, "ONLY");
+        gMC->Gspos("S09C",2*index  ,volNam9, xx, 0.,-zPanel , 0, "ONLY");
+        gMC->Gspos("S10C",2*index-1,volNam10, xx, 0., zPanel , 0, "ONLY");
+        gMC->Gspos("S10C",2*index  ,volNam10, xx, 0.,-zPanel , 0, "ONLY");
+
+        gMC->Gspos("S09I",index,volNam9, xx, 0., 0 , 0, "ONLY");
+        gMC->Gspos("S10I",index,volNam10, xx, 0., 0 , 0, "ONLY");
+       } 
+     }
+
+     // position the rohacell volume inside the panel volume
+     gMC->Gspos("S09R",1,"S09C",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10R",1,"S10C",0.,0.,0.,0,"ONLY"); 
+
+     // position the PCB volume inside the insulating material volume
+     gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
+     // position the horizontal frame volume inside the PCB volume
+     gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
+     gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
+     // position the sensitive volume inside the horizontal frame volume
+     gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
+     gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
+     // position the border volumes inside the PCB volume
+     Float_t yborder = ( kpcbHeight - kbFrameHeight ) / 2.; 
+     gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
+     gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
+
+     // create the NULOC volume and position it in the horizontal frame
+
+     gMC->Gsvolu("S09N","BOX",knulocMaterial,nulocpar,3);
+     gMC->Gsvolu("S10N","BOX",knulocMaterial,nulocpar,3);
+     index = 0;
+     for (xx = -xxmax; xx<=xxmax; xx+=2*knulocLength) { 
+       index++; 
+       gMC->Gspos("S09N",2*index-1,"S09B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S09N",2*index  ,"S09B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S10N",2*index-1,"S10B", xx, 0.,-kbFrameWidth/4., 0, "ONLY");
+       gMC->Gspos("S10N",2*index  ,"S10B", xx, 0., kbFrameWidth/4., 0, "ONLY");
+     }
+     // position the volumes approximating the circular section of the pipe
+     Float_t yoffs = ksensHeight/2. - kyOverlap; 
+     Float_t epsilon = 0.001; 
+     Int_t ndiv=6;
+     Float_t divpar[3];
+     Double_t dydiv= ksensHeight/ndiv;
+     Double_t ydiv = yoffs -dydiv;
+     Int_t imax=0; 
+     //     for (Int_t islat=0; islat<knSlats3; islat++) imax += knPCB3[islat]; 
+     imax = 1; 
+     Float_t rmin = 40.; 
+     Float_t z1 = spar[2], z2=2*spar[2]*1.01; 
+     for (Int_t idiv=0;idiv<ndiv; idiv++){ 
+       ydiv+= dydiv;
+       Float_t xdiv = 0.; 
+       if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
+       divpar[0] = (kpcbLength-xdiv)/2.; 
+       divpar[1] = dydiv/2. - epsilon;
+       divpar[2] = ksensWidth/2.; 
+       Float_t xvol=(kpcbLength+xdiv)/2. + 1.999;
+       Float_t yvol=ydiv + dydiv/2.;
+       gMC->Gsposp("S09G",imax+4*idiv+1,"S09M", -xvol, yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S10G",imax+4*idiv+1,"S10M", -xvol, yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S09G",imax+4*idiv+2,"S09M", -xvol,-yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S10G",imax+4*idiv+2,"S10M", -xvol,-yvol, -z1-z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S09G",imax+4*idiv+3,"S09M", +xvol, yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S10G",imax+4*idiv+3,"S10M", +xvol, yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S09G",imax+4*idiv+4,"S09M", +xvol,-yvol, -z1+z2, 0, "ONLY",divpar,3);
+       gMC->Gsposp("S10G",imax+4*idiv+4,"S10M", +xvol,-yvol, -z1+z2, 0, "ONLY",divpar,3);
+     }
+
+ }
+//********************************************************************
+//                            Trigger                               **
+//******************************************************************** 
+ /* 
+    zpos1 and zpos2 are the middle of the first and second
+    planes of station 1 (+1m for second station):
+    zpos1=(zpos1m+zpos1p)/2=(15999+16071)/2=16035 mm, thick/2=40 mm
+    zpos2=(zpos2m+zpos2p)/2=(16169+16241)/2=16205 mm, thick/2=40 mm
+    zposxm and zposxp= middles of gaz gaps within a detection plane
+    rem: the total thickness accounts for 1 mm of al on both
+    side of the RPCs (see zpos1 and zpos2)
+ */
+
+// vertical gap between right and left chambers (kDXZERO*2=4cm)
+ const Float_t kDXZERO=2.; 
+// main distances for chamber definition in first plane/first station
+ const Float_t kXMIN=34.;       
+ const Float_t kXMED=51.;                                
+ const Float_t kXMAX=272.; 
+// kXMAX will become 255. in real life. segmentation to be updated accordingly
+// (see fig.2-4 & 2-5 of Local Trigger Board PRR)
+ const Float_t kYMIN=34.;                              
+ const Float_t kYMAX=51.;                              
+// inner/outer radius of flange between beam shield. and chambers (1/station)
+ const Float_t kRMIN[2]={50.,50.};
+ const Float_t kRMAX[2]={64.,68.};
+// z position of the middle of the gas gap in mother vol 
+ const Float_t kZm=-3.6;
+ const Float_t kZp=+3.6;     
+ iChamber1 = (AliMUONChamber*) (*fChambers)[10];     
+ zpos1 = iChamber1->Z();
+
+// ratio of zpos1m/zpos1p and inverse for first plane
+ Float_t zmp=(zpos1+3.6)/(zpos1-3.6);
+ Float_t zpm=1./zmp;
+ Int_t icount=0; // chamber counter (0 1 2 3)
+ for (Int_t istation=0; istation<2; istation++) { // loop on stations   
+     for (Int_t iplane=0; iplane<2; iplane++) {          // loop on detection planes
+        
+        Int_t iVolNum=1; // counter Volume Number
+        icount = Int_t(iplane*TMath::Power(2,0))+
+            Int_t(istation*TMath::Power(2,1));
+        
+        char volPlane[5]; 
+        sprintf(volPlane,"SM%d%d",istation+1,iplane+1);
+        
+        iChamber = (AliMUONChamber*) (*fChambers)[10+icount];
+        Float_t zpos = iChamber->Z();       
+        
+// mother volume 
+        tpar[0] = iChamber->RInner(); 
+        tpar[1] = iChamber->ROuter(); 
+        tpar[2] = 4.0;    
+        gMC->Gsvolu(volPlane,"TUBE",idAir,tpar,3);
+        
+// Flange between beam shielding and RPC 
+        tpar[0]= kRMIN[istation];
+        tpar[1]= kRMAX[istation];
+        tpar[2]= 4.0;
+        
+        char volFlange[5];
+        sprintf(volFlange,"SF%dA",icount+1);    
+        gMC->Gsvolu(volFlange,"TUBE",idAlu1,tpar,3);     //Al
+        gMC->Gspos(volFlange,1,volPlane,0.,0.,0.,0,"MANY");
+        
+// scaling factor
+        Float_t zRatio = zpos / zpos1;
+        
+// chamber prototype
+        tpar[0]= 0.;
+        tpar[1]= 0.;
+        tpar[2]= 0.;
+        
+        char volAlu[5]; // Alu
+        char volBak[5]; // Bakelite
+        char volGaz[5]; // Gas streamer
+        
+        sprintf(volAlu,"SC%dA",icount+1);
+        sprintf(volBak,"SB%dA",icount+1);
+        sprintf(volGaz,"SG%dA",icount+1);
+        
+        gMC->Gsvolu(volAlu,"BOX",idAlu1,tpar,0);           // Al
+        gMC->Gsvolu(volBak,"BOX",idtmed[1107],tpar,0);     // Bakelite
+        gMC->Gsvolu(volGaz,"BOX",idtmed[1106],tpar,0);     // Gas streamer
+        
+// chamber type A
+        tpar[0] = -1.;
+        tpar[1] = -1.;
+        
+        Float_t xA=(kDXZERO+kXMED+(kXMAX-kXMED)/2.)*zRatio;
+        Float_t yAm=0.;
+        Float_t yAp=0.;
+        
+        tpar[2] = 0.1;    
+        gMC->Gsposp(volGaz,1,volBak,0.,0.,0.,0,"ONLY",tpar,3);
+        tpar[2] = 0.3;
+        gMC->Gsposp(volBak,1,volAlu,0.,0.,0.,0,"ONLY",tpar,3);
+        
+        tpar[2] = 0.4;
+        tpar[0] = ((kXMAX-kXMED)/2.)*zRatio;
+        tpar[1] = kYMIN*zRatio;
+        
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xA,yAm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xA,yAp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsbool(volAlu,volFlange);
+        
+// chamber type B    
+        Float_t tpar1save=tpar[1];
+        Float_t y1msave=yAm;
+        Float_t y1psave=yAp;
+        
+        tpar[0] = ((kXMAX-kXMIN)/2.) * zRatio;
+        tpar[1] = ((kYMAX-kYMIN)/2.) * zRatio;
+        
+        Float_t xB=(kDXZERO+kXMIN)*zRatio+tpar[0];
+        Float_t yBp=(y1msave+tpar1save)*zpm+tpar[1];
+        Float_t yBm=(y1psave+tpar1save)*zmp+tpar[1];    
+
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xB, yBp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xB, yBm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xB,-yBp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xB,-yBm,-kZm,0,"ONLY",tpar,3);
+        
+// chamber type C (note : same Z than type B)
+        tpar1save=tpar[1];
+        y1msave=yBm;
+        y1psave=yBp;
+        
+        tpar[0] = (kXMAX/2)*zRatio;
+        tpar[1] = (kYMAX/2)*zRatio;
+        
+        Float_t xC=kDXZERO*zRatio+tpar[0];
+        Float_t yCp=(y1psave+tpar1save)*1.+tpar[1];
+        Float_t yCm=(y1msave+tpar1save)*1.+tpar[1];
+        
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,-xC, yCp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, xC, yCm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,-xC,-yCp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, xC,-yCm,-kZm,0,"ONLY",tpar,3);
+                
+// chamber type D, E and F (same size)        
+        tpar1save=tpar[1];
+        y1msave=yCm;
+        y1psave=yCp;
+        
+        tpar[0] = (kXMAX/2.)*zRatio;
+        tpar[1] =  kYMIN*zRatio;
+        
+        Float_t xD=kDXZERO*zRatio+tpar[0];
+        Float_t yDp=(y1msave+tpar1save)*zpm+tpar[1];
+        Float_t yDm=(y1psave+tpar1save)*zmp+tpar[1];
+        
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xD, yDm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xD, yDp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xD,-yDm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xD,-yDp,-kZp,0,"ONLY",tpar,3);
+        
+        tpar1save=tpar[1];
+        y1msave=yDm;
+        y1psave=yDp;
+        Float_t yEp=(y1msave+tpar1save)*zpm+tpar[1];
+        Float_t yEm=(y1psave+tpar1save)*zmp+tpar[1];
+        
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xD, yEp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xD, yEm,-kZm,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xD,-yEp,-kZp,0,"ONLY",tpar,3);
+        gMC->Gsposp(volAlu,iVolNum++,volPlane,  xD,-yEm,-kZm,0,"ONLY",tpar,3);
+        
+        tpar1save=tpar[1];
+        y1msave=yEm;
+        y1psave=yEp;
+        Float_t yFp=(y1msave+tpar1save)*zpm+tpar[1];
+        Float_t yFm=(y1psave+tpar1save)*zmp+tpar[1];
+        
+        gMC->Gsposp(volAlu,iVolNum++,volPlane, -xD, yFm,-kZm,0,"ONLY",tpar,3);