]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICH.cxx
Removed fDeadZone data member.
[u/mrichter/AliRoot.git] / RICH / AliRICH.cxx
index bfc8cd8dbc272a5cc8350105035b0c971f0a360c..2b2c5df64baba5aaf0266c4b28549eb0dc65aee0 100644 (file)
 
 /*
   $Log$
+  Revision 1.39  2001/01/22 21:40:24  jbarbosa
+  Removing magic numbers
+
+  Revision 1.37  2000/12/20 14:07:25  jbarbosa
+  Removed dependencies on TGeant3 (thanks to F. Carminati and I. Hrivnacova)
+
+  Revision 1.36  2000/12/18 17:45:54  jbarbosa
+  Cleaned up PadHits object.
+
+  Revision 1.35  2000/12/15 16:49:40  jbarbosa
+  Geometry and materials updates (wire supports, pcbs, backplane supports, frame).
+
+  Revision 1.34  2000/11/10 18:12:12  jbarbosa
+  Bug fix for AliRICHCerenkov (thanks to P. Hristov)
+
+  Revision 1.33  2000/11/02 10:09:01  jbarbosa
+  Minor bug correction (some pointers were not initialised in the default constructor)
+
+  Revision 1.32  2000/11/01 15:32:55  jbarbosa
+  Updated to handle both reconstruction algorithms.
+
   Revision 1.31  2000/10/26 20:18:33  jbarbosa
   Supports for methane and freon vessels
 
 
 #include "AliRICH.h"
 #include "AliSegmentation.h"
+#include "AliRICHSegmentationV0.h"
 #include "AliRICHHit.h"
 #include "AliRICHCerenkov.h"
 #include "AliRICHPadHit.h"
 #include "AliPDG.h"
 #include "AliPoints.h"
 #include "AliCallf77.h" 
-#include "TGeant3.h"
 
 
 // Static variables for the pad-hit iterator routines
@@ -133,6 +154,10 @@ AliRICH::AliRICH()
     fNPadHits   = 0;
     fNcerenkovs = 0;
     fDchambers  = 0;
+    fRecHits1D = 0;
+    fRecHits3D = 0;
+    fRawClusters = 0;
+    fChambers = 0;
     fCerenkovs  = 0;
     for (Int_t i=0; i<7; i++)
       {
@@ -141,6 +166,8 @@ AliRICH::AliRICH()
        fNrechits1D[i] = 0;
        fNrechits3D[i] = 0;
       }
+
+    fFileName = 0;
 }
 
 //___________________________________________
@@ -199,6 +226,13 @@ AliRICH::AliRICH(const char *name, const char *title)
 
         
     SetMarkerColor(kRed);
+    
+    /*fChambers = new TObjArray(kNCH);
+    for (i=0; i<kNCH; i++) 
+      (*fChambers)[i] = new AliRICHChamber();*/  
+    
+    fFileName = 0;
+
 }
 
 AliRICH::AliRICH(const AliRICH& RICH)
@@ -217,6 +251,29 @@ AliRICH::~AliRICH()
     delete fHits;
     delete fPadHits;
     delete fCerenkovs;
+    
+    //PH Delete TObjArrays
+    if (fChambers) {
+      fChambers->Delete();
+      delete fChambers;
+    }
+    if (fDchambers) {
+      fDchambers->Delete();
+      delete fDchambers;
+    }
+    if (fRawClusters) {
+      fRawClusters->Delete();
+      delete fRawClusters;
+    }
+    if (fRecHits1D) {
+      fRecHits1D->Delete();
+      delete fRecHits1D;
+    }
+    if (fRecHits3D) {
+      fRecHits3D->Delete();
+      delete fRecHits3D;
+    }                     
+    
 }
 
 //___________________________________________
@@ -308,75 +365,226 @@ void AliRICH::BuildGeometry()
   //
   // Builds a TNode geometry for event display
   //
-    TNode *node, *top;
+    TNode *node, *subnode, *top;
     
-    const int kColorRICH = kGreen;
+    const int kColorRICH = kRed;
     //
     top=gAlice->GetGeometry()->GetNode("alice");
-    
+
+    AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH"); 
+    AliRICHSegmentationV0*  segmentation;
+    AliRICHChamber*       iChamber;
+
+    iChamber = &(pRICH->Chamber(0));
+    segmentation=(AliRICHSegmentationV0*) iChamber->GetSegmentationModel(0);
     
     new TBRIK("S_RICH","S_RICH","void",71.09999,11.5,73.15);
-    
+
+    Float_t csi_length = segmentation->Npx()*segmentation->Dpx() + segmentation->DeadZone();
+    Float_t csi_width = segmentation->Npy()*segmentation->Dpy() + 2*segmentation->DeadZone();
+
+    Float_t padplane_width = (csi_width - 2*segmentation->DeadZone())/3;
+    Float_t padplane_length = (csi_length - segmentation->DeadZone())/2;
+
+    //if (segmentation->GetPadPlaneWidth()>0)
+      //{
+       new TBRIK("PHOTO","PHOTO","void", padplane_width/2,.1,padplane_length/2);
+       //printf("\n\n\n\n\n Padplane   w: %f l: %f \n\n\n\n\n", padplane_width/2,padplane_length/2);
+       //printf("\n\n\n\n\n Padplane   w: %f l: %f \n\n\n\n\n", segmentation->GetPadPlaneWidth(), segmentation->GetPadPlaneLength());
+      //}
+
     top->cd();
     Float_t pos1[3]={0,471.8999,165.2599};
     //Chamber(0).SetChamberTransform(pos1[0],pos1[1],pos1[2],
     new TRotMatrix("rot993","rot993",90,0,70.69,90,19.30999,-90);
     node = new TNode("RICH1","RICH1","S_RICH",pos1[0],pos1[1],pos1[2],"rot993");
-    
-
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node);
-    top->cd();
-    
+
+
+    top->cd(); 
     Float_t pos2[3]={171,470,0};
     //Chamber(1).SetChamberTransform(pos2[0],pos2[1],pos2[2],
     new TRotMatrix("rot994","rot994",90,-20,90,70,0,0);
     node = new TNode("RICH2","RICH2","S_RICH",pos2[0],pos2[1],pos2[2],"rot994");
-    
-    
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node);
+
+
     top->cd();
     Float_t pos3[3]={0,500,0};
     //Chamber(2).SetChamberTransform(pos3[0],pos3[1],pos3[2],
     new TRotMatrix("rot995","rot995",90,0,90,90,0,0);
     node = new TNode("RICH3","RICH3","S_RICH",pos3[0],pos3[1],pos3[2],"rot995");
-    
-
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node);
+
     top->cd();
     Float_t pos4[3]={-171,470,0};
     //Chamber(3).SetChamberTransform(pos4[0],pos4[1],pos4[2], 
     new TRotMatrix("rot996","rot996",90,20,90,110,0,0);  
     node = new TNode("RICH4","RICH4","S_RICH",pos4[0],pos4[1],pos4[2],"rot996");
-    
-
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node);
+
+
     top->cd();
     Float_t pos5[3]={161.3999,443.3999,-165.3};
     //Chamber(4).SetChamberTransform(pos5[0],pos5[1],pos5[2],
     new TRotMatrix("rot997","rot997",90,340,108.1999,70,18.2,70);
     node = new TNode("RICH5","RICH5","S_RICH",pos5[0],pos5[1],pos5[2],"rot997");
-    
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node);
+
+
     top->cd();
     Float_t pos6[3]={0., 471.9, -165.3,};
     //Chamber(5).SetChamberTransform(pos6[0],pos6[1],pos6[2],
     new TRotMatrix("rot998","rot998",90,0,109.3099,90,19.30999,90);
     node = new TNode("RICH6","RICH6","S_RICH",pos6[0],pos6[1],pos6[2],"rot998");
-    
-    
     node->SetLineColor(kColorRICH);
-    fNodes->Add(node);
+    
+    fNodes->Add(node);node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+
+
     top->cd();
     Float_t pos7[3]={-161.399,443.3999,-165.3};
     //Chamber(6).SetChamberTransform(pos7[0],pos7[1],pos7[2],
     new TRotMatrix("rot999","rot999",90,20,108.1999,110,18.2,110);
     node = new TNode("RICH7","RICH7","S_RICH",pos7[0],pos7[1],pos7[2],"rot999");
     node->SetLineColor(kColorRICH);
+    node->cd();
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,padplane_length/2 + segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),0,-padplane_length/2 - segmentation->DeadZone()/2,"");
+    subnode->SetLineColor(kGreen);
+    fNodes->Add(subnode);
     fNodes->Add(node); 
     
 }
@@ -419,10 +627,16 @@ void AliRICH::CreateGeometry()
   Float_t oqua_thickness = .5;
   //CsI dimensions
 
-  Float_t csi_length = 160*.8 + 2.6;
-  Float_t csi_width = 144*.84 + 2*2.6;
-    
-    Int_t *idtmed = fIdtmed->GetArray()-999;
+  //Float_t csi_length = 160*.8 + 2.6;
+  //Float_t csi_width = 144*.84 + 2*2.6;
+
+  Float_t deadzone=2.6;
+
+  Float_t csi_length = segmentation->Npx()*segmentation->Dpx() + deadzone;
+  Float_t csi_width = segmentation->Npy()*segmentation->Dpy() + 2*deadzone;
+  
+  Int_t *idtmed = fIdtmed->GetArray()-999;
     
     Int_t i;
     Float_t zs;
@@ -432,7 +646,7 @@ void AliRICH::CreateGeometry()
     // --- Define the RICH detector 
     //     External aluminium box 
     par[0] = 68.8;
-    par[1] = 11.5;                 //Original Settings
+    par[1] = 13;                 //Original Settings
     par[2] = 70.86;
     /*par[0] = 73.15;
     par[1] = 11.5;
@@ -441,13 +655,27 @@ void AliRICH::CreateGeometry()
     
     //     Air 
     par[0] = 66.3;
-    par[1] = 11.5;                 //Original Settings
+    par[1] = 13;                 //Original Settings
     par[2] = 68.35;
     /*par[0] = 66.55;
     par[1] = 11.5;
     par[2] = 64.8;*/
     gMC->Gsvolu("SRIC", "BOX ", idtmed[1000], par, 3);
     
+    //    Air 2 (cutting the lower part of the box)
+    
+    par[0] = 1.25;
+    par[1] = 3;                 //Original Settings
+    par[2] = 70.86;
+    gMC->Gsvolu("AIR2", "BOX ", idtmed[1000], par, 3);
+
+    //    Air 3 (cutting the lower part of the box)
+    
+    par[0] = 66.3;
+    par[1] = 3;                 //Original Settings
+    par[2] = 1.2505;
+    gMC->Gsvolu("AIR3", "BOX ", idtmed[1000], par, 3);
+    
     //     Honeycomb 
     par[0] = 66.3;
     par[1] = .188;                 //Original Settings
@@ -586,6 +814,28 @@ void AliRICH::CreateGeometry()
     par[2] = 20.;
     gMC->Gsvolu("GRID", "TUBE", idtmed[1006], par, 3);
 
+    // Wire supports
+    // Bar of metal
+    
+    par[0] = csi_width/2;
+    par[1] = 1.05;
+    par[2] = 1.05;
+    gMC->Gsvolu("WSMe", "BOX ", idtmed[1009], par, 3);
+
+    // Ceramic pick up (base)
+    
+    par[0] =  csi_width/2;
+    par[1] = .25;
+    par[2] = 1.05;
+    gMC->Gsvolu("WSG1", "BOX ", idtmed[1010], par, 3);
+
+    // Ceramic pick up (head)
+
+    par[0] = csi_width/2;
+    par[1] = .1;
+    par[2] = .1;
+    gMC->Gsvolu("WSG2", "BOX ", idtmed[1010], par, 3);
+
     // Aluminium supports for methane and CsI
     // Short bar
 
@@ -616,12 +866,66 @@ void AliRICH::CreateGeometry()
     par[2] = geometry->GetQuartzLength()/2 + 68.35 - geometry->GetQuartzLength()/2;
     gMC->Gsvolu("SFLG", "BOX", idtmed[1009], par, 3);
     
-      
+    // PCB backplane
+    
+    par[0] = csi_width/2;
+    par[1] = .25;
+    par[2] = csi_length/4 -.5025;
+    gMC->Gsvolu("PCB ", "BOX", idtmed[1011], par, 3);
+
     
+    // Backplane supports
 
+    // Aluminium slab
+    
+    par[0] = 33.15;
+    par[1] = 2;
+    par[2] = 21.65;
+    gMC->Gsvolu("BACK", "BOX", idtmed[1009], par, 3);
+    
+    // Big hole
+    
+    par[0] = 9.05;
+    par[1] = 2;
+    par[2] = 4.4625;
+    gMC->Gsvolu("BKHL", "BOX", idtmed[1000], par, 3);
+
+    // Small hole
+    
+    par[0] = 5.7;
+    par[1] = 2;
+    par[2] = 4.4625;
+    gMC->Gsvolu("BKHS", "BOX", idtmed[1000], par, 3);
+
+    // Place holes inside backplane support
+
+    gMC->Gspos("BKHS", 1, "BACK", .8 + 5.7,0., .6 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 2, "BACK", -.8 - 5.7,0., .6 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 3, "BACK", .8 + 5.7,0., -.6 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 4, "BACK", -.8 - 5.7,0., -.6 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 5, "BACK", .8 + 5.7,0., .6 + 8.925 + 1.2 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 6, "BACK", -.8 - 5.7,0., .6 + 8.925 + 1.2 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 7, "BACK", .8 + 5.7,0., -.6 - 8.925 - 1.2 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHS", 8, "BACK", -.8 - 5.7,0., -.6 - 8.925 - 1.2 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 1, "BACK", .8 + 11.4 + 1.6 + 9.05, 0., .6 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 2, "BACK", -.8 - 11.4 - 1.6 - 9.05, 0., .6 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 3, "BACK", .8 + 11.4 + 1.6 + 9.05, 0., -.6 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 4, "BACK", -.8 - 11.4 - 1.6 - 9.05, 0., -.6 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 5, "BACK", .8 + 11.4+ 1.6 + 9.05, 0., .6 + 8.925 + 1.2 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 6, "BACK", -.8 - 11.4 - 1.6 - 9.05, 0., .6 + 8.925 + 1.2 + 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 7, "BACK", .8 + 11.4 + 1.6 + 9.05, 0., -.6 - 8.925 - 1.2 - 4.4625, 0, "ONLY");
+    gMC->Gspos("BKHL", 8, "BACK", -.8 - 11.4 - 1.6 - 9.05, 0., -.6 - 8.925 - 1.2 - 4.4625, 0, "ONLY");
+
+    
+  
     // --- Places the detectors defined with GSVOLU 
     //     Place material inside RICH 
-    gMC->Gspos("SRIC", 1, "RICH", 0., 0., 0., 0, "ONLY");
+    gMC->Gspos("SRIC", 1, "RICH", 0.,0., 0., 0, "ONLY");
+    gMC->Gspos("AIR2", 1, "RICH", 66.3 + 1.2505, 1.276 - geometry->GetGapThickness()/2 - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.5, 0., 0, "ONLY");
+    gMC->Gspos("AIR2", 2, "RICH", -66.3 - 1.2505, 1.276 - geometry->GetGapThickness()/2 - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.5, 0., 0, "ONLY");
+    gMC->Gspos("AIR3", 1, "RICH", 0.,  1.276 - geometry->GetGapThickness()/2 - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.5, -68.35 - 1.25, 0, "ONLY");
+    gMC->Gspos("AIR3", 2, "RICH", 0., 1.276 - geometry->GetGapThickness()/2 - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.5,  68.35 + 1.25, 0, "ONLY");
+    
       
     gMC->Gspos("ALUM", 1, "SRIC", 0., 1.276 - geometry->GetGapThickness()/2 - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .376 -.025, 0., 0, "ONLY");
     gMC->Gspos("HONE", 1, "SRIC", 0., 1.276- geometry->GetGapThickness()/2  - geometry->GetQuartzThickness() - geometry->GetFreonThickness()- .4 - .6 - .05 - .188, 0., 0, "ONLY");
@@ -715,6 +1019,28 @@ void AliRICH::CreateGeometry()
     gMC->Gspos("GAP ", 1, "META", 0., geometry->GetGapThickness()/2 - geometry->GetProximityGapThickness()/2 - 0.0001, 0., 0, "ONLY");
     gMC->Gspos("META", 1, "SRIC", 0., 1.276, 0., 0, "ONLY");
     gMC->Gspos("CSI ", 1, "SRIC", 0., 1.276 + geometry->GetGapThickness()/2 + .25, 0., 0, "ONLY");
+   
+    // Wire support placing
+
+    gMC->Gspos("WSG2", 1, "GAP ", 0., geometry->GetProximityGapThickness()/2 - .1, 0., 0, "ONLY");
+    gMC->Gspos("WSG1", 1, "CSI ", 0., 0., 0., 0, "ONLY");
+    gMC->Gspos("WSMe", 1, "SRIC ", 0., 1.276 + geometry->GetGapThickness()/2 + .5 + 1.05, 0., 0, "ONLY");
+
+    // Backplane placing
+    
+    gMC->Gspos("BACK", 1, "SRIC ", -33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2, 43.3, 0, "ONLY");
+    gMC->Gspos("BACK", 2, "SRIC ", 33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2 , 43.3, 0, "ONLY");
+    gMC->Gspos("BACK", 3, "SRIC ", -33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
+    gMC->Gspos("BACK", 4, "SRIC ", 33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
+    gMC->Gspos("BACK", 5, "SRIC ", 33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
+    gMC->Gspos("BACK", 6, "SRIC ", -33.15, 1.276 + geometry->GetGapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
+
+    // PCB placing
+    
+    gMC->Gspos("PCB ", 1, "SRIC ", 0.,  1.276 + geometry->GetGapThickness()/2 + .5 + 1.05, csi_width/4 + .5025 + 1.2, 0, "ONLY");
+    gMC->Gspos("PCB ", 2, "SRIC ", 0.,  1.276 + geometry->GetGapThickness()/2 + .5 + 1.05, -csi_width/4 - .5025 - 1.2, 0, "ONLY");
+   
+    
 
     //printf("Position of the gap: %f to %f\n", 1.276 + geometry->GetGapThickness()/2 - geometry->GetProximityGapThickness()/2 - .2, 1.276 + geometry->GetGapThickness()/2 - geometry->GetProximityGapThickness()/2 + .2);
     
@@ -934,8 +1260,6 @@ void AliRICH::CreateMaterials()
     
     Int_t *idtmed = fIdtmed->GetArray()-999;
     
-    TGeant3 *geant3 = (TGeant3*) gMC;
-    
     // --- Photon energy (GeV) 
     // --- Refraction indexes 
     for (i = 0; i < 26; ++i) {
@@ -1010,6 +1334,14 @@ void AliRICH::CreateMaterials()
     zal    = 13.;
     densal = 2.7;
     radlal = 8.9;
+
+    // --- Glass parameters
+
+    Float_t aglass[5]={12.01, 28.09, 16.,   10.8,  23.};
+    Float_t zglass[5]={ 6.,   14.,    8.,    5.,   11.};
+    Float_t wglass[5]={ 0.5,  0.105, 0.355, 0.03,  0.01};
+    Float_t dglass=1.74;
+
     
     AliMaterial(1, "Air     $", 14.61, 7.3, .001205, 30420., 67500);
     AliMaterial(6, "HON", ahon, zhon, denshon, radlhon, 0);
@@ -1021,6 +1353,8 @@ void AliRICH::CreateMaterials()
     AliMixture(41, "METG", amet, zmet, densmet, nlmatmet, wmatmet);
     AliMaterial(11, "GRI", agri, zgri, densgri, radlgri, 0);
     AliMaterial(50, "ALUM", aal, zal, densal, radlal, 0);
+    AliMixture(32, "GLASS",aglass, zglass, dglass, 5, wglass);
+    AliMaterial(31, "COPPER$",   63.54,    29.,   8.96,  1.4, 0.);
     
     tmaxfd = -10.;
     stemax = -.1;
@@ -1038,18 +1372,21 @@ void AliRICH::CreateMaterials()
     AliMedium(8, "QUARZOO$", 21, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     AliMedium(9, "GAP$", 41, 1, isxfld, sxmgmx,tmaxfd, .1, -deemax, epsil, -stmin);
     AliMedium(10, "ALUMINUM$", 50, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    
-
-    geant3->Gsckov(idtmed[1000], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    geant3->Gsckov(idtmed[1001], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    geant3->Gsckov(idtmed[1002], 26, ppckov, abscoQuarz, efficAll,rIndexQuarz);
-    geant3->Gsckov(idtmed[1003], 26, ppckov, abscoFreon, efficAll,rIndexFreon);
-    geant3->Gsckov(idtmed[1004], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    geant3->Gsckov(idtmed[1005], 26, ppckov, abscoCsI, efficCsI, rIndexMethane);
-    geant3->Gsckov(idtmed[1006], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
-    geant3->Gsckov(idtmed[1007], 26, ppckov, abscoOpaqueQuarz, efficAll, rIndexOpaqueQuarz);
-    geant3->Gsckov(idtmed[1008], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    geant3->Gsckov(idtmed[1009], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
+    AliMedium(11, "GLASS", 32, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+    AliMedium(12, "PCB_COPPER", 31, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+    
+
+    gMC->SetCerenkov(idtmed[1000], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
+    gMC->SetCerenkov(idtmed[1001], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
+    gMC->SetCerenkov(idtmed[1002], 26, ppckov, abscoQuarz, efficAll,rIndexQuarz);
+    gMC->SetCerenkov(idtmed[1003], 26, ppckov, abscoFreon, efficAll,rIndexFreon);
+    gMC->SetCerenkov(idtmed[1004], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
+    gMC->SetCerenkov(idtmed[1005], 26, ppckov, abscoCsI, efficCsI, rIndexMethane);
+    gMC->SetCerenkov(idtmed[1006], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
+    gMC->SetCerenkov(idtmed[1007], 26, ppckov, abscoOpaqueQuarz, efficAll, rIndexOpaqueQuarz);
+    gMC->SetCerenkov(idtmed[1008], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
+    gMC->SetCerenkov(idtmed[1009], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
+    gMC->SetCerenkov(idtmed[1010], 26, ppckov, abscoOpaqueQuarz, efficAll, rIndexOpaqueQuarz);
 }
 
 //___________________________________________
@@ -1539,7 +1876,6 @@ void AliRICH::StepManager()
     const  Float_t kBig=1.e10;
        
     TClonesArray &lhits = *fHits;
-    TGeant3 *geant3 = (TGeant3*) gMC;
     TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->CurrentTrack()];
 
  //if (current->Energy()>1)
@@ -1561,6 +1897,7 @@ void AliRICH::StepManager()
     ckovData[1] = pos[0];                 // X-position for hit
     ckovData[2] = pos[1];                 // Y-position for hit
     ckovData[3] = pos[2];                 // Z-position for hit
+    ckovData[6] = 0;                      // dummy track length
     //ckovData[11] = gAlice->CurrentTrack();
     
     //printf("\n+++++++++++\nTrack: %d\n++++++++++++\n",gAlice->CurrentTrack());
@@ -1582,7 +1919,7 @@ void AliRICH::StepManager()
                //printf("Track entered (1)\n");
                if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
                  {                                                          //is it in freo?
-                   if (geant3->Gctrak()->nstep<1){                          //is it the first step?
+                   if (gMC->IsNewTrack()){                          //is it the first step?
                      //printf("I'm in!\n");
                      Int_t mother = current->GetFirstMother(); 
                      
@@ -1598,7 +1935,7 @@ void AliRICH::StepManager()
                    }    //first step question
                  }        //freo question
                
-               if (geant3->Gctrak()->nstep<1){                                  //is it first step?
+               if (gMC->IsNewTrack()){                                  //is it first step?
                  if (gMC->VolId("QUAR")==gMC->CurrentVolID(copy))             //is it in quarz?
                    {
                      ckovData[12] = 2;
@@ -1634,7 +1971,7 @@ void AliRICH::StepManager()
                        gMC->Rndm(ranf, 1);
                        //printf("grid calculation:%f\n",t);
                        if (ranf[0] > t) {
-                         geant3->StopTrack();
+                         gMC->StopTrack();
                          ckovData[13] = 5;
                          AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
                          //printf("Added One (1)!\n");
@@ -1661,7 +1998,7 @@ void AliRICH::StepManager()
                        Float_t t = Fresnel(ckovEnergy*1e9,cophi,1);
                        gMC->Rndm(ranf, 1);
                        if (ranf[0] < t) {
-                         geant3->StopTrack();
+                         gMC->StopTrack();
                          ckovData[13] = 6;
                          AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
                          //printf("Added One (2)!\n");
@@ -1675,21 +2012,22 @@ void AliRICH::StepManager()
                  /********************Evaluation of losses************************/
                  /******************still in the old fashion**********************/
                  
-                 Int_t i1 = geant3->Gctrak()->nmec;            //number of physics mechanisms acting on the particle
+                 TArrayI procs;
+                 Int_t i1 = gMC->StepProcesses(procs);            //number of physics mechanisms acting on the particle
                  for (Int_t i = 0; i < i1; ++i) {
                    //        Reflection loss 
-                   if (geant3->Gctrak()->lmec[i] == 106) {        //was it reflected
+                   if (procs[i] == kPLightReflection) {        //was it reflected
                      ckovData[13]=10;
                      if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
                        ckovData[13]=1;
                      if (gMC->CurrentVolID(copy) == gMC->VolId("QUAR")) 
                        ckovData[13]=2;
-                     //geant3->StopTrack();
+                     //gMC->StopTrack();
                      //AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
                    } //reflection question
                     
                    //        Absorption loss 
-                   else if (geant3->Gctrak()->lmec[i] == 101) {              //was it absorbed?
+                   else if (procs[i] == kPLightAbsorption) {              //was it absorbed?
                      //printf("Got in absorption\n");
                      ckovData[13]=20;
                      if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
@@ -1708,7 +2046,7 @@ void AliRICH::StepManager()
                      if (gMC->CurrentVolID(copy) == gMC->VolId("CSI ")) {
                        ckovData[13]=16;
                      }
-                     geant3->StopTrack();
+                     gMC->StopTrack();
                      AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
                      //printf("Added One (3)!\n");
                      //printf("Added cerenkov %d\n",fCkovNumber);
@@ -1716,9 +2054,9 @@ void AliRICH::StepManager()
                    
                    
                    //        Photon goes out of tracking scope 
-                   else if (geant3->Gctrak()->lmec[i] == 30) {                 //is it below energy treshold?
+                   else if (procs[i] == kPStop) {                 //is it below energy treshold?
                      ckovData[13]=21;
-                     geant3->StopTrack();
+                     gMC->StopTrack();
                      AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
                      //printf("Added One (4)!\n");
                    }   // energy treshold question         
@@ -2351,7 +2689,6 @@ void AliRICH::Digitise(Int_t nev, Int_t flag, Option_t *option,Text_t *filename)
                   mPad;
                   mPad=(AliRICHPadHit*)pRICH->NextPad(fPadHits))
                {
-                 Int_t cathode  = mPad->fCathode;    // cathode number
                  Int_t ipx      = mPad->fPadX;       // pad number on X
                  Int_t ipy      = mPad->fPadY;       // pad number on Y
                  Int_t iqpad    = mPad->fQpad;       // charge per pad
@@ -2360,7 +2697,7 @@ void AliRICH::Digitise(Int_t nev, Int_t flag, Option_t *option,Text_t *filename)
                  //printf("X:%d, Y:%d, Q:%d\n",ipx,ipy,iqpad);
                  
                  Float_t thex, they, thez;
-                 segmentation=iChamber->GetSegmentationModel(cathode);
+                 segmentation=iChamber->GetSegmentationModel(0);
                  segmentation->GetPadC(ipx,ipy,thex,they,thez);
                  new((*pAddress)[countadr++]) TVector(2);
                  TVector &trinfo=*((TVector*) (*pAddress)[countadr-1]);
@@ -2450,13 +2787,12 @@ void AliRICH::Digitise(Int_t nev, Int_t flag, Option_t *option,Text_t *filename)
                 mPad;
                 mPad=(AliRICHPadHit*)pRICH->NextPad(fClusters2))
              {
-               Int_t cathode  = mPad->fCathode;    // cathode number
                Int_t ipx      = mPad->fPadX;       // pad number on X
                Int_t ipy      = mPad->fPadY;       // pad number on Y
                Int_t iqpad    = mPad->fQpad;       // charge per pad
                
                Float_t thex, they, thez;
-               segmentation=iChamber->GetSegmentationModel(cathode);
+               segmentation=iChamber->GetSegmentationModel(0);
                segmentation->GetPadC(ipx,ipy,thex,they,thez);
                Float_t rpad=TMath::Sqrt(thex*thex+they*they);
                if (rpad < rmin || iqpad ==0 || rpad > rmax) continue;
@@ -2637,8 +2973,8 @@ Int_t AliRICH::MakePadHits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol,
 //  Calls the charge disintegration method of the current chamber and adds
 //  the simulated cluster to the root treee 
 //
-    Int_t clhits[kNCH];
-    Float_t newclust[6][500];
+    Int_t clhits[5];
+    Float_t newclust[4][500];
     Int_t nnew;
     
 //
@@ -2652,20 +2988,16 @@ Int_t AliRICH::MakePadHits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol,
 //
 //  Add new clusters
     for (Int_t i=0; i<nnew; i++) {
-       if (Int_t(newclust[3][i]) > 0) {
+       if (Int_t(newclust[0][i]) > 0) {
            ic++;
-// Cathode plane
-           clhits[1] = Int_t(newclust[5][i]);
 //  Cluster Charge
-           clhits[2] = Int_t(newclust[0][i]);
+           clhits[1] = Int_t(newclust[0][i]);
 //  Pad: ix
-           clhits[3] = Int_t(newclust[1][i]);
+           clhits[2] = Int_t(newclust[1][i]);
 //  Pad: iy 
-           clhits[4] = Int_t(newclust[2][i]);
-//  Pad: charge
-           clhits[5] = Int_t(newclust[3][i]);
+           clhits[3] = Int_t(newclust[2][i]);
 //  Pad: chamber sector
-           clhits[6] = Int_t(newclust[4][i]);
+           clhits[4] = Int_t(newclust[3][i]);
            
            AddPadHit(clhits);
        }