]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDisplay.cxx
Corrected mapping management group definition
[u/mrichter/AliRoot.git] / MUON / AliMUONDisplay.cxx
index df8f7a143edeba34df4f02393c5831a949b9d367..2c2fbecf454282064ae041fd888c97e15f8c5fd1 100644 (file)
 //                                                                      //
 //////////////////////////////////////////////////////////////////////////
 
+#include "AliMUONDisplay.h"
+#include "AliMUON.h"
+#include "AliMUONPoints.h"
+#include "AliMUONGlobalTrigger.h"
+#include "AliMUONHit.h"
+#include "AliMUONDigit.h"
+#include "AliMUONRawCluster.h"
+#include "AliMUONTrack.h"
+#include "AliMUONTrackParam.h"
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONSegmentation.h"
+#include "AliMUONGeometrySegmentation.h"
+#include "AliMUONConstants.h"
+#include "AliMUONTriggerSegmentationV2.h"
+
+#include "AliMpDEIterator.h"
+#include "AliMpSegFactory.h"
+#include "AliMpSlatSegmentation.h"
+#include "AliMpSlat.h"
+#include "AliMpSectorSegmentation.h"
+#include "AliMpSector.h"
+#include "AliMpTriggerSegmentation.h"
+#include "AliMpTrigger.h"
+#include "AliMpStationType.h"
+#include "AliMpDEManager.h"
+
+#include "AliMC.h"
+#include "AliLog.h"
+#include "AliRun.h"
+#include "AliHeader.h"
+
 #include <TButton.h>
 #include <TColor.h>
 #include <TCanvas.h>
 #include <TMarker3DBox.h>
 #include <TParticle.h>
 #include <TPolyLine3D.h>
-
-#include "AliMUONDisplay.h"
-#include "AliRun.h"
-#include "AliMUON.h"
-#include "AliMUONPoints.h"
-#include "AliMUONGlobalTrigger.h"
-#include "AliHeader.h"
-
-#include "AliMUONHit.h"
-#include "AliMUONDigit.h"
-#include "AliMUONRawCluster.h"
-#include "AliMUONTrack.h"
-#include "AliMUONTrackParam.h"
-
-#include "AliSegmentation.h"
-#include "AliMUONChamber.h"
-#include "AliMUONConstants.h"
-#include "AliMC.h"
-#include "AliLog.h"
-// to manage the same zoom on both cathodes
+#include <TBox.h>
 
 
 
@@ -545,63 +557,66 @@ void AliMUONDisplay::PrintKinematics()
 
 void AliMUONDisplay::DrawSegmentation()
 {
+  // to be re-written for new seg
 // Draw graphical representation of segmenatation
 // Attention: still experimental code
-    Int_t icat=1;
+//     Int_t icat=1;
     
-    AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
-    AliMUONChamber*   iChamber;
-    AliSegmentation*  seg;
-    iChamber = &(pMUON->Chamber(fChamber));
-    seg=iChamber->SegmentationModel(icat);
-    Float_t zpos=iChamber->Z();
-    Float_t r=iChamber->ROuter();
+//     AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
+//     AliMUONChamber*   iChamber;
+
+//     AliSegmentation*  seg;
+//     iChamber = &(pMUON->Chamber(fChamber));
+//     seg=iChamber->SegmentationModel(icat);
+
+//     Float_t zpos=iChamber->Z();
+//     Float_t r=iChamber->ROuter();
     
-    TMarker3DBox *marker;
-    if (icat == 1) {
-       for (Int_t j=0; j<seg->Npy(); j++) {
-           Float_t y0;
-           y0=j*seg->Dpy()-seg->Dpy()/2.;
-           for (seg->FirstPad(0.,y0,0,300,0.); 
-                seg->MorePads();
-                seg->NextPad())
-           {
-               if (seg->ISector()==0) continue;
-               Float_t x,y,z;
-               seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
-               Float_t dpx=seg->Dpx(seg->ISector())/2;
-               Float_t dpy=seg->Dpy(seg->ISector())/2;
-               marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
-               marker->SetLineColor(seg->ISector()+1);
-               marker->SetFillStyle(1001);
-               marker->SetFillColor(0);
-               marker->Draw();
-           }
-       }
-    } else {
-       for (Int_t j=0; j<250; j++) {
-           Float_t x0=j*seg->Dpx();
-           Float_t y0=TMath::Sqrt(r*r-x0*x0);
+//     TMarker3DBox *marker;
+//     if (icat == 1) {
+//     for (Int_t j=0; j<seg->Npy(); j++) {
+//         Float_t y0;
+//         y0=j*seg->Dpy()-seg->Dpy()/2.;
+//         for (seg->FirstPad(0.,y0,0,300,0.); 
+//              seg->MorePads();
+//              seg->NextPad())
+//         {
+//             if (seg->ISector()==0) continue;
+//             Float_t x,y,z;
+//             seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
+//             Float_t dpx=seg->Dpx(seg->ISector())/2;
+//             Float_t dpy=seg->Dpy(seg->ISector())/2;
+//             marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
+//             marker->SetLineColor(seg->ISector()+1);
+//             marker->SetFillStyle(1001);
+//             marker->SetFillColor(0);
+//             marker->Draw();
+//         }
+//     }
+//     } else {
+//     for (Int_t j=0; j<250; j++) {
+//         Float_t x0=j*seg->Dpx();
+//         Float_t y0=TMath::Sqrt(r*r-x0*x0);
            
-           for (seg->FirstPad(x0,0,0,0,y0); 
-                seg->MorePads();
-                seg->NextPad())
-           {
-               if (seg->ISector()==0) continue;
+//         for (seg->FirstPad(x0,0,0,0,y0); 
+//              seg->MorePads();
+//              seg->NextPad())
+//         {
+//             if (seg->ISector()==0) continue;
                
-               Float_t x,y,z;
-               seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
-               Float_t dpx=seg->Dpx(seg->ISector())/2;
-               Float_t dpy=seg->Dpy(seg->ISector())/2;
-               marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
-               marker->SetLineColor(seg->ISector()+1);
-               marker->SetFillStyle(1001);
-               marker->SetFillColor(0);
-               marker->Draw();
-           }
-       }
-    }
-}
+//             Float_t x,y,z;
+//             seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
+//             Float_t dpx=seg->Dpx(seg->ISector())/2;
+//             Float_t dpy=seg->Dpy(seg->ISector())/2;
+//             marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
+//             marker->SetLineColor(seg->ISector()+1);
+//             marker->SetFillStyle(1001);
+//             marker->SetFillColor(0);
+//             marker->Draw();
+//         }
+//     }
+//     }
+ }
 
 //_____________________________________________________________________________
 void AliMUONDisplay::DrawClusters()
@@ -628,7 +643,7 @@ void AliMUONDisplay::DrawClusters()
                marker->Draw();
        }
        pm->Draw();
-       fClustersCuts +=pm->GetN();
+       fClustersCuts += pm->GetN();
     }
 }
 
@@ -747,7 +762,7 @@ void AliMUONDisplay::DrawTitle(Option_t *option)
 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
 {
 //    Draw a view of MUON clusters
-    printf("\n Draw View\n");
+    AliInfo(" Draw View");
     
     gPad->SetCursor(kWatch);
     // gPad->SetFillColor(39);
@@ -771,12 +786,164 @@ void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
        fZooms = 0;
     }
 
+    Float_t xg1, xg2, yg1, yg2, zg1, zg2;
+
+    // Recovering the chamber 
+    AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
+
+    const AliMUONGeometryTransformer* kGeomTransformer 
+      = pMUON->GetGeometryTransformer();
+
+    AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
+    AliMpSegFactory segFactory;
+        // Mapping segmentation factory will be used only to create mapping
+       // segmentations if not present in the DE segmentations
+
 // Display MUON Chamber Geometry
     char nodeName[7];
     sprintf(nodeName,"MUON%d",100+fChamber);
+    printf(">>>> chamber is %d\n",fChamber);
+
+    if(fChamber < 5) {
+      AliMpDEIterator it;
+      for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
+
+       Int_t detElemId = it.CurrentDE();
+       AliMpSectorSegmentation * seg =   
+         (AliMpSectorSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
+       const AliMpSector * sector = seg->GetSector();
+
+       // get sector measurements
+       TVector2 position  = sector->Position(); 
+       TVector2 dimension = sector->Dimensions(); // half length
+       
+       Float_t xlocal1 =  position.Px(); // mm to cm
+       Float_t ylocal1 =  position.Py();
+       Float_t xlocal2 =  dimension.Px() * 2.;
+       Float_t ylocal2 =  dimension.Px() * 2.;
+
+       kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+       kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
+
+       // drawing 
+       TPolyLine3D* poly = new  TPolyLine3D();
+       Int_t nPoint = 0;
+
+       poly->SetPoint(nPoint++, xg1, yg1, 0.);
+       for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
+         Float_t x = xg1 + xg2 * TMath::Cos(d);
+         Float_t y = yg1 + yg2 * TMath::Sin(d);
+         poly->SetPoint(nPoint++, x, y, 0.);
+       }
+       poly->SetPoint(nPoint++, xg1, yg1, 0.);
+
+       poly->SetLineColor(2);
+       poly->Draw("s");
+      }
+   
+      //     }
+
+    }
+
+    if(fChamber >4 && fChamber <11) {
+      AliMpDEIterator it;
+      for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
+       Int_t detElemId = it.CurrentDE();
+       if (  segmentation->HasDE(detElemId) ) {
+         AliMpSlatSegmentation * seg =   
+           (AliMpSlatSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
+         if (!seg) { 
+           // Create mapping segmentation if old trigger segmentation
+           // (not using mapping)
+           seg = (AliMpSlatSegmentation *)
+                  segFactory.CreateMpSegmentation(detElemId, 0);
+         }       
+         if (seg) {  
+           const AliMpSlat* slat = seg->Slat();
+           Float_t deltax = slat->DX();
+           Float_t deltay = slat->DY();
+           Float_t xlocal1 =  -deltax;
+           Float_t ylocal1 =  -deltay;
+           Float_t xlocal2 =  +deltax;
+           Float_t ylocal2 =  +deltay;
+           kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+           kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
+
+           // drawing slat active volumes
+           Float_t xCenter = (xg1 + xg2)/2.;
+           Float_t yCenter = (yg1 + yg2)/2.;
+
+           TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
+
+           box->SetFillStyle(0);
+           box->SetLineColor(2);
+           box->Draw("s");
+
+           // drawing inner circle + disc
+           TPolyLine3D* poly  = new  TPolyLine3D();
+           TPolyLine3D* poly1 = new  TPolyLine3D();
+
+           Int_t nPoint = 0;
+           Int_t nPoint1 = 0;
+           for (Float_t d = 0; d < 6.24; d+= 0.005) {
+             Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
+             Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
+             if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
+             poly->SetPoint(nPoint++, x, y, 0.);
+             poly1->SetPoint(nPoint1++, x, y, 0.);
+
+           }
+           poly->SetLineColor(1);
+           poly->Draw("s");
+           poly1->SetLineColor(2);
+           poly1->Draw("s");
+         }  
+       }
+      }
+    }
+    
+/*-- Trigger Chambers ---------------------------------------*/
+    if(fChamber >10 && fChamber <15) {
+      AliMpDEIterator it;
+      for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
+       Int_t detElemId = it.CurrentDE();
+       AliMpTriggerSegmentation * seg  
+         = (AliMpTriggerSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
+       if (!seg) {  
+           printf(" AliMUONDisplay no segmentation \n");
+           
+         // Create mapping segmentation if old trigger segmentation
+         // (not using mapping)
+         seg = (AliMpTriggerSegmentation *)
+                segFactory.CreateMpSegmentation(detElemId, 0);
+       }         
+       if (seg) {   
+         const AliMpTrigger* slat = seg->Slat();
+         Float_t deltax = slat->DX();
+         Float_t deltay = slat->DY();
+         Float_t xlocal1 =  -deltax;
+         Float_t ylocal1 =  -deltay;
+         Float_t xlocal2 =  +deltax;
+         Float_t ylocal2 =  +deltay;
+         
+         kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+         kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
+
+         // drawing slat active volumes
+         Float_t xCenter = (xg1 + xg2)/2.;
+         Float_t yCenter = (yg1 + yg2)/2.;
+
+         TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
+
+         box->SetFillStyle(0);
+         box->SetLineColor(4);
+         box->Draw("s");
+       }  
+      }
+    }
+    // Delete mapping segmentations created with factory
+    segFactory.DeleteSegmentations();
     
-    TNode *node1=gAlice->GetGeometry()->GetNode(nodeName);
-    if (node1) node1->Draw("same");  
 //add clusters to the pad
     DrawClusters();
     DrawHits();
@@ -918,9 +1085,9 @@ void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
     ResetPoints();
     
     AliMUON *pMUON  =     (AliMUON*)gAlice->GetModule("MUON");
-    AliMUONChamber*       iChamber;
-    AliSegmentation*      segmentation;
-   
+
+    AliMUONGeometrySegmentation*  segmentation2 = 0x0;
+
     GetMUONData()->SetTreeAddress("D");
 
     TClonesArray *muonDigits  = GetMUONData()->Digits(chamber-1);
@@ -929,96 +1096,187 @@ void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
     gAlice->ResetDigits();
     Int_t nent = 0;
  
-   if (GetLoader()->TreeD()) {
-     nent = (Int_t) GetLoader()->TreeD()->GetEntries();
-     //     gAlice->TreeD()->GetEvent(nent-2+cathode-1);
-     GetMUONData()->GetCathode(cathode-1);
+    if (GetLoader()->TreeD()) {
+       nent = (Int_t) GetLoader()->TreeD()->GetEntries();
+       //     gAlice->TreeD()->GetEvent(nent-2+cathode-1);
+       GetMUONData()->GetDigits();
     }
     
-    Int_t ndigits = muonDigits->GetEntriesFast();
+    Int_t ndigits = muonDigits->GetEntriesFast();    
     if (ndigits == 0) return;
     if (fPoints == 0) fPoints = new TObjArray(ndigits);
     
-    iChamber = &(pMUON->Chamber(chamber-1));
-
-    segmentation = iChamber->SegmentationModel(cathode);
-    Float_t zpos = iChamber->Z();
+    Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
 
     AliMUONDigit  *mdig;
     AliMUONPoints *points  = 0;
     TMarker3DBox  *marker  = 0;
-    //
-    //loop over all digits and store their position
-    
+
     Int_t npoints  = 1;
     Float_t adcmax = 1024; // default
     if (chamber<11) adcmax = 4096;
 
-    for (Int_t digit = 0; digit < ndigits; digit++) {
-        mdig    = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
-       if (mdig->Cathode() != cathode-1) continue;
-       
-        //
-        // First get all needed parameters
-        //
-        Int_t charge = mdig->Signal();
-        Int_t index  = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
-        Int_t color  = 261+index;
-       Int_t colorTrigger = 2;   
-        if (color > 282) color = 282;
-
-       if (chamber > 10) { // trigger chamber 
-
-           Int_t sumCharge = 0;
-           for (Int_t icharge = 0; icharge < 10; icharge++) {
-               sumCharge = sumCharge+mdig->TrackCharge(icharge);
+// check if trigger is using new or old segmentation
+    Bool_t old = true;
+    AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
+    if ( segmentation->GetMpSegmentation(1100, cathode-1) ) old = false;
+
+    if ( old  && chamber > 10) {
+       if (chamber > 10) printf(">>> old segmentation for trigger \n");
+       else printf(">>> old segmentation for tracking \n");
+
+       segmentation2
+           = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
+       for (Int_t digit = 0; digit < ndigits; digit++) {
+           mdig    = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
+           if (mdig->Cathode() != cathode-1) continue;
+           
+           //
+           // First get all needed parameters
+           //
+           Int_t charge = mdig->Signal();
+           Int_t index  = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
+           Int_t color  = 261+index;
+           Int_t colorTrigger = 2;   
+           if (color > 282) color = 282;
+           
+           if (chamber > 10) { // trigger chamber 
+               
+               Int_t sumCharge = 0;
+               for (Int_t icharge = 0; icharge < 10; icharge++) {
+                   sumCharge = sumCharge+mdig->TrackCharge(icharge);
+               }
+               Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
+               if(sumCharge <= 10 || testCharge > 0) {
+                   colorTrigger = color; 
+               } else {
+                   colorTrigger = 5; 
+               }
            }
-           Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
-           if(sumCharge <= 10 || testCharge > 0) {
-               colorTrigger = color; 
-           } else {
-               colorTrigger = 5; 
+           
+           // get the center of the pad - add on x and y half of pad size
+           Float_t xpad, ypad, zpad;
+           Int_t isec;
+           Float_t dpx, dpy;
+           
+           Int_t detElemId = mdig->DetElemId();
+           segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
+           isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
+           dpx = segmentation2->Dpx(detElemId, isec)/2;
+           dpy = segmentation2->Dpy(detElemId, isec)/2;
+           
+           // Then set the objects
+           points = new AliMUONPoints(npoints);
+           fPoints->AddAt(points,digit);
+           if (chamber > 10) {
+               points->SetMarkerColor(colorTrigger);
+           } else {  
+               points->SetMarkerColor(color);
            }
-       }
-
-       // get the center of the pad - add on x and y half of pad size
-       Float_t xpad, ypad, zpad;
-       segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
+           points->SetMarkerStyle(21);
+           points->SetMarkerSize(0.5);
+           points->SetParticle(-1);
+           points->SetHitIndex(-1);
+           points->SetTrackIndex(-1);
+           points->SetDigitIndex(digit);
+           points->SetPoint(0,xpad,ypad,zpos);
+           
+           Int_t lineColor = (zpad-zpos > 0) ? 2:3;
+           marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
+           
+           
+           marker->SetLineColor(lineColor);
+           marker->SetFillStyle(1001);
+           marker->SetFillColor(color);
+           marker->SetRefObject((TObject*)points);
+           points->Set3DMarker(0, marker);
+       } // end loop on digits     
        
-        Int_t   isec = segmentation->Sector(mdig->PadX(), mdig->PadY());
-        Float_t  dpx = segmentation->Dpx(isec)/2;
-        Float_t  dpy = segmentation->Dpy(isec)/2;
-//
-//     segmentation->Dump();
+    } else {   
+       if (chamber > 10) printf(">>> new segmentation for trigger \n");
+       else printf(">>> new segmentation for tracking \n");
        
-       //
-       // Then set the objects
-       //
-        points = new AliMUONPoints(npoints);
-       fPoints->AddAt(points,digit);
-       if (chamber > 10) {
-           points->SetMarkerColor(colorTrigger);
-       } else {  
-           points->SetMarkerColor(color);
-       }
-        points->SetMarkerStyle(21);
-        points->SetMarkerSize(0.5);
-        points->SetParticle(-1);
-        points->SetHitIndex(-1);
-        points->SetTrackIndex(-1);
-        points->SetDigitIndex(digit);
-        points->SetPoint(0,xpad,ypad,zpos);
+       const AliMUONGeometryTransformer* kGeomTransformer 
+           = pMUON->GetGeometryTransformer();
        
-       Int_t lineColor = (zpad-zpos > 0) ? 2:3;
-       marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
-
+       //loop over all digits and store their position
+       for (Int_t digit = 0; digit < ndigits; digit++) {
+           mdig    = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
+           if (mdig->Cathode() != cathode-1) continue;
            
-       marker->SetLineColor(lineColor);
-       marker->SetFillStyle(1001);
-       marker->SetFillColor(color);
-       marker->SetRefObject((TObject*)points);
-       points->Set3DMarker(0, marker);
-    }
+           // get all needed parameters
+           Int_t ix=mdig->PadX();
+           Int_t iy=mdig->PadY();
+           Int_t detElemId=mdig->DetElemId();      
+           Int_t charge = mdig->Signal();
+           Int_t index  = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
+           Int_t color  = 261+index;
+           Int_t colorTrigger = 2;   
+           if (color > 282) color = 282;
+           
+           const AliMpVSegmentation* seg = 
+               pMUON->GetSegmentation()->GetMpSegmentation(detElemId,cathode-1);
+           
+           AliMpStationType station = AliMpDEManager::GetStationType(detElemId);
+           
+           Int_t intOffset = station == kStation345 ? 1 : 0;   
+           
+           AliMpPad pad = 
+               seg->PadByIndices(AliMpIntPair(ix-intOffset,iy-intOffset),kTRUE);
+           
+           if (chamber > 10) { // trigger chamber
+               Int_t sumCharge = 0;
+               for (Int_t icharge = 0; icharge < 10; icharge++) {
+                   sumCharge = sumCharge+mdig->TrackCharge(icharge);
+               }
+               Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
+               if(sumCharge <= 10 || testCharge > 0) {
+                   colorTrigger = color; 
+               } else {
+                   colorTrigger = 5; 
+               }
+           }
+           
+           // get the pad position and dimensions
+           Float_t xlocal1 = pad.Position().X();
+           Float_t ylocal1 = pad.Position().Y();
+           Float_t xlocal2 = pad.Dimensions().X();
+           Float_t ylocal2 = pad.Dimensions().Y();
+           
+           Float_t xg1, xg2, yg1, yg2, zg1;
+           
+           kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
+           // (no transformation for pad dimensions)
+           xg2 = xlocal2;
+           yg2 = ylocal2;
+           
+           // Then set the objects
+           points = new AliMUONPoints(npoints);
+           fPoints->AddAt(points,digit);
+           if (chamber > 10) {
+               points->SetMarkerColor(colorTrigger);
+           } else {  
+               points->SetMarkerColor(color);
+           }
+           points->SetMarkerStyle(21);
+           points->SetMarkerSize(0.5);
+           points->SetParticle(-1);
+           points->SetHitIndex(-1);
+           points->SetTrackIndex(-1);
+           points->SetDigitIndex(digit);
+           points->SetPoint(0,xg1,yg1,zpos);
+           
+           Int_t lineColor = (zg1-zpos > 0) ? 2:3;
+           marker=new TMarker3DBox(xg1,yg1,zpos,xg2,yg2,0,0,0);
+           
+           marker->SetLineColor(lineColor);
+           marker->SetFillStyle(1001);
+           marker->SetFillColor(color);
+           marker->SetRefObject((TObject*)points);
+           points->Set3DMarker(0, marker);
+           
+       } // end loop on digits
+    } // end of new segmentation    
 }
 //___________________________________________
 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
@@ -1030,9 +1288,6 @@ void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
     
     ResetRpoints();
     
-    AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
-    AliMUONChamber*  iChamber;
-    
     GetMUONData()->SetTreeAddress("RC");
     TClonesArray *muonRawClusters  = GetMUONData()->RawClusters(chamber-1);
 
@@ -1048,8 +1303,7 @@ void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
     if (nrawcl == 0) return;
     if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
     
-    iChamber = &(pMUON->Chamber(chamber-1));
-    Float_t zpos=iChamber->Z();  
+    Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);  
     AliMUONRawCluster  *mRaw;
     AliMUONPoints *points = 0;
     //
@@ -1174,12 +1428,7 @@ void AliMUONDisplay::LoadHits(Int_t chamber)
  
     ResetPhits();
     
-    AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
-    AliMUONChamber*  iChamber;
-
-    iChamber = &(pMUON->Chamber(chamber-1));
-    Float_t zpos=iChamber->Z();
-
+    Float_t zpos=AliMUONConstants::DefaultChamberZ(chamber-1);
 
     if (GetMUONData()->TreeH()) {
       GetMUONData()->SetTreeAddress("H");