]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSegmentationSlat.cxx
Remove Process_t
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationSlat.cxx
index 2a53407baba9faec88a3fb238f561f52a24c7dbb..33fa34189e4f72ef0a449f82b84fe16f12b36c80 100644 (file)
 
 /*
 $Log$
+Revision 1.10  2001/01/23 18:58:19  hristov
+Initialisation of some pointers
+
+Revision 1.9  2001/01/17 20:53:40  hristov
+Destructors corrected to avoid memory leaks
+
+Revision 1.8  2000/12/21 22:12:41  morsch
+Clean-up of coding rule violations,
+
+Revision 1.7  2000/11/08 13:01:40  morsch
+Chamber half-planes of stations 3-5 at different z-positions.
+
+Revision 1.6  2000/11/06 09:20:43  morsch
+AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
+Draw() method. This avoids code and parameter replication.
+
+Revision 1.5  2000/10/23 13:37:40  morsch
+Correct z-position of slat planes.
+
 Revision 1.4  2000/10/22 16:55:43  morsch
 Use only x-symmetry in global to local transformations and delegation.
 
@@ -38,6 +57,9 @@ Segmentation class for chambers built out of slats.
 #include "TObjArray.h"
 #include "AliRun.h"
 #include <TMath.h>
+#include <TBRIK.h>
+#include <TNode.h>
+#include <TGeometry.h>
 #include <iostream.h>
 
 //___________________________________________
@@ -46,8 +68,28 @@ ClassImp(AliMUONSegmentationSlat)
 AliMUONSegmentationSlat::AliMUONSegmentationSlat() 
 {
 // Default constructor
+}
+
+AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t nsec) 
+{
+// Non default constructor
     fSlats=0;            
-    fNDiv = new TArrayI(4);   
+    fNDiv = new TArrayI(4);
+    fChamber = 0;
+    fCurrentSlat = 0;
+}
+
+AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
+  //PH Delete TObjArrays
+  if (fSlats) {
+    fSlats->Delete();
+    delete fSlats;
+  }
+
+  if (fNDiv) {
+    delete fNDiv;
+  }
+
 }
 
 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
@@ -109,6 +151,7 @@ void AliMUONSegmentationSlat::GlobalToLocal(
 //                                                 positive side is shifted up
 // by half the overlap
     zlocal = z-fChamber->Z();
+    zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
 //  Set the signs for the symmetry transformation and transform to first quadrant
     SetSymmetry(x);
     Float_t xabs=TMath::Abs(x);
@@ -171,7 +214,9 @@ LocalToGlobal(Int_t islat, Float_t  xlocal, Float_t  ylocal, Float_t  &x, Float_
     x = (xlocal+fXPosition[islat])*fSym;
     y=(ylocal+fYPosition[islat]);
 
-    z = (TMath::Even(islat)) ? -fDz : fDz ; 
+    z = (TMath::Even(islat)) ?     -fDz : fDz ; 
+    z = (x>0)                ? z+2.*fDz : z-2.*fDz ; 
+
     z+=fChamber->Z();
 }
 
@@ -243,7 +288,8 @@ GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
     x=x*TMath::Sign(1,ix);
 
 // z-position
-    z = (TMath::Even(islat)) ? -fDz : fDz ; 
+    z = (TMath::Even(islat)) ?      -fDz : fDz ; 
+    z = (x>0)                ?  z+2.*fDz : z-2.*fDz ; 
     z += fChamber->Z();
 }
 
@@ -258,6 +304,7 @@ Int_t AliMUONSegmentationSlat::ISector()
 
 Int_t AliMUONSegmentationSlat::Sector(Int_t ix, Int_t iy)
 {
+// Returns sector for pad coordiantes (ix,iy)
     Int_t ixlocal, iylocal, iregion, islat;
 
     GlobalToLocal(ix,iy,islat,ixlocal,iylocal);
@@ -424,7 +471,7 @@ void AliMUONSegmentationSlat::Init(Int_t chamber)
     printf("\n Initialise Segmentation Slat \n");
 //
 
-//    Initialize Slat modules
+// Initialize Slat modules
     Int_t islat, i;
     Int_t ndiv[4];
 // Pad division
@@ -472,6 +519,7 @@ void AliMUONSegmentationSlat::Init(Int_t chamber)
 // Set parent chamber number
     AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
     fChamber=&(pMUON->Chamber(chamber));
+    fId=chamber;
 }
 
 
@@ -504,10 +552,64 @@ AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
 CreateSlatModule()
 {
     // Factory method for slat module
-    return new AliMUONSegmentationSlatModule();
+    return new AliMUONSegmentationSlatModule(4);
 }
 
 
+void AliMUONSegmentationSlat::Draw(const char* opt) const
+{
+// Draw method for event display
+// 
+  if (!strcmp(opt,"eventdisplay")) { 
+    const int kColorMUON1 = kYellow;
+    const int kColorMUON2 = kBlue; 
+    //
+    //  Drawing Routines for example for Event Display
+    Int_t i,j;
+    Int_t npcb[15];
+    char nameChamber[9], nameSlat[9], nameNode[9];
+    
+    //
+    // Number of modules per slat
+    for (i=0; i<fNSlats; i++) {
+      npcb[i]=0;
+      for (j=0; j<4; j++) npcb[i]+=fPcb[i][j];
+    }  
+    //
+    TNode* top=gAlice->GetGeometry()->GetNode("alice");
+    sprintf(nameChamber,"C_MUON%d",fId+1);
+    new TBRIK(nameChamber,"Mother","void",340,340,5.);
+    top->cd();
+    sprintf(nameNode,"MUON%d",100+fId+1);
+    TNode* node = new TNode(nameNode,"Chambernode",nameChamber,0,0,fChamber->Z(),"");
+    
+    node->SetLineColor(kBlack);
+    AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
+    (pMUON->Nodes())->Add(node);
+    TNode* nodeSlat;
+    Int_t color;
+    
+    for (j=0; j<fNSlats; j++)
+      {
+       sprintf(nameSlat,"SLAT%d",100*fId+1+j);
+       Float_t dx = 20.*npcb[j];
+       Float_t dy = 20;
+       new TBRIK(nameSlat,"Slat Module","void",dx,20.,0.25);
+       node->cd();
+       color =  TMath::Even(j) ? kColorMUON1 : kColorMUON2;
+       
+       sprintf(nameNode,"SLAT%d",100*fId+1+j);
+       nodeSlat = 
+         new TNode(nameNode,"Slat Module",nameSlat, dx+fXPosition[j],fYPosition[j]+dy,0,"");
+       nodeSlat->SetLineColor(color);
+       node->cd();
+       sprintf(nameNode,"SLAT%d",100*fId+1+j+fNSlats);
+       nodeSlat = 
+         new TNode(nameNode,"Slat Module",nameSlat,-dx-fXPosition[j],fYPosition[j]+dy,0,"");
+       nodeSlat->SetLineColor(color);
+      }
+  }
+}